12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- (function universalModuleDefinition(root, factory) {
- var amdDependencies = [];
- if(typeof exports === 'object' && typeof module === 'object') {
- module.exports = factory();
- } else if(typeof define === 'function' && define.amd) {
- define("babylonjs-viewer", amdDependencies, factory);
- } else if(typeof exports === 'object') {
- exports["babylonjs-viewer"] = factory();
- } else {
- root["BabylonViewer"] = factory();
- }
- })(this, function() {
- var BabylonViewer=function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=19)}([function(e,t,i){(function(t){!function(t,r){var n=t.CANNON||this.CANNON,o=t.OIMO||this.OIMO,s=t.earcut||this.earcut;try{n=n||i(22)}catch(e){}try{o=o||i(23)}catch(e){}try{s=s||i(24)}catch(e){}e.exports=r(n,o,s)}(this,function(e,i,r){e=e||this.CANNON,i=i||this.OIMO,r=r||this.earcut;var 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++){if(s[o].effect===t){n.computeBonesUsingShaders=!1;break}}}}else{var a=this._defines[this._currentRank];if(a)for(r=0;r<a.length;r++)e=e.replace("#define "+a[r],"");this._currentRank++}return e},e}();e.EffectFallbacks=t;var i=function(){return function(){}}();e.EffectCreationOptions=i;var r=function(){function t(i,r,n,o,s,a,l,c,u,h){void 0===o&&(o=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null);var d,f,p=this;if(this.uniqueId=0,this.onCompileObservable=new e.Observable,this.onErrorObservable=new e.Observable,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this.name=i,r.attributes){var m=r;if(this._engine=n,this._attributesNames=m.attributes,this._uniformsNames=m.uniformsNames.concat(m.samplers),this._samplers=m.samplers.slice(),this.defines=m.defines,this.onError=m.onError,this.onCompiled=m.onCompiled,this._fallbacks=m.fallbacks,this._indexParameters=m.indexParameters,this._transformFeedbackVaryings=m.transformFeedbackVaryings,m.uniformBuffersNames)for(var g=0;g<m.uniformBuffersNames.length;g++)this._uniformBuffersNames[m.uniformBuffersNames[g]]=g}else this._engine=s,this.defines=a,this._uniformsNames=n.concat(o),this._samplers=o?o.slice():[],this._attributesNames=r,this.onError=u,this.onCompiled=c,this._indexParameters=h,this._fallbacks=l;this.uniqueId=t._uniqueIdSeed++,i.vertexElement?(d=document.getElementById(i.vertexElement))||(d=i.vertexElement):d=i.vertex||i,i.fragmentElement?(f=document.getElementById(i.fragmentElement))||(f=i.fragmentElement):f=i.fragment||i,this._loadVertexShader(d,function(e){p._processIncludes(e,function(e){p._processShaderConversion(e,!1,function(e){p._loadFragmentShader(f,function(t){p._processIncludes(t,function(t){p._processShaderConversion(t,!0,function(t){if(i){var r=i.vertexElement||i.vertex||i,n=i.fragmentElement||i.fragment||i;p._vertexSourceCode="#define SHADER_NAME vertex:"+r+"\n"+e,p._fragmentSourceCode="#define SHADER_NAME fragment:"+n+"\n"+t}else p._vertexSourceCode=e,p._fragmentSourceCode=t;p._prepareEffect()})})})})})})}return Object.defineProperty(t.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new e.Observable),this._onBindObservable},enumerable:!0,configurable:!0}),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){this.isReady()?e(this):this.onCompileObservable.add(function(t){e(t)})},t.prototype._loadVertexShader=function(i,r){var n;if(e.Tools.IsWindowObjectExist()&&i instanceof HTMLElement)return void r(e.Tools.GetDOMTextContent(i));"base64:"!==i.substr(0,7)?t.ShadersStore[i+"VertexShader"]?r(t.ShadersStore[i+"VertexShader"]):(n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,this._engine._loadFile(n+".vertex.fx",r)):r(window.atob(i.substr(7)))},t.prototype._loadFragmentShader=function(i,r){var n;if(e.Tools.IsWindowObjectExist()&&i instanceof HTMLElement)return void r(e.Tools.GetDOMTextContent(i));"base64:"!==i.substr(0,7)?t.ShadersStore[i+"PixelShader"]?r(t.ShadersStore[i+"PixelShader"]):t.ShadersStore[i+"FragmentShader"]?r(t.ShadersStore[i+"FragmentShader"]):(n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,this._engine._loadFile(n+".fragment.fx",r)):r(window.atob(i.substr(7)))},t.prototype._dumpShadersSource=function(t,i,r){var n=(this._engine.webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"")+(r?r+"\n":"");i=n+i;var o=2,s=/\n/gm,a="\n1\t"+(t=n+t).replace(s,function(){return"\n"+o+++"\t"});o=2;var l="\n1\t"+i.replace(s,function(){return"\n"+o+++"\t"});this.name.vertexElement?(e.Tools.Error("Vertex shader: "+this.name.vertexElement+a),e.Tools.Error("Fragment shader: "+this.name.fragmentElement+l)):this.name.vertex?(e.Tools.Error("Vertex shader: "+this.name.vertex+a),e.Tools.Error("Fragment shader: "+this.name.fragment+l)):(e.Tools.Error("Vertex shader: "+this.name+a),e.Tools.Error("Fragment shader: "+this.name+l))},t.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1!=this._engine.webGLVersion)if(-1===r.indexOf("#version 3")){var n=-1!==r.search(/#extension.+GL_EXT_draw_buffers.+require/),o=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"");o=(o=(o=o.replace(/varying(?![\n\r])\s/g,t?"in ":"out ")).replace(/attribute[ \t]/g,"in ")).replace(/[ \t]attribute/g," in"),t&&(o=(o=(o=(o=(o=(o=(o=(o=o.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/texture2D\s*\(/g,"texture(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(n?"":"out vec4 glFragColor;\n")+"void main(")),i(o)}else i(r.replace("#version 300 es",""));else i(r)},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=l.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),l+="Declaration"),!t.IncludesShadersStore[l]){var c=e.Engine.ShadersRepository+"ShadersInclude/"+l+".fx";return void this._engine._loadFile(c,function(e){t.IncludesShadersStore[l]=e,n._processIncludes(a,r)})}var u=t.IncludesShadersStore[l];if(s[2])for(var h=s[3].split(","),d=0;d<h.length;d+=2){var f=new RegExp(h[d],"g"),p=h[d+1];u=u.replace(f,p)}if(s[4]){var m=s[5];if(-1!==m.indexOf("..")){var g=m.split(".."),_=parseInt(g[0]),v=parseInt(g[1]),A=u.slice(0);u="",isNaN(v)&&(v=this._indexParameters[g[1]]);for(var y=_;y<v;y++)this._engine.supportsUniformBuffers||(A=A.replace(/light\{X\}.(\w*)/g,function(e,t){return t+"{X}"})),u+=A.replace(/\{X\}/g,y.toString())+"\n"}else this._engine.supportsUniformBuffers||(u=u.replace(/light\{X\}.(\w*)/g,function(e,t){return t+"{X}"})),u=u.replace(/\{X\}/g,m)}a=a.replace(s[0],u),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,s=this._engine;if(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._program=s.createRawShaderProgram(this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,void 0,this._transformFeedbackVaryings):this._program=s.createShaderProgram(this._vertexSourceCode,this._fragmentSourceCode,i,void 0,this._transformFeedbackVaryings),this._program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this),s.supportsUniformBuffers)for(var a in this._uniformBuffersNames)this.bindUniformBlock(a,this._uniformBuffersNames[a]);for(this._uniforms=s.getUniforms(this._program,this._uniformsNames),this._attributes=s.getAttributes(this._program,t),o=0;o<this._samplers.length;o++){null==this.getUniform(this._samplers[o])&&(this._samplers.splice(o,1),o--)}s.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(i){this._compilationError=i.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})),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.RegisterShader=function(e,i,r){i&&(t.ShadersStore[e+"PixelShader"]=i),r&&(t.ShadersStore[e+"VertexShader"]=r)},t.ResetCache=function(){t._baseCache={}},t._uniqueIdSeed=0,t._baseCache={},t.ShadersStore={},t.IncludesShadersStore={},t}();e.Effect=r}(a||(a={})),function(e){var t=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}();e.KeyboardEventTypes=t;var i=function(){return function(e,t){this.type=e,this.event=t}}();e.KeyboardInfo=i;var r=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.type=t,r.event=i,r.skipOnPointerObservable=!1,r}return o(t,e),t}(i);e.KeyboardInfoPre=r}(a||(a={})),function(e){var t=function(){function e(){}return e.POINTERDOWN=1,e.POINTERUP=2,e.POINTERMOVE=4,e.POINTERWHEEL=8,e.POINTERPICK=16,e.POINTERTAP=32,e.POINTERDOUBLETAP=64,e}();e.PointerEventTypes=t;var i=function(){return function(e,t){this.type=e,this.event=t}}();e.PointerInfoBase=i;var r=function(t){function i(i,r,n,o){var s=t.call(this,i,r)||this;return s.ray=null,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}(a||(a={})),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=397*e^(this.g||0))^(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){var n=new t(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},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=397*(e=397*e^(this.g||0))^(this.b||0))^(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.FromColor3=function(e,i){return void 0===i&&(i=1),new t(e.r,e.g,e.b,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){void 0===e&&(e=0),void 0===t&&(t=0),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.floor=function(){return new t(Math.floor(this.x),Math.floor(this.y))},t.prototype.fract=function(){return new t(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},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=n>r.x?r.x:n)<i.x?i.x:n;var o=e.y;return new t(n,o=(o=o>r.y?r.y:o)<i.y?i.y:o)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,c=-2*a+3*s,u=a-2*s+o,h=a-s;return new t(e.x*l+r.x*c+i.x*u+n.x*h,e.y*l+r.y*c+i.y*u+n.y*h)},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){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=i}return 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=397*e^(this.y||0))^(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 this.minimizeInPlaceFromFloats(e.x,e.y,e.z)},t.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.x,e.y,e.z)},t.prototype.minimizeInPlaceFromFloats=function(e,t,i){return e<this.x&&(this.x=e),t<this.y&&(this.y=t),i<this.z&&(this.z=i),this},t.prototype.maximizeInPlaceFromFloats=function(e,t,i){return e>this.x&&(this.x=e),t>this.y&&(this.y=t),i>this.z&&(this.z=i),this},Object.defineProperty(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.floor=function(){return new t(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},t.prototype.fract=function(){return new t(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},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.Vector3[1].copyFrom(e).normalize(),o=E.Vector3[2].copyFrom(i).normalize(),s=t.Dot(n,o),a=E.Vector3[3];return t.CrossToRef(n,o,a),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.Down=function(){return new t(0,-1,0)},t.Forward=function(){return new t(0,0,1)},t.Backward=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=n>r.x?r.x:n)<i.x?i.x:n;var o=e.y;o=(o=o>r.y?r.y:o)<i.y?i.y:o;var s=e.z;return new t(n,o,s=(s=s>r.z?r.z:s)<i.z?i.z:s)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,c=-2*a+3*s,u=a-2*s+o,h=a-s;return new t(e.x*l+r.x*c+i.x*u+n.x*h,e.y*l+r.y*c+i.y*u+n.y*h,e.z*l+r.z*c+i.z*u+n.z*h)},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,c=n.y,u=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+c,.5,1,u);var h=E.Matrix[0];return i.multiplyToRef(r,h),h.multiplyToRef(u,h),t.TransformCoordinates(e,h)},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),c=i.x*a.m[3]+i.y*a.m[7]+i.z*a.m[11]+a.m[15];return e.Scalar.WithinEpsilon(c,1)&&(l=l.scale(1/c)),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,c,u){var h=E.Matrix[0];a.multiplyToRef(l,h),h.multiplyToRef(c,h),h.invert();var d=E.Vector3[0];d.x=i/o*2-1,d.y=-(r/s*2-1),d.z=2*n-1,t.TransformCoordinatesToRef(d,h,u);var f=d.x*h.m[3]+d.y*h.m[7]+d.z*h.m[11]+h.m[15];e.Scalar.WithinEpsilon(f,1)&&u.scaleInPlace(1/f)},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=397*(e=397*e^(this.y||0))^(this.z||0))^(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.floor=function(){return new t(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},t.prototype.fract=function(){return new t(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},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=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,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,c=n*n,u=n*i-r*o;return u<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):u>.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+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-l-c+s)),this},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,c=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(l+c),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(l-c),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,e._markAsUpdated(),this},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],c=r[9],u=r[2],h=r[6],d=r[10],f=n+l+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(h-c)*i,t.y=(s-u)*i,t.z=(a-o)*i):n>l&&n>d?(i=2*Math.sqrt(1+n-l-d),t.w=(h-c)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+u)/i):l>d?(i=2*Math.sqrt(1+l-n-d),t.w=(s-u)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(c+h)/i):(i=2*Math.sqrt(1+d-n-l),t.w=(a-o)/i,t.x=(s+u)/i,t.y=(c+h)/i,t.z=.25*i)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e.AreClose=function(t,i){return e.Dot(t,i)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.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),c=Math.sin(o),u=Math.cos(o),h=Math.sin(s),d=Math.cos(s);r.x=d*c*l+h*u*a,r.y=h*u*l-d*c*a,r.z=d*u*a-h*c*l,r.w=d*u*l+h*c*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),c=1/Math.sin(l);o=Math.sin((1-i)*l)*c,n=a?-Math.sin(i*l)*c:Math.sin(i*l)*c}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,c=-2*a+3*s,u=a-2*s+o,h=a-s;return new e(t.x*l+r.x*c+i.x*u+n.x*h,t.y*l+r.y*c+i.y*u+n.y*h,t.z*l+r.z*c+i.z*u+n.z*h,t.w*l+r.w*c+i.w*u+n.w*h)},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],c=this.m[8],u=this.m[9],h=this.m[10],d=this.m[11],f=this.m[12],p=this.m[13],m=this.m[14],g=this.m[15],_=h*g-d*m,v=u*g-d*p,A=u*m-h*p,y=c*g-d*f,b=c*m-h*f,T=c*p-u*f,E=s*_-a*v+l*A,x=-(o*_-a*y+l*b),P=o*v-s*y+l*T,M=-(o*A-s*b+a*T),S=1/(t*E+i*x+r*P+n*M),C=a*g-l*m,R=s*g-l*p,O=s*m-a*p,D=o*g-l*f,I=o*m-a*f,w=o*p-s*f,L=a*d-l*h,B=s*d-l*u,F=s*h-a*u,N=o*d-l*c,V=o*h-a*c,U=o*u-s*c;return e.m[0]=E*S,e.m[4]=x*S,e.m[8]=P*S,e.m[12]=M*S,e.m[1]=-(i*_-r*v+n*A)*S,e.m[5]=(t*_-r*y+n*b)*S,e.m[9]=-(t*v-i*y+n*T)*S,e.m[13]=(t*A-i*b+r*T)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*D+n*I)*S,e.m[10]=(t*R-i*D+n*w)*S,e.m[14]=-(t*O-i*I+r*w)*S,e.m[3]=-(i*L-r*B+n*F)*S,e.m[7]=(t*L-r*N+n*V)*S,e.m[11]=-(t*B-i*N+n*U)*S,e.m[15]=(t*F-i*V+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],c=this.m[6],u=this.m[7],h=this.m[8],d=this.m[9],f=this.m[10],p=this.m[11],m=this.m[12],g=this.m[13],_=this.m[14],v=this.m[15],A=e.m[0],y=e.m[1],b=e.m[2],T=e.m[3],E=e.m[4],x=e.m[5],P=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],D=e.m[12],I=e.m[13],w=e.m[14],L=e.m[15];return t[i]=r*A+n*E+o*S+s*D,t[i+1]=r*y+n*x+o*C+s*I,t[i+2]=r*b+n*P+o*R+s*w,t[i+3]=r*T+n*M+o*O+s*L,t[i+4]=a*A+l*E+c*S+u*D,t[i+5]=a*y+l*x+c*C+u*I,t[i+6]=a*b+l*P+c*R+u*w,t[i+7]=a*T+l*M+c*O+u*L,t[i+8]=h*A+d*E+f*S+p*D,t[i+9]=h*y+d*x+f*C+p*I,t[i+10]=h*b+d*P+f*R+p*w,t[i+11]=h*T+d*M+f*O+p*L,t[i+12]=m*A+g*E+_*S+v*D,t[i+13]=m*y+g*x+_*C+v*I,t[i+14]=m*b+g*P+_*R+v*w,t[i+15]=m*T+g*M+_*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]).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,c,u,h,d,f,p,m,g){g.m[0]=e,g.m[1]=t,g.m[2]=i,g.m[3]=r,g.m[4]=n,g.m[5]=o,g.m[6]=s,g.m[7]=a,g.m[8]=l,g.m[9]=c,g.m[10]=u,g.m[11]=h,g.m[12]=d,g.m[13]=f,g.m[14]=p,g.m[15]=m,g._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,c,u,h,d,f,p,m,g){var _=new e;return _.m[0]=t,_.m[1]=i,_.m[2]=r,_.m[3]=n,_.m[4]=o,_.m[5]=s,_.m[6]=a,_.m[7]=l,_.m[8]=c,_.m[9]=u,_.m[10]=h,_.m[11]=d,_.m[12]=f,_.m[13]=p,_.m[14]=m,_.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],c=E.Vector3[1];t.decompose(s,l,c);var u=E.Vector3[2],h=E.Quaternion[1],d=E.Vector3[3];i.decompose(u,h,d);var f=E.Vector3[4];n.LerpToRef(s,u,r,f);var p=E.Quaternion[2];a.SlerpToRef(l,h,r,p);var m=E.Vector3[5];n.LerpToRef(c,d,r,m),e.ComposeToRef(f,p,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=2/t,a=2/i,l=2/(n-r),c=-(n+r)/(n-r);e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,l,0,0,0,c,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=2/(i-t),c=2/(n-r),u=2/(s-o),h=-(s+o)/(s-o),d=(t+i)/(t-i),f=(n+r)/(r-n);e.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,u,0,d,f,h,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=2*r/t,a=2*r/i,l=(n+r)/(n-r),c=-2*n*r/(n-r);return e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,l,1,0,0,c,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,c=1/Math.tan(.5*t),u=s?c/i:c,h=s?c:c*i,d=(l+a)/(l-a),f=-2*l*a/(l-a);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,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,c=1/Math.tan(.5*t),u=s?c/i:c,h=s?c:c*i,d=-(l+a)/(l-a),f=-2*l*a/(l-a);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,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),c=Math.tan(e.rightDegrees*Math.PI/180),u=2/(l+c),h=2/(s+a);r.m[0]=u,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=h,r.m[6]=r.m[7]=0,r.m[8]=(l-c)*u*.5,r.m[9]=-(s-a)*h*.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,c=t.x,u=t.y,h=e.FromValues(a/2,0,0,0,0,-l/2,0,0,0,0,s-o,0,c+a/2,l/2+u,o,1);return i.multiply(r).multiply(n).multiply(h)},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,c=e.y*e.z,u=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-l),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+u),t.m[7]=0,t.m[8]=2*(a+l),t.m[9]=2*(c-u),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},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 c=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,c=i.z-e.z,u=o*c-s*l,h=s*a-n*c,d=n*l-o*a,f=Math.sqrt(u*u+h*h+d*d);return r=0!==f?1/f:0,this.normal.x=u*r,this.normal.y=h*r,this.normal.z=d*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=c;var u=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=u;var h=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new c(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=h,function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(e.Space||(e.Space={}));var d=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=d;var f,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,c=0;c<5;c++){var u=l*l;l-=(o*(u*l)+s*u+a*l-e)*(1/(3*o*u+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,function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(f=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 g=function(){return function(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(),c=m.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),u=m.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-l>180&&(c-=360),c-l<-180&&(c+=360),u-c>180&&(u-=360),u-c<-180&&(u+=360),this.orientation=c-l<0?f.CW:f.CCW,this.angle=m.FromDegrees(this.orientation===f.CW?l-u:u-l)}}();e.Arc2=g;var _=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),c=new g(s,a,l),u=c.angle.radians()/o;c.orientation===f.CW&&(u*=-1);for(var h=c.startAngle.radians()+u,d=0;d<o;d++){var p=Math.cos(h)*c.radius+c.centerPoint.x,m=Math.sin(h)*c.radius+c.centerPoint.y;this.addLineTo(p,m),h+=u}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].subtract(s),l=a.length()+i;if(t>=i&&t<=l){var c=a.normalize(),u=t-i;return new r(s.x+c.x*u,s.y+c.y*u)}i=l}return r.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}();e.Path2=_;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,r,o,s,a=this._tangents[0],l=this._normalVector(this._curve[0],a,e);this._normals[0]=l,this._raw||this._normals[0].normalize(),this._binormals[0]=n.Cross(a,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var c=1;c<t;c++)i=this._getLastNonNullVector(c),c<t-1&&(r=this._getFirstNonNullVector(c),this._tangents[c]=i.add(r),this._tangents[c].normalize()),this._distances[c]=this._distances[c-1]+i.length(),o=this._tangents[c],s=this._binormals[c-1],this._normals[c]=n.Cross(s,o),this._raw||this._normals[c].normalize(),this._binormals[c]=n.Cross(o,this._normals[c]),this._raw||this._binormals[c].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,a=i.length();(0===a&&(a=1),void 0===r||null===r)?(s=e.Scalar.WithinEpsilon(Math.abs(i.y)/a,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.x)/a,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.z)/a,1,e.Epsilon)?n.Zero():new n(0,0,1):new n(1,0,0):new n(0,-1,0),o=n.Cross(i,s)):(o=n.Cross(i,r),n.CrossToRef(o,i,o));return o.normalize(),o},t}();e.Path3D=v;var A=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},c=0;c<=s;c++)a.push(new n(l(c/s,t.x,i.x,r.x,o.x),l(c/s,t.y,i.y,r.y,o.y),l(c/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,c=0;c<=s;c++)a.push(n.Hermite(t,i,r,o,c*l));return new e(a)},e.CreateCatmullRomSpline=function(t,i,r){var o=new Array,s=1/i,a=0;if(r){for(var l=t.length,c=0;c<l;c++){a=0;for(var u=0;u<i;u++)o.push(n.CatmullRom(t[c%l],t[(c+1)%l],t[(c+2)%l],t[(c+3)%l],a)),a+=s}o.push(o[0])}else{var h=new Array;h.push(t[0].clone()),Array.prototype.push.apply(h,t),h.push(t[t.length-1].clone());for(c=0;c<h.length-3;c++){a=0;for(u=0;u<i;u++)o.push(n.CatmullRom(h[c],h[c+1],h[c+2],h[c+3],a)),a+=s}c--,o.push(n.CatmullRom(h[c],h[c+1],h[c+2],h[c+3],a))}return 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=A;var y=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=y;var b=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=b;var T=function(){function e(){}return e.Color3=[t.Black(),t.Black(),t.Black()],e.Color4=[new i(0,0,0,0),new i(0,0,0,0)],e.Vector2=[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}()}(a||(a={})),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 0===(e=+e)||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var 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 i*(n=-2*n*n*n+3*n*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}(a||(a={})),function(e){var t={},i={},r=function(t,i,r){var o=t();e.Tags&&e.Tags.AddTagsTo(o,i.tags);var s=n(o);for(var a in s){var l=s[a],c=i[a],u=l.type;if(void 0!==c&&null!==c)switch(u){case 0:case 6:case 11:o[a]=c;break;case 1:o[a]=r||c.isRenderTarget?c:c.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:o[a]=r?c:c.clone()}}return o};function n(e){var r=e.getClassName();if(i[r])return i[r];i[r]={};for(var n=i[r],o=e,s=r;s;){var a=t[s];for(var l in a)n[l]=a[l];var c=void 0,u=!1;do{if(!(c=Object.getPrototypeOf(o)).getClassName){u=!0;break}if(c.getClassName()!==s)break;o=c}while(c);if(u)break;s=c.getClassName(),o=c}return n}function o(e,i){return function(r,n){var o=function(e){var i=e.getClassName();return t[i]||(t[i]={}),t[i]}(r);o[n]||(o[n]={type:e,sourceName:i})}}e.expandToProperty=function(e,t){return void 0===t&&(t=null),function(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})}}(e,t)},e.serialize=function(e){return o(0,e)},e.serializeAsTexture=function(e){return o(1,e)},e.serializeAsColor3=function(e){return o(2,e)},e.serializeAsFresnelParameters=function(e){return o(3,e)},e.serializeAsVector2=function(e){return o(4,e)},e.serializeAsVector3=function(e){return o(5,e)},e.serializeAsMeshReference=function(e){return o(6,e)},e.serializeAsColorCurves=function(e){return o(7,e)},e.serializeAsColor4=function(e){return o(8,e)},e.serializeAsImageProcessingConfiguration=function(e){return o(9,e)},e.serializeAsQuaternion=function(e){return o(10,e)},e.serializeAsCameraReference=function(e){return o(11,e)};var s=function(){function t(){}return t.Serialize=function(t,i){i||(i={}),e.Tags&&(i.tags=e.Tags.GetTags(t));var r=n(t);for(var o in r){var s=r[o],a=s.sourceName||o,l=s.type,c=t[o];if(void 0!==c&&null!==c)switch(l){case 0:i[a]=c;break;case 1:i[a]=c.serialize();break;case 2:i[a]=c.asArray();break;case 3:i[a]=c.serialize();break;case 4:case 5:i[a]=c.asArray();break;case 6:i[a]=c.id;break;case 7:i[a]=c.serialize();break;case 8:i[a]=c.asArray();break;case 9:i[a]=c.serialize();break;case 10:i[a]=c.asArray();break;case 11:i[a]=c.id}}return i},t.Parse=function(t,i,r,o){void 0===o&&(o=null);var s=t();o||(o=""),e.Tags&&e.Tags.AddTagsTo(s,i.tags);var a=n(s);for(var l in a){var c=a[l],u=i[c.sourceName||l],h=c.type;if(void 0!==u&&null!==u){var d=s;switch(h){case 0:d[l]=u;break;case 1:r&&(d[l]=e.Texture.Parse(u,r,o));break;case 2:d[l]=e.Color3.FromArray(u);break;case 3:d[l]=e.FresnelParameters.Parse(u);break;case 4:d[l]=e.Vector2.FromArray(u);break;case 5:d[l]=e.Vector3.FromArray(u);break;case 6:r&&(d[l]=r.getLastMeshByID(u));break;case 7:d[l]=e.ColorCurves.Parse(u);break;case 8:d[l]=e.Color4.FromArray(u);break;case 9:d[l]=e.ImageProcessingConfiguration.Parse(u);break;case 10:d[l]=e.Quaternion.FromArray(u);break;case 11:r&&(d[l]=r.getCameraByID(u))}}}return s},t.Clone=function(e,t){return r(e,t,!1)},t.Instanciate=function(e,t){return r(e,t,!0)},t}();e.SerializationHelper=s}(a||(a={})),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}(a||(a={})),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(){return function(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1}}();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].add(i,r,!1,n);l&&o._observers.push(l)}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.addOnce=function(e){return this.add(e,void 0,void 0,void 0,!0)},r.prototype.remove=function(e){return!!e&&(-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!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._deferUnregister(this._observers[i]),!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._remove=function(e){if(!e)return!1;var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},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}(a||(a={})),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.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}(a||(a={})),function(e){var t=function(){function t(){}return t.prototype.getColorToRef=function(t){this.color2?e.Color4.LerpToRef(this.color1,this.color2,Math.random(),t):t.copyFrom(this.color1)},t}();e.ColorGradient=t;var i=function(){return function(){}}();e.Color3Gradient=i;var r=function(){function t(){}return t.prototype.getFactor=function(){return void 0===this.factor2?this.factor1:e.Scalar.Lerp(this.factor1,this.factor2,Math.random())},t}();e.FactorGradient=r;var n=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=n;var s,a=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=a;var l=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},c=function(){function t(){}return t.FetchToRef=function(e,t,i,r,n,o){var s=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*r%r|0)*i);o.r=n[s]/255,o.g=n[s+1]/255,o.b=n[s+2]/255,o.a=n[s+3]/255},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){t.IsWindowObjectExist()&&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){var o;switch(void 0===n&&(n=e.Engine.SCALEMODE_NEAREST),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+/=",c="",u=0,h=new Uint8Array(e);u<h.length;)n=(t=h[u++])>>2,o=(3&t)<<4|(i=u<h.length?h[u++]:Number.NaN)>>4,s=(15&i)<<2|(r=u<h.length?h[u++]:Number.NaN)>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),c+=l.charAt(n)+l.charAt(o)+l.charAt(s)+l.charAt(a);return"data:image/png;base64,"+c},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 c=3*i[l],u=t[c],h=t[c+1],d=t[c+2];s.minimizeInPlaceFromFloats(u,h,d),a.maximizeInPlaceFromFloats(u,h,d)}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,c=i*o;l<i+r;l++,c+=o){var u=t[c],h=t[c+1],d=t[c+2];s.minimizeInPlaceFromFloats(u,h,d),a.maximizeInPlaceFromFloats(u,h,d)}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.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){var s,a=!1;i instanceof ArrayBuffer?(s=URL.createObjectURL(new Blob([i])),a=!0):i instanceof Blob?(s=URL.createObjectURL(i),a=!0):(s=t.CleanUrl(i),s=t.PreprocessUrl(i));var l=new Image;t.SetCorsBehavior(s,l);var c=function(){a&&l.src&&URL.revokeObjectURL(l.src),l.removeEventListener("load",c),l.removeEventListener("error",u),r(l)},u=function(e){a&&l.src&&URL.revokeObjectURL(l.src),l.removeEventListener("load",c),l.removeEventListener("error",u),t.Error("Error while trying to load image: "+i),n&&n("Error while trying to load image: "+i,e)};l.addEventListener("load",c),l.addEventListener("error",u);var h=function(){l.src=s};if("data:"!==s.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(function(){o&&o.loadImageFromDB(s,l)},h);else{if(-1!==s.indexOf("file:")){var d=decodeURIComponent(s.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[d]){try{var f;try{f=URL.createObjectURL(e.FilesInput.FilesToLoad[d])}catch(t){f=URL.createObjectURL(e.FilesInput.FilesToLoad[d])}l.src=f,a=!0}catch(e){l.src=""}return l}}h()}return l},t.LoadFile=function(i,r,o,s,a,l){if(i=t.CleanUrl(i),-1!==(i=t.PreprocessUrl(i)).indexOf("file:")){var c=decodeURIComponent(i.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[c])return t.ReadFile(e.FilesInput.FilesToLoad[c],r,o,a)}var u=t.BaseUrl+i,h=!1,d={onCompleteObservable:new e.Observable,abort:function(){return h=!0}},f=function(){var e=new XMLHttpRequest,i=null;d.abort=function(){h=!0,e.readyState!==(XMLHttpRequest.DONE||4)&&e.abort(),null!==i&&(clearTimeout(i),i=null)};var s=function(c){e.open("GET",u,!0),a&&(e.responseType="arraybuffer"),o&&e.addEventListener("progress",o);var f=function(){e.removeEventListener("loadend",f),d.onCompleteObservable.notifyObservers(d),d.onCompleteObservable.clear()};e.addEventListener("loadend",f);var p=function(){if(!h&&e.readyState===(XMLHttpRequest.DONE||4)){if(e.removeEventListener("readystatechange",p),e.status>=200&&e.status<300||0===e.status&&(!t.IsWindowObjectExist()||t.IsFileURL()))return void r(a?e.response:e.responseText,e.responseURL);var o=t.DefaultRetryStrategy;if(o){var d=o(u,e,c);if(-1!==d)return e.removeEventListener("loadend",f),e=new XMLHttpRequest,void(i=setTimeout(function(){return s(c+1)},d))}var m=new n("Error status: "+e.status+" "+e.statusText+" - Unable to load "+u,e);if(!l)throw m;l(e,m)}};e.addEventListener("readystatechange",p),e.send()};s(0)};if(s&&s.enableSceneOffline){var p=function(e){e&&e.status>400?l&&l(e):h||f()};s.openAsync(function(){h||s&&s.loadFileFromDB(i,function(e){h||r(e),d.onCompleteObservable.notifyObservers(d)},o?function(e){h||o(e)}:void 0,p,a)},p)}else f();return d},t.LoadScript=function(e,i,r){if(t.IsWindowObjectExist()){var n=document.getElementsByTagName("head")[0],o=document.createElement("script");o.type="text/javascript",o.src=e,o.onload=function(){i&&i()},o.onerror=function(t){r&&r("Unable to load script '"+e+"'",t)},n.appendChild(o)}},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],s=typeof o;if("function"!==s)try{if("object"===s)if(o instanceof Array){if(t[n]=[],o.length>0)if("object"==typeof o[0])for(var a=0;a<o.length;a++){var c=l(o[a],t);-1===t[n].indexOf(c)&&t[n].push(c)}else t[n]=o.slice(0)}else t[n]=l(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,n,o,a){void 0===o&&(o="image/png");for(var l=4*e,c=i/2,u=r.readPixels(0,0,e,i),h=0;h<c;h++)for(var d=0;d<l;d++){var f=d+h*l,p=d+(i-h-1)*l,m=u[f];u[f]=u[p],u[p]=m}s||(s=document.createElement("canvas")),s.width=e,s.height=i;var g=s.getContext("2d");if(g){var _=g.createImageData(e,i);_.data.set(u),g.putImageData(_,0,0),t.EncodeScreenshotCanvasData(n,o,a)}},t.ToBlob=function(e,t,i){void 0===i&&(i="image/png"),e.toBlob||(e.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]))})}),e.toBlob(function(e){t(e)},i)},t.EncodeScreenshotCanvasData=function(e,i,r){(void 0===i&&(i="image/png"),e)?e(s.toDataURL(i)):this.ToBlob(s,function(e){if("download"in document.createElement("a")){if(!r){var i=new Date,n=(i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2);r="screenshot_"+n+".png"}t.Download(e,r)}else{var o=URL.createObjectURL(e),s=window.open("");if(!s)return;var a=s.document.createElement("img");a.onload=function(){URL.revokeObjectURL(o)},a.src=o,s.document.body.appendChild(a)}},i)},t.Download=function(e,t){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(e,t);else{var i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",function(){r.parentElement&&r.parentElement.removeChild(r)}),r.click(),window.URL.revokeObjectURL(i)}},t.CreateScreenshot=function(e,i,r,n,o){var a,l;if(void 0===o&&(o="image/png"),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}s||(s=document.createElement("canvas")),s.width=a,s.height=l;var c=s.getContext("2d"),u=e.getRenderWidth()/e.getRenderHeight(),h=a,d=h/u;d>l&&(h=(d=l)*u);var f=Math.max(0,a-h)/2,p=Math.max(0,l-d)/2,m=e.getRenderingCanvas();c&&m&&c.drawImage(m,f,p,h,d),t.EncodeScreenshotCanvasData(n,o)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s,a,l,c){var u,h;if(void 0===s&&(s="image/png"),void 0===a&&(a=1),void 0===l&&(l=!1),n.precision)u=Math.round(i.getRenderWidth()*n.precision),h=Math.round(u/i.getAspectRatio(r)),n={width:u,height:h};else if(n.width&&n.height)u=n.width,h=n.height;else if(n.width&&!n.height)u=n.width,h=Math.round(u/i.getAspectRatio(r)),n={width:u,height:h};else if(n.height&&!n.width)h=n.height,n={width:u=Math.round(h*i.getAspectRatio(r)),height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,u=n}var d=r.getScene(),f=null;d.activeCamera!==r&&(f=d.activeCamera,d.activeCamera=r);var p=new e.RenderTargetTexture("screenShot",n,d,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);p.renderList=null,p.samples=a,l&&p.addPostProcess(new e.FxaaPostProcess("antialiasing",1,d.activeCamera)),p.onAfterRenderObservable.add(function(){t.DumpFramebuffer(u,h,i,o,s,c)}),d.incrementRenderId(),d.resetCachedMaterial(),p.render(!0),p.dispose(),f&&(d.activeCamera=f),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},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.IsFileURL=function(){return"file:"===location.protocol},t.IsWindowObjectExist=function(){return"undefined"!=typeof window},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.DelayAsync=function(e){return new Promise(function(t){setTimeout(function(){t()},e)})},t.GetCurrentGradient=function(e,t,i){for(var r=0;r<t.length-1;r++){var n=t[r],o=t[r+1];if(e>=n.gradient&&e<=o.gradient)return void i(n,o,(e-n.gradient)/(o.gradient-n.gradient))}var s=t.length-1;i(t[s],t[s],1)},t.BaseUrl="",t.DefaultRetryStrategy=a.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.AllLogLevel=7,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=c;var u=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=c.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=c.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=c.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=u,e.className=function(e,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}};var h=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}return 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){return 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}(a||(a={})),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(){return function(){this.count=0,this.target=0,this.results=[]}}(),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,r=this;if((i=this._children).push.apply(i,e.splice(0,e.length)),this._children.forEach(function(e){e._parent=r}),this._state===t.Fulfilled)for(var n=0,o=this._children;n<o.length;n++){o[n]._resolve(this._result)}else if(this._state===t.Rejected)for(var s=0,a=this._children;s<a.length;s++){a[s]._reject(this._reason)}},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++){n[i].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){(void 0===e&&(e=!1),e||"undefined"==typeof Promise)&&(window.Promise=r)},e}();e.PromisePolyfill=n}(a||(a={})),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}(a||(a={})),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._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e}();e._AlphaState=t}(a||(a={})),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}(a||(a={})),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}(a||(a={}));var s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(e){var t=function(){return function(){}}(),i=function(){return function(){}}();e.InstancingAttributeInfo=i;var r=function(){return function(){}}();e.RenderTargetCreationOptions=r;var n=function(){return function(){}}();e.DepthTextureCreationOptions=n;var o=function(){return function(){}}();e.EngineCapabilities=o;var a=function(){function i(r,n,o,s){void 0===s&&(s=!1);var a=this;this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.scenes=new Array,this.postProcesses=new Array,this.validateShaderPrograms=!1,this.onResizeObservable=new 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=i.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._firstBoundInternalTextureTracker=new 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.premultipliedAlpha=!0,this._viewportCached=new e.Vector4(0,0,0,0),this._onVRFullScreenTriggered=function(){if(a._vrDisplay&&a._vrDisplay.isPresenting){a._oldSize=new e.Size(a.getRenderWidth(),a.getRenderHeight()),a._oldHardwareScaleFactor=a.getHardwareScalingLevel();var t=a._vrDisplay.getEyeParameters("left");a.setHardwareScalingLevel(1),a.setSize(2*t.renderWidth,t.renderHeight)}else a.setHardwareScalingLevel(a._oldHardwareScaleFactor),a.setSize(a._oldSize.width,a._oldSize.height)},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},e.PromisePolyfill.Apply();var l=null;if(i.Instances.push(this),r){if(o=o||{},r.getContext){if(l=r,this._renderingCanvas=l,null!=n&&(o.antialias=n),void 0===o.deterministicLockstep&&(o.deterministicLockstep=!1),void 0===o.lockstepMaxSteps&&(o.lockstepMaxSteps=4),void 0===o.preserveDrawingBuffer&&(o.preserveDrawingBuffer=!1),void 0===o.audioEngine&&(o.audioEngine=!0),void 0===o.stencil&&(o.stencil=!0),!1===o.premultipliedAlpha&&(this.premultipliedAlpha=!1),this._deterministicLockstep=o.deterministicLockstep,this._lockstepMaxSteps=o.lockstepMaxSteps,this._doNotHandleContextLost=!!o.doNotHandleContextLost,navigator&&navigator.userAgent)for(var c=navigator.userAgent,u=0,h=i.ExceptionList;u<h.length;u++){var d=h[u],f=d.key,p=d.targets;if(c.indexOf(f)>-1){if(d.capture&&d.captureConstraint){var m=d.capture,g=d.captureConstraint,_=new RegExp(m).exec(c);if(_&&_.length>0)if(parseInt(_[_.length-1])>=g)continue}for(var v=0,A=p;v<A.length;v++){switch(A[v]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"textureBindingOptimization":this.disableTextureBindingOptimization=!0}}}}if(!o.disableWebGL2Support)try{this._gl=l.getContext("webgl2",o)||l.getContext("experimental-webgl2",o),this._gl&&(this._webGLVersion=2,this._gl.deleteQuery||(this._webGLVersion=1))}catch(e){}if(!this._gl){if(!l)throw new Error("The provided canvas is null or undefined.");try{this._gl=l.getContext("webgl",o)||l.getContext("experimental-webgl",o)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onCanvasFocus=function(){a.onCanvasFocusObservable.notifyObservers(a)},this._onCanvasBlur=function(){a.onCanvasBlurObservable.notifyObservers(a)},l.addEventListener("focus",this._onCanvasFocus),l.addEventListener("blur",this._onCanvasBlur),this._onBlur=function(){a.disablePerformanceMonitorInBackground&&a._performanceMonitor.disable(),a._windowIsBackground=!0},this._onFocus=function(){a.disablePerformanceMonitorInBackground&&a._performanceMonitor.enable(),a._windowIsBackground=!1},this._onCanvasPointerOut=function(e){a.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(),a._contextWasLost=!0,e.Tools.Warn("WebGL context lost."),a.onContextLostObservable.notifyObservers(a)},this._onContextRestored=function(t){setTimeout(function(){a._initGLContext(),a._rebuildEffects(),a._rebuildInternalTextures(),a._rebuildBuffers(),a.wipeCaches(!0),e.Tools.Warn("WebGL context successfully restored."),a.onContextRestoredObservable.notifyObservers(a),a._contextWasLost=!1},0)},l.addEventListener("webglcontextlost",this._onContextLost,!1),l.addEventListener("webglcontextrestored",this._onContextRestored,!1))}else{this._gl=r,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var y=this._gl.getContextAttributes();y&&(o.stencil=y.stencil)}var b=o.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=s?1/Math.min(b,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=!!o.stencil,this._initGLContext(),l&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?a.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?a.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?a.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(a.isFullscreen=document.msIsFullScreen),a.isFullscreen&&a._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(){a.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)),!i.audioEngine&&o.audioEngine&&i.AudioEngineFactory&&(i.audioEngine=i.AudioEngineFactory(this.getRenderingCanvas()));for(var T=0;T<this._caps.maxVertexAttribs;T++)this._currentBufferPointers[T]=new t;this._linkTrackers(this._firstBoundInternalTextureTracker,this._lastBoundInternalTextureTracker),o.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"+i.Version+") launched"),this.enableOfflineSupport=void 0!==e.Database}}return Object.defineProperty(i,"LastCreatedEngine",{get:function(){return 0===i.Instances.length?null:i.Instances[i.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LastCreatedScene",{get:function(){var e=i.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),i.MarkAllMaterialsAsDirty=function(e,t){for(var r=0;r<i.Instances.length;r++)for(var n=i.Instances[r],o=0;o<n.scenes.length;o++)n.scenes[o].markAllMaterialsAsDirty(e,t)},Object.defineProperty(i,"Version",{get:function(){return"3.3.0"},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,i.TEXTUREFORMAT_RGBA,!1,!1,i.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,i.TEXTUREFORMAT_RGBA,!1,!1,i.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,i.TEXTUREFORMAT_RGBA,i.TEXTURETYPE_UNSIGNED_INT,!1,!1,i.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),i.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e<t.length;e++){t[e]._rebuild()}},i.prototype._rebuildEffects=function(){for(var t in this._compiledEffects){this._compiledEffects[t]._prepareEffect()}e.Effect.ResetCache()},i.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()}},i.prototype._initGLContext=function(){this._caps=new o,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 s=this._gl.getExtension("ANGLE_instanced_arrays");null!=s?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=s.drawArraysInstancedANGLE.bind(s),this._gl.drawElementsInstanced=s.drawElementsInstancedANGLE.bind(s),this._gl.vertexAttribDivisor=s.vertexAttribDivisorANGLE.bind(s)):this._caps.instancedArrays=!1}if(this._caps.astc&&this.texturesSupported.push("-astc.ktx"),this._caps.s3tc&&this.texturesSupported.push("-dxt.ktx"),this._caps.pvrtc&&this.texturesSupported.push("-pvrtc.ktx"),this._caps.etc2&&this.texturesSupported.push("-etc2.ktx"),this._caps.etc1&&this.texturesSupported.push("-etc1.ktx"),this._gl.getShaderPrecisionFormat){var a=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&(this._caps.highPrecisionShaderSupported=0!==a.precision)}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var l=0;l<this._maxSimultaneousTextures;l++)this._nextFreeTextureSlots.push(l)},Object.defineProperty(i.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),i.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=document.createElement("canvas");var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},i.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},i.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},i.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},i.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)},i.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._gl.drawingBufferWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._gl.drawingBufferHeight},i.prototype.getRenderingCanvas=function(){return this._renderingCanvas},i.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},i.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},i.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},i.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},i.prototype.getCaps=function(){return this._caps},Object.defineProperty(i.prototype,"drawCalls",{get:function(){return e.Tools.Warn("drawCalls is deprecated. Please use SceneInstrumentation class"),0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"drawCallsPerfCounter",{get:function(){return e.Tools.Warn("drawCallsPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},i.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},i.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},i.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},i.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},i.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},i.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},i.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},i.prototype.getStencilMask=function(){return this._stencilState.stencilMask},i.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},i.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},i.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},i.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},i.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},i.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},i.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},i.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},i.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},i.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},i.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},i.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},i.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},i.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},i.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},i.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},i.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},i.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)))},i.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,this._renderingCanvas&&e.Tools.RequestFullscreen(this._renderingCanvas))},i.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)},i.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)},i.prototype._viewport=function(e,t,i,r){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&r===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=r,this._gl.viewport(e,t,i,r))},i.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._viewport(o*r,s*n,r*e.width,n*e.height)},i.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),n},i.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},i.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame(),this.onEndFrameObservable.notifyObservers(this)},i.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)}},i.prototype.setSize=function(e,t){if(this._renderingCanvas&&(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){r.cameras[n]._currentRenderId=0}this.onResizeObservable.hasObservers&&this.onResizeObservable.notifyObservers(this)}},i.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},i.prototype.getVRDevice=function(){return this._vrDisplay},i.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},i.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},i.prototype.enableVR=function(){var e=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){this.onVRRequestPresentStart.notifyObservers(this),this._vrDisplay.requestPresent([{source:this.getRenderingCanvas()}]).then(function(){e.onVRRequestPresentComplete.notifyObservers(!0),e._onVRFullScreenTriggered()}).catch(function(){e.onVRRequestPresentComplete.notifyObservers(!1)})}},i.prototype.disableVR=function(){this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered)},i.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}))})},i.prototype.bindFramebuffer=function(e,t,i,r,n,o,s){void 0===s&&(s=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var a=this._gl;e.isCube&&(void 0===t&&(t=0),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,s),o&&(o._generateStencilBuffer?a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s):a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s))),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):(i||(i=e.width,s&&(i/=Math.pow(2,s))),r||(r=e.height,s&&(r/=Math.pow(2,s))),this._viewport(0,0,i,r)),this.wipeCaches()},i.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},i.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)},i.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(o=0;o<n.length;o++)n[o]=r[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(n)}for(o=0;o<e.length;o++){!(s=e[o]).generateMipMaps||t||s.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,s),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null))}i&&(e[0]._MSAAFramebuffer&&this.bindUnboundFramebuffer(e[0]._framebuffer),i()),this.bindUnboundFramebuffer(null)},i.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)}},i.prototype.flushFramebuffer=function(){this._gl.flush()},i.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},i.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},i.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},i.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)},i.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},i.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},i.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},i.prototype.updateDynamicIndexBuffer=function(e,t,i){var r;void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),r=t instanceof Uint16Array||t instanceof Uint32Array?t:e.is32Bits?new Uint32Array(t):new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},i.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()},i.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},i.prototype.createIndexBuffer=function(e,t){var i,r=this._gl.createBuffer();if(!r)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);var n=!1;if(e instanceof Uint16Array)i=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)i=e,n=!0;else{for(var o=0;o<e.length;o++)if(e[o]>65535){n=!0;break}i=n?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=n,r},i.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},i.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},i.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},i.prototype.bindUniformBlock=function(e,t,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},i.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},i.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},i.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},i.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))},i.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},i.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))))}}},i.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},i.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)},i.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)},i.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},i.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)},i.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},i.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},i.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._gl.deleteBuffer(e),!0)},i.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},i.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},i.prototype.updateAndBindInstancesBuffer=function(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index){for(var r=0,n=0;n<i.length;n++){r+=4*(o=i[n]).attributeSize}for(n=0;n<i.length;n++){var o=i[n];this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this._vertexAttribPointer(e,o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._gl.vertexAttribDivisor(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;s<4;s++){var a=i[s];this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this._vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*s),this._gl.vertexAttribDivisor(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},i.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},i.prototype.draw=function(t,i,r,n){this.drawElementsType(t?e.Material.TriangleFillMode:e.Material.WireFrameFillMode,i,r,n)},i.prototype.drawPointClouds=function(t,i,r){this.drawArraysType(e.Material.PointFillMode,t,i,r)},i.prototype.drawUnIndexed=function(t,i,r,n){this.drawArraysType(t?e.Material.TriangleFillMode:e.Material.WireFrameFillMode,i,r,n)},i.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)},i.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)},i.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}},i.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deleteProgram(e.getProgram()))},i.prototype._deleteProgram=function(e){e&&(e.__SPECTOR_rebuildProgram=null,e.transformFeedback&&(this.deleteTransformFeedback(e.transformFeedback),e.transformFeedback=null),this._gl.deleteProgram(e))},i.prototype.createEffect=function(t,i,r,n,o,s,a,l,c){var u=(t.vertexElement||t.vertex||t)+"+"+(t.fragmentElement||t.fragment||t)+"@"+(o||i.defines);if(this._compiledEffects[u]){var h=this._compiledEffects[u];return a&&h.isReady()&&a(h),h}var d=new e.Effect(t,i,r,n,this,o,s,a,l,c);return d._key=u,this._compiledEffects[u]=d,d},i.prototype._compileShader=function(e,t,i,r){return this._compileRawShader(r+(i?i+"\n":"")+e,t)},i.prototype._compileRawShader=function(e,t){var i=this._gl,r=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!r)throw new Error("Something went wrong while compile the shader.");if(i.shaderSource(r,e),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS)){var n=i.getShaderInfoLog(r);if(n)throw new Error(n)}return r},i.prototype.createRawShaderProgram=function(e,t,i,r){void 0===r&&(r=null),i=i||this._gl;var n=this._compileRawShader(e,"vertex"),o=this._compileRawShader(t,"fragment");return this._createShaderProgram(n,o,i,r)},i.prototype.createShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null),r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var o=this._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(e,"vertex",i,o),a=this._compileShader(t,"fragment",i,o),l=this._createShaderProgram(s,a,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),l},i.prototype._createShaderProgram=function(e,t,i,r){void 0===r&&(r=null);var n,o=i.createProgram();if(!o)throw new Error("Unable to create program");if(i.attachShader(o,e),i.attachShader(o,t),this.webGLVersion>1&&r){var s=this.createTransformFeedback();this.bindTransformFeedback(s),this.setTranformFeedbackVaryings(o,r),o.transformFeedback=s}if((i.linkProgram(o),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),!i.getProgramParameter(o,i.LINK_STATUS))&&(n=i.getProgramInfoLog(o)))throw new Error(n);if(this.validateShaderPrograms&&(i.validateProgram(o),!i.getProgramParameter(o,i.VALIDATE_STATUS)&&(n=i.getProgramInfoLog(o))))throw new Error(n);return i.deleteShader(e),i.deleteShader(t),o},i.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},i.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},i.prototype.enableEffect=function(e){e&&e!==this._currentEffect&&(this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},i.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},i.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},i.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},i.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},i.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},i.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},i.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},i.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},i.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},i.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},i.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},i.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},i.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},i.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},i.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},i.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},i.prototype.setInt=function(e,t){e&&this._gl.uniform1i(e,t)},i.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},i.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},i.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},i.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},i.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},i.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},i.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},i.prototype.setDirectColor4=function(e,t){e&&this._gl.uniform4f(e,t.r,t.g,t.b,t.a)},i.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)},i.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},i.prototype.getZOffset=function(){return this._depthCullingState.zOffset},i.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},i.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},i.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},i.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e),this._colorWrite=e},i.prototype.getColorWrite=function(){return this._colorWrite},i.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},i.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case i.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case i.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 i.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 i.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 i.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.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 i.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.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 i.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 i.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===i.ALPHA_DISABLE),this._alphaMode=e}},i.prototype.getAlphaMode=function(){return this._alphaMode},i.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache=[]},i.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,e&&(this.resetTextureCache(),this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._unpackFlipYCached=null),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unbindVertexArrayObject(),this.bindIndexBuffer(null))},i.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},i.prototype._getSamplingParameters=function(e,t){var r=this._gl,n=r.NEAREST,o=r.NEAREST;switch(e){case i.TEXTURE_BILINEAR_SAMPLINGMODE:n=r.LINEAR,o=t?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case i.TEXTURE_TRILINEAR_SAMPLINGMODE:n=r.LINEAR,o=t?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case i.TEXTURE_NEAREST_SAMPLINGMODE:n=r.NEAREST,o=t?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case i.TEXTURE_NEAREST_NEAREST_MIPNEAREST:n=r.NEAREST,o=t?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case i.TEXTURE_NEAREST_LINEAR_MIPNEAREST:n=r.NEAREST,o=t?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case i.TEXTURE_NEAREST_LINEAR_MIPLINEAR:n=r.NEAREST,o=t?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case i.TEXTURE_NEAREST_LINEAR:n=r.NEAREST,o=r.LINEAR;break;case i.TEXTURE_NEAREST_NEAREST:n=r.NEAREST,o=r.NEAREST;break;case i.TEXTURE_LINEAR_NEAREST_MIPNEAREST:n=r.LINEAR,o=t?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case i.TEXTURE_LINEAR_NEAREST_MIPLINEAR:n=r.LINEAR,o=t?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case i.TEXTURE_LINEAR_LINEAR:n=r.LINEAR,o=r.LINEAR;break;case i.TEXTURE_LINEAR_NEAREST:n=r.LINEAR,o=r.NEAREST}return{min:o,mag:n}},i.prototype._partialLoadImg=function(t,i,r,n,o,s){var a;void 0===s&&(s=null);a=e.Tools.LoadImage(t,function(){r[i]=a,r._internalCount++,n&&n._removePendingData(a),6===r._internalCount&&o(r)},function(e,t){n&&n._removePendingData(a),s&&s(e,t)},n?n.database:null),n&&n._addPendingData(a)},i.prototype._cascadeLoadImgs=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var s=0;s<6;s++)this._partialLoadImg(r[s],s,o,t,i,n)},i.prototype._createTexture=function(){var e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e},i.prototype.createTexture=function(t,r,n,o,s,a,l,c,u,h,d){var f=this;void 0===s&&(s=i.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null);for(var p=String(t),m="data:"===p.substr(0,5),g="blob:"===p.substr(0,5),_=m&&-1!==p.indexOf(";base64,"),v=u||new e.InternalTexture(this,e.InternalTexture.DATASOURCE_URL),A=p.lastIndexOf("."),y=d||(A>-1?p.substring(A).toLowerCase():""),b=null,T=0,E=i._TextureLoaders;T<E.length;T++){var x=E[T];if(x.canLoad(y,this._textureFormatInUse,u,_,!!c)){b=x;break}}b&&(p=b.transformUrl(p,this._textureFormatInUse)),o&&o._addPendingData(v),v.url=p,v.generateMipMaps=!r,v.samplingMode=s,v.invertY=n,this._doNotHandleContextLost||(v._buffer=c);var P=null;a&&!u&&(P=v.onLoadedObservable.add(a)),u||this._internalTexturesCache.push(v);var M=function(i,a){o&&o._removePendingData(v);var u=!1;b&&(b.getFallbackTextureUrl(p,f._textureFormatInUse)&&(u=!0,f.createTexture(t,r,n,o,s,null,l,c,v)));u||(P&&v.onLoadedObservable.remove(P),e.Tools.UseFallbackTexture&&f.createTexture(e.Tools.fallbackTexture,r,n,o,s,null,l,c,v)),l&&l(i||"Unknown error",a)};if(b){var S=function(e){b.loadData(e,v,function(e,t,i,r,a){f._prepareWebGLTexture(v,o,e,t,n,!i,r,function(){return a(),!1},s)})};c?S(c):this._loadFile(p,S,void 0,o?o.database:void 0,!0,function(e,t){M("Unable to load "+(e&&e.responseURL,t))})}else{var C=function(t){g&&!f._doNotHandleContextLost&&(v._buffer=t),f._prepareWebGLTexture(v,o,t.width,t.height,n,r,!1,function(i,r,n){var s=f._gl,a=t.width===i&&t.height===r,l=h?f._getInternalFormat(h):".jpg"===y?s.RGB:s.RGBA;if(a)return s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,t),!1;var c=f._caps.maxTextureSize;if(t.width>c||t.height>c)return f._prepareWorkingCanvas(),!(!f._workingCanvas||!f._workingContext)&&(f._workingCanvas.width=i,f._workingCanvas.height=r,f._workingContext.drawImage(t,0,0,t.width,t.height,0,0,i,r),s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,f._workingCanvas),v.width=i,v.height=r,!1);var u=new e.InternalTexture(f,e.InternalTexture.DATASOURCE_TEMP);return f._bindTextureDirectly(s.TEXTURE_2D,u,!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),f._rescaleTexture(u,v,o,l,function(){f._releaseTexture(u),f._bindTextureDirectly(s.TEXTURE_2D,v,!0),n()}),!0},s)};!m||_?c instanceof HTMLImageElement?C(c):e.Tools.LoadImage(p,C,M,o?o.database:null):"string"==typeof c||c instanceof ArrayBuffer||c instanceof Blob?e.Tools.LoadImage(c,C,M,o?o.database:null):C(c)}return v},i.prototype._rescaleTexture=function(t,r,n,o,s){var a=this,l=this.createRenderTargetTexture({width:r.width,height:r.height},{generateMipMaps:!1,type:i.TEXTURETYPE_UNSIGNED_INT,samplingMode:i.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});this._rescalePostProcess||(this._rescalePostProcess=new e.PassPostProcess("rescale",1,null,i.TEXTURE_BILINEAR_SAMPLINGMODE,this,!1,i.TEXTURETYPE_UNSIGNED_INT)),this._rescalePostProcess.getEffect().executeWhenCompiled(function(){a._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=n;e||(e=a.scenes[a.scenes.length-1]),e.postProcessManager.directRender([a._rescalePostProcess],l,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,r,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,o,0,0,r.width,r.height,0),a.unBindFramebuffer(l),a._releaseTexture(l),s&&s()})},i.prototype.updateRawTexture=function(e,t,r,n,o,s){if(void 0===o&&(o=null),void 0===s&&(s=i.TEXTURETYPE_UNSIGNED_INT),e){var a=this._getRGBABufferInternalSizedFormat(s,r),l=this._getInternalFormat(r),c=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(e._bufferView=t,e.format=r,e.type=s,e.invertY=n,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,c,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},i.prototype.createRawTexture=function(t,r,n,o,s,a,l,c,u){void 0===c&&(c=null),void 0===u&&(u=i.TEXTURETYPE_UNSIGNED_INT);var h=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW);h.baseWidth=r,h.baseHeight=n,h.width=r,h.height=n,h.format=o,h.generateMipMaps=s,h.samplingMode=l,h.invertY=a,h._compression=c,h.type=u,this._doNotHandleContextLost||(h._bufferView=t),this.updateRawTexture(h,t,o,a,c,u),this._bindTextureDirectly(this._gl.TEXTURE_2D,h,!0);var d=this._getSamplingParameters(l,s);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,d.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,d.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(h),h},i.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},i.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},i.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},i.prototype.updateTextureSamplingMode=function(e,t){var i=this._getSamplingParameters(e,t.generateMipMaps);t.isCube?(this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):t.is3D?(this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_3D,null)):(this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},i.prototype.updateDynamicTexture=function(e,t,i,r,n){if(void 0===r&&(r=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(i),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var o=n?this._getInternalFormat(n):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}},i.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var r=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,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 n=e._workingCanvas.getContext("2d");if(!n)throw new Error("Unable to get 2d context");e._workingContext=n,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),r||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},i.prototype.updateTextureComparisonFunction=function(t,r){if(1!==this.webGLVersion){var n=this._gl;t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t,!0),0===r?(n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_COMPARE_FUNC,i.LEQUAL),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_COMPARE_MODE,n.NONE)):(n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_COMPARE_FUNC,r),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),0===r?(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_COMPARE_FUNC,i.LEQUAL),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_COMPARE_MODE,n.NONE)):(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_COMPARE_FUNC,r),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t._comparisonFunction=r}else e.Tools.Error("WebGL 1 does not support texture comparison.")},i.prototype._setupDepthStencilTexture=function(e,t,r,n,o){var s=t.width||t,a=t.height||t;e.baseWidth=s,e.baseHeight=a,e.width=s,e.height=a,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=r,e.samplingMode=n?i.TEXTURE_BILINEAR_SAMPLINGMODE:i.TEXTURE_NEAREST_SAMPLINGMODE,e.type=i.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=o;var l=this._gl,c=e.isCube?l.TEXTURE_CUBE_MAP:l.TEXTURE_2D,u=this._getSamplingParameters(e.samplingMode,!1);l.texParameteri(c,l.TEXTURE_MAG_FILTER,u.mag),l.texParameteri(c,l.TEXTURE_MIN_FILTER,u.min),l.texParameteri(c,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(c,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),0===o?(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,i.LEQUAL),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.NONE)):(l.texParameteri(c,l.TEXTURE_COMPARE_FUNC,o),l.texParameteri(c,l.TEXTURE_COMPARE_MODE,l.COMPARE_REF_TO_TEXTURE))},i.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t)}return this._createDepthStencilTexture(e,t)},i.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},i.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},i.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)}},i.prototype.createRenderTargetTexture=function(t,n){var o=new r;void 0!==n&&"object"==typeof n?(o.generateMipMaps=n.generateMipMaps,o.generateDepthBuffer=void 0===n.generateDepthBuffer||n.generateDepthBuffer,o.generateStencilBuffer=o.generateDepthBuffer&&n.generateStencilBuffer,o.type=void 0===n.type?i.TEXTURETYPE_UNSIGNED_INT:n.type,o.samplingMode=void 0===n.samplingMode?i.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode,o.format=void 0===n.format?i.TEXTUREFORMAT_RGBA:n.format):(o.generateMipMaps=n,o.generateDepthBuffer=!0,o.generateStencilBuffer=!1,o.type=i.TEXTURETYPE_UNSIGNED_INT,o.samplingMode=i.TEXTURE_TRILINEAR_SAMPLINGMODE,o.format=i.TEXTUREFORMAT_RGBA),(o.type!==i.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(o.type!==i.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(o.samplingMode=i.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=this._getSamplingParameters(o.samplingMode,!!o.generateMipMaps);o.type!==i.TEXTURETYPE_FLOAT||this._caps.textureFloat||(o.type=i.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 h=this._currentFramebuffer,d=s.createFramebuffer();return this.bindUnboundFramebuffer(d),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(h),a._framebuffer=d,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.format=o.format,a._generateDepthBuffer=o.generateDepthBuffer,a._generateStencilBuffer=!!o.generateStencilBuffer,this._internalTexturesCache.push(a),a},i.prototype.createMultipleRenderTarget=function(t,r){var n=!1,o=!0,s=!1,a=!1,l=1,c=i.TEXTURETYPE_UNSIGNED_INT,u=i.TEXTURE_TRILINEAR_SAMPLINGMODE,h=new Array,d=new Array;void 0!==r&&(n=void 0!==r.generateMipMaps&&r.generateMipMaps,o=void 0===r.generateDepthBuffer||r.generateDepthBuffer,s=void 0!==r.generateStencilBuffer&&r.generateStencilBuffer,a=void 0!==r.generateDepthTexture&&r.generateDepthTexture,l=r.textureCount||1,r.types&&(h=r.types),r.samplingModes&&(d=r.samplingModes));var f=this._gl,p=f.createFramebuffer();this.bindUnboundFramebuffer(p);for(var m=t.width||t,g=t.height||t,_=[],v=[],A=this._setupFramebufferDepthAttachments(s,o,m,g),y=0;y<l;y++){var b=d[y]||u,T=h[y]||c;(T!==i.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(T!==i.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(b=i.TEXTURE_NEAREST_SAMPLINGMODE);var E=this._getSamplingParameters(b,n);T!==i.TEXTURETYPE_FLOAT||this._caps.textureFloat||(T=i.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var x=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_MULTIRENDERTARGET),P=f[this.webGLVersion>1?"COLOR_ATTACHMENT"+y:"COLOR_ATTACHMENT"+y+"_WEBGL"];_.push(x),v.push(P),f.activeTexture(f["TEXTURE"+y]),f.bindTexture(f.TEXTURE_2D,x._webGLTexture),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,E.mag),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,E.min),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texImage2D(f.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(T),m,g,0,f.RGBA,this._getWebGLTextureType(T),null),f.framebufferTexture2D(f.DRAW_FRAMEBUFFER,P,f.TEXTURE_2D,x._webGLTexture,0),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(f.TEXTURE_2D,null),x._framebuffer=p,x._depthStencilBuffer=A,x.baseWidth=m,x.baseHeight=g,x.width=m,x.height=g,x.isReady=!0,x.samples=1,x.generateMipMaps=n,x.samplingMode=b,x.type=T,x._generateDepthBuffer=o,x._generateStencilBuffer=s,x._attachments=v,this._internalTexturesCache.push(x)}if(a&&this._caps.depthTextureExtension){var M=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_MULTIRENDERTARGET);f.activeTexture(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,M._webGLTexture),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texImage2D(f.TEXTURE_2D,0,this.webGLVersion<2?f.DEPTH_COMPONENT:f.DEPTH_COMPONENT16,m,g,0,f.DEPTH_COMPONENT,f.UNSIGNED_SHORT,null),f.framebufferTexture2D(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.TEXTURE_2D,M._webGLTexture,0),M._framebuffer=p,M.baseWidth=m,M.baseHeight=g,M.width=m,M.height=g,M.isReady=!0,M.samples=1,M.generateMipMaps=n,M.samplingMode=f.NEAREST,M._generateDepthBuffer=o,M._generateStencilBuffer=s,_.push(M),this._internalTexturesCache.push(M)}return f.drawBuffers(v),f.bindRenderbuffer(f.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),_},i.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},i.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},i.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);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r<e.length;r++){var a=e[r],l=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],c=i.createRenderbuffer();if(!c)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,c),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(a.type),a.width,a.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,c),a._MSAAFramebuffer=n,a._MSAARenderBuffer=c,a.samples=t,a._depthStencilBuffer=o,i.bindRenderbuffer(i.RENDERBUFFER,null),s.push(l)}i.drawBuffers(s)}else this.bindUnboundFramebuffer(e[0]._framebuffer);return this.bindUnboundFramebuffer(null),t},i.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0);var a=this._gl,l=a.TEXTURE_2D;e.isCube&&(l=a.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(l,s,t,i,r,0,n)},i.prototype._uploadDataToTextureDirectly=function(t,i,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var o=this._gl,s=this._getWebGLTextureType(t.type),a=this._getInternalFormat(t.format),l=this._getRGBABufferInternalSizedFormat(t.type,a);this._unpackFlipY(t.invertY);var c=o.TEXTURE_2D;t.isCube&&(c=o.TEXTURE_CUBE_MAP_POSITIVE_X+r);var u=Math.round(e.Scalar.Log2(t.width)),h=Math.round(e.Scalar.Log2(t.height)),d=Math.pow(2,Math.max(u-n,0)),f=Math.pow(2,Math.max(h-n,0));o.texImage2D(c,n,l,d,f,0,a,s,i)},i.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(o,null,!0)},i.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s),l=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);var c=n.TEXTURE_2D;e.isCube&&(c=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(c,r,a,s,o,t),this._bindTextureDirectly(l,null,!0)},i.prototype.createRenderTargetCubeTexture=function(t,r){var n=s({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:i.TEXTURETYPE_UNSIGNED_INT,samplingMode:i.TEXTURE_TRILINEAR_SAMPLINGMODE,format:i.TEXTUREFORMAT_RGBA},r);n.generateStencilBuffer=n.generateDepthBuffer&&n.generateStencilBuffer,(n.type!==i.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(n.type!==i.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(n.samplingMode=i.TEXTURE_NEAREST_SAMPLINGMODE);var o=this._gl,a=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,a,!0);var l=this._getSamplingParameters(n.samplingMode,n.generateMipMaps);n.type!==i.TEXTURETYPE_FLOAT||this._caps.textureFloat||(n.type=i.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,l.mag),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,l.min),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);for(var c=0;c<6;c++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,this._getRGBABufferInternalSizedFormat(n.type,n.format),t,t,0,this._getInternalFormat(n.format),this._getWebGLTextureType(n.type),null);var u=o.createFramebuffer();return this.bindUnboundFramebuffer(u),a._depthStencilBuffer=this._setupFramebufferDepthAttachments(n.generateStencilBuffer,n.generateDepthBuffer,t,t),n.generateMipMaps&&o.generateMipmap(o.TEXTURE_CUBE_MAP),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),o.bindRenderbuffer(o.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),a._framebuffer=u,a.width=t,a.height=t,a.isReady=!0,a.isCube=!0,a.samples=1,a.generateMipMaps=n.generateMipMaps,a.samplingMode=n.samplingMode,a.type=n.type,a.format=n.format,a._generateDepthBuffer=n.generateDepthBuffer,a._generateStencilBuffer=n.generateStencilBuffer,this._internalTexturesCache.push(a),a},i.prototype.createPrefilteredCubeTexture=function(t,i,r,n,o,s,a,l,c){var u=this;void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===c&&(c=!0);return this.createCubeTexture(t,i,null,!1,function(t){if(t){var s=t.texture;if(c?t.info.sphericalPolynomial&&(s._sphericalPolynomial=t.info.sphericalPolynomial):s._sphericalPolynomial=new e.SphericalPolynomial,s._dataSource=e.InternalTexture.DATASOURCE_CUBEPREFILTERED,u._caps.textureLOD)o&&o(s);else{var a=u._gl,l=t.width;if(l){for(var h=[],d=0;d<3;d++){var f=1-d/2,p=n,m=e.Scalar.Log2(l)*r+n,g=p+(m-p)*f,_=Math.round(Math.min(Math.max(g,0),m)),v=new e.InternalTexture(u,e.InternalTexture.DATASOURCE_TEMP);if(v.type=s.type,v.format=s.format,v.width=Math.pow(2,Math.max(e.Scalar.Log2(l)-_,0)),v.height=v.width,v.isCube=!0,u._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 A=t.info,y=t.data;u._unpackFlipY(A.isCompressed),e.DDSTools.UploadDDSLevels(u,v,y,A,!0,6,_)}else e.Tools.Warn("DDS is the only prefiltered cube map supported so far.");u._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var b=new e.BaseTexture(i);b.isCube=!0,b._texture=v,v.isReady=!0,h.push(b)}s._lodTextureHigh=h[2],s._lodTextureMid=h[1],s._lodTextureLow=h[0],o&&o(s)}}}else o&&o(null)},s,a,l,c,r,n)},i.prototype.createCubeTexture=function(t,r,n,o,s,a,l,c,u,h,d,f){var p=this;void 0===s&&(s=null),void 0===a&&(a=null),void 0===c&&(c=null),void 0===u&&(u=!1),void 0===h&&(h=0),void 0===d&&(d=0),void 0===f&&(f=null);var m=this._gl,g=f||new e.InternalTexture(this,e.InternalTexture.DATASOURCE_CUBE);g.isCube=!0,g.url=t,g.generateMipMaps=!o,g._lodGenerationScale=h,g._lodGenerationOffset=d,this._doNotHandleContextLost||(g._extension=c,g._files=n);for(var _=t.lastIndexOf("."),v=c||(_>-1?t.substring(_).toLowerCase():""),A=null,y=0,b=i._TextureLoaders;y<b.length;y++){var T=b[y];if(T.canLoad(v,this._textureFormatInUse,f,!1,!1)){A=T;break}}if(A){t=A.transformUrl(t,this._textureFormatInUse);var E=function(e){p._bindTextureDirectly(m.TEXTURE_CUBE_MAP,g,!0),A.loadCubeData(e,g,u,s,a)};n&&6===n.length?A.supportCascades?this._cascadeLoadFiles(r,E,n,a):a&&a("Textures type does not support cascades."):this._loadFile(t,E,void 0,void 0,!0,function(e,i){if(A){var c=A.getFallbackTextureUrl(t,p._textureFormatInUse);c&&p.createCubeTexture(c,r,n,o,s,a,l,v,u,h,d,g)}a&&e&&a(e.status+" "+e.statusText,i)})}else{if(!n)throw new Error("Cannot load cubemap because files were not defined");this._cascadeLoadImgs(t,r,function(t){var i=p.needPOTTextures?e.Tools.GetExponentOfTwo(t[0].width,p._caps.maxCubemapTextureSize):t[0].width,r=i;if(p._prepareWorkingCanvas(),p._workingCanvas&&p._workingContext){p._workingCanvas.width=i,p._workingCanvas.height=r;var n=[m.TEXTURE_CUBE_MAP_POSITIVE_X,m.TEXTURE_CUBE_MAP_POSITIVE_Y,m.TEXTURE_CUBE_MAP_POSITIVE_Z,m.TEXTURE_CUBE_MAP_NEGATIVE_X,m.TEXTURE_CUBE_MAP_NEGATIVE_Y,m.TEXTURE_CUBE_MAP_NEGATIVE_Z];p._bindTextureDirectly(m.TEXTURE_CUBE_MAP,g,!0),p._unpackFlipY(!1);for(var a=l?p._getInternalFormat(l):p._gl.RGBA,c=0;c<n.length;c++)p._workingContext.drawImage(t[c],0,0,t[c].width,t[c].height,0,0,i,r),m.texImage2D(n[c],0,a,a,m.UNSIGNED_BYTE,p._workingCanvas);o||m.generateMipmap(m.TEXTURE_CUBE_MAP),p._setCubeMapTextureParams(!o),g.width=i,g.height=r,g.isReady=!0,l&&(g.format=l),g.onLoadedObservable.notifyObservers(g),g.onLoadedObservable.clear(),s&&s()}},n,a)}return this._internalTexturesCache.push(g),g},i.prototype._setCubeMapTextureParams=function(e){var t=this._gl;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)},i.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,c=this._getWebGLTextureType(n),u=this._getInternalFormat(r),h=this._getRGBABufferInternalSizedFormat(n),d=!1;u===l.RGB&&(u=l.RGBA,d=!0),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,t,!0),this._unpackFlipY(void 0===o||!!o),t.width%4!=0&&l.pixelStorei(l.UNPACK_ALIGNMENT,1);for(var f=0;f<6;f++){var p=i[f];s?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+f,a,this.getCaps().s3tc[s],t.width,t.height,0,p):(d&&(p=this._convertRGBtoRGBATextureData(p,t.width,t.height,n)),l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+f,a,h,t.width,t.height,0,u,c,p))}(!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},i.prototype.createRawCubeTexture=function(t,r,n,o,s,a,l,c){void 0===c&&(c=null);var u=this._gl,h=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_CUBERAW);h.isCube=!0,h.format=n,h.type=o,this._doNotHandleContextLost||(h._bufferViewArray=t);var d=this._getWebGLTextureType(o),f=this._getInternalFormat(n);f===u.RGB&&(f=u.RGBA),d!==u.FLOAT||this._caps.textureFloatLinearFiltering?d!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?d!==u.FLOAT||this._caps.textureFloatRender?d!==u.HALF_FLOAT||this._caps.colorBufferFloat||(s=!1,e.Tools.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(s=!1,e.Tools.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(s=!1,l=i.TEXTURE_NEAREST_SAMPLINGMODE,e.Tools.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(s=!1,l=i.TEXTURE_NEAREST_SAMPLINGMODE,e.Tools.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var p=r,m=p;h.width=p,h.height=m,!this.needPOTTextures||e.Tools.IsExponentOfTwo(h.width)&&e.Tools.IsExponentOfTwo(h.height)||(s=!1),t&&this.updateRawCubeTexture(h,t,n,o,a,c),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,h,!0),t&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var g=this._getSamplingParameters(l,s);return u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,g.mag),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,g.min),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,null),h.generateMipMaps=s,h},i.prototype.createRawCubeTextureFromUrl=function(e,t,r,n,o,s,a,l,c,u,h,d){var f=this;void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=i.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===d&&(d=!1);var p=this._gl,m=this.createRawCubeTexture(null,r,n,o,!s,d,h);t._addPendingData(m),m.url=e,this._internalTexturesCache.push(m);return this._loadFile(e,function(e){!function(e){var i=m.width,r=a(e);if(r){if(l){var s=f._getWebGLTextureType(o),u=f._getInternalFormat(n),h=f._getRGBABufferInternalSizedFormat(o),g=!1;u===p.RGB&&(u=p.RGBA,g=!0),f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),f._unpackFlipY(!1);for(var _=l(r),v=0;v<_.length;v++)for(var A=i>>v,y=0;y<6;y++){var b=_[v][y];g&&(b=f._convertRGBtoRGBATextureData(b,A,A,o)),p.texImage2D(y,v,h,A,A,0,u,s,b)}f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else f.updateRawCubeTexture(m,r,n,o,d);m.isReady=!0,t._removePendingData(m),c&&c()}}(e)},void 0,t.database,!0,function(e,i){t._removePendingData(m),u&&e&&u(e.status+" "+e.statusText,i)}),m},i.prototype.updateRawTexture3D=function(e,t,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=i.TEXTURETYPE_UNSIGNED_INT);var a=this._getWebGLTextureType(s),l=this._getInternalFormat(r),c=this._getRGBABufferInternalSizedFormat(s,r);this._bindTextureDirectly(this._gl.TEXTURE_3D,e,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(e._bufferView=t,e.format=r,e.invertY=n,e._compression=o),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&t?this._gl.compressedTexImage3D(this._gl.TEXTURE_3D,0,this.getCaps().s3tc[o],e.width,e.height,e.depth,0,t):this._gl.texImage3D(this._gl.TEXTURE_3D,0,c,e.width,e.height,e.depth,0,l,a,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),e.isReady=!0},i.prototype.createRawTexture3D=function(t,r,n,o,s,a,l,c,u,h){void 0===u&&(u=null),void 0===h&&(h=i.TEXTURETYPE_UNSIGNED_INT);var d=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW3D);d.baseWidth=r,d.baseHeight=n,d.baseDepth=o,d.width=r,d.height=n,d.depth=o,d.format=s,d.type=h,d.generateMipMaps=a,d.samplingMode=c,d.is3D=!0,this._doNotHandleContextLost||(d._bufferView=t),this.updateRawTexture3D(d,t,s,l,u,h),this._bindTextureDirectly(this._gl.TEXTURE_3D,d,!0);var f=this._getSamplingParameters(c,a);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(d),d},i.prototype._prepareWebGLTextureContinuation=function(e,t,i,r,n){var o=this._gl;if(o){var s=this._getSamplingParameters(n,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.min),i||r||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},i.prototype._prepareWebGLTexture=function(t,r,n,o,s,a,l,c,u){var h=this;void 0===u&&(u=i.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?e.Tools.GetExponentOfTwo(n,d):n),p=Math.min(d,this.needPOTTextures?e.Tools.GetExponentOfTwo(o,d):o),m=this._gl;m&&(t._webGLTexture?(this._bindTextureDirectly(m.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===s||!!s),t.baseWidth=n,t.baseHeight=o,t.width=f,t.height=p,t.isReady=!0,c(f,p,function(){h._prepareWebGLTextureContinuation(t,r,a,l,u)})||this._prepareWebGLTextureContinuation(t,r,a,l,u)):r&&r._removePendingData(t))},i.prototype._convertRGBtoRGBATextureData=function(e,t,r,n){var o;o=n===i.TEXTURETYPE_FLOAT?new Float32Array(t*r*4):new Uint32Array(t*r*4);for(var s=0;s<t;s++)for(var a=0;a<r;a++){var l=3*(a*t+s),c=4*(a*t+s);o[c+0]=e[l+0],o[c+1]=e[l+1],o[c+2]=e[l+2],o[c+3]=1}return o},i.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)},i.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)})})})},i.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},i.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},i.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))},i.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},i.prototype._linkTrackers=function(e,t){e.next=t,t.previous=e},i.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))},i.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},i.prototype._bindTextureDirectly=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=!1;i&&t&&t._designatedSlot>-1&&(this._activeChannel=t._designatedSlot);var o=this._boundTexturesCache[this._activeChannel],s=t&&t._initialSlot>-1;if(o!==t||r){if(o&&this._removeDesignatedSlot(o),this._activateCurrentTexture(),this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t){if(!this.disableTextureBindingOptimization){var a=this._nextFreeTextureSlots.indexOf(this._activeChannel);a>-1&&this._nextFreeTextureSlots.splice(a,1),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,t),this._linkTrackers(t,this._lastBoundInternalTextureTracker)}t._designatedSlot=this._activeChannel}}else i&&(n=!0,this._activateCurrentTexture());return s&&!i&&this._bindSamplerUniformToChannel(t._initialSlot,this._activeChannel),n},i.prototype._bindTexture=function(e,t){e<0||(t&&(e=this._getCorrectTextureChannel(e,t)),this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},i.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},i.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},i.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)},i.prototype.setTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},i.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))},i.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},i.prototype._getTextureWrapMode=function(e){switch(e){case i.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case i.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case i.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},i.prototype._setTexture=function(e,t,r,n){if(void 0===r&&(r=!1),void 0===n&&(n=!1),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===i.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var o;o=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:this.emptyTexture,r||(e=this._getCorrectTextureChannel(e,o));var s=!0;if(this._boundTexturesCache[e]===o&&(this._moveBoundTextureOnTop(o),r||this._bindSamplerUniformToChannel(o._initialSlot,e),s=!1),this._activeChannel=e,o&&o.is3D)s&&this._bindTextureDirectly(this._gl.TEXTURE_3D,o,r),o&&o._cachedWrapU!==t.wrapU&&(o._cachedWrapU=t.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),o)),o&&o._cachedWrapV!==t.wrapV&&(o._cachedWrapV=t.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),o)),o&&o._cachedWrapR!==t.wrapR&&(o._cachedWrapR=t.wrapR,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),o)),this._setAnisotropicLevel(this._gl.TEXTURE_3D,t);else if(o&&o.isCube){if(s&&this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,o,r),o._cachedCoordinatesMode!==t.coordinatesMode){o._cachedCoordinatesMode=t.coordinatesMode;var a=t.coordinatesMode!==i.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==i.TEXTURE_SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,a,o),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,a)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,t)}else s&&this._bindTextureDirectly(this._gl.TEXTURE_2D,o,r),o&&o._cachedWrapU!==t.wrapU&&(o._cachedWrapU=t.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),o)),o&&o._cachedWrapV!==t.wrapV&&(o._cachedWrapV=t.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),o)),this._setAnisotropicLevel(this._gl.TEXTURE_2D,t);return!0},i.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)}},i.prototype._setAnisotropicLevel=function(e,t){var r=t.getInternalTexture();if(r){var n=this._caps.textureAnisotropicFilterExtension,o=t.anisotropicFilteringLevel;r.samplingMode!==i.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&r.samplingMode!==i.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&r.samplingMode!==i.TEXTURE_LINEAR_LINEAR&&(o=1),n&&r._cachedAnisotropicFilteringLevel!==o&&(this._setTextureParameterFloat(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o,this._caps.maxAnisotropy),r),r._cachedAnisotropicFilteringLevel=o)}},i.prototype._setTextureParameterFloat=function(e,t,i,r){this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameterf(e,t,i)},i.prototype._setTextureParameterInteger=function(e,t,i,r){r&&this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameteri(e,t,i)},i.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},i.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},i.prototype.getExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.get(t)},i.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},i.prototype.removeExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.remove(t)},i.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}else{e=0;for(var t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)}},i.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},i.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===i.Instances.length&&i.audioEngine&&i.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=i.Instances.indexOf(this);t>=0&&i.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 r=0,n=this._activeRequests;r<n.length;r++){n[r].abort()}},i.prototype.displayLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.displayLoadingUI()}},i.prototype.hideLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.hideLoadingUI()}},Object.defineProperty(i.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(i.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),i.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},i.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},i.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},i.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},i.prototype.getError=function(){return this._gl.getError()},i.prototype.getFps=function(){return this._fps},i.prototype.getDeltaTime=function(){return this._deltaTime},i.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},i.prototype._readTexturePixels=function(e,t,i,r,n,o){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null);var s=this._gl;if(!this._dummyFramebuffer){var a=s.createFramebuffer();if(!a)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=a}s.bindFramebuffer(s.FRAMEBUFFER,this._dummyFramebuffer),r>-1?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,n):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e._webGLTexture,n);var l=void 0!==e.type?this._getWebGLTextureType(e.type):s.UNSIGNED_BYTE;switch(l){case s.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),l=s.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),l=s.FLOAT}return s.readPixels(0,0,t,i,s.RGBA,l,o),s.bindFramebuffer(s.FRAMEBUFFER,this._currentFramebuffer),o},i.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(i.TEXTURETYPE_FLOAT)},i.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(i.TEXTURETYPE_HALF_FLOAT)},i.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,l=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,l),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},i.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case i.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case i.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case i.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE}return this._gl.UNSIGNED_BYTE}switch(e){case i.TEXTURETYPE_BYTE:return this._gl.BYTE;case i.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case i.TEXTURETYPE_SHORT:return this._gl.SHORT;case i.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case i.TEXTURETYPE_INT:return this._gl.INT;case i.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case i.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case i.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case i.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},i.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case i.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case i.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case i.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case i.TEXTUREFORMAT_RED:t=this._gl.RED;break;case i.TEXTUREFORMAT_RG:t=this._gl.RG;break;case i.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case i.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}if(this._webGLVersion>1)switch(e){case i.TEXTUREFORMAT_RED_INTEGER:t=this._gl.RED_INTEGER;break;case i.TEXTUREFORMAT_RG_INTEGER:t=this._gl.RG_INTEGER;break;case i.TEXTUREFORMAT_RGB_INTEGER:t=this._gl.RGB_INTEGER;break;case i.TEXTUREFORMAT_RGBA_INTEGER:t=this._gl.RGBA_INTEGER}return t},i.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case i.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case i.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case i.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA}return this._gl.RGBA}switch(e){case i.TEXTURETYPE_BYTE:switch(t){case i.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case i.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case i.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case i.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case i.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case i.TEXTUREFORMAT_RED:return this._gl.R8;case i.TEXTUREFORMAT_RG:return this._gl.RG8;case i.TEXTUREFORMAT_RGB:return this._gl.RGB8;case i.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case i.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;default:return this._gl.RGBA8}case i.TEXTURETYPE_SHORT:switch(t){case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case i.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case i.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case i.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case i.TEXTURETYPE_INT:switch(t){case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case i.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case i.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case i.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case i.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case i.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case i.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case i.TEXTURETYPE_FLOAT:switch(t){case i.TEXTUREFORMAT_RED:return this._gl.R32F;case i.TEXTUREFORMAT_RG:return this._gl.RG32F;case i.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case i.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case i.TEXTURETYPE_HALF_FLOAT:switch(t){case i.TEXTUREFORMAT_RED:return this._gl.R16F;case i.TEXTUREFORMAT_RG:return this._gl.RG16F;case i.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case i.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case i.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case i.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},i.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===i.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===i.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},i.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},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.prototype._partialLoadFile=function(e,t,i,r,n,o){void 0===o&&(o=null);this._loadFile(e,function(e){i[t]=e,i._internalCount++,6===i._internalCount&&n(i)},void 0,void 0,!0,function(e,t){o&&e&&o(e.status+" "+e.statusText,t)})},i.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)},i.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},i.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"]}],i.Instances=new Array,i._TextureLoaders=[],i.ALPHA_DISABLE=0,i.ALPHA_ADD=1,i.ALPHA_COMBINE=2,i.ALPHA_SUBTRACT=3,i.ALPHA_MULTIPLY=4,i.ALPHA_MAXIMIZED=5,i.ALPHA_ONEONE=6,i.ALPHA_PREMULTIPLIED=7,i.ALPHA_PREMULTIPLIED_PORTERDUFF=8,i.ALPHA_INTERPOLATE=9,i.ALPHA_SCREENMODE=10,i.DELAYLOADSTATE_NONE=0,i.DELAYLOADSTATE_LOADED=1,i.DELAYLOADSTATE_LOADING=2,i.DELAYLOADSTATE_NOTLOADED=4,i.NEVER=512,i.ALWAYS=519,i.LESS=513,i.EQUAL=514,i.LEQUAL=515,i.GREATER=516,i.GEQUAL=518,i.NOTEQUAL=517,i.KEEP=7680,i.REPLACE=7681,i.INCR=7682,i.DECR=7683,i.INVERT=5386,i.INCR_WRAP=34055,i.DECR_WRAP=34056,i.TEXTURE_CLAMP_ADDRESSMODE=0,i.TEXTURE_WRAP_ADDRESSMODE=1,i.TEXTURE_MIRROR_ADDRESSMODE=2,i.TEXTUREFORMAT_ALPHA=0,i.TEXTUREFORMAT_LUMINANCE=1,i.TEXTUREFORMAT_LUMINANCE_ALPHA=2,i.TEXTUREFORMAT_RGB=4,i.TEXTUREFORMAT_RGBA=5,i.TEXTUREFORMAT_RED=6,i.TEXTUREFORMAT_R=6,i.TEXTUREFORMAT_RG=7,i.TEXTUREFORMAT_RED_INTEGER=8,i.TEXTUREFORMAT_R_INTEGER=8,i.TEXTUREFORMAT_RG_INTEGER=9,i.TEXTUREFORMAT_RGB_INTEGER=10,i.TEXTUREFORMAT_RGBA_INTEGER=11,i.TEXTURETYPE_UNSIGNED_BYTE=0,i.TEXTURETYPE_UNSIGNED_INT=0,i.TEXTURETYPE_FLOAT=1,i.TEXTURETYPE_HALF_FLOAT=2,i.TEXTURETYPE_BYTE=3,i.TEXTURETYPE_SHORT=4,i.TEXTURETYPE_UNSIGNED_SHORT=5,i.TEXTURETYPE_INT=6,i.TEXTURETYPE_UNSIGNED_INTEGER=7,i.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,i.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,i.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,i.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,i.TEXTURETYPE_UNSIGNED_INT_24_8=12,i.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,i.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,i.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,i.TEXTURE_NEAREST_SAMPLINGMODE=1,i.TEXTURE_BILINEAR_SAMPLINGMODE=2,i.TEXTURE_TRILINEAR_SAMPLINGMODE=3,i.TEXTURE_NEAREST_NEAREST_MIPLINEAR=1,i.TEXTURE_LINEAR_LINEAR_MIPNEAREST=2,i.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,i.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,i.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,i.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,i.TEXTURE_NEAREST_LINEAR=7,i.TEXTURE_NEAREST_NEAREST=8,i.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,i.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,i.TEXTURE_LINEAR_LINEAR=11,i.TEXTURE_LINEAR_NEAREST=12,i.TEXTURE_EXPLICIT_MODE=0,i.TEXTURE_SPHERICAL_MODE=1,i.TEXTURE_PLANAR_MODE=2,i.TEXTURE_CUBIC_MODE=3,i.TEXTURE_PROJECTION_MODE=4,i.TEXTURE_SKYBOX_MODE=5,i.TEXTURE_INVCUBIC_MODE=6,i.TEXTURE_EQUIRECTANGULAR_MODE=7,i.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,i.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.SCALEMODE_FLOOR=1,i.SCALEMODE_NEAREST=2,i.SCALEMODE_CEILING=3,i.CollisionsEpsilon=.001,i.CodeRepository="src/",i.ShadersRepository="src/Shaders/",i}();e.Engine=a}(a||(a={})),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._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this._childRenderId=-1,this._worldMatrix=e.Matrix.Identity(),this._worldMatrixDeterminant=0,this._sceneRootNodesIndex=-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(),this.addToSceneRootNodes()}return t.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},t.Construct=function(e,t,i,r){var n=this._NodeConstructors[e];return n?n(t,i,r):null},t.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this.addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this.removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!0,configurable:!0}),t.prototype.addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},t.prototype.removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(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,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(function(){e.attach(i)}):e.attach(this),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 this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},t.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminant},Object.defineProperty(t.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),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._parentNode&&(this._parentRenderId=this._parentNode._childRenderId)},t.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentRenderId===this._parentNode._childRenderId&&this._parentNode.isSynchronized()},t.prototype.isSynchronized=function(){return this._cache.parent!=this._parentNode?(this._cache.parent=this._parentNode,!1):!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},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:!!this._isEnabled&&this._isParentEnabled},t.prototype._syncParentEnabledState=function(){this._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach(function(e){e._syncParentEnabledState()})},t.prototype.setEnabled=function(e){this._isEnabled=e,this._syncParentEnabledState()},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){e!==this._isReady&&(e?(this.onReady&&this.onReady(this),this._isReady=!0):this._isReady=!1)},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 this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},t.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),e)for(var i=0,r=this.getChildTransformNodes(!0);i<r.length;i++){var n=r[i];n.parent=null,n.computeWorldMatrix(!0)}else for(var o=0,s=this.getDescendants(!0);o<s.length;o++){s[o].dispose(e,t)}this.parent?this.parent=null:this.removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var a=0,l=this._behaviors;a<l.length;a++){l[a].detach()}this._behaviors=[],this._isDisposed=!0},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)}},t._NodeConstructors={},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}(a||(a={})),function(e){var t=e.Matrix.Identity(),i=function(){function i(t,i){this.center=e.Vector3.Zero(),this.centerWorld=e.Vector3.Zero(),this.minimum=e.Vector3.Zero(),this.maximum=e.Vector3.Zero(),this.reConstruct(t,i)}return i.prototype.reConstruct=function(i,r){this.minimum.copyFrom(i),this.maximum.copyFrom(r);var n=e.Vector3.Distance(i,r);e.Vector3.LerpToRef(i,r,.5,this.center),this.radius=.5*n,this.centerWorld.set(0,0,0),this._update(t)},i.prototype.scale=function(t){var i=this.radius*t,r=e.Tmp.Vector3[0].set(i,i,i),n=e.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(r),o=e.Tmp.Vector3[2].copyFrom(this.center).addInPlace(r);return this.reConstruct(n,o),this},i.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.Tmp.Vector3[0];e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius},i.prototype.isInFrustum=function(e){for(var t=0;t<6;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},i.prototype.intersectsPoint=function(e){var t=this.centerWorld.x-e.x,i=this.centerWorld.y-e.y,r=this.centerWorld.z-e.z,n=Math.sqrt(t*t+i*i+r*r);return!(this.radiusWorld<n)},i.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)},i}();e.BoundingSphere=i}(a||(a={})),function(e){var t=function(){function t(t,i){this.vectors=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],this.center=e.Vector3.Zero(),this.centerWorld=e.Vector3.Zero(),this.extendSize=e.Vector3.Zero(),this.extendSizeWorld=e.Vector3.Zero(),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],this.vectorsWorld=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this.minimum=e.Vector3.Zero(),this.maximum=e.Vector3.Zero(),this.reConstruct(t,i)}return t.prototype.reConstruct=function(t,i){this.minimum.copyFrom(t),this.maximum.copyFrom(i),this.vectors[0].copyFrom(this.minimum),this.vectors[1].copyFrom(this.maximum),this.vectors[2].copyFrom(this.minimum),this.vectors[3].copyFrom(this.minimum),this.vectors[4].copyFrom(this.minimum),this.vectors[5].copyFrom(this.maximum),this.vectors[6].copyFrom(this.maximum),this.vectors[7].copyFrom(this.maximum),this.vectors[2].x=this.maximum.x,this.vectors[3].y=this.maximum.y,this.vectors[4].z=this.maximum.z,this.vectors[5].z=this.minimum.z,this.vectors[6].x=this.minimum.x,this.vectors[7].y=this.minimum.y,this.center.copyFrom(this.maximum).addInPlace(this.minimum).scaleInPlace(.5),this.extendSize.copyFrom(this.maximum).subtractInPlace(this.minimum).scaleInPlace(.5);for(var r=0;r<3;r++)this.directions[r].copyFromFloats(0,0,0);for(r=0;r<8;r++)this.vectorsWorld[r].copyFromFloats(0,0,0);this.minimumWorld.copyFromFloats(0,0,0),this.maximumWorld.copyFromFloats(0,0,0),this.centerWorld.copyFromFloats(0,0,0),this.extendSizeWorld.copyFromFloats(0,0,0),this._update(this._worldMatrix||e.Matrix.Identity())},t.prototype.scale=function(t){var i=e.Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(this.minimum),r=i.length()*t;i.normalize();var n=i.scaleInPlace(.5*r),o=e.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(n),s=e.Tmp.Vector3[2].copyFrom(this.center).addInPlace(n);return this.reConstruct(o,s),this},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<8;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),this.minimumWorld.minimizeInPlace(r),this.maximumWorld.maximizeInPlace(r)}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}(a||(a={})),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+Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y+Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z;return{min:r-n,max:r+n}},i=function(e,i,r){var n=t(e,i),o=t(e,r);return function(e,t,i,r){return!(e>r||i>t)}(n.min,n.max,o.min,o.max)},r=function(){function t(t,i){this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!0,configurable:!0}),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){var r=e.Tmp.Vector3[0].copyFrom(t).subtractInPlace(i),n=e.Tmp.Vector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(r,n),this.boundingSphere.reConstruct(r,n),this},t.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},t.prototype.isInFrustum=function(t,i){return void 0===i&&(i=e.AbstractMesh.CULLINGSTRATEGY_STANDARD),!!this.boundingSphere.isInFrustum(t)&&(i===e.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY||this.boundingBox.isInFrustum(t))},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,r){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(!r)return!0;var n=this.boundingBox,o=t.boundingBox;return!!i(n.directions[0],n,o)&&(!!i(n.directions[1],n,o)&&(!!i(n.directions[2],n,o)&&(!!i(o.directions[0],n,o)&&(!!i(o.directions[1],n,o)&&(!!i(o.directions[2],n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&(!!i(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&!!i(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))))))))))))))},t}();e.BoundingInfo=r}(a||(a={})),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._position=e.Vector3.Zero(),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.ignoreNonUniformScaling=!1,s._localWorld=e.Matrix.Zero(),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,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},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.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 c=-Math.atan2(a.z,a.x)-Math.PI/2,u=Math.sqrt(a.x*a.x+a.z*a.z),h=Math.atan2(a.y,u);return this.rotationQuaternion?e.Quaternion.RotationYawPitchRollToRef(c+r,h+n,o,this.rotationQuaternion):(this.rotation.x=h+n,this.rotation.y=c+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(!t&&!this.parent)return this;if(t){n=e.Tmp.Quaternion[0],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[1];var i=e.Tmp.Matrix[0],r=e.Tmp.Matrix[1];this.computeWorldMatrix(!0),t.computeWorldMatrix(!0),t.getWorldMatrix().invertToRef(r),this.getWorldMatrix().multiplyToRef(r,i),i.decompose(s,n,o),this.rotationQuaternion?this.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(this.rotation),this.position.x=o.x,this.position.y=o.y,this.position.z=o.z,this.scaling.x=s.x,this.scaling.y=s.y,this.scaling.z=s.z}else{var n=e.Tmp.Quaternion[0],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[1];this.parent&&this.parent.computeWorldMatrix&&this.parent.computeWorldMatrix(!0),this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(s,n,o),this.rotationQuaternion?this.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(this.rotation),this.scaling.x=s.x,this.scaling.y=s.y,this.scaling.z=s.z,this.position.x=o.x,this.position.y=o.y,this.position.z=o.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=e,!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){var o;if(t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero()),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)).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())return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;(this._updateCache(),this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this.getScene().getRenderId(),this._isDirty=!1,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 this._postMultiplyPivotMatrix&&e.Tmp.Matrix[5].multiplyToRef(this._pivotMatrixInverse,e.Tmp.Matrix[5]),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.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this.scaling.isNonUniform?this._updateNonUniformScalingState(!0):this.parent&&this.parent._nonUniformScaling?this._updateNonUniformScalingState(this.parent._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=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 c=a[l];c.clone&&c.clone(t+"."+c.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("position")],i.prototype,"_position",void 0),n([e.serializeAsVector3("rotation")],i.prototype,"_rotation",void 0),n([e.serializeAsQuaternion("rotationQuaternion")],i.prototype,"_rotationQuaternion",void 0),n([e.serializeAsVector3("scaling")],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.serialize()],i.prototype,"ignoreNonUniformScaling",void 0),i}(e.Node);e.TransformNode=t}(a||(a={})),function(e){var t=function(){return function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=e.Vector3.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}(),i=function(i){function r(n,o){void 0===o&&(o=null);var s=i.call(this,n,o,!1)||this;return s._facetData=new t,s.cullingStrategy=r.CULLINGSTRATEGY_STANDARD,s.onCollideObservable=new e.Observable,s.onCollisionPositionChangeObservable=new e.Observable,s.onMaterialChangedObservable=new e.Observable,s.definedFacingForward=!0,s._visibility=1,s.alphaIndex=Number.MAX_VALUE,s.isVisible=!0,s.isPickable=!0,s.showSubMeshesBoundingBox=!1,s.isBlocker=!1,s.enablePointerMoveEvents=!1,s.renderingGroupId=0,s._receiveShadows=!1,s.outlineColor=e.Color3.Red(),s.outlineWidth=.02,s.overlayColor=e.Color3.Red(),s.overlayAlpha=.5,s._hasVertexAlpha=!1,s._useVertexColors=!0,s._computeBonesUsingShaders=!0,s._numBoneInfluencers=4,s._applyFog=!0,s.useOctreeForRenderingSelection=!0,s.useOctreeForPicking=!0,s.useOctreeForCollisions=!0,s._layerMask=268435455,s.alwaysSelectAsActiveMesh=!1,s.actionManager=null,s._checkCollisions=!1,s._collisionMask=-1,s._collisionGroup=-1,s.ellipsoid=new e.Vector3(.5,1,.5),s.ellipsoidOffset=new e.Vector3(0,0,0),s._oldPositionForCollisions=new e.Vector3(0,0,0),s._diffPositionForCollisions=new e.Vector3(0,0,0),s.edgesWidth=1,s.edgesColor=new e.Color4(1,0,0,1),s._renderId=0,s._intersectionsInProgress=new Array,s._unIndexed=!1,s._lightSources=new Array,s.onRebuildObservable=new e.Observable,s._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),s.getScene().workerCollisions&&i.multiplyInPlace(s._collider._radius),i.subtractToRef(s._oldPositionForCollisions,s._diffPositionForCollisions),s._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&s.position.addInPlace(s._diffPositionForCollisions),r&&s.onCollideObservable.notifyObservers(r),s.onCollisionPositionChangeObservable.notifyObservers(s.position)},s.getScene().addMesh(s),s._resyncLightSources(),s}return o(r,i),Object.defineProperty(r,"BILLBOARDMODE_NONE",{get:function(){return e.TransformNode.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_X",{get:function(){return e.TransformNode.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_Y",{get:function(){return e.TransformNode.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_Z",{get:function(){return e.TransformNode.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_ALL",{get:function(){return e.TransformNode.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"facetNb",{get:function(){return this._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"partitioningSubdivisions",{get:function(){return this._facetData.partitioningSubdivisions},set:function(e){this._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"partitioningBBoxRatio",{get:function(){return this._facetData.partitioningBBoxRatio},set:function(e){this._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"mustDepthSortFacets",{get:function(){return this._facetData.facetDepthSort},set:function(e){this._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"facetDepthSortFrom",{get:function(){return this._facetData.facetDepthSortFrom},set:function(e){this._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFacetDataEnabled",{get:function(){return this._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),r.prototype._updateNonUniformScalingState=function(e){return!!i.prototype._updateNonUniformScalingState.call(this,e)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(r.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility!==e&&(this._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.prototype,"receiveShadows",{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.prototype,"useVertexColors",{get:function(){return this._useVertexColors},set:function(e){this._useVertexColors!==e&&(this._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"computeBonesUsingShaders",{get:function(){return this._computeBonesUsingShaders},set:function(e){this._computeBonesUsingShaders!==e&&(this._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"numBoneInfluencers",{get:function(){return this._numBoneInfluencers},set:function(e){this._numBoneInfluencers!==e&&(this._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"applyFog",{get:function(){return this._applyFog},set:function(e){this._applyFog!==e&&(this._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layerMask",{get:function(){return this._layerMask},set:function(e){e!==this._layerMask&&(this._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),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,"collisionGroup",{get:function(){return this._collisionGroup},set:function(e){this._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.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}),r.prototype.getClassName=function(){return"AbstractMesh"},r.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},r.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){t[e]._rebuild()}},r.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()},r.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()},r.prototype._unBindEffect=function(){for(var e=0,t=this.subMeshes;e<t.length;e++){t[e].setEffect(null)}},r.prototype._removeLightSource=function(e){var t=this._lightSources.indexOf(e);-1!==t&&(this._lightSources.splice(t,1),this._markSubMeshesAsLightDirty())},r.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)}},r.prototype._markSubMeshesAsLightDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsLightDirty()})},r.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsAttributesDirty()})},r.prototype._markSubMeshesAsMiscDirty=function(){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t].getMaterial();r&&r.markAsDirty(e.Material.MiscDirtyFlag)}},Object.defineProperty(r.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype.getLOD=function(e){return this},r.prototype.getTotalVertices=function(){return 0},r.prototype.getIndices=function(){return null},r.prototype.getVerticesData=function(e){return null},r.prototype.setVerticesData=function(e,t,i,r){return this},r.prototype.updateVerticesData=function(e,t,i,r){return this},r.prototype.setIndices=function(e,t){return this},r.prototype.isVerticesDataPresent=function(e){return!1},r.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},r.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},r.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(r.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){},r.prototype._preActivateForIntermediateRendering=function(e){},r.prototype._activate=function(e){this._renderId=e},r.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():i.prototype.getWorldMatrix.call(this)},r.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():i.prototype._getWorldMatrixDeterminant.call(this)},r.prototype.movePOV=function(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this},r.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},r.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},r.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},r.prototype.getHierarchyBoundingVectors=function(t,i){var r,n;void 0===t&&(t=!0),void 0===i&&(i=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var o=this.getBoundingInfo();if(this.subMeshes?(r=o.boundingBox.minimumWorld,n=o.boundingBox.maximumWorld):(r=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)),t)for(var s=0,a=this.getDescendants(!1);s<a.length;s++){var l=a[s];if(l.computeWorldMatrix(!0),(!i||i(l))&&l.getBoundingInfo&&0!==l.getTotalVertices()){var c=l.getBoundingInfo().boundingBox,u=c.minimumWorld,h=c.maximumWorld;e.Tools.CheckExtends(u,r,n),e.Tools.CheckExtends(h,r,n)}}return{min:r,max:n}},r.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},r.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,i=0;i<t;i++){var r=this.subMeshes[i];(t>1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},r.prototype._afterComputeWorldMatrix=function(){this._updateBoundingInfo()},r.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},r.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},r.prototype.intersectsMesh=function(e,t,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var r=0,n=this.getChildMeshes();r<n.length;r++){if(n[r].intersectsMesh(e,t,!0))return!0}return!1},r.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},r.prototype.getPositionInCameraSpace=function(t){return void 0===t&&(t=null),t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},r.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},Object.defineProperty(r.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(r.prototype,"collider",{get:function(){return this._collider},enumerable:!0,configurable:!0}),r.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},r.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},r.prototype._processCollisionsForSubMeshes=function(e,t){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),r=i.length,n=0;n<r;n++){var o=i.data[n];r>1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},r.prototype._checkCollision=function(t){if(!this._boundingInfo||!this._boundingInfo._checkCollision(t))return this;var i=e.Tmp.Matrix[0],r=e.Tmp.Matrix[1];return e.Matrix.ScalingToRef(1/t._radius.x,1/t._radius.y,1/t._radius.z,i),this.worldMatrixFromCache.multiplyToRef(i,r),this._processCollisionsForSubMeshes(t,r),this},r.prototype._generatePointsArray=function(){return!1},r.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;for(var n=null,o=this._scene.getIntersectingSubMeshCandidates(this,t),s=o.length,a=0;a<s;a++){var l=o.data[a];if(!(s>1)||l.canIntersects(t)){var c=l.intersects(t,this._positions,this.getIndices(),i);if(c&&(i||!n||c.distance<n.distance)&&((n=c).subMeshId=a,i))break}}if(n){var u=this.getWorldMatrix(),h=e.Vector3.TransformCoordinates(t.origin,u),d=t.direction.clone();d=d.scale(n.distance);var f=e.Vector3.TransformNormal(d,u),p=h.add(f);return r.hit=!0,r.distance=e.Vector3.Distance(h,p),r.pickedPoint=p,r.pickedMesh=this,r.bu=n.bu||0,r.bv=n.bv||0,r.faceId=n.faceId,r.subMeshId=n.subMeshId,r}return r},r.prototype.clone=function(e,t,i){return null},r.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},r.prototype.dispose=function(e,t){var r,n=this;for(void 0===t&&(t=!1),this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._skeleton=null,r=0;r<this._intersectionsInProgress.length;r++){var o=this._intersectionsInProgress[r],s=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(s,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach(function(e){var t=e.includedOnlyMeshes.indexOf(n);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(n))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var r=i.getShadowMap();r&&r.renderList&&-1!==(t=r.renderList.indexOf(n))&&r.renderList.splice(t,1)}}),"InstancedMesh"!==this.getClassName()&&this.releaseSubMeshes();var a=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,a.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),a.wipeCaches(),this.getScene().removeMesh(this),t&&this.material&&this.material.dispose(!1,!0),!e)for(r=0;r<this.getScene().particleSystems.length;r++)this.getScene().particleSystems[r].emitter===this&&(this.getScene().particleSystems[r].dispose(),r--);this._facetData.facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),i.prototype.dispose.call(this,e,t)},r.prototype.addChild=function(e){return e.setParent(this),this},r.prototype.removeChild=function(e){return e.setParent(null),this},r.prototype._initFacetData=function(){var t=this._facetData;t.facetNormals||(t.facetNormals=new Array),t.facetPositions||(t.facetPositions=new Array),t.facetPartitioning||(t.facetPartitioning=new Array),t.facetNb=this.getIndices().length/3|0,t.partitioningSubdivisions=t.partitioningSubdivisions?t.partitioningSubdivisions:10,t.partitioningBBoxRatio=t.partitioningBBoxRatio?t.partitioningBBoxRatio:1.01;for(var i=0;i<t.facetNb;i++)t.facetNormals[i]=e.Vector3.Zero(),t.facetPositions[i]=e.Vector3.Zero();return t.facetDataEnabled=!0,this},r.prototype.updateFacetData=function(){var t=this._facetData;t.facetDataEnabled||this._initFacetData();var i=this.getVerticesData(e.VertexBuffer.PositionKind),r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.NormalKind),o=this.getBoundingInfo();if(t.facetDepthSort&&!t.facetDepthSortEnabled){if(t.facetDepthSortEnabled=!0,r instanceof Uint16Array)t.depthSortedIndices=new Uint16Array(r);else if(r instanceof Uint32Array)t.depthSortedIndices=new Uint32Array(r);else{for(var s=!1,a=0;a<r.length;a++)if(r[a]>65535){s=!0;break}t.depthSortedIndices=s?new Uint32Array(r):new Uint16Array(r)}if(t.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!t.facetDepthSortFrom){var l=this.getScene().activeCamera;t.facetDepthSortFrom=l?l.position:e.Vector3.Zero()}t.depthSortedFacets=[];for(var c=0;c<t.facetNb;c++){var u={ind:3*c,sqDistance:0};t.depthSortedFacets.push(u)}t.invertedMatrix=e.Matrix.Identity(),t.facetDepthSortOrigin=e.Vector3.Zero()}t.bbSize.x=o.maximum.x-o.minimum.x>e.Epsilon?o.maximum.x-o.minimum.x:e.Epsilon,t.bbSize.y=o.maximum.y-o.minimum.y>e.Epsilon?o.maximum.y-o.minimum.y:e.Epsilon,t.bbSize.z=o.maximum.z-o.minimum.z>e.Epsilon?o.maximum.z-o.minimum.z:e.Epsilon;var h=t.bbSize.x>t.bbSize.y?t.bbSize.x:t.bbSize.y;if(h=h>t.bbSize.z?h:t.bbSize.z,t.subDiv.max=t.partitioningSubdivisions,t.subDiv.X=Math.floor(t.subDiv.max*t.bbSize.x/h),t.subDiv.Y=Math.floor(t.subDiv.max*t.bbSize.y/h),t.subDiv.Z=Math.floor(t.subDiv.max*t.bbSize.z/h),t.subDiv.X=t.subDiv.X<1?1:t.subDiv.X,t.subDiv.Y=t.subDiv.Y<1?1:t.subDiv.Y,t.subDiv.Z=t.subDiv.Z<1?1:t.subDiv.Z,t.facetParameters.facetNormals=this.getFacetLocalNormals(),t.facetParameters.facetPositions=this.getFacetLocalPositions(),t.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),t.facetParameters.bInfo=o,t.facetParameters.bbSize=t.bbSize,t.facetParameters.subDiv=t.subDiv,t.facetParameters.ratio=this.partitioningBBoxRatio,t.facetParameters.depthSort=t.facetDepthSort,t.facetDepthSort&&t.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(t.invertedMatrix),e.Vector3.TransformCoordinatesToRef(t.facetDepthSortFrom,t.invertedMatrix,t.facetDepthSortOrigin),t.facetParameters.distanceTo=t.facetDepthSortOrigin),t.facetParameters.depthSortedFacets=t.depthSortedFacets,e.VertexData.ComputeNormals(i,r,n,t.facetParameters),t.facetDepthSort&&t.facetDepthSortEnabled){t.depthSortedFacets.sort(t.facetDepthSortFunction);var d=t.depthSortedIndices.length/3|0;for(c=0;c<d;c++){var f=t.depthSortedFacets[c].ind;t.depthSortedIndices[3*c]=r[f],t.depthSortedIndices[3*c+1]=r[f+1],t.depthSortedIndices[3*c+2]=r[f+2]}this.updateIndices(t.depthSortedIndices)}return this},r.prototype.getFacetLocalNormals=function(){return this._facetData.facetNormals||this.updateFacetData(),this._facetData.facetNormals},r.prototype.getFacetLocalPositions=function(){return this._facetData.facetPositions||this.updateFacetData(),this._facetData.facetPositions},r.prototype.getFacetLocalPartitioning=function(){return this._facetData.facetPartitioning||this.updateFacetData(),this._facetData.facetPartitioning},r.prototype.getFacetPosition=function(t){var i=e.Vector3.Zero();return this.getFacetPositionToRef(t,i),i},r.prototype.getFacetPositionToRef=function(t,i){var r=this.getFacetLocalPositions()[t],n=this.getWorldMatrix();return e.Vector3.TransformCoordinatesToRef(r,n,i),this},r.prototype.getFacetNormal=function(t){var i=e.Vector3.Zero();return this.getFacetNormalToRef(t,i),i},r.prototype.getFacetNormalToRef=function(t,i){var r=this.getFacetLocalNormals()[t];return e.Vector3.TransformNormalToRef(r,this.getWorldMatrix(),i),this},r.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=this._facetData,o=Math.floor((e-r.minimum.x*n.partitioningBBoxRatio)*n.subDiv.X*n.partitioningBBoxRatio/n.bbSize.x),s=Math.floor((t-r.minimum.y*n.partitioningBBoxRatio)*n.subDiv.Y*n.partitioningBBoxRatio/n.bbSize.y),a=Math.floor((i-r.minimum.z*n.partitioningBBoxRatio)*n.subDiv.Z*n.partitioningBBoxRatio/n.bbSize.z);return o<0||o>n.subDiv.max||s<0||s>n.subDiv.max||a<0||a>n.subDiv.max?null:n.facetPartitioning[o+n.subDiv.max*s+n.subDiv.max*n.subDiv.max*a]},r.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 c=e.Tmp.Vector3[8];e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,l,c);var u=this.getClosestFacetAtLocalCoordinates(c.x,c.y,c.z,n,o,s);return n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),u},r.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,m=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),_=this.getFacetsAtLocalCoordinates(e,t,i);if(!_)return null;for(var v,A,y,b=Number.MAX_VALUE,T=b,E=0;E<_.length;E++)A=g[v=_[E]],u=(e-(y=m[v]).x)*A.x+(t-y.y)*A.y+(i-y.z)*A.z,(!n||n&&o&&u>=0||n&&!o&&u<=0)&&(u=A.x*y.x+A.y*y.y+A.z*y.z,h=-(A.x*e+A.y*t+A.z*i-u)/(A.x*A.x+A.y*A.y+A.z*A.z),d=e+A.x*h,f=t+A.y*h,p=i+A.z*h,(T=(a=d-e)*a+(l=f-t)*l+(c=p-i)*c)<b&&(b=T,s=v,r&&(r.x=d,r.y=f,r.z=p)));return s},r.prototype.getFacetDataParameters=function(){return this._facetData.facetParameters},r.prototype.disableFacetData=function(){return this._facetData.facetDataEnabled&&(this._facetData.facetDataEnabled=!1,this._facetData.facetPositions=new Array,this._facetData.facetNormals=new Array,this._facetData.facetPartitioning=new Array,this._facetData.facetParameters=null,this._facetData.depthSortedIndices=new Uint32Array(0)),this},r.prototype.updateIndices=function(e){return this},r.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},r.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},r.prototype._checkOcclusionQuery=function(){return!1},r.OCCLUSION_TYPE_NONE=0,r.OCCLUSION_TYPE_OPTIMISTIC=1,r.OCCLUSION_TYPE_STRICT=2,r.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,r.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,r.CULLINGSTRATEGY_STANDARD=0,r.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,r}(e.TransformNode);e.AbstractMesh=i}(a||(a={})),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.falloffType=i.FALLOFF_DEFAULT,o.intensity=1,o._range=Number.MAX_VALUE,o._inverseSquaredRange=0,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.prototype,"range",{get:function(){return this._range},set:function(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!0,configurable:!0}),Object.defineProperty(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,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},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._syncParentEnabledState=function(){t.prototype._syncParentEnabledState.call(this),this._resyncMeshes()},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.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){var n=e.Node.Construct("Light_Type_"+t,i,r);return n||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.FALLOFF_DEFAULT=0,i.FALLOFF_PHYSICAL=1,i.FALLOFF_GLTF=2,i.FALLOFF_STANDARD=3,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,"falloffType",void 0),n([e.serialize()],i.prototype,"intensity",void 0),n([e.serialize()],i.prototype,"range",null),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("shadowEnabled")],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}(a||(a={})),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.customRenderTargets=new Array,a.onViewMatrixChangedObservable=new e.Observable,a.onProjectionMatrixChangedObservable=new e.Observable,a.onAfterCheckInputsObservable=new e.Observable,a.onRestoreStateObservable=new e.Observable,a._rigCameras=new Array,a._webvrViewMatrix=e.Matrix.Identity(),a._skipRendering=!1,a._projectionMatrix=new e.Matrix,a._postProcesses=new Array,a._activeMeshes=new e.SmartArray(256),a._globalPosition=e.Vector3.Zero(),a._computedViewMatrix=e.Matrix.Identity(),a._doNotComputeProjectionMatrix=!1,a._transformMatrix=e.Matrix.Zero(),a._refreshFrustumPlanes=!0,a.getScene().addCamera(a),s&&!a.getScene().activeCamera&&(a.getScene().activeCamera=a),a.position=n,a}return o(i,t),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.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),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=this._scene.useRightHandedSystem?new e.Vector3(0,0,-1):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(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 c=r.vrDisplay.getEyeParameters("left"),u=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",c),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",u),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){void 0===n&&(n=0),void 0===o&&(o=!0);var s=e.Node.Construct(t,i,r,{interaxial_distance:n,isStereoscopicSideBySide:o});return s||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 c=t.animations[l];s.animations.push(e.Animation.Parse(c))}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}(a||(a={})),function(e){var t=function(){function t(i){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new e.RenderingGroupInfo,this._scene=i;for(var r=t.MIN_RENDERINGGROUPS;r<t.MAX_RENDERINGGROUPS;r++)this._autoClearDepthStencil[r]={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(e,i,r,n){var o=this._renderingGroupInfo;if(o.scene=this._scene,o.camera=this._scene.activeCamera,this._scene.spriteManagers&&n)for(var s=0;s<this._scene.spriteManagers.length;s++){var a=this._scene.spriteManagers[s];this.dispatchSprites(a)}for(s=t.MIN_RENDERINGGROUPS;s<t.MAX_RENDERINGGROUPS;s++){this._depthStencilBufferAlreadyCleaned=s===t.MIN_RENDERINGGROUPS;var l=this._renderingGroups[s];if(l){var c=Math.pow(2,s);if(o.renderingGroupId=s,this._scene.onBeforeRenderingGroupObservable.notifyObservers(o,c),t.AUTOCLEAR){var u=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(s):this._autoClearDepthStencil[s];u&&u.autoClear&&this._clearDepthStencilBuffer(u.depth,u.stencil)}for(var h=0,d=this._scene._beforeRenderingGroupDrawStage;h<d.length;h++){d[h].action(s)}l.render(e,n,r,i);for(var f=0,p=this._scene._afterRenderingGroupDrawStage;f<p.length;f++){p[f].action(s)}this._scene.onAfterRenderingGroupObservable.notifyObservers(o,c)}}},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,this._renderingGroupInfo=null},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.prototype.getAutoClearDepthStencilSetup=function(e){return this._autoClearDepthStencil[e]},t.MAX_RENDERINGGROUPS=4,t.MIN_RENDERINGGROUPS=0,t.AUTOCLEAR=!0,t}();e.RenderingManager=t}(a||(a={})),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)t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{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();if(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),this._edgesRenderers.length){for(var a=0;a<this._edgesRenderers.length;a++)this._edgesRenderers.data[a].render();o.setAlphaMode(e.Engine.ALPHA_DISABLE)}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])._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 c=o.getMaterial();if(c&&c.needDepthPrePass){var u=c.getScene().getEngine();u.setColorWrite(!1),u.setAlphaMode(e.Engine.ALPHA_DISABLE),o.render(!1),u.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)),t._edgesRenderer&&t._edgesRenderer.isEnabled&&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}(a||(a={})),function(e){var t=function(){function e(){}return e.NAME_EFFECTLAYER="EffectLayer",e.NAME_LAYER="Layer",e.NAME_LENSFLARESYSTEM="LensFlareSystem",e.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",e.NAME_PARTICLESYSTEM="ParticleSystem",e.NAME_GAMEPAD="Gamepad",e.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",e.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",e.NAME_DEPTHRENDERER="DepthRenderer",e.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",e.NAME_SPRITE="Sprite",e.NAME_OUTLINERENDERER="Outline",e.NAME_PROCEDURALTEXTURE="ProceduralTexture",e.NAME_SHADOWGENERATOR="ShadowGenerator",e.NAME_OCTREE="Octree",e.NAME_PHYSICSENGINE="PhysicsEngine",e.NAME_AUDIO="Audio",e.STEP_ISREADYFORMESH_EFFECTLAYER=0,e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,e.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,e.STEP_BEFORECAMERADRAW_LAYER=1,e.STEP_BEFORERENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,e.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,e.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,e.STEP_AFTERCAMERADRAW_EFFECTLAYER=0,e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=1,e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=2,e.STEP_AFTERCAMERADRAW_LAYER=3,e.STEP_AFTERRENDER_AUDIO=0,e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=0,e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=2,e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,e.STEP_POINTERMOVE_SPRITE=0,e.STEP_POINTERDOWN_SPRITE=0,e.STEP_POINTERUP_SPRITE=0,e}();e.SceneComponentConstants=t;var i=function(e){function t(t){return e.apply(this,t)||this}return o(t,e),t.Create=function(){return Object.create(t.prototype)},t.prototype.registerStep=function(e,t,i){var r=0;for(Number.MAX_VALUE;r<this.length;r++){if(e<this[r].index)break}this.splice(r,0,{index:e,component:t,action:i.bind(t)})},t.prototype.clear=function(){this.length=0},t}(Array);e.Stage=i}(a||(a={})),function(e){var t=function(){function e(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array}return e.AddParser=function(e,t){this._BabylonFileParsers[e]=t},e.GetParser=function(e){return this._BabylonFileParsers[e]?this._BabylonFileParsers[e]:null},e.AddIndividualParser=function(e,t){this._IndividualBabylonFileParsers[e]=t},e.GetIndividualParser=function(e){return this._IndividualBabylonFileParsers[e]?this._IndividualBabylonFileParsers[e]:null},e.Parse=function(e,t,i,r){for(var n in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(n)&&this._BabylonFileParsers[n](e,t,i,r)},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e}();e.AbstractScene=t}(a||(a={})),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(){return function(){}}();e.RenderingGroupInfo=i;var r=function(i){function r(t){var n=i.call(this)||this;return n.autoClear=!0,n.autoClearDepthAndStencil=!0,n.clearColor=new e.Color4(.2,.2,.3,1),n.ambientColor=new e.Color3(0,0,0),n._forceWireframe=!1,n._forcePointsCloud=!1,n.animationsEnabled=!0,n._animationPropertiesOverride=null,n.useConstantAnimationDeltaTime=!1,n.constantlyUpdateMeshUnderPointer=!1,n.hoverCursor="pointer",n.defaultCursor="",n.preventDefaultOnPointerDown=!0,n.metadata=null,n.disableOfflineSupportExceptionRules=new Array,n.onDisposeObservable=new e.Observable,n._onDisposeObserver=null,n.onBeforeRenderObservable=new e.Observable,n._onBeforeRenderObserver=null,n.onAfterRenderObservable=new e.Observable,n._onAfterRenderObserver=null,n.onBeforeAnimationsObservable=new e.Observable,n.onAfterAnimationsObservable=new e.Observable,n.onBeforeDrawPhaseObservable=new e.Observable,n.onAfterDrawPhaseObservable=new e.Observable,n.onReadyObservable=new e.Observable,n.onBeforeCameraRenderObservable=new e.Observable,n._onBeforeCameraRenderObserver=null,n.onAfterCameraRenderObservable=new e.Observable,n._onAfterCameraRenderObserver=null,n.onBeforeActiveMeshesEvaluationObservable=new e.Observable,n.onAfterActiveMeshesEvaluationObservable=new e.Observable,n.onBeforeParticlesRenderingObservable=new e.Observable,n.onAfterParticlesRenderingObservable=new e.Observable,n.onDataLoadedObservable=new e.Observable,n.onNewCameraAddedObservable=new e.Observable,n.onCameraRemovedObservable=new e.Observable,n.onNewLightAddedObservable=new e.Observable,n.onLightRemovedObservable=new e.Observable,n.onNewGeometryAddedObservable=new e.Observable,n.onGeometryRemovedObservable=new e.Observable,n.onNewTransformNodeAddedObservable=new e.Observable,n.onTransformNodeRemovedObservable=new e.Observable,n.onNewMeshAddedObservable=new e.Observable,n.onMeshRemovedObservable=new e.Observable,n.onNewMaterialAddedObservable=new e.Observable,n.onMaterialRemovedObservable=new e.Observable,n.onNewTextureAddedObservable=new e.Observable,n.onTextureRemovedObservable=new e.Observable,n.onBeforeRenderTargetsRenderObservable=new e.Observable,n.onAfterRenderTargetsRenderObservable=new e.Observable,n.onBeforeStepObservable=new e.Observable,n.onAfterStepObservable=new e.Observable,n.onBeforeRenderingGroupObservable=new e.Observable,n.onAfterRenderingGroupObservable=new e.Observable,n.onMeshImportedObservable=new e.Observable,n._registeredForLateAnimationBindings=new e.SmartArrayNoDuplicate(256),n.onPrePointerObservable=new e.Observable,n.onPointerObservable=new e.Observable,n._meshPickProceed=!1,n._currentPickResult=null,n._previousPickResult=null,n._totalPointersPressed=0,n._doubleClickOccured=!1,n.cameraToUseForPointers=null,n._pointerX=0,n._pointerY=0,n._startingPointerPosition=new e.Vector2(0,0),n._previousStartingPointerPosition=new e.Vector2(0,0),n._startingPointerTime=0,n._previousStartingPointerTime=0,n._pointerCaptures={},n._timeAccumulator=0,n._currentStepId=0,n._currentInternalStep=0,n.onPreKeyboardObservable=new e.Observable,n.onKeyboardObservable=new e.Observable,n._useRightHandedSystem=!1,n._fogEnabled=!0,n._fogMode=r.FOGMODE_NONE,n.fogColor=new e.Color3(.2,.2,.3),n.fogDensity=.1,n.fogStart=0,n.fogEnd=1e3,n._shadowsEnabled=!0,n._lightsEnabled=!0,n.activeCameras=new Array,n._texturesEnabled=!0,n.particlesEnabled=!0,n.spritesEnabled=!0,n._skeletonsEnabled=!0,n.lensFlaresEnabled=!0,n.collisionsEnabled=!0,n.gravity=new e.Vector3(0,-9.807,0),n.postProcessesEnabled=!0,n.postProcesses=new Array,n.renderTargetsEnabled=!0,n.dumpNextRenderTargets=!1,n.customRenderTargets=new Array,n.importedMeshesFiles=new Array,n.probesEnabled=!0,n._meshesForIntersections=new e.SmartArrayNoDuplicate(256),n.proceduralTexturesEnabled=!0,n._totalVertices=new e.PerfCounter,n._activeIndices=new e.PerfCounter,n._activeParticles=new e.PerfCounter,n._activeBones=new e.PerfCounter,n._animationTime=0,n.animationTimeScale=1,n._renderId=0,n._frameId=0,n._executeWhenReadyTimeoutId=-1,n._intermediateRendering=!1,n._viewUpdateFlag=-1,n._projectionUpdateFlag=-1,n._alternateViewUpdateFlag=-1,n._alternateProjectionUpdateFlag=-1,n._toBeDisposed=new Array(256),n._activeRequests=new Array,n._pendingData=new Array,n._isDisposed=!1,n.dispatchAllSubMeshesOfActiveMeshes=!1,n._activeMeshes=new e.SmartArray(256),n._processedMaterials=new e.SmartArray(256),n._renderTargets=new e.SmartArrayNoDuplicate(256),n._activeParticleSystems=new e.SmartArray(256),n._activeSkeletons=new e.SmartArrayNoDuplicate(32),n._softwareSkinnedMeshes=new e.SmartArrayNoDuplicate(32),n._activeAnimatables=new Array,n._transformMatrix=e.Matrix.Zero(),n._useAlternateCameraConfiguration=!1,n._alternateRendering=!1,n.requireLightSorting=!1,n._components=[],n._serializableComponents=[],n._transientComponents=[],n._beforeCameraUpdateStage=e.Stage.Create(),n._beforeClearStage=e.Stage.Create(),n._gatherRenderTargetsStage=e.Stage.Create(),n._gatherActiveCameraRenderTargetsStage=e.Stage.Create(),n._isReadyForMeshStage=e.Stage.Create(),n._beforeEvaluateActiveMeshStage=e.Stage.Create(),n._evaluateSubMeshStage=e.Stage.Create(),n._activeMeshStage=e.Stage.Create(),n._cameraDrawRenderTargetStage=e.Stage.Create(),n._beforeCameraDrawStage=e.Stage.Create(),n._beforeRenderingGroupDrawStage=e.Stage.Create(),n._beforeRenderingMeshStage=e.Stage.Create(),n._afterRenderingMeshStage=e.Stage.Create(),n._afterRenderingGroupDrawStage=e.Stage.Create(),n._afterCameraDrawStage=e.Stage.Create(),n._afterRenderStage=e.Stage.Create(),n._pointerMoveStage=e.Stage.Create(),n._pointerDownStage=e.Stage.Create(),n._pointerUpStage=e.Stage.Create(),n._defaultMeshCandidates={data:[],length:0},n._defaultSubMeshCandidates={data:[],length:0},n._activeMeshesFrozen=!1,n._allowPostProcessClearColor=!0,n.getDeterministicFrameTime=function(){return 1e3/60},n._tempPickingRay=e.Ray?e.Ray.Zero():null,n._blockMaterialDirtyMechanism=!1,n._engine=t||e.Engine.LastCreatedEngine,n._engine.scenes.push(n),n._uid=null,n._renderingManager=new e.RenderingManager(n),e.PostProcessManager&&(n.postProcessManager=new e.PostProcessManager(n)),e.Tools.IsWindowObjectExist()&&n.attachControl(),n.workerCollisions=!1,n._createUbo(),e.ImageProcessingConfiguration&&(n._imageProcessingConfiguration=new e.ImageProcessingConfiguration),n.setDefaultCandidateProviders(),n}return o(r,i),Object.defineProperty(r.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(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.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(r.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.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(r.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(r.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}),r.prototype.setStepId=function(e){this._currentStepId=e},r.prototype.getStepId=function(){return this._currentStepId},r.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(r.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(r.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(r.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(r.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(r.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(r.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(r.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(r.prototype,"_isAlternateRenderingEnabled",{get:function(){return this._alternateRendering},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),r.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var e=0,t=this._transientComponents;e<t.length;e++){t[e].register()}this._transientComponents=[]}},r.prototype._addComponent=function(e){this._components.push(e),this._transientComponents.push(e);var t=e;t.addFromContainer&&this._serializableComponents.push(t)},r.prototype._getComponent=function(e){for(var t=0,i=this._components;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},r.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},r.prototype._getDefaultSubMeshCandidates=function(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates},r.prototype.setDefaultCandidateProviders=function(){this.getActiveMeshCandidates=this._getDefaultMeshCandidates.bind(this),this.getActiveSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getIntersectingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getCollidingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this)},Object.defineProperty(r.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(r.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),r.prototype.getCachedMaterial=function(){return this._cachedMaterial},r.prototype.getCachedEffect=function(){return this._cachedEffect},r.prototype.getCachedVisibility=function(){return this._cachedVisibility},r.prototype.isCachedMaterialInvalid=function(e,t,i){return void 0===i&&(i=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},r.prototype.getEngine=function(){return this._engine},r.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(r.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),r.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(r.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),r.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(r.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),r.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(r.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),r.prototype.getInterFramePerfCounter=function(){return e.Tools.Warn("getInterFramePerfCounter is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"interFramePerfCounter",{get:function(){return e.Tools.Warn("interFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getLastFrameDuration=function(){return e.Tools.Warn("getLastFrameDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"lastFramePerfCounter",{get:function(){return e.Tools.Warn("lastFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getEvaluateActiveMeshesDuration=function(){return e.Tools.Warn("getEvaluateActiveMeshesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return e.Tools.Warn("evaluateActiveMeshesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getActiveMeshes=function(){return this._activeMeshes},r.prototype.getRenderTargetsDuration=function(){return e.Tools.Warn("getRenderTargetsDuration is deprecated. Please use SceneInstrumentation class"),0},r.prototype.getRenderDuration=function(){return e.Tools.Warn("getRenderDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"renderDurationPerfCounter",{get:function(){return e.Tools.Warn("renderDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getParticlesDuration=function(){return e.Tools.Warn("getParticlesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"particlesDurationPerfCounter",{get:function(){return e.Tools.Warn("particlesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getSpritesDuration=function(){return e.Tools.Warn("getSpritesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(r.prototype,"spriteDuractionPerfCounter",{get:function(){return e.Tools.Warn("spriteDuractionPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),r.prototype.getAnimationRatio=function(){return void 0!==this._animationRatio?this._animationRatio:1},r.prototype.getRenderId=function(){return this._renderId},r.prototype.getFrameId=function(){return this._frameId},r.prototype.incrementRenderId=function(){this._renderId++},r.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)},r.prototype._createUbo=function(){this._sceneUbo=new e.UniformBuffer(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},r.prototype._createAlternateUbo=function(){this._alternateSceneUbo=new e.UniformBuffer(this._engine,void 0,!0),this._alternateSceneUbo.addUniform("viewProjection",16),this._alternateSceneUbo.addUniform("view",16)},r.prototype._setRayOnPointerInfo=function(t){t.pickInfo&&(t.pickInfo.ray||(t.pickInfo.ray=this.createPickingRay(t.event.offsetX,t.event.offsetY,e.Matrix.Identity(),this.activeCamera)))},r.prototype.simulatePointerMove=function(t,i){var r=new PointerEvent("pointermove",i);return this._checkPrePointerObservable(t,r,e.PointerEventTypes.POINTERMOVE)?this:this._processPointerMove(t,r)},r.prototype._processPointerMove=function(t,i){var r=this._engine.getRenderingCanvas();if(!r)return this;r.style.cursor=this.defaultCursor;var n=!!(t&&t.hit&&t.pickedMesh);n?(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)):this.setPointerOverMesh(null);for(var o=0,s=this._pointerMoveStage;o<s.length;o++){t=s[o].action(this._unTranslatedPointerX,this._unTranslatedPointerY,t,n,r)}if(t){var a="mousewheel"===i.type||"DOMMouseScroll"===i.type?e.PointerEventTypes.POINTERWHEEL:e.PointerEventTypes.POINTERMOVE;if(this.onPointerMove&&this.onPointerMove(i,t,a),this.onPointerObservable.hasObservers()){var l=new e.PointerInfo(a,i,t);this._setRayOnPointerInfo(l),this.onPointerObservable.notifyObservers(l,a)}}return this},r.prototype._checkPrePointerObservable=function(t,i,r){var n=new e.PointerInfoPre(r,i,this._unTranslatedPointerX,this._unTranslatedPointerY);return t&&(n.ray=t.ray),this.onPrePointerObservable.notifyObservers(n,r),!!n.skipOnPointerObservable},r.prototype.simulatePointerDown=function(t,i){var r=new PointerEvent("pointerdown",i);return this._checkPrePointerObservable(t,r,e.PointerEventTypes.POINTERDOWN)?this:this._processPointerDown(t,r)},r.prototype._processPointerDown=function(t,i){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,i)),i.button){case 0:o.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i));break;case 1:o.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i));break;case 2:o.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i))}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>r.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,o.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)))},r.LongPressDelay)}}else for(var s=0,a=this._pointerDownStage;s<a.length;s++){t=a[s].action(this._unTranslatedPointerX,this._unTranslatedPointerY,t,i)}if(t){var l=e.PointerEventTypes.POINTERDOWN;if(this.onPointerDown&&this.onPointerDown(i,t,l),this.onPointerObservable.hasObservers()){var c=new e.PointerInfo(l,i,t);this._setRayOnPointerInfo(c),this.onPointerObservable.notifyObservers(c,l)}}return this},r.prototype.simulatePointerUp=function(i,r){var n=new PointerEvent("pointerup",r),o=new t;return o.singleClick=!0,o.ignore=!0,this._checkPrePointerObservable(i,n,e.PointerEventTypes.POINTERUP)?this:this._processPointerUp(i,n,o)},r.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._setRayOnPointerInfo(o),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)))}else if(!r.ignore)for(var s=0,a=this._pointerUpStage;s<a.length;s++){t=a[s].action(this._unTranslatedPointerX,this._unTranslatedPointerY,t,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 l=e.PointerEventTypes.POINTERUP;if(this.onPointerObservable.hasObservers())if(r.ignore){o=new e.PointerInfo(l,i,t);this._setRayOnPointerInfo(o),this.onPointerObservable.notifyObservers(o,l)}else if(!r.hasSwiped){if(r.singleClick&&this.onPointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERTAP)){var c=e.PointerEventTypes.POINTERTAP,o=new e.PointerInfo(c,i,t);this._setRayOnPointerInfo(o),this.onPointerObservable.notifyObservers(o,c)}if(r.doubleClick&&this.onPointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)){var u=e.PointerEventTypes.POINTERDOUBLETAP;o=new e.PointerInfo(u,i,t);this._setRayOnPointerInfo(o),this.onPointerObservable.notifyObservers(o,u)}}return this.onPointerUp&&this.onPointerUp(i,t,l),this},r.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._pointerCaptures[e]},r.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>r.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>r.DragMovementThreshold},r.prototype.attachControl=function(i,n,o){var s=this;void 0===i&&(i=!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,i){(Date.now()-s._previousStartingPointerTime>r.DoubleClickDelay&&!s._doubleClickOccured||e!==s._previousButtonPressed)&&(s._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,i(t,s._currentPickResult))},this._initClickEvent=function(i,n,o,a){var l=new t;s._currentPickResult=null;var c=null,u=i.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||n.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||i.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||i.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);if(!u&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(c=s._initActionManager(c,l))&&(u=c.hasPickTriggers),u){var h=o.button;if(l.hasSwiped=s._isPointerSwiping(),!l.hasSwiped){var d=!r.ExclusiveDoubleClickMode;d||(d=!i.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)&&!n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=s._initActionManager(c,l))&&(d=!c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?(Date.now()-s._previousStartingPointerTime>r.DoubleClickDelay||h!==s._previousButtonPressed)&&(l.singleClick=!0,a(l,s._currentPickResult)):(s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,s._delayedSimpleClickTimeout=window.setTimeout(s._delayedSimpleClick.bind(s,h,l,a),r.DoubleClickDelay));var f=i.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);!f&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=s._initActionManager(c,l))&&(f=c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),f&&(h===s._previousButtonPressed&&Date.now()-s._previousStartingPointerTime<r.DoubleClickDelay&&!s._doubleClickOccured?l.hasSwiped||s._isPointerSwiping()?(s._doubleClickOccured=!1,s._previousStartingPointerTime=s._startingPointerTime,s._previousStartingPointerPosition.x=s._startingPointerPosition.x,s._previousStartingPointerPosition.y=s._startingPointerPosition.y,s._previousButtonPressed=h,r.ExclusiveDoubleClickMode?(s._previousDelayedSimpleClickTimeout&&clearTimeout(s._previousDelayedSimpleClickTimeout),s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,a(l,s._previousPickResult)):a(l,s._currentPickResult)):(s._previousStartingPointerTime=0,s._doubleClickOccured=!0,l.doubleClick=!0,l.ignore=!1,r.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=h))}}l.ignore=!0,a(l,s._currentPickResult)},this._onPointerMove=function(t){if(s._updatePointerPosition(t),!s._checkPrePointerObservable(null,t,"mousewheel"===t.type||"DOMMouseScroll"===t.type?e.PointerEventTypes.POINTERWHEEL:e.PointerEventTypes.POINTERMOVE)&&(s.cameraToUseForPointers||s.activeCamera)){s.pointerMovePredicate||(s.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var i=s.pick(s._unTranslatedPointerX,s._unTranslatedPointerY,s.pointerMovePredicate,!1,s.cameraToUseForPointers);s._processPointerMove(i,t)}},this._onPointerDown=function(t){if(s._totalPointersPressed++,s._pickedDownMesh=null,s._meshPickProceed=!1,s._updatePointerPosition(t),s.preventDefaultOnPointerDown&&c&&(t.preventDefault(),c.focus()),!s._checkPrePointerObservable(null,t,e.PointerEventTypes.POINTERDOWN)&&(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 i=s.pick(s._unTranslatedPointerX,s._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);s._processPointerDown(i,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(i,r){if(s.onPrePointerObservable.hasObservers())if(i.ignore){if(s._checkPrePointerObservable(null,t,e.PointerEventTypes.POINTERUP))return}else if(!i.hasSwiped){if(i.singleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERTAP)&&s._checkPrePointerObservable(null,t,e.PointerEventTypes.POINTERTAP))return;if(i.doubleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)&&s._checkPrePointerObservable(null,t,e.PointerEventTypes.POINTERDOUBLETAP))return}(s.cameraToUseForPointers||s.activeCamera)&&(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,i),r||(r=s._currentPickResult),s._processPointerUp(r,t,i),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()){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()){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(){c&&(c.addEventListener("keydown",s._onKeyDown,!1),c.addEventListener("keyup",s._onKeyUp,!1))}),this._onCanvasBlurObserver=a.onCanvasBlurObservable.add(function(){c&&(c.removeEventListener("keydown",s._onKeyDown),c.removeEventListener("keyup",s._onKeyUp))});var l=e.Tools.GetPointerPrefix(),c=this._engine.getRenderingCanvas();c&&(o&&(c.addEventListener(l+"move",this._onPointerMove,!1),c.addEventListener("mousewheel",this._onPointerMove,!1),c.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),n&&c.addEventListener(l+"down",this._onPointerDown,!1),i&&window.addEventListener(l+"up",this._onPointerUp,!1),c.tabIndex=1)},r.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())},r.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._isReadyForMeshStage;o<s.length;o++){if(!s[o].action(r,n))return!1}}}if(this.activeCameras&&this.activeCameras.length>0)for(var a=0,l=this.activeCameras;a<l.length;a++){if(!l[a].isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var c=0,u=this.particleSystems;c<u.length;c++){if(!u[c].isReady())return!1}return!0},r.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},r.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},r.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},r.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},r.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},r.prototype._executeOnceBeforeRender=function(e){var t=this,i=function(){e(),setTimeout(function(){t.unregisterBeforeRender(i)})};this.registerBeforeRender(i)},r.prototype.executeOnceBeforeRender=function(e,t){var i=this;void 0!==t?setTimeout(function(){i._executeOnceBeforeRender(e)},t):this._executeOnceBeforeRender(e)},r.prototype._addPendingData=function(e){this._pendingData.push(e)},r.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)},r.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(r.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!0,configurable:!0}),r.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout(function(){t._checkIsReady()},150))},r.prototype.whenReadyAsync=function(){var e=this;return new Promise(function(t){e.executeWhenReady(function(){t()})})},r.prototype._checkIsReady=function(){var e=this;if(this._registerTransientComponents(),this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout(function(){e._checkIsReady()},150)},r.prototype.beginWeightedAnimation=function(e,t,i,r,n,o,s,a,l){void 0===r&&(r=1),void 0===o&&(o=1);var c=this.beginAnimation(e,t,i,n,o,s,a,!1,l);return c.weight=r,c},r.prototype.beginAnimation=function(t,i,r,n,o,s,a,l,c){void 0===o&&(o=1),void 0===l&&(l=!0),i>r&&o>0&&(o*=-1),l&&this.stopAnimation(t,void 0,c),a||(a=new e.Animatable(this,t,i,r,n,o,s));var u=!c||c(t);if(t.animations&&u&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),d=0;d<h.length;d++)this.beginAnimation(h[d],i,r,n,o,s,a,l,c);return a.reset(),a},r.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)},r.prototype.beginDirectHierarchyAnimation=function(e,t,i,r,n,o,s,a){var l=e.getDescendants(t),c=[];c.push(this.beginDirectAnimation(e,i,r,n,o,s,a));for(var u=0,h=l;u<h.length;u++){var d=h[u];c.push(this.beginDirectAnimation(d,i,r,n,o,s,a))}return c},r.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},r.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(r.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),r.prototype.stopAnimation=function(e,t,i){for(var r=0,n=this.getAllAnimatablesByTarget(e);r<n.length;r++){n[r].stop(t,i)}},r.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()}},r.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()}},r.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},r.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,c=1;if(t.totalWeight<1)l.decompose(n,o,r),c=1-t.totalWeight;else if(s=1,i=t.totalWeight,a.currentValue.decompose(n,o,r),1==(c=a.weight/i))return a.currentValue;n.scaleInPlace(c),r.scaleInPlace(c),o.scaleInPlace(c);for(var u=s;u<t.animations.length;u++){var h=t.animations[u],d=(c=h.weight/i,e.Tmp.Vector3[2]),f=e.Tmp.Vector3[3],p=e.Tmp.Quaternion[1];h.currentValue.decompose(f,p,d),f.scaleAndAddToRef(c,n),p.scaleAndAddToRef(c,o),d.scaleAndAddToRef(c,r)}return e.Matrix.ComposeToRef(n,o,r,a._workValue),a._workValue},r.prototype._processLateAnimationBindingsForQuaternions=function(t,i){var r=t.animations[0],n=t.originalValue;if(1===t.animations.length)return e.Quaternion.SlerpToRef(n,r.currentValue,Math.min(1,t.totalWeight),i),i;var o,s,a=1;if(t.totalWeight<1){var l=1-t.totalWeight;s=[],(o=[]).push(n),s.push(l)}else{if(2===t.animations.length)return e.Quaternion.SlerpToRef(t.animations[0].currentValue,t.animations[1].currentValue,t.animations[1].weight/t.totalWeight,i),i;o=[],s=[],a=t.totalWeight}for(var c=0;c<t.animations.length;c++){var u=t.animations[c];o.push(u.currentValue),s.push(u.weight/a)}for(var h=0,d=null,f=0;f<o.length;)d?(h+=s[f],e.Quaternion.SlerpToRef(d,o[f],s[f]/h,d),f++):(e.Quaternion.SlerpToRef(o[f],o[f+1],s[f+1]/(s[f]+s[f+1]),i),d=i,h=s[f]+s[f+1],f+=2);return d},r.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=i[r];if(a)l=this._processLateAnimationBindingsForMatrices(n);else if(void 0!==s.w)l=this._processLateAnimationBindingsForQuaternions(n,l||e.Quaternion.Identity());else{var c=0,u=1;if(n.totalWeight<1)l=s.scale?s.scale(1-n.totalWeight):s*(1-n.totalWeight);else{u=n.totalWeight;var h=o.weight/u;l=1!==h?o.currentValue.scale?o.currentValue.scale(h):o.currentValue*h:o.currentValue,c=1}for(var d=c;d<n.animations.length;d++){var f=n.animations[d],p=f.weight/u;f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(p,l):l+=f.currentValue*p}}i[r]=l}i._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},r.prototype._switchToAlternateCameraConfiguration=function(e){this._useAlternateCameraConfiguration=e},r.prototype.getViewMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateViewMatrix:this._viewMatrix},r.prototype.getProjectionMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateProjectionMatrix:this._projectionMatrix},r.prototype.getTransformMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateTransformMatrix:this._transformMatrix},r.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())}},r.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()))},r.prototype.getSceneUniformBuffer=function(){return this._useAlternateCameraConfiguration?this._alternateSceneUbo:this._sceneUbo},r.prototype.getUniqueId=function(){var e=r._uniqueIdCounter;return r._uniqueIdCounter++,e},r.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this.meshes.push(e),this.collisionCoordinator&&this.collisionCoordinator.onMeshAdded(e),e._resyncLightSources(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach(function(e){i.addMesh(e)})},r.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},r.prototype.addTransformNode=function(e){this.transformNodes.push(e),this.onNewTransformNodeAddedObservable.notifyObservers(e)},r.prototype.removeTransformNode=function(e){var t=this.transformNodes.indexOf(e);return-1!==t&&this.transformNodes.splice(t,1),this.onTransformNodeRemovedObservable.notifyObservers(e),t},r.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},r.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},r.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},r.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},r.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},r.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},r.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},r.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},r.prototype.removeMaterial=function(e){var t=this.materials.indexOf(e);return-1!==t&&this.materials.splice(t,1),this.onMaterialRemovedObservable.notifyObservers(e),t},r.prototype.removeActionManager=function(e){var t=this.actionManagers.indexOf(e);return-1!==t&&this.actionManagers.splice(t,1),t},r.prototype.removeTexture=function(e){var t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t},r.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)},r.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.CompareLightsPriority)},r.prototype.addCamera=function(e){this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},r.prototype.addSkeleton=function(e){this.skeletons.push(e)},r.prototype.addParticleSystem=function(e){this.particleSystems.push(e)},r.prototype.addAnimation=function(e){this.animations.push(e)},r.prototype.addAnimationGroup=function(e){this.animationGroups.push(e)},r.prototype.addMultiMaterial=function(e){this.multiMaterials.push(e)},r.prototype.addMaterial=function(e){this.materials.push(e),this.onNewMaterialAddedObservable.notifyObservers(e)},r.prototype.addMorphTargetManager=function(e){this.morphTargetManagers.push(e)},r.prototype.addGeometry=function(e){this.geometries.push(e)},r.prototype.addActionManager=function(e){this.actionManagers.push(e)},r.prototype.addTexture=function(e){this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e)},r.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))},r.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},r.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.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)},r.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)},r.prototype.getGeometries=function(){return this.geometries},r.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},r.prototype.getMeshesByID=function(e){return this.meshes.filter(function(t){return t.id===e})},r.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},r.prototype.getTransformNodesByID=function(e){return this.transformNodes.filter(function(t){return t.id===e})},r.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},r.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},r.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},r.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)},r.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)},r.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},r.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},r.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},r.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},r.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},r.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},r.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},Object.defineProperty(r.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),r.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},r.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},r.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},r.prototype.removeExternalData=function(e){return this._externalData.remove(e)},r.prototype._evaluateSubMesh=function(e,t){if(this.dispatchAllSubMeshesOfActiveMeshes||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){for(var i=0,r=this._evaluateSubMeshStage;i<r.length;i++){r[i].action(t,e)}var n=e.getMaterial();null!==n&&void 0!==n&&(n.hasRenderTargetTextures&&void 0!==n.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(n)&&(this._processedMaterials.push(n),this._renderTargets.concatWithNoDuplicate(n.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e,t,n))}},r.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},r.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()}},r.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()}},r.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},r.prototype.freezeActiveMeshes=function(){return this.activeCamera?(this._frustumPlanes||this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this):this},r.prototype.unfreezeActiveMeshes=function(){return this._activeMeshesFrozen=!1,this},r.prototype._evaluateActiveMeshes=function(){if((!this._activeMeshesFrozen||!this._activeMeshes.length)&&this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(var t=0,i=this._beforeEvaluateActiveMeshStage;t<i.length;t++){i[t].action()}for(var r=this.getActiveMeshCandidates(),n=r.length,o=0;o<n;o++){var s=r.data[o];if(!s.isBlocked&&(this._totalVertices.addCount(s.getTotalVertices(),!1),s.isReady()&&s.isEnabled())){s.computeWorldMatrix(),s.actionManager&&s.actionManager.hasSpecificTriggers2(e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(s);var a=s.getLOD(this.activeCamera);void 0!==a&&null!==a&&(s._preActivate(),s.isVisible&&s.visibility>0&&(s.alwaysSelectAsActiveMesh||0!=(s.layerMask&this.activeCamera.layerMask)&&s.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),s._activate(this._renderId),a!==s&&a._activate(this._renderId),this._activeMesh(s,a)))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var l=0;l<this.particleSystems.length;l++){var c=this.particleSystems[l];if(c.isStarted()&&c.emitter){var u=c.emitter;u.position&&!u.isEnabled()||(this._activeParticleSystems.push(c),c.animate(),this._renderingManager.dispatchParticles(c))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},r.prototype._activeMesh=function(e,t){this._skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t));for(var i=0,r=this._activeMeshStage;i<r.length;i++){r[i].action(e,t)}if(void 0!==t&&null!==t&&void 0!==t.subMeshes&&null!==t.subMeshes&&t.subMeshes.length>0)for(var n=this.getActiveSubMeshCandidates(t),o=n.length,s=0;s<o;s++){var a=n.data[s];this._evaluateSubMesh(a,t)}},r.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},r.prototype.updateAlternateTransformMatrix=function(e){this._setAlternateTransformMatrix(e.getViewMatrix(),e.getProjectionMatrix())},r.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");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),t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),i&&i.customRenderTargets&&i.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(i.customRenderTargets);for(var s=0,a=this._gatherActiveCameraRenderTargetsStage;s<a.length;s++){a[s].action(this._renderTargets)}if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l<this._renderTargets.length;l++){var c=this._renderTargets.data[l];if(c._shouldRender()){this._renderId++;var u=c.activeCamera&&c.activeCamera!==this.activeCamera;c.render(u,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var h=0,d=this._cameraDrawRenderTargetStage;h<d.length;h++){d[h].action(this.activeCamera)}this._intermediateRendering=!1,r.restoreDefaultFramebuffer()}this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&this.postProcessManager._prepareFrame();for(var f=0,p=this._beforeCameraDrawStage;f<p.length;f++){p[f].action(this.activeCamera)}this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var m=0,g=this._afterCameraDrawStage;m<g.length;m++){g[m].action(this.activeCamera)}this.postProcessManager&&this.postProcessManager._finalizeFrame(t.isIntermediate),this._renderTargets.reset(),this._alternateRendering=!1,this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},r.prototype._processSubCameras=function(t){if(t.cameraRigMode!==e.Camera.RIG_MODE_NONE){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())}else this._renderForCamera(t)},r.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))}}}},r.prototype._advancePhysicsEngineStep=function(e){},r.prototype.render=function(t){if(void 0===t&&(t=!0),!this.isDisposed){if(this._frameId++,this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger),this._engine.isDeterministicLockStep()){var i=Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime))+this._timeAccumulator,n=this.getDeterministicFrameTime(),o=0,s=this._engine.getLockstepMaxSteps(),a=Math.floor(i/60);a=Math.min(a,s);do{this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*n,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(n),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,o++,i-=n}while(i>0&&o<a);this._timeAccumulator=i<0?0:i}else{i=this.useConstantAnimationDeltaTime?16:Math.max(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.MaxDeltaTime));this._animationRatio=.06*i,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(i)}for(var l=0,c=this._beforeCameraUpdateStage;l<c.length;l++){c[l].action()}if(t)if(this.activeCameras.length>0)for(var u=0;u<this.activeCameras.length;u++){var h=this.activeCameras[u];if(h.update(),h.cameraRigMode!==e.Camera.RIG_MODE_NONE)for(var d=0;d<h._rigCameras.length;d++)h._rigCameras[d].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==e.Camera.RIG_MODE_NONE))for(d=0;d<this.activeCamera._rigCameras.length;d++)this.activeCamera._rigCameras[d].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var f=this.getEngine(),p=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var m=0;m<this.customRenderTargets.length;m++){var g=this.customRenderTargets[m];if(g._shouldRender()){if(this._renderId++,this.activeCamera=g.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");f.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),g.render(p!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this.customRenderTargets.length>0&&f.restoreDefaultFramebuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.activeCamera=p;for(var _=0,v=this._beforeClearStage;_<v.length;_++){v[_].action()}(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var A=0,y=this._gatherRenderTargetsStage;A<y.length;A++){y[A].action(this._renderTargets)}if(this.activeCameras.length>0)for(u=0;u<this.activeCameras.length;u++)u>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[u]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var b=0,T=this._afterRenderStage;b<T.length;b++){T[b].action()}if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(d=0;d<this._toBeDisposed.length;d++){var E=this._toBeDisposed[d];E&&E.dispose()}this._toBeDisposed=[]}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},r.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},r.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},r.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._activeMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear();for(var e=0,t=this._components;e<t.length;e++){t[e].dispose()}this.importedMeshesFiles=new Array,this.stopAllAnimations(),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed=[];for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.detachControl();var n,o=this._engine.getRenderingCanvas();if(o)for(n=0;n<this.cameras.length;n++)this.cameras[n].detachControl(o);for(;this.animationGroups.length;)this.animationGroups[0].dispose();for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.transformNodes.length;)this.removeTransformNode(this.transformNodes[0]);for(;this.cameras.length;)this.cameras[0].dispose();for(this.defaultMaterial&&this.defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._alternateSceneUbo&&this._alternateSceneUbo.dispose(),this.postProcessManager.dispose(),(n=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(n,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(r.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),r.prototype.clearCachedVertexData=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e].geometry;if(t)for(var i in t._indices=[],t._vertexBuffers)t._vertexBuffers.hasOwnProperty(i)&&(t._vertexBuffers[i]._buffer._data=null)}},r.prototype.cleanCachedTextureBuffer=function(){for(var e=0,t=this.textures;e<t.length;e++){var i=t[e];i._buffer&&(i._buffer=null)}},r.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}},r.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},r.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.toGlobal(a.getRenderWidth(),a.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-l.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-l.y-l.height),n.update(t,i,l.width,l.height,r||e.Matrix.Identity(),s?e.Matrix.Identity():o.getViewMatrix(),o.getProjectionMatrix()),this},r.prototype.createPickingRayInCameraSpace=function(t,i,r){var n=e.Ray.Zero();return this.createPickingRayInCameraSpaceToRef(t,i,n,r),n},r.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.toGlobal(o.getRenderWidth(),o.getRenderHeight()),a=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-s.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-s.y-s.height),r.update(t,i,s.width,s.height,a,a,n.getProjectionMatrix()),this},r.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=t(s.getWorldMatrix()),l=s.intersects(a,r);if(l&&l.hit&&((r||null==n||!(l.distance>=n.distance))&&(n=l,r)))break}return n||new e.PickingInfo},r.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=t(o.getWorldMatrix()),a=o.intersects(s,!1);a&&a.hit&&r.push(a)}return r},r.prototype.pick=function(t,i,r,n,o){var s=this;if(!e.PickingInfo)return null;var a=this._internalPick(function(e){return s.createPickingRayToRef(t,i,e,s._tempPickingRay,o||null),s._tempPickingRay},r,n);return a&&(a.ray=this.createPickingRay(t,i,e.Matrix.Identity(),o||null)),a},r.prototype.pickWithRay=function(t,i,r){var n=this,o=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);return o&&(o.ray=t),o},r.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick(function(i){return n.createPickingRay(e,t,i,r||null)},i)},r.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)},r.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)))},r.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},r.prototype._rebuildGeometries=function(){for(var e=0,t=this.geometries;e<t.length;e++){t[e]._rebuild()}for(var i=0,r=this.meshes;i<r.length;i++){r[i]._rebuild()}this.postProcessManager&&this.postProcessManager._rebuild();for(var n=0,o=this._components;n<o.length;n++){o[n].rebuild()}for(var s=0,a=this.particleSystems;s<a.length;s++){a[s].rebuild()}},r.prototype._rebuildTextures=function(){for(var t=0,i=this.textures;t<i.length;t++){i[t]._rebuild()}this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)},r.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];for(var o in r=r||function(e){},t){var s=t[o];e.Tags&&e.Tags.MatchesQuery(s,i)&&(n.push(s),r(s))}return n},r.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},r.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},r.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},r.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},r.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)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},r.prototype.getAutoClearDepthStencilSetup=function(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)},Object.defineProperty(r.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(t){this._blockMaterialDirtyMechanism!==t&&(this._blockMaterialDirtyMechanism=t,t||this.markAllMaterialsAsDirty(e.Material.AllDirtyFlag))},enumerable:!0,configurable:!0}),r.prototype.markAllMaterialsAsDirty=function(e,t){if(!this._blockMaterialDirtyMechanism)for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},r.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},r.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)})})},r._uniqueIdCounter=0,r.FOGMODE_NONE=0,r.FOGMODE_EXP=1,r.FOGMODE_EXP2=2,r.FOGMODE_LINEAR=3,r.MinDeltaTime=1,r.MaxDeltaTime=1e3,r.DragMovementThreshold=10,r.LongPressDelay=500,r.DoubleClickDelay=300,r.ExclusiveDoubleClickMode=!1,r}(e.AbstractScene);e.Scene=r}(a||(a={})),function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t}(e.AbstractScene);e.KeepAssets=t;var i=function(i){function r(e){var t=i.call(this)||this;return t.scene=e,t}return o(r,i),r.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.animations.forEach(function(t){e.scene.addAnimation(t)}),this.animationGroups.forEach(function(t){e.scene.addAnimationGroup(t)}),this.multiMaterials.forEach(function(t){e.scene.addMultiMaterial(t)}),this.materials.forEach(function(t){e.scene.addMaterial(t)}),this.morphTargetManagers.forEach(function(t){e.scene.addMorphTargetManager(t)}),this.geometries.forEach(function(t){e.scene.addGeometry(t)}),this.transformNodes.forEach(function(t){e.scene.addTransformNode(t)}),this.actionManagers.forEach(function(t){e.scene.addActionManager(t)}),this.textures.forEach(function(t){e.scene.addTexture(t)});for(var t=0,i=this.scene._serializableComponents;t<i.length;t++){i[t].addFromContainer(this.scene)}},r.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.animations.forEach(function(t){e.scene.removeAnimation(t)}),this.animationGroups.forEach(function(t){e.scene.removeAnimationGroup(t)}),this.multiMaterials.forEach(function(t){e.scene.removeMultiMaterial(t)}),this.materials.forEach(function(t){e.scene.removeMaterial(t)}),this.morphTargetManagers.forEach(function(t){e.scene.removeMorphTargetManager(t)}),this.geometries.forEach(function(t){e.scene.removeGeometry(t)}),this.transformNodes.forEach(function(t){e.scene.removeTransformNode(t)}),this.actionManagers.forEach(function(t){e.scene.removeActionManager(t)}),this.textures.forEach(function(t){e.scene.removeTexture(t)});for(var t=0,i=this.scene._serializableComponents;t<i.length;t++){i[t].removeFromContainer(this.scene)}},r.prototype._moveAssets=function(e,t,i){if(e)for(var r=0,n=e;r<n.length;r++){var o=n[r],s=!0;if(i)for(var a=0,l=i;a<l.length;a++){if(o===l[a]){s=!1;break}}s&&t.push(o)}},r.prototype.moveAllFromScene=function(e){for(var i in void 0===e&&(e=new t),this)this.hasOwnProperty(i)&&(this[i]=this[i]||[],this._moveAssets(this.scene[i],this[i],e[i]));this.removeAllFromScene()},r.prototype.createRootMesh=function(){var t=new e.Mesh("assetContainerRootMesh",this.scene);return this.meshes.forEach(function(e){e.parent||t.addChild(e)}),this.meshes.unshift(t),t},r}(e.AbstractScene);e.AssetContainer=i}(a||(a={})),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}(a||(a={})),function(e){var t=function(){function t(i,r,n,o,s,a,l,c,u,h,d,f){if(void 0===d&&(d=!1),void 0===f&&(f=!1),r instanceof e.Buffer?(this._buffer=r,this._ownsBuffer=!1):(this._buffer=new e.Buffer(i,r,o,a,s,l,f),this._ownsBuffer=!0),this._kind=n,void 0==h){var p=this.getData();this.type=t.FLOAT,p instanceof Int8Array?this.type=t.BYTE:p instanceof Uint8Array?this.type=t.UNSIGNED_BYTE:p instanceof Int16Array?this.type=t.SHORT:p instanceof Uint16Array?this.type=t.UNSIGNED_SHORT:p instanceof Int32Array?this.type=t.INT:p instanceof Uint32Array&&(this.type=t.UNSIGNED_INT)}else this.type=h;var m=t.GetTypeByteLength(this.type);f?(this._size=u||(a?a/m:t.DeduceStride(n)),this.byteStride=a||this._buffer.byteStride||this._size*m,this.byteOffset=c||0):(this._size=u||a||t.DeduceStride(n),this.byteStride=a?a*m:this._buffer.byteStride||this._size*m,this.byteOffset=(c||0)*m),this.normalized=d,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){this._buffer.create(e)},t.prototype.update=function(e){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)},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 c=i/4,u=r/4,h=0;h<s;h+=n){for(var d=0;d<n;d++)l(e[c+d],h+d);c+=u}else{var f=e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),p=t.GetTypeByteLength(o);for(h=0;h<s;h+=n){var m=i;for(d=0;d<n;d++){l(t._GetFloatValue(f,o,m,a),h+d),m+=p}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:o=e.getUint8(r);return n&&(o/=255),o;case t.SHORT:o=e.getInt16(r,!0);return n&&(o=Math.max(o/16383,-1)),o;case t.UNSIGNED_SHORT: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}(a||(a={})),function(e){var t=function(){return function(){this.previous=null,this.next=null}}();e.DummyInternalTextureTracker=t}(a||(a={})),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._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._isRGBD=!1,this._references=1,this._engine=i,this._dataSource=r,this._webGLTexture=i._createTexture()}return t.prototype.getEngine=function(){return this._engine},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 void(i=this._engine.createTexture(this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,function(){r.isReady=!0},null,this._buffer,void 0,this.format))._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))._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))._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_DYNAMIC:return void(i=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._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))._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_CUBE:return void(i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,function(){r.isReady=!0},null,this.format,this._extension))._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))._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_CUBERAW_RGBD:return i=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),e.RawCubeTexture._UpdateRGBDAsync(i,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then(function(){r.isReady=!0}),void i._swapAndDie(this);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))._sphericalPolynomial=this._sphericalPolynomial)}},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&&(this._references--,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.DATASOURCE_CUBERAW_RGBD=12,t}();e.InternalTexture=t}(a||(a={})),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.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._cachedSize=e.Size.Zero(),this._scene=i||e.Engine.LastCreatedScene,this._scene&&(this._scene.textures.push(this),this._scene.onNewTextureAddedObservable.notifyObservers(this)),this._uid=null}return Object.defineProperty(t.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(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,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=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(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new 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,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=null),!this._texture)return null;var r=this.getSize(),n=r.width,o=r.height,s=this.getScene();if(!s)return null;var a=s.getEngine();return 0!=t&&(n/=Math.pow(2,t),o/=Math.pow(2,t),n=Math.round(n),o=Math.round(o)),this._texture.isCube?a._readTexturePixels(this._texture,n,o,e,t,i):a._readTexturePixels(this._texture,n,o,-1,t,i)},t.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},Object.defineProperty(t.prototype,"sphericalPolynomial",{get:function(){return this._texture&&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),this._scene.onTextureRemovedObservable.notifyObservers(this),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var r,n,o=function(){if((r=e[s]).isReady())0==--i&&t();else{var o=function(){n.removeCallback(o),0==--i&&t()};(n=r.onLoadObservable).add(o)}},s=0;s<e.length;s++)o();else t()},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",null),n([e.serialize()],t.prototype,"lodGenerationScale",null),n([e.serialize()],t.prototype,"isRenderTarget",void 0),t}();e.BaseTexture=t}(a||(a={})),function(e){var t=function(t){function i(r,n,o,s,a,l,c,u,h,d){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=!1);var f=t.call(this,n)||this;if(f.uOffset=0,f.vOffset=0,f.uScale=1,f.vScale=1,f.uAng=0,f.vAng=0,f.wAng=0,f.uRotationCenter=.5,f.vRotationCenter=.5,f.wRotationCenter=.5,f.onLoadObservable=new e.Observable,f._isBlocking=!0,f.name=r||"",f.url=r,f._noMipmap=o,f._invertY=s,f._samplingMode=a,f._buffer=u,f._deleteBuffer=h,d&&(f._format=d),!(n=f.getScene()))return f;n.getEngine().onBeforeTextureInitObservable.notifyObservers(f);var p=function(){f.onLoadObservable.hasObservers()&&f.onLoadObservable.notifyObservers(f),l&&l(),!f.isBlocking&&n&&n.resetCachedMaterial()};return f.url?(f._texture=f._getFromCache(f.url,o,a),f._texture?f._texture.isReady?e.Tools.SetImmediate(function(){return p()}):f._texture.onLoadedObservable.add(p):n.useDelayedTextureLoading?(f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,f._delayedOnLoad=p,f._delayedOnError=c):(f._texture=n.getEngine().createTexture(f.url,o,s,n,f._samplingMode,p,c,f._buffer,void 0,f._format),h&&delete f._buffer),f):(f._delayedOnLoad=p,f._delayedOnError=c,f)}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,i){if(void 0===i&&(i=null),this.url)throw new Error("URL is already set");this.url=t,this._buffer=i,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-=this.uRotationCenter*this.uScale,i-=this.vRotationCenter*this.vScale,r-=this.wRotationCenter,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=this.uRotationCenter*this.uScale+this.uOffset,n.y+=this.vRotationCenter*this.vScale+this.vOffset,n.z+=this.wRotationCenter},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)},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.clear(),this._delayedOnLoad=null,this._delayedOnError=null},i.Parse=function(t,r,n){if(t.customType){var o=e.Tools.Instantiate(t.customType).Parse(t,r,n);return t.samplingMode&&o.updateSamplingMode&&o._samplingMode&&o._samplingMode!==t.samplingMode&&o.updateSamplingMode(t.samplingMode),o}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var s=e.SerializationHelper.Parse(function(){var o,s=!0;if(t.noMipmap&&(s=!1),t.mirrorPlane){var a=new e.MirrorTexture(t.name,t.renderTargetSize,r,s);return a._waitingRenderList=t.renderList,a.mirrorPlane=e.Plane.FromArray(t.mirrorPlane),a}if(t.isRenderTarget){var l=new e.RenderTargetTexture(t.name,t.renderTargetSize,r,s);return l._waitingRenderList=t.renderList,l}if(t.base64String)o=i.CreateFromBase64String(t.base64String,t.name,r,!s);else{var c=n+t.name;i.UseSerializedUrlIfAny&&t.url&&(c=t.url),o=new i(c,r,!s,t.invertY)}return o},t,r);if(t.samplingMode){var a=t.samplingMode;s._samplingMode!==a&&s.updateSamplingMode(a)}if(t.animations)for(var l=0;l<t.animations.length;l++){var c=t.animations[l];s.animations.push(e.Animation.Parse(c))}return s},i.CreateFromBase64String=function(t,r,n,o,s,a,l,c,u){return void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===c&&(c=null),void 0===u&&(u=e.Engine.TEXTUREFORMAT_RGBA),new i("data:"+r,n,o,s,a,l,c,t,!1,u)},i.LoadFromDataString=function(t,r,n,o,s,a,l,c,u,h){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===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=e.Engine.TEXTUREFORMAT_RGBA),"data:"!==t.substr(0,5)&&(t="data:"+t),new i(t,n,s,a,l,c,u,r,o,h)},i.NEAREST_SAMPLINGMODE=e.Engine.TEXTURE_NEAREST_SAMPLINGMODE,i.NEAREST_NEAREST_MIPLINEAR=e.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR,i.BILINEAR_SAMPLINGMODE=e.Engine.TEXTURE_BILINEAR_SAMPLINGMODE,i.LINEAR_LINEAR_MIPNEAREST=e.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST,i.TRILINEAR_SAMPLINGMODE=e.Engine.TEXTURE_TRILINEAR_SAMPLINGMODE,i.LINEAR_LINEAR_MIPLINEAR=e.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR,i.NEAREST_NEAREST_MIPNEAREST=e.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST,i.NEAREST_LINEAR_MIPNEAREST=e.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST,i.NEAREST_LINEAR_MIPLINEAR=e.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR,i.NEAREST_LINEAR=e.Engine.TEXTURE_NEAREST_LINEAR,i.NEAREST_NEAREST=e.Engine.TEXTURE_NEAREST_NEAREST,i.LINEAR_NEAREST_MIPNEAREST=e.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST,i.LINEAR_NEAREST_MIPLINEAR=e.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR,i.LINEAR_LINEAR=e.Engine.TEXTURE_LINEAR_LINEAR,i.LINEAR_NEAREST=e.Engine.TEXTURE_LINEAR_NEAREST,i.EXPLICIT_MODE=e.Engine.TEXTURE_EXPLICIT_MODE,i.SPHERICAL_MODE=e.Engine.TEXTURE_SPHERICAL_MODE,i.PLANAR_MODE=e.Engine.TEXTURE_PLANAR_MODE,i.CUBIC_MODE=e.Engine.TEXTURE_CUBIC_MODE,i.PROJECTION_MODE=e.Engine.TEXTURE_PROJECTION_MODE,i.SKYBOX_MODE=e.Engine.TEXTURE_SKYBOX_MODE,i.INVCUBIC_MODE=e.Engine.TEXTURE_INVCUBIC_MODE,i.EQUIRECTANGULAR_MODE=e.Engine.TEXTURE_EQUIRECTANGULAR_MODE,i.FIXED_EQUIRECTANGULAR_MODE=e.Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,i.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=e.Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,i.CLAMP_ADDRESSMODE=e.Engine.TEXTURE_CLAMP_ADDRESSMODE,i.WRAP_ADDRESSMODE=e.Engine.TEXTURE_WRAP_ADDRESSMODE,i.MIRROR_ADDRESSMODE=e.Engine.TEXTURE_MIRROR_ADDRESSMODE,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,"uRotationCenter",void 0),n([e.serialize()],i.prototype,"vRotationCenter",void 0),n([e.serialize()],i.prototype,"wRotationCenter",void 0),n([e.serialize()],i.prototype,"isBlocking",null),i}(e.BaseTexture);e.Texture=t}(a||(a={})),function(e){var t=function(){return function(){}}();e._CreationDataStorage=t;var i=function(){return function(){this.visibleInstances={},this.renderIdForInstances=new Array,this.batchCache=new r,this.instancesBufferSize=2048}}(),r=function(){return function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}}();e._InstancesBatch=r;var n=function(t){function r(n,o,s,a,l,c){void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===c&&(c=!0);var u=t.call(this,n,o)||this;if(u.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,u.instances=new Array,u._LODLevels=new Array,u._instanceDataStorage=new i,u._originalBuilderSideOrientation=r.DEFAULTSIDE,u.overrideMaterialSideOrientation=null,u._areNormalsFrozen=!1,u._source=null,o=u.getScene(),a){if(a._geometry&&a._geometry.applyToMesh(u),e.Tools.DeepCopy(a,u,["name","material","skeleton","instances","parent","uniqueId","source","metadata","hasLODLevels","geometry","isBlocked","areNormalsFrozen","onBeforeDrawObservable","onBeforeRenderObservable","onAfterRenderObservable","onBeforeDraw"],["_poseMatrix"]),u._source=a,u._originalBuilderSideOrientation=a._originalBuilderSideOrientation,u._creationDataStorage=a._creationDataStorage,u._source._ranges){var h=u._source._ranges;for(var n in h)h.hasOwnProperty(n)&&h[n]&&u.createAnimationRange(n,h[n].from,h[n].to)}var d;if(a.metadata&&a.metadata.clone?u.metadata=a.metadata.clone():u.metadata=a.metadata,e.Tags&&e.Tags.HasTags(a)&&e.Tags.AddTagsTo(u,e.Tags.GetTags(a,!0)),u.parent=a.parent,u.setPivotMatrix(a.getPivotMatrix()),u.id=n+"."+a.id,u.material=a.material,!l)for(var f=a.getDescendants(!0),p=0;p<f.length;p++){var m=f[p];m.clone&&m.clone(n+"."+m.name,u)}var g=u.getScene().getPhysicsEngine();if(c&&g){var _=g.getImpostorForPhysicsObject(a);_&&(u.physicsImpostor=_.clone(u))}for(d=0;d<o.particleSystems.length;d++){var v=o.particleSystems[d];v.emitter===a&&v.clone(v.name,u)}u.refreshBoundingInfo(),u.computeWorldMatrix(!0)}return null!==s&&(u.parent=s),u}return o(r,t),Object.defineProperty(r.prototype,"onBeforeRenderObservable",{get:function(){return this._onBeforeRenderObservable||(this._onBeforeRenderObservable=new e.Observable),this._onBeforeRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onAfterRenderObservable",{get:function(){return this._onAfterRenderObservable||(this._onAfterRenderObservable=new e.Observable),this._onAfterRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeDrawObservable",{get:function(){return this._onBeforeDrawObservable||(this._onBeforeDrawObservable=new e.Observable),this._onBeforeDrawObservable},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(i){var r=t.prototype.toString.call(this,i);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(i);if(i)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(){t.prototype._unBindEffect.call(this);for(var e=0,i=this.instances;e<i.length;e++){i[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;t?i=t:i=this.getBoundingInfo().boundingSphere;var r=i.centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var n=0;n<this._LODLevels.length;n++){var o=this._LODLevels[n];if(o.distance<r)return o.mesh&&(o.mesh._preActivate(),o.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(r,this,o.mesh),o.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this},Object.defineProperty(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,t){return this._geometry?this._geometry.getIndices(e,t):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),r.prototype.isReady=function(i,r){if(void 0===i&&(i=!1),void 0===r&&(r=!1),this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1;if(!t.prototype.isReady.call(this,i))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!i)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,c=this.subMeshes;l<c.length;l++){var u=(g=c[l]).getMaterial();if(u)if(u.storeEffectOnSubMeshes){if(!u.isReadyForSubMesh(this,g,s))return!1}else if(!u.isReady(this,s))return!1}else if(!a.isReady(this,s))return!1;for(var h=0,d=this._lightSources;h<d.length;h++){var f=d[h].getShadowGenerator();if(f)for(var p=0,m=this.subMeshes;p<m.length;p++){var g=m[p];if(!f.isReady(g,s))return!1}}for(var _=0,v=this._LODLevels;_<v.length;_++){var A=v[_];if(A.mesh&&!A.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._instanceDataStorage.overridenInstanceCount=e},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e?this:(this._preActivateId=e,this._instanceDataStorage.visibleInstances=null,this)},r.prototype._preActivateForIntermediateRendering=function(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this},r.prototype._registerInstanceForRenderId=function(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={},this._instanceDataStorage.visibleInstances.defaultRenderId=t,this._instanceDataStorage.visibleInstances.selfDefaultRenderId=this._renderId),this._instanceDataStorage.visibleInstances[t]||(this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this},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=this.geometry?this.geometry.boundingBias:null,n=e.Tools.ExtractMinAndMax(i,0,this.getTotalVertices(),r);this._boundingInfo=new e.BoundingInfo(n.minimum,n.maximum)}if(this.subMeshes)for(var o=0;o<this.subMeshes.length;o++)this.subMeshes[o].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),c=e.Tmp.Vector3[0],u=e.Tmp.Matrix[0],h=e.Tmp.Matrix[1],d=0,f=0;f<i.length;f+=3,d+=4){var p,m;for(u.reset(),p=0;p<4;p++)(m=n[d+p])>0&&(e.Matrix.FromFloat32ArrayToRefScaled(l,Math.floor(16*r[d+p]),m,h),u.addToSelf(h));if(o)for(p=0;p<4;p++)(m=a[d+p])>0&&(e.Matrix.FromFloat32ArrayToRefScaled(l,Math.floor(16*s[d+p]),m,h),u.addToSelf(h));e.Vector3.TransformCoordinatesFromFloatsToRef(i[f],i[f+1],i[f+2],u,c),c.toArray(i,f)}}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&&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(),i=this._instanceDataStorage.batchCache;if(i.mustReturn=!1,i.renderSelf[e]=this.isEnabled()&&this.isVisible,i.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances){var r=this._instanceDataStorage.visibleInstances,n=t.getRenderId(),o=t._isInIntermediateRendering()?r.intermediateDefaultRenderId:r.defaultRenderId;i.visibleInstances[e]=r[n];var s=this._renderId;!i.visibleInstances[e]&&o&&(i.visibleInstances[e]=r[o],n=Math.max(o,n),s=Math.max(r.selfDefaultRenderId,n));var a=i.visibleInstances[e];if(a&&a.length){if(this._instanceDataStorage.renderIdForInstances[e]===n)return i.mustReturn=!0,i;n!==s&&(i.renderSelf[e]=!1)}this._instanceDataStorage.renderIdForInstances[e]=n}return i},r.prototype._renderWithInstances=function(t,i,r,n,o){var s=r.visibleInstances[t._id];if(!s)return this;for(var a=16*(s.length+1)*4,l=this._instanceDataStorage,c=l.instancesBufferSize,u=l.instancesBuffer;l.instancesBufferSize<a;)l.instancesBufferSize*=2;l.instancesData&&c==l.instancesBufferSize||(l.instancesData=new Float32Array(l.instancesBufferSize/4));var h=0,d=0,f=this.getWorldMatrix();if(r.renderSelf[t._id]&&(f.copyToArray(l.instancesData,h),h+=16,d++),s)for(var p=0;p<s.length;p++){s[p].getWorldMatrix().copyToArray(l.instancesData,h),h+=16,d++}return u&&c==l.instancesBufferSize?u.updateDirectly(l.instancesData,0,d):(u&&u.dispose(),u=new e.Buffer(o,l.instancesData,!0,16,!1,!0),l.instancesBuffer=u,this.setVerticesBuffer(u.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(u.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(u.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(u.createVertexBuffer("world3",12,4))),this._bind(t,n,i),this._draw(t,i,d),o.unbindInstanceAttributes(),this},r.prototype._processRendering=function(e,t,i,r,n,o,s){var a=this.getScene().getEngine();if(n)this._renderWithInstances(e,i,r,t,a);else{r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,i,this._instanceDataStorage.overridenInstanceCount));var l=r.visibleInstances[e._id];if(l)for(var c=0;c<l.length;c++){var u=l[c].getWorldMatrix();o&&o(!0,u,s),this._draw(e,i)}}return this},r.prototype.render=function(t,i){if(this._checkOcclusionQuery())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&&this._onBeforeRenderObservable.notifyObservers(this);var o,s=r.getEngine(),a=s.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],l=t.getMaterial();if(!l)return this;if(this._effectiveMaterial=l,this._effectiveMaterial.storeEffectOnSubMeshes){if(!this._effectiveMaterial.isReadyForSubMesh(this,t,a))return this}else if(!this._effectiveMaterial.isReady(this,a))return this;i&&s.setAlphaMode(this._effectiveMaterial.alphaMode);for(var c=0,u=r._beforeRenderingMeshStage;c<u.length;c++){u[c].action(this,t,n)}if(!(o=this._effectiveMaterial.storeEffectOnSubMeshes?t.effect:this._effectiveMaterial.getEffect()))return this;var h=this.overrideMaterialSideOrientation;null==h&&(h=this._effectiveMaterial.sideOrientation,this._getWorldMatrixDeterminant()<0&&(h=h===e.Material.ClockWiseSideOrientation?e.Material.CounterClockWiseSideOrientation:e.Material.ClockWiseSideOrientation));var d=this._effectiveMaterial._preBind(o,h);this._effectiveMaterial.forceDepthWrite&&s.setDepthWrite(!0);var f=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:this._effectiveMaterial.fillMode;a||this._bind(t,o,f);var p=this.getWorldMatrix();this._effectiveMaterial.storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(p,this,t):this._effectiveMaterial.bind(p,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(s.setState(!0,this._effectiveMaterial.zOffset,!1,!d),this._processRendering(t,o,f,n,a,this._onBeforeDraw,this._effectiveMaterial),s.setState(!0,this._effectiveMaterial.zOffset,!1,d)),this._processRendering(t,o,f,n,a,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var m=0,g=r._afterRenderingMeshStage;m<g.length;m++){g[m].action(this,t,n)}return this._onAfterRenderObservable&&this._onAfterRenderObservable.notifyObservers(this),this},r.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},r.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},r.prototype.normalizeSkinFourWeights=function(){for(var t=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),i=t.length,r=0;r<i;r+=4){var n=t[r]+t[r+1]+t[r+2]+t[r+3];if(0===n)t[r]=1;else{var o=1/n;t[r]*=o,t[r+1]*=o,t[r+2]*=o,t[r+3]*=o}}this.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t)},r.prototype.normalizeSkinWeightsAndExtra=function(){for(var t=this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind),i=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),r=i.length,n=0;n<r;n+=4){var o=i[n]+i[n+1]+i[n+2]+i[n+3];if(0===(o+=t[n]+t[n+1]+t[n+2]+t[n+3]))i[n]=1;else{var s=1/o;i[n]*=s,i[n+1]*=s,i[n+2]*=s,i[n+3]*=s,t[n]*=s,t[n+1]*=s,t[n+2]*=s,t[n+3]*=s}}this.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i),this.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t)},r.prototype.validateSkinning=function(){var t=this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind),i=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind);if(null===i||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};for(var r=i.length,n=0,o=0,s=0,a=0,l=null===t?4:8,c=new Array,u=0;u<=l;u++)c[u]=0;for(u=0;u<r;u+=4){for(var h=i[u],d=h,f=0===d?0:1,p=1;p<l;p++){var m=p<4?i[u+p]:t[u+p-4];m>h&&n++,0!==m&&f++,d+=m,h=m}if(c[f]++,f>s&&(s=f),0===d)o++;else{var g=1/d,_=0;for(p=0;p<l;p++)_+=p<4?Math.abs(i[u+p]-i[u+p]*g):Math.abs(t[u+p-4]-t[u+p-4]*g);_>.001&&a++}}var v=this.skeleton.bones.length,A=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),y=this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind),b=0;for(u=0;u<r;u++)for(p=0;p<l;p++){var T=p<4?A[p]:y[p-4];(T>=v||T<0)&&b++}return{skinned:!0,valid:0===o&&0===a&&0===b,report:"Number of Weights = "+r/4+"\nMaximum influences = "+s+"\nMissing Weights = "+o+"\nNot Sorted = "+n+"\nNot Normalized = "+a+"\nWeightCounts = ["+c+"]\nNumber of bones = "+v+"\nBad Bone Indices = "+b}},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(i){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(!!t.prototype.isInFrustum.call(this,i)&&(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)){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);this.setVerticesData(e.VertexBuffer.NormalKind,o,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable())}return 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===e&&(e=""),void 0===n&&(n=!0),new r(e,this.getScene(),t,this,i,n)},r.prototype.dispose=function(e,i){var r=this;for(void 0===i&&(i=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0),this._onBeforeDrawObservable&&this._onBeforeDrawObservable.clear(),this._onBeforeRenderObservable&&this._onBeforeRenderObservable.clear(),this._onAfterRenderObservable&&this._onAfterRenderObservable.clear(),this.getScene().meshes.forEach(function(e){var t=e;t._source&&t._source===r&&(t._source=null)}),this._source=null,this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();t.prototype.dispose.call(this,e,i)},r.prototype.applyDisplacementMap=function(t,i,r,n,o,s,a){var l=this;void 0===a&&(a=!1);var c=this.getScene();return e.Tools.LoadImage(t,function(e){var t=document.createElement("canvas"),c=t.getContext("2d"),u=e.width,h=e.height;t.width=u,t.height=h,c.drawImage(e,0,0);var d=c.getImageData(0,0,u,h).data;l.applyDisplacementMapFromBuffer(d,u,h,i,r,o,s,a),n&&n(l)},function(){},c.database),this},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,o,s,a,l){if(void 0===l&&(l=!1),!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 c=this.getVerticesData(e.VertexBuffer.PositionKind,!0,!0),u=this.getVerticesData(e.VertexBuffer.NormalKind),h=this.getVerticesData(e.VertexBuffer.UVKind),d=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 m=0;m<c.length;m+=3){e.Vector3.FromArrayToRef(c,m,d),e.Vector3.FromArrayToRef(u,m,f),e.Vector2.FromArrayToRef(h,m/3*2,p);var g=4*((Math.abs(p.x*a.x+s.x)*i%i|0)+(Math.abs(p.y*a.y+s.y)*r%r|0)*i),_=.3*(t[g]/255)+.59*(t[g+1]/255)+.11*(t[g+2]/255);f.normalize(),f.scaleInPlace(n+(o-n)*_),(d=d.add(f)).toArray(c,m)}return e.VertexData.ComputeNormals(c,this.getIndices(),u),l?(this.setVerticesData(e.VertexBuffer.PositionKind,c),this.setVerticesData(e.VertexBuffer.NormalKind,u)):(this.updateVerticesData(e.VertexBuffer.PositionKind,c),this.updateVerticesData(e.VertexBuffer.NormalKind,u)),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 c,u=this.subMeshes.slice(0),h=this.getIndices(),d=this.getTotalIndices();for(c=0;c<d;c++){var f=h[c];for(t=0;t<r.length;t++)for(var p=n[i=r[t]].getStrideSize(),m=0;m<p;m++)s[i].push(o[i][f*p+m])}var g=[],_=s[e.VertexBuffer.PositionKind];for(c=0;c<d;c+=3){h[c]=c,h[c+1]=c+1,h[c+2]=c+2;for(var v=e.Vector3.FromArray(_,3*c),A=e.Vector3.FromArray(_,3*(c+1)),y=e.Vector3.FromArray(_,3*(c+2)),b=v.subtract(A),T=y.subtract(A),E=e.Vector3.Normalize(e.Vector3.Cross(b,T)),x=0;x<3;x++)g.push(E.x),g.push(E.y),g.push(E.z)}for(this.setIndices(h),this.setVerticesData(e.VertexBuffer.NormalKind,g,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var P=0;P<u.length;P++){var M=u[P];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,c=this.subMeshes.slice(0),u=this.getIndices(),h=this.getTotalIndices();for(l=0;l<h;l++){var d=u[l];for(t=0;t<r.length;t++)for(var f=n[i=r[t]].getStrideSize(),p=0;p<f;p++)s[i].push(o[i][d*f+p])}for(l=0;l<h;l+=3)u[l]=l,u[l+1]=l+1,u[l+2]=l+2;for(this.setIndices(u),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var m=0;m<c.length;m++){var g=c[m];e.SubMesh.AddToMesh(g.materialIndex,g.indexStart,g.indexCount,g.indexStart,g.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r,n=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&n.normals)for(i=0;i<n.normals.length;i++)n.normals[i]*=-1;if(n.indices)for(i=0;i<n.indices.length;i+=3)r=n.indices[i+1],n.indices[i+1]=n.indices[i+2],n.indices[i+2]=r;return n.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.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];if(!l.doNotSerialize){var c={name:l.name,id:l.id,position:l.position.asArray(),scaling:l.scaling.asArray()};l.parent&&(c.parentId=l.parent.id),l.rotationQuaternion?c.rotationQuaternion=l.rotationQuaternion.asArray():l.rotation&&(c.rotation=l.rotation.asArray()),t.instances.push(c),e.Animation.AppendSerializedAnimations(l,c),c.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(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)).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 c=t.instances[l],u=o.createInstance(c.name);if(c.id&&(u.id=c.id),e.Tags&&(c.tags?e.Tags.AddTagsTo(u,c.tags):e.Tags.AddTagsTo(u,t.tags)),u.position=e.Vector3.FromArray(c.position),c.parentId&&(u._waitingParentId=c.parentId),c.rotationQuaternion?u.rotationQuaternion=e.Quaternion.FromArray(c.rotationQuaternion):c.rotation&&(u.rotation=e.Vector3.FromArray(c.rotation)),u.scaling=e.Vector3.FromArray(c.scaling),void 0!=c.checkCollisions&&null!=c.checkCollisions&&(u.checkCollisions=c.checkCollisions),void 0!=c.pickable&&null!=c.pickable&&(u.isPickable=c.pickable),void 0!=c.showBoundingBox&&null!=c.showBoundingBox&&(u.showBoundingBox=c.showBoundingBox),void 0!=c.showSubMeshesBoundingBox&&null!=c.showSubMeshesBoundingBox&&(u.showSubMeshesBoundingBox=c.showSubMeshesBoundingBox),void 0!=c.alphaIndex&&null!=c.showSubMeshesBoundingBox&&(u.alphaIndex=c.alphaIndex),c.physicsImpostor&&(u.physicsImpostor=new e.PhysicsImpostor(u,c.physicsImpostor,{mass:c.physicsMass,friction:c.physicsFriction,restitution:c.physicsRestitution},i)),c.animations){for(s=0;s<c.animations.length;s++)a=c.animations[s],u.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(u,c,i),c.autoAnimate&&i.beginAnimation(u,c.autoAnimateFrom,c.autoAnimateTo,c.autoAnimateLoop,c.autoAnimateSpeed||1)}}return o},r.CreateRibbon=function(t,i,r,n,o,s,a,l,c){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:c},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,c,u){void 0!==l&&l instanceof e.Scene||(void 0!==l&&(u=c||r.DEFAULTSIDE,c=l),l=a,a=1);var h={height:i,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:u,updatable:c};return e.MeshBuilder.CreateCylinder(t,h,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,c,u){var h={radius:i,tube:r,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:u,updatable:c};return e.MeshBuilder.CreateTorusKnot(t,h,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 c={points:i,dashSize:r,gapSize:n,dashNb:o,updatable:a,instance:l};return e.MeshBuilder.CreateDashedLines(t,c,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,c,u,h){void 0===l&&(l=null);var d={shape:i,path:n,scale:o,rotation:s,cap:0===a?0:a||r.NO_CAP,sideOrientation:u,instance:h,updatable:c};return e.MeshBuilder.ExtrudeShape(t,d,l)},r.ExtrudeShapeCustom=function(t,i,n,o,s,a,l,c,u,h,d,f){var p={shape:i,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:l,cap:0===c?0:c||r.NO_CAP,sideOrientation:d,instance:f,updatable:h};return e.MeshBuilder.ExtrudeShapeCustom(t,p,u)},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,c){var u={xmin:i,zmin:r,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:c};return e.MeshBuilder.CreateTiledGround(t,u,l)},r.CreateGroundFromHeightMap=function(t,i,r,n,o,s,a,l,c,u,h){var d={width:r,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:c,onReady:u,alphaFilter:h};return e.MeshBuilder.CreateGroundFromHeightMap(t,i,d,l)},r.CreateTube=function(t,i,r,n,o,s,a,l,c,u){var h={path:i,radius:r,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:l,sideOrientation:c,instance:u};return e.MeshBuilder.CreateTube(t,h,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._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!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,c=l?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,u=l?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,h=t.getTransformMatrices(this),d=e.Vector3.Zero(),f=new e.Matrix,p=new e.Matrix,m=0,g=0;g<r.length;g+=3,m+=4){var _;for(a=0;a<4;a++)(_=s[m+a])>0&&(e.Matrix.FromFloat32ArrayToRefScaled(h,Math.floor(16*o[m+a]),_,p),f.addToSelf(p));if(l)for(a=0;a<4;a++)(_=u[m+a])>0&&(e.Matrix.FromFloat32ArrayToRefScaled(h,Math.floor(16*c[m+a]),_,p),f.addToSelf(p));e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[g],this._sourcePositions[g+1],this._sourcePositions[g+2],f,d),d.toArray(r,g),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[g],this._sourceNormals[g+1],this._sourceNormals[g+2],f,d),d.toArray(n,g),f.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().boundingBox;i&&r?(i.minimizeInPlace(o.minimumWorld),r.maximizeInPlace(o.maximumWorld)):(i=o.minimumWorld,r=o.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){var a;if(void 0===i&&(i=!0),!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 c,u=null,h=new Array,d=null;for(a=0;a<t.length;a++)if(t[a]){var f=t[a].computeWorldMatrix(!0);(c=e.VertexData.ExtractFromMesh(t[a],!0,!0)).transform(f),u?u.merge(c,n):(u=c,d=t[a]),s&&h.push(t[a].getTotalIndices())}if(d=d,o||(o=new r(d.name+"_merged",d.getScene())),u.applyToMesh(o),o.material=d.material,o.checkCollisions=d.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<h.length;)e.SubMesh.CreateFromIndices(0,p,h[a],o),p+=h[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=n}(a||(a={})),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){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e}();e.BaseSubMesh=t;var i=function(t){function i(e,i,r,n,o,s,a,l){void 0===l&&(l=!0);var c=t.call(this)||this;return c.materialIndex=e,c.verticesStart=i,c.verticesCount=r,c.indexStart=n,c.indexCount=o,c._renderId=0,c._mesh=s,c._renderingMesh=a||s,s.subMeshes.push(c),c._trianglePlanes=[],c._id=s.subMeshes.length-1,l&&(c.refreshBoundingInfo(),s.computeWorldMatrix(!0)),c}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.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}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,this._mesh.cullingStrategy)},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=this.getMaterial();if(!o)return null;switch(o.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){var s=this._mesh instanceof e.InstancedMesh?this._mesh.sourceMesh:this._mesh;if(s instanceof e.LinesMesh){var a=s;return this._intersectLines(t,i,r,a.intersectionThreshold,n)}}return this._intersectTriangles(t,i,r,n)},i.prototype._intersectLines=function(t,i,r,n,o){for(var s=null,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var l=i[r[a]],c=i[r[a+1]],u=t.intersectionSegment(l,c,n);if(!(u<0)&&((o||!s||u<s.distance)&&(s=new e.IntersectionInfo(null,null,u),o)))break}return s},i.prototype._intersectTriangles=function(e,t,i,r){for(var n=null,o=this.indexStart;o<this.indexStart+this.indexCount;o+=3){var s=t[i[o]],a=t[i[o+1]],l=t[i[o+2]],c=e.intersectsTriangle(s,a,l);if(c){if(c.distance<0)continue;if((r||!n||c.distance<n.distance)&&((n=c).faceId=o/3,r))break}}return n},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){for(var s=Number.MAX_VALUE,a=-Number.MAX_VALUE,l=(o=o||n).getIndices(),c=t;c<t+r;c++){var u=l[c];u<s&&(s=u),u>a&&(a=u)}return new i(e,s,a-s+1,t,r,n,o)},i}(t);e.SubMesh=i}(a||(a={}));s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(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._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.uniqueId=this._scene.getUniqueId(),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),this._scene.onNewMaterialAddedObservable.notifyObservers(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.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,"hasRenderTargetTextures",{get:function(){return!1},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,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new e.Observable),this._onBindObservable},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,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new e.Observable),this._onUnBindObservable},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)===t.ClockWiseSideOrientation;return r.enableEffect(e||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,n),n},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,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){(this._onUnBindObservable&&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(),c=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(c,16):n.isReady(t)?i&&i(n):setTimeout(c,16),o.clipPlane&&(l.clipPlane=r)}};c()},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),this._scene.onMaterialRemovedObservable.notifyObservers(this),i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];if(r.material===this&&(r.material=null,r.geometry)){var n=r.geometry;if(this.storeEffectOnSubMeshes)for(var o=0,s=r.subMeshes;o<s.length;o++){var a=s[o];n._releaseVertexArrayObject(a._materialEffect),e&&a._materialEffect&&this._scene.getEngine()._releaseEffect(a._materialEffect)}else n._releaseVertexArrayObject(this._effect)}}this._uniformBuffer.dispose(),e&&this._effect&&(this.storeEffectOnSubMeshes||this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear()},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)?e.Tools.Instantiate(t.customType).Parse(t,i,r):void e.Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."):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,t.AllDirtyFlag=31,n([e.serialize()],t.prototype,"id",void 0),n([e.serialize()],t.prototype,"uniqueId",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}(a||(a={})),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)t=(i=t).length;else{t=t,i=[];for(var r=0;r<t;r++)i.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},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(){this._buffer?(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1):this.create()},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(s=0;s<r;s++)this._bufferData[n+s]=i[s];else{for(var o=!1,s=0;s<r;s++)this._bufferData[n+s]!==i[s]&&(o=!0,this._bufferData[n+s]=i[s]);this._needSync=this._needSync||o}},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}(a||(a={})),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):t.setIndices([],null),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=t.m[0]*t.m[5]*t.m[10]<0,n=e.Vector3.Zero();if(this.positions){var o=e.Vector3.Zero();for(i=0;i<this.positions.length;i+=3)e.Vector3.FromArrayToRef(this.positions,i,o),e.Vector3.TransformCoordinatesToRef(o,t,n),this.positions[i]=n.x,this.positions[i+1]=n.y,this.positions[i+2]=n.z}if(this.normals){var s=e.Vector3.Zero();for(i=0;i<this.normals.length;i+=3)e.Vector3.FromArrayToRef(this.normals,i,s),e.Vector3.TransformNormalToRef(s,t,n),this.normals[i]=n.x,this.normals[i+1]=n.y,this.normals[i+2]=n.z}if(this.tangents){var a=e.Vector4.Zero(),l=e.Vector4.Zero();for(i=0;i<this.tangents.length;i+=4)e.Vector4.FromArrayToRef(this.tangents,i,a),e.Vector4.TransformNormalToRef(a,t,l),this.tangents[i]=l.x,this.tangents[i+1]=l.y,this.tangents[i+2]=l.z,this.tangents[i+3]=l.w}if(r&&this.indices)for(i=0;i<this.indices.length;i+=3){var c=this.indices[i+1];this.indices[i+1]=this.indices[i+2],this.indices[i+2]=c}return this},t.prototype.merge=function(e,t){if(void 0===t&&(t=!1),this._validate(),e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(e.indices){this.indices||(this.indices=[]);var i=this.positions?this.positions.length/3:0;if(void 0!==this.indices.BYTES_PER_ELEMENT){var r=this.indices.length+e.indices.length,n=t||this.indices instanceof Uint32Array?new Uint32Array(r):new Uint16Array(r);n.set(this.indices);for(var o=this.indices.length,s=0;s<e.indices.length;s++)n[o+s]=e.indices[s]+i;this.indices=n}else for(s=0;s<e.indices.length;s++)this.indices.push(e.indices[s]+i)}return this.positions=this._mergeElement(this.positions,e.positions),this.normals=this._mergeElement(this.normals,e.normals),this.tangents=this._mergeElement(this.tangents,e.tangents),this.uvs=this._mergeElement(this.uvs,e.uvs),this.uvs2=this._mergeElement(this.uvs2,e.uvs2),this.uvs3=this._mergeElement(this.uvs3,e.uvs3),this.uvs4=this._mergeElement(this.uvs4,e.uvs4),this.uvs5=this._mergeElement(this.uvs5,e.uvs5),this.uvs6=this._mergeElement(this.uvs6,e.uvs6),this.colors=this._mergeElement(this.colors,e.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,e.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,e.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,e.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,e.matricesWeightsExtra),this},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){var s=e.slice(0),a=0;for(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,n),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 c,u,h,d,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,m=i.colors,g=[],_=[],v=[],A=[],y=[],b=[],T=[],E=[],x=[],P=[];if(r.length<2){var M=[],S=[];for(h=0;h<r[0].length-l;h++)M.push(r[0][h]),S.push(r[0][h+l]);r=[M,S]}var C,R,O,D,I,w=0,L=o?1:0;for(c=r[0].length,u=0;u<r.length;u++){for(T[u]=0,y[u]=[0],c=c<(R=(C=r[u]).length)?c:R,d=0;d<R;)g.push(C[d].x,C[d].y,C[d].z),d>0&&(O=C[d].subtract(C[d-1]).length()+T[u],y[u].push(O),T[u]=O),d++;o&&(d--,g.push(C[0].x,C[0].y,C[0].z),O=C[d].subtract(C[0]).length()+T[u],y[u].push(O),T[u]=O),x[u]=R+L,P[u]=w,w+=R+L}var B,F,N=null,V=null;for(h=0;h<c+L;h++){for(E[h]=0,b[h]=[0],u=0;u<r.length-1;u++)D=r[u],I=r[u+1],h===c?(N=D[0],V=I[0]):(N=D[h],V=I[h]),O=V.subtract(N).length()+E[h],b[h].push(O),E[h]=O;n&&V&&N&&(D=r[u],I=r[0],h===c&&(V=I[0]),O=V.subtract(N).length()+E[h],E[h]=O)}if(p)for(u=0;u<p.length;u++)A.push(p[u].x,p[u].y);else for(u=0;u<r.length;u++)for(h=0;h<c+L;h++)B=0!=T[u]?y[u][h]/T[u]:0,F=0!=E[h]?b[h][u]/E[h]:0,s?A.push(F,B):A.push(B,F);for(var U=0,G=x[u=0]-1,k=x[u+1]-1,z=G<k?G:k,H=P[1]-P[0],j=n?x.length:x.length-1;U<=z&&u<j;)_.push(U,U+H,U+1),_.push(U+H+1,U+1,U+H),(U+=1)===z&&(++u===x.length-1?(H=P[0]-P[u],G=x[u]-1,k=x[0]-1):(H=P[u+1]-P[u],G=x[u]-1,k=x[u+1]-1),U=P[u],z=G<k?G+U:k+U);if(t.ComputeNormals(g,_,v),o){var W=0,X=0;for(u=0;u<r.length;u++)W=3*P[u],X=u+1<r.length?3*(P[u+1]-1):v.length-3,v[W]=.5*(v[W]+v[X]),v[W+1]=.5*(v[W+1]+v[X+1]),v[W+2]=.5*(v[W+2]+v[X+2]),v[X]=v[W],v[X+1]=v[W+1],v[X+2]=v[W+2]}t._ComputeSides(f,g,_,v,A,i.frontUVs,i.backUVs);var Y=null;if(m){Y=new Float32Array(4*m.length);for(var Q=0;Q<m.length;Q++)Y[4*Q]=m[Q].r,Y[4*Q+1]=m[Q].g,Y[4*Q+2]=m[Q].b,Y[4*Q+3]=m[Q].a}var K=new t,Z=new Float32Array(g),J=new Float32Array(v),q=new Float32Array(A);return K.indices=_,K.positions=Z,K.normals=J,K.uvs=q,Y&&K.set(Y,e.VertexBuffer.ColorKind),o&&(K._idx=P),K},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,c=i.height||i.size||1,u=i.depth||i.size||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(6),f=i.faceColors,p=[],m=0;m<6;m++)void 0===d[m]&&(d[m]=new e.Vector4(0,0,1,1)),f&&void 0===f[m]&&(f[m]=new e.Color4(1,1,1,1));for(var g=new e.Vector3(l/2,c/2,u/2),_=0;_<r.length;_++){var v=r[_],A=new e.Vector3(v.y,v.z,v.x),y=e.Vector3.Cross(v,A),b=o.length/3;n.push(b),n.push(b+1),n.push(b+2),n.push(b),n.push(b+2),n.push(b+3);var T=v.subtract(A).subtract(y).multiply(g);o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(d[_].z,d[_].w),f&&p.push(f[_].r,f[_].g,f[_].b,f[_].a),T=v.subtract(A).add(y).multiply(g),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(d[_].x,d[_].w),f&&p.push(f[_].r,f[_].g,f[_].b,f[_].a),T=v.add(A).add(y).multiply(g),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(d[_].x,d[_].y),f&&p.push(f[_].r,f[_].g,f[_].b,f[_].a),T=v.add(A).subtract(y).multiply(g),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(d[_].z,d[_].y),f&&p.push(f[_].r,f[_].g,f[_].b,f[_].a)}t._ComputeSides(h,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,f){var x=h===e.Mesh.DOUBLESIDE?p.concat(p):p;E.colors=x}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,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=new e.Vector3(n/2,o/2,s/2),h=2+r,d=2*h,f=[],p=[],m=[],g=[],_=0;_<=h;_++){for(var v=_/h,A=v*Math.PI*l,y=0;y<=d;y++){var b=y/d,T=b*Math.PI*2*a,E=e.Matrix.RotationZ(-A),x=e.Matrix.RotationY(T),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),M=e.Vector3.TransformCoordinates(P,x),S=M.multiply(u),C=M.divide(u).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),g.push(b,v)}if(_>0)for(var R=p.length/3,O=R-2*(d+1);O+d+2<R;O++)f.push(O),f.push(O+1),f.push(O+d+1),f.push(O+d+1),f.push(O+1),f.push(O+d+2)}t._ComputeSides(c,p,f,m,g,i.frontUVs,i.backUVs);var D=new t;return D.indices=f,D.positions=p,D.normals=m,D.uvs=g,D},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,c=!!i.hasRings,u=!!i.enclose,h=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(3),p=i.faceColors,m=2+(1+(1!==h&&u?2:0))*(c?l:1);for(r=0;r<m;r++)p&&void 0===p[r]&&(p[r]=new e.Color4(1,1,1,1));for(r=0;r<m;r++)f&&void 0===f[r]&&(f[r]=new e.Vector4(0,0,1,1));var g,_,v,A,y,b,T=new Array,E=new Array,x=new Array,P=new Array,M=new Array,S=2*Math.PI*h/a,C=(s-o)/2/n,R=e.Vector3.Zero(),O=e.Vector3.Zero(),D=e.Vector3.Zero(),I=e.Vector3.Zero(),w=e.Vector3.Zero(),L=e.Axis.Y,B=1,F=1,N=0,V=0;for(A=0;A<=l;A++)for(v=((_=A/l)*(o-s)+s)/2,B=c&&0!==A&&A!==l?2:1,b=0;b<B;b++){for(c&&(F+=b),u&&(F+=2*b),y=0;y<=a;y++)g=y*S,R.x=Math.cos(-g)*v,R.y=-n/2+_*n,R.z=Math.sin(-g)*v,0===o&&A===l?(O.x=x[x.length-3*(a+1)],O.y=x[x.length-3*(a+1)+1],O.z=x[x.length-3*(a+1)+2]):(O.x=R.x,O.z=R.z,O.y=Math.sqrt(O.x*O.x+O.z*O.z)*C,O.normalize()),0===y&&(D.copyFrom(R),I.copyFrom(O)),E.push(R.x,R.y,R.z),x.push(O.x,O.y,O.z),V=c?N!==F?f[F].y:f[F].w:f[F].y+(f[F].w-f[F].y)*_,P.push(f[F].x+(f[F].z-f[F].x)*y/a,V),p&&M.push(p[F].r,p[F].g,p[F].b,p[F].a);1!==h&&u&&(E.push(R.x,R.y,R.z),E.push(0,R.y,0),E.push(0,R.y,0),E.push(D.x,D.y,D.z),e.Vector3.CrossToRef(L,O,w),w.normalize(),x.push(w.x,w.y,w.z,w.x,w.y,w.z),e.Vector3.CrossToRef(I,L,w),w.normalize(),x.push(w.x,w.y,w.z,w.x,w.y,w.z),V=c?N!==F?f[F+1].y:f[F+1].w:f[F+1].y+(f[F+1].w-f[F+1].y)*_,P.push(f[F+1].x,V),P.push(f[F+1].z,V),V=c?N!==F?f[F+2].y:f[F+2].w:f[F+2].y+(f[F+2].w-f[F+2].y)*_,P.push(f[F+2].x,V),P.push(f[F+2].z,V),p&&(M.push(p[F+1].r,p[F+1].g,p[F+1].b,p[F+1].a),M.push(p[F+1].r,p[F+1].g,p[F+1].b,p[F+1].a),M.push(p[F+2].r,p[F+2].g,p[F+2].b,p[F+2].a),M.push(p[F+2].r,p[F+2].g,p[F+2].b,p[F+2].a))),N!==F&&(N=F)}var U=1!==h&&u?a+4:a;for(A=0,F=0;F<l;F++){var G=0,k=0,z=0,H=0;for(y=0;y<a;y++)G=A*(U+1)+y,k=(A+1)*(U+1)+y,z=A*(U+1)+(y+1),H=(A+1)*(U+1)+(y+1),T.push(G,k,z),T.push(H,z,k);1!==h&&u&&(T.push(G+2,k+2,z+2),T.push(H+2,z+2,k+2),T.push(G+4,k+4,z+4),T.push(H+4,z+4,k+4)),A=c?A+2:A+1}var j=function(t){var i=t?o/2:s/2;if(0!==i){var r,l,c,u=t?f[m-1]:f[0],d=null;p&&(d=t?p[m-1]:p[0]);var g=E.length/3,_=t?n/2:-n/2,v=new e.Vector3(0,_,0);E.push(v.x,v.y,v.z),x.push(0,t?1:-1,0),P.push(u.x+.5*(u.z-u.x),u.y+.5*(u.w-u.y)),d&&M.push(d.r,d.g,d.b,d.a);var A=new e.Vector2(.5,.5);for(c=0;c<=a;c++){r=2*Math.PI*c*h/a;var y=Math.cos(-r),b=Math.sin(-r);l=new e.Vector3(y*i,_,b*i);var S=new e.Vector2(y*A.x+.5,b*A.y+.5);E.push(l.x,l.y,l.z),x.push(0,t?1:-1,0),P.push(u.x+(u.z-u.x)*S.x,u.y+(u.w-u.y)*S.y),d&&M.push(d.r,d.g,d.b,d.a)}for(c=0;c<a;c++)t?(T.push(g),T.push(g+(c+2)),T.push(g+(c+1))):(T.push(g),T.push(g+(c+1)),T.push(g+(c+2)))}};j(!1),j(!0),t._ComputeSides(d,E,T,x,P,i.frontUVs,i.backUVs);var W=new t;return W.indices=T,W.positions=E,W.normals=x,W.uvs=P,p&&(W.colors=M),W},t.CreateTorus=function(i){for(var r=[],n=[],o=[],s=[],a=i.diameter||1,l=i.thickness||.5,c=i.tessellation||16,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,h=c+1,d=0;d<=c;d++)for(var f=d/c,p=d*Math.PI*2/c-Math.PI/2,m=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),g=0;g<=c;g++){var _=1-g/c,v=g*Math.PI*2/c+Math.PI,A=Math.cos(v),y=Math.sin(v),b=new e.Vector3(A,y,0),T=b.scale(l/2),E=new e.Vector2(f,_);T=e.Vector3.TransformCoordinates(T,m),b=e.Vector3.TransformNormal(b,m),n.push(T.x,T.y,T.z),o.push(b.x,b.y,b.z),s.push(E.x,E.y);var x=(d+1)%h,P=(g+1)%h;r.push(d*h+g),r.push(d*h+P),r.push(x*h+g),r.push(d*h+P),r.push(x*h+P),r.push(x*h+g)}t._ComputeSides(u,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 c=n[l],u=0;u<c.length;u++){if(r.push(c[u].x,c[u].y,c[u].z),o){var h=o[l];s.push(h[u].r,h[u].g,h[u].b,h[u].a)}u>0&&(i.push(a-1),i.push(a)),a++}var d=new t;return d.indices=i,d.positions=r,o&&(d.colors=s),d},t.CreateDashedLines=function(i){var r,n,o=i.dashSize||3,s=i.gapSize||1,a=i.dashNb||200,l=i.points,c=new Array,u=new Array,h=e.Vector3.Zero(),d=0,f=0,p=0,m=0,g=0;for(g=0;g<l.length-1;g++)l[g+1].subtractToRef(l[g],h),d+=h.length();for(n=o*(r=d/a)/(o+s),g=0;g<l.length-1;g++){l[g+1].subtractToRef(l[g],h),f=Math.floor(h.length()/r),h.normalize();for(var _=0;_<f;_++)p=r*_,c.push(l[g].x+p*h.x,l[g].y+p*h.y,l[g].z+p*h.z),c.push(l[g].x+(p+n)*h.x,l[g].y+(p+n)*h.y,l[g].z+(p+n)*h.z),u.push(m,m+1),m+=2}var v=new t;return v.positions=c,v.indices=u,v},t.CreateGround=function(i){var r,n,o=[],s=[],a=[],l=[],c=i.width||1,u=i.height||1,h=i.subdivisionsX||i.subdivisions||1,d=i.subdivisionsY||i.subdivisions||1;for(r=0;r<=d;r++)for(n=0;n<=h;n++){var f=new e.Vector3(n*c/h-c/2,0,(d-r)*u/d-u/2),p=new e.Vector3(0,1,0);s.push(f.x,f.y,f.z),a.push(p.x,p.y,p.z),l.push(n/h,1-r/d)}for(r=0;r<d;r++)for(n=0;n<h;n++)o.push(n+1+(r+1)*(h+1)),o.push(n+1+r*(h+1)),o.push(n+r*(h+1)),o.push(n+(r+1)*(h+1)),o.push(n+1+(r+1)*(h+1)),o.push(n+r*(h+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,c=void 0!==i.xmax&&null!==i.xmax?i.xmax:1,u=void 0!==i.zmax&&null!==i.zmax?i.zmax:1,h=i.subdivisions||{w:1,h:1},d=i.precision||{w:1,h:1},f=new Array,p=new Array,m=new Array,g=new Array;h.h=h.h<1?1:h.h,h.w=h.w<1?1:h.w,d.w=d.w<1?1:d.w,d.h=d.h<1?1:d.h;var _=(c-a)/h.w,v=(u-l)/h.h;function A(t,i,o,s){var a=p.length/3,l=d.w+1;for(r=0;r<d.h;r++)for(n=0;n<d.w;n++){var c=[a+n+r*l,a+(n+1)+r*l,a+(n+1)+(r+1)*l,a+n+(r+1)*l];f.push(c[1]),f.push(c[2]),f.push(c[3]),f.push(c[0]),f.push(c[1]),f.push(c[3])}var u=e.Vector3.Zero(),h=new e.Vector3(0,1,0);for(r=0;r<=d.h;r++)for(u.z=r*(s-i)/d.h+i,n=0;n<=d.w;n++)u.x=n*(o-t)/d.w+t,u.y=0,p.push(u.x,u.y,u.z),m.push(h.x,h.y,h.z),g.push(n/d.w,r/d.h)}for(o=0;o<h.h;o++)for(s=0;s<h.w;s++)A(a+s*_,l+o*v,a+(s+1)*_,l+(o+1)*v);var y=new t;return y.indices=f,y.positions=p,y.normals=m,y.uvs=g,y},t.CreateGroundFromHeightMap=function(i){var r,n,o=[],s=[],a=[],l=[],c=i.colorFilter||new e.Color3(.3,.59,.11),u=i.alphaFilter||0;for(r=0;r<=i.subdivisions;r++)for(n=0;n<=i.subdivisions;n++){var h=new e.Vector3(n*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-r)*i.height/i.subdivisions-i.height/2),d=4*(((h.x+i.width/2)/i.width*(i.bufferWidth-1)|0)+((1-(h.z+i.height/2)/i.height)*(i.bufferHeight-1)|0)*i.bufferWidth),f=i.buffer[d]/255,p=i.buffer[d+1]/255,m=i.buffer[d+2]/255,g=i.buffer[d+3]/255,_=f*c.r+p*c.g+m*c.b;h.y=g>=u?i.minHeight+(i.maxHeight-i.minHeight)*_:i.minHeight-e.Epsilon,s.push(h.x,h.y,h.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++){var v=n+1+(r+1)*(i.subdivisions+1),A=n+1+r*(i.subdivisions+1),y=n+r*(i.subdivisions+1),b=n+(r+1)*(i.subdivisions+1),T=s[3*v+1]>=i.minHeight,E=s[3*A+1]>=i.minHeight,x=s[3*y+1]>=i.minHeight;T&&E&&x&&(o.push(v),o.push(A),o.push(y)),s[3*b+1]>=i.minHeight&&T&&x&&(o.push(b),o.push(v),o.push(y))}t.ComputeNormals(s,o,a);var P=new t;return P.indices=o,P.positions=s,P.normals=a,P.uvs=l,P},t.CreatePlane=function(i){var r=[],n=[],o=[],s=[],a=i.width||i.size||1,l=i.height||i.size||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=a/2,h=l/2;n.push(-u,-h,0),o.push(0,0,-1),s.push(0,0),n.push(u,-h,0),o.push(0,0,-1),s.push(1,0),n.push(u,h,0),o.push(0,0,-1),s.push(1,1),n.push(-u,h,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(c,n,r,o,s,i.frontUVs,i.backUVs);var d=new t;return d.indices=r,d.positions=n,d.normals=o,d.uvs=s,d},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,c=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var h=2*Math.PI*c,d=h/l,f=0;f<h;f+=d){var p=Math.cos(f),m=Math.sin(f),g=(p+1)/2,_=(1-m)/2;r.push(a*p,a*m,0),s.push(g,_)}1===c&&(r.push(r[3],r[4],r[5]),s.push(s[2],s[3]));for(var v=r.length/3,A=1;A<v-1;A++)n.push(A+1,0,A);t.ComputeNormals(r,n,o),t._ComputeSides(u,r,n,o,s,i.frontUVs,i.backUVs);var y=new t;return y.indices=n,y.positions=r,y.normals=o,y.uvs=s,y},t.CreatePolygon=function(i,r,n,o,s,a){for(var l=n||new Array(3),c=o,u=[],h=0;h<3;h++)void 0===l[h]&&(l[h]=new e.Vector4(0,0,1,1)),c&&void 0===c[h]&&(c[h]=new e.Color4(1,1,1,1));for(var d=i.getVerticesData(e.VertexBuffer.PositionKind),f=i.getVerticesData(e.VertexBuffer.NormalKind),p=i.getVerticesData(e.VertexBuffer.UVKind),m=i.getIndices(),g=0,_=0,v=0;v<f.length;v+=3)Math.abs(f[v+1])<.001&&(_=1),Math.abs(f[v+1]-1)<.001&&(_=0),Math.abs(f[v+1]+1)<.001&&(_=2),p[2*(g=v/3)]=(1-p[2*g])*l[_].x+p[2*g]*l[_].z,p[2*g+1]=(1-p[2*g+1])*l[_].y+p[2*g+1]*l[_].w,c&&u.push(c[_].r,c[_].g,c[_].b,c[_].a);t._ComputeSides(r,d,m,f,p,s,a);var A=new t;if(A.indices=m,A.positions=d,A.normals=f,A.uvs=p,c){var y=r===e.Mesh.DOUBLESIDE?u.concat(u):u;A.colors=y}return A},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,c=i.radiusY||o,u=i.radiusZ||o,h=(1+Math.sqrt(5))/2,d=[-1,h,-0,1,h,0,-1,-h,0,1,-h,0,0,-1,-h,0,1,-h,0,-1,h,0,1,h,h,0,1,h,0,-1,-h,0,1,-h,0,-1],f=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],p=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],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],g=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],_=new Array,v=new Array,A=new Array,y=new Array,b=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 x=0;x<20;x++){for(r=0;r<3;r++){var P=f[3*x+r];T[r].copyFromFloats(d[3*p[P]],d[3*p[P]+1],d[3*p[P]+2]),T[r].normalize().scaleInPlace(o),E[r].copyFromFloats(m[2*P]*(138/1024)+60/1024+g[x]*(-40/1024),m[2*P+1]*(239/1024)+26/1024+g[x]*(20/1024))}for(var M=function(t,i,r,n){var o,h=e.Vector3.Lerp(T[0],T[2],i/a),d=e.Vector3.Lerp(T[1],T[2],i/a),f=a===i?T[2]:e.Vector3.Lerp(h,d,t/(a-i));if(f.normalize(),s){var p=e.Vector3.Lerp(T[0],T[2],n/a),m=e.Vector3.Lerp(T[1],T[2],n/a);o=e.Vector3.Lerp(p,m,r/(a-n))}else o=new e.Vector3(f.x,f.y,f.z);o.x/=l,o.y/=c,o.z/=u,o.normalize();var g=e.Vector2.Lerp(E[0],E[2],i/a),x=e.Vector2.Lerp(E[1],E[2],i/a),P=a===i?E[2]:e.Vector2.Lerp(g,x,t/(a-i));v.push(f.x*l,f.y*c,f.z*u),A.push(o.x,o.y,o.z),y.push(P.x,P.y),_.push(b),b++},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,_,A,y,i.frontUVs,i.backUVs);var R=new t;return R.indices=_,R.positions=v,R.normals=A,R.uvs=y,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,c,u=i.type&&(i.type<0||i.type>=r.length)?0:i.type||0,h=i.size,d=i.sizeX||h||1,f=i.sizeY||h||1,p=i.sizeZ||h||1,m=i.custom||r[u],g=m.face.length,_=i.faceUV||new Array(g),v=i.faceColors,A=void 0===i.flat||i.flat,y=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=new Array,T=new Array,E=new Array,x=new Array,P=new Array,M=0,S=0,C=new Array,R=0,O=0;if(A)for(O=0;O<g;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),_&&void 0===_[O]&&(_[O]=new e.Vector4(0,0,1,1));if(A)for(O=0;O<g;O++){var D=m.face[O].length;for(s=2*Math.PI/D,a=.5*Math.tan(s/2),l=.5,R=0;R<D;R++)b.push(m.vertex[m.face[O][R]][0]*d,m.vertex[m.face[O][R]][1]*f,m.vertex[m.face[O][R]][2]*p),C.push(M),M++,n=_[O].x+(_[O].z-_[O].x)*(.5+a),o=_[O].y+(_[O].w-_[O].y)*(l-.5),x.push(n,o),c=a*Math.cos(s)-l*Math.sin(s),l=a*Math.sin(s)+l*Math.cos(s),a=c,v&&P.push(v[O].r,v[O].g,v[O].b,v[O].a);for(R=0;R<D-2;R++)T.push(C[0+S],C[R+2+S],C[R+1+S]);S+=D}else{for(R=0;R<m.vertex.length;R++)b.push(m.vertex[R][0]*d,m.vertex[R][1]*f,m.vertex[R][2]*p),x.push(0,0);for(O=0;O<g;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(b,T,E),t._ComputeSides(y,b,T,E,x,i.frontUVs,i.backUVs);var I=new t;return I.positions=b,I.indices=T,I.normals=E,I.uvs=x,v&&A&&(I.colors=P),I},t.CreateTorusKnot=function(i){var r,n,o=new Array,s=new Array,a=new Array,l=new Array,c=i.radius||2,u=i.tube||.5,h=i.radialSegments||32,d=i.tubularSegments||32,f=i.p||2,p=i.q||3,m=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,g=function(t){var i=Math.cos(t),r=Math.sin(t),n=p/f*t,o=Math.cos(n),s=c*(2+o)*.5*i,a=c*(2+o)*r*.5,l=c*Math.sin(n)*.5;return new e.Vector3(s,a,l)};for(r=0;r<=h;r++){var _=r%h/h*2*f*Math.PI,v=g(_),A=g(_+.01),y=A.subtract(v),b=A.add(v),T=e.Vector3.Cross(y,b);for(b=e.Vector3.Cross(T,y),T.normalize(),b.normalize(),n=0;n<d;n++){var E=n%d/d*2*Math.PI,x=-u*Math.cos(E),P=u*Math.sin(E);s.push(v.x+x*b.x+P*T.x),s.push(v.y+x*b.y+P*T.y),s.push(v.z+x*b.z+P*T.z),l.push(r/h),l.push(n/d)}}for(r=0;r<h;r++)for(n=0;n<d;n++){var M=(n+1)%d,S=r*d+n,C=(r+1)*d+n,R=(r+1)*d+M,O=r*d+M;o.push(O),o.push(C),o.push(S),o.push(O),o.push(R),o.push(C)}t.ComputeNormals(s,o,a),t._ComputeSides(m,s,o,a,l,i.frontUVs,i.backUVs);var D=new t;return D.indices=o,D.positions=s,D.normals=a,D.uvs=l,D},t.ComputeNormals=function(t,i,r,n){var o=0,s=0,a=0,l=0,c=0,u=0,h=0,d=0,f=0,p=0,m=0,g=0,_=0,v=0,A=0,y=0,b=0,T=0,E=0,x=0,P=!1,M=!1,S=!1,C=!1,R=1,O=0,D=null;if(n&&(P=!!n.facetNormals,M=!!n.facetPositions,S=!!n.facetPartitioning,R=!0===n.useRightHandedSystem?-1:1,O=n.ratio||0,C=!!n.depthSort,D=n.distanceTo,C)){void 0===D&&(D=e.Vector3.Zero());var I=n.depthSortedFacets}var w=0,L=0,B=0,F=0;if(S&&n&&n.bbSize){var N=0,V=0,U=0,G=0,k=0,z=0,H=0,j=0,W=0,X=0,Y=0,Q=0,K=0,Z=0,J=0,q=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,B=n.subDiv.Z*O/n.bbSize.z,F=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(_=(g=3*i[3*o])+1,v=g+2,y=(A=3*i[3*o+1])+1,b=A+2,E=(T=3*i[3*o+2])+1,x=T+2,s=t[g]-t[A],a=t[_]-t[y],l=t[v]-t[b],c=t[T]-t[A],u=t[E]-t[y],d=R*(a*(h=t[x]-t[b])-l*u),f=R*(l*c-s*h),p=R*(s*u-a*c),d/=m=0===(m=Math.sqrt(d*d+f*f+p*p))?1:m,f/=m,p/=m,P&&n&&(n.facetNormals[o].x=d,n.facetNormals[o].y=f,n.facetNormals[o].z=p),M&&n&&(n.facetPositions[o].x=(t[g]+t[A]+t[T])/3,n.facetPositions[o].y=(t[_]+t[y]+t[E])/3,n.facetPositions[o].z=(t[v]+t[b]+t[x])/3),S&&n&&(N=Math.floor((n.facetPositions[o].x-n.bInfo.minimum.x*O)*w),V=Math.floor((n.facetPositions[o].y-n.bInfo.minimum.y*O)*L),U=Math.floor((n.facetPositions[o].z-n.bInfo.minimum.z*O)*B),G=Math.floor((t[g]-n.bInfo.minimum.x*O)*w),k=Math.floor((t[_]-n.bInfo.minimum.y*O)*L),z=Math.floor((t[v]-n.bInfo.minimum.z*O)*B),H=Math.floor((t[A]-n.bInfo.minimum.x*O)*w),j=Math.floor((t[y]-n.bInfo.minimum.y*O)*L),W=Math.floor((t[b]-n.bInfo.minimum.z*O)*B),X=Math.floor((t[T]-n.bInfo.minimum.x*O)*w),Y=Math.floor((t[E]-n.bInfo.minimum.y*O)*L),Q=Math.floor((t[x]-n.bInfo.minimum.z*O)*B),Z=G+n.subDiv.max*k+F*z,J=H+n.subDiv.max*j+F*W,q=X+n.subDiv.max*Y+F*Q,K=N+n.subDiv.max*V+F*U,n.facetPartitioning[K]=n.facetPartitioning[K]?n.facetPartitioning[K]:new Array,n.facetPartitioning[Z]=n.facetPartitioning[Z]?n.facetPartitioning[Z]:new Array,n.facetPartitioning[J]=n.facetPartitioning[J]?n.facetPartitioning[J]:new Array,n.facetPartitioning[q]=n.facetPartitioning[q]?n.facetPartitioning[q]:new Array,n.facetPartitioning[Z].push(o),J!=Z&&n.facetPartitioning[J].push(o),q!=J&&q!=Z&&n.facetPartitioning[q].push(o),K!=Z&&K!=J&&K!=q&&n.facetPartitioning[K].push(o)),C&&n&&n.facetPositions){var te=I[o];te.ind=3*o,te.sqDistance=e.Vector3.DistanceSquared(n.facetPositions[o],D)}r[g]+=d,r[_]+=f,r[v]+=p,r[A]+=d,r[y]+=f,r[b]+=p,r[T]+=d,r[E]+=f,r[x]+=p}for(o=0;o<r.length/3;o++)d=r[3*o],f=r[3*o+1],p=r[3*o+2],d/=m=0===(m=Math.sqrt(d*d+f*f+p*p))?1:m,f/=m,p/=m,r[3*o]=d,r[3*o+1]=f,r[3*o+2]=p},t._ComputeSides=function(t,i,r,n,o,s,a){var l,c,u=r.length,h=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var d;for(l=0;l<u;l+=3)d=r[l],r[l]=r[l+2],r[l+2]=d;for(c=0;c<h;c++)n[c]=-n[c];break;case e.Mesh.DOUBLESIDE:for(var f=i.length,p=f/3,m=0;m<f;m++)i[f+m]=i[m];for(l=0;l<u;l+=3)r[l+u]=r[l+2]+p,r[l+1+u]=r[l+1]+p,r[l+2+u]=r[l]+p;for(c=0;c<h;c++)n[h+c]=-n[c];var g=o.length,_=0;for(_=0;_<g;_++)o[_+g]=o[_];for(s=s||new e.Vector4(0,0,1,1),a=a||new e.Vector4(0,0,1,1),_=0,l=0;l<g/2;l++)o[_]=s.x+(s.z-s.x)*o[_],o[_+1]=s.y+(s.w-s.y)*o[_+1],o[_+g]=a.x+(a.z-a.x)*o[_+g],o[_+g+1]=a.y+(a.w-a.y)*o[_+g+1],_+=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 c=i.uv2s;c&&n.set(c,e.VertexBuffer.UV2Kind);var u=i.uv3s;u&&n.set(u,e.VertexBuffer.UV3Kind);var h=i.uv4s;h&&n.set(h,e.VertexBuffer.UV4Kind);var d=i.uv5s;d&&n.set(d,e.VertexBuffer.UV5Kind);var f=i.uv6s;f&&n.set(f,e.VertexBuffer.UV6Kind);var p=i.colors;p&&n.set(e.Color4.CheckColors4(p,o.length/3),e.VertexBuffer.ColorKind);var m=i.matricesIndices;m&&n.set(m,e.VertexBuffer.MatricesIndicesKind);var g=i.matricesWeights;g&&n.set(g,e.VertexBuffer.MatricesWeightsKind);var _=i.indices;_&&(n.indices=_),r.setAllVerticesData(n,i.updatable)},t}();e.VertexData=t}(a||(a={})),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){if(this._boundingBias){if(this._boundingBias.equals(e))return;this._boundingBias.copyFrom(e)}else this._boundingBias=e.clone();this._updateBoundingInfo(!0,null)},enumerable:!0,configurable:!0}),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(){for(var e in this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._vertexBuffers){this._vertexBuffers[e]._rebuild()}},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();i&&(t==this._indexBuffer&&this._vertexArrayObjects?(this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(i,t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)):this._engine.bindBuffers(i,t,e))}},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 c=n.byteOffset/4;return e.Tools.Slice(o,c,c+a)}if(o instanceof ArrayBuffer)return new Float32Array(o,n.byteOffset,a);c=o.byteOffset+n.byteOffset;if(r||i&&1!==this._meshes.length){var u=new Float32Array(a),h=new Float32Array(o.buffer,c,a);return u.set(h),u}return new Float32Array(o.buffer,c,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,t){if(!this.isReady())return null;var i=this._indices;if(t||e&&1!==this._meshes.length){for(var r=i.length,n=[],o=0;o<r;o++)n.push(i[o]);return n}return i},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._syncGeometryWithMorphTargetManager()},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){this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(this.isReady()?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(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(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;var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t||0===t.length)return!1;this._positions=[];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]);for(var n in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=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 c=this.getVerticesData(s);if(c instanceof Float32Array?r.set(new Float32Array(c),s):r.set(c.slice(0),s),!l){var u=this.getVertexBuffer(s);u&&(l=!(a=u.isUpdatable()))}}var h=new t(i,this._scene,r,a);for(s in h.delayLoadState=this.delayLoadState,h.delayLoadingFile=this.delayLoadingFile,h._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)h._delayInfo=h._delayInfo||[],h._delayInfo.push(s);return h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h},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 c=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,c,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){var u=new Float32Array(i,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);r.setVerticesData(e.VertexBuffer.TangentKind,u,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var h=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,h,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var d=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,d,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var p=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,p,!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 g=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,g,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){for(var v=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count),A=[],y=0;y<v.length;y++){var b=v[y];A.push(255&b),A.push((65280&b)>>8),A.push((16711680&b)>>16),A.push(b>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,A,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var T=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,T,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var E=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(E,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(y=0;y<a.subMeshesAttrDesc.count;y++){var P=x[5*y+0],M=x[5*y+1],S=x[5*y+2],C=x[5*y+3],R=x[5*y+4];e.SubMesh.AddToMesh(P,M,S,C,R,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(A=[],y=0;y<i.matricesIndices.length;y++){var O=i.matricesIndices[y];A.push(255&O),A.push((65280&O)>>8),A.push((16711680&O)>>16),A.push(O>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,A,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(A=[],y=0;y<i.matricesIndicesExtra.length;y++){O=i.matricesIndicesExtra[y];A.push(255&O),A.push((65280&O)>>8),A.push((16711680&O)>>16),A.push(O>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,A,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 D=0;D<i.subMeshes.length;D++){var I=i.subMeshes[D];e.SubMesh.AddToMesh(I.materialIndex,I.verticesStart,I.verticesCount,I.indexStart,I.indexCount,r)}}r._shouldGenerateFlatShading&&(r.convertToFlatShadedMesh(),delete r._shouldGenerateFlatShading),r.computeWorldMatrix(!0),n.onMeshImportedObservable.notifyObservers(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,c=t.numBoneInfluencer,u=a.length,h=0;h<u;h+=4){for(var d=0,f=-1,p=0;p<4;p++){d+=m=a[h+p],m<.001&&f<0&&(f=p)}if(l)for(p=0;p<4;p++){var m;d+=m=l[h+p],m<.001&&f<0&&(f=p+4)}if((f<0||f>c-1)&&(f=c-1),d>.001){var g=1/d;for(p=0;p<4;p++)a[h+p]*=g;if(l)for(p=0;p<4;p++)l[h+p]*=g}else f>=4?(l[h+f-4]=1-d,s[h+f-4]=r):(a[h+f]=1-d,o[h+f]=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,c,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,l,c)||this;return h.pathArray=n,h.closeArray=o,h.closePath=s,h.offset=a,h.side=u,h}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 c=t.call(this,i,r,s,a)||this;return c.segments=n,c.diameter=o,c.side=l,c}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 c=t.call(this,i,r,s,a)||this;return c.radius=n,c.tessellation=o,c.side=l,c}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,c,u,h){void 0===l&&(l=1),void 0===u&&(u=null),void 0===h&&(h=e.Mesh.DEFAULTSIDE);var d=t.call(this,i,r,c,u)||this;return d.height=n,d.diameterTop=o,d.diameterBottom=s,d.tessellation=a,d.subdivisions=l,d.side=h,d}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 c=function(t){function i(i,r,n,o,s,a,l,c){void 0===l&&(l=null),void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,a,l)||this;return u.diameter=n,u.thickness=o,u.tessellation=s,u.side=c,u}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=c;var u=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=u;var h=function(t){function i(e,i,r,n,o,s,a,l,c,u){void 0===u&&(u=null);var h=t.call(this,e,i,c,u)||this;return h.xmin=r,h.zmin=n,h.xmax=o,h.zmax=s,h.subdivisions=a,h.precision=l,h}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=h;var d=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=d;var f=function(t){function i(i,r,n,o,s,a,l,c,u,h,d){void 0===h&&(h=null),void 0===d&&(d=e.Mesh.DEFAULTSIDE);var f=t.call(this,i,r,u,h)||this;return f.radius=n,f.tube=o,f.radialSegments=s,f.tubularSegments=a,f.p=l,f.q=c,f.side=d,f}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=f}(a||(a={})),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}(a||(a={})),function(e){var t=function(){function t(){}return t.BindEyePosition=function(e,t){t._forcedViewPosition?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,s,a,l,c=!1;o=null==n?void 0!==e.clipPlane&&null!==e.clipPlane:n,s=null==n?void 0!==e.clipPlane2&&null!==e.clipPlane2:n,a=null==n?void 0!==e.clipPlane3&&null!==e.clipPlane3:n,l=null==n?void 0!==e.clipPlane4&&null!==e.clipPlane4:n,i.CLIPPLANE!==o&&(i.CLIPPLANE=o,c=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,c=!0),i.CLIPPLANE3!==a&&(i.CLIPPLANE3=a,c=!0),i.CLIPPLANE4!==l&&(i.CLIPPLANE4=l,c=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,c=!0),i.INSTANCES!==r&&(i.INSTANCES=r,c=!0),c&&i.markAsUnprocessed()},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,c=!1,u=!1,h=!1,d=!1;if(t.lightsEnabled&&!s)for(var f=0,p=i._lightSources;f<p.length;f++){var m=p[f];switch(l=!0,void 0===r["LIGHT"+a]&&(c=!0),r["LIGHT"+a]=!0,r["SPOTLIGHT"+a]=!1,r["HEMILIGHT"+a]=!1,r["POINTLIGHT"+a]=!1,r["DIRLIGHT"+a]=!1,m.prepareLightSpecificDefines(r,a),r["LIGHT_FALLOFF_PHYSICAL"+a]=!1,r["LIGHT_FALLOFF_GLTF"+a]=!1,r["LIGHT_FALLOFF_STANDARD"+a]=!1,m.falloffType){case e.Light.FALLOFF_GLTF:r["LIGHT_FALLOFF_GLTF"+a]=!0;break;case e.Light.FALLOFF_PHYSICAL:r["LIGHT_FALLOFF_PHYSICAL"+a]=!0;break;case e.Light.FALLOFF_STANDARD:r["LIGHT_FALLOFF_STANDARD"+a]=!0}if(n&&!m.specular.equalsFloats(0,0,0)&&(d=!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 g=m.getShadowGenerator();if(g){var _=g.getShadowMap();_&&_.renderList&&_.renderList.length>0&&(h=!0,g.prepareDefines(r,a))}}if(m.lightmapMode!=e.Light.LIGHTMAP_DEFAULT?(u=!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=d,r.SHADOWS=h;for(var v=a;v<o;v++)void 0!==r["LIGHT"+v]&&(r["LIGHT"+v]=!1,r["HEMILIGHT"+a]=!1,r["POINTLIGHT"+a]=!1,r["DIRLIGHT"+a]=!1,r["SPOTLIGHT"+a]=!1,r["SHADOW"+a]=!1);var A=t.getEngine().getCaps();return void 0===r.SHADOWFLOAT&&(c=!0),r.SHADOWFLOAT=h&&(A.textureFloatRender&&A.textureFloatLinearFiltering||A.textureHalfFloatRender&&A.textureHalfFloatLinearFiltering),r.LIGHTMAPEXCLUDED=u,c&&r.rebuild(),l},t.PrepareUniformsAndSamplersList=function(e,t,i,r){var n;void 0===r&&(r=4);var o=null;if(e.uniformsNames){var s=e;n=s.uniformsNames,o=s.uniformBuffersNames,t=s.samplers,i=s.defines,r=s.maxSimultaneousLights}else n=e,t||(t=[]);for(var a=0;a<r&&i["LIGHT"+a];a++)n.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightFalloff"+a,"vLightGround"+a,"lightMatrix"+a,"shadowsInfo"+a,"depthValues"+a),o&&o.push("Light"+a),t.push("shadowSampler"+a),t.push("depthSampler"+a),i["PROJECTEDLIGHTTEXTURE"+a]&&(t.push("projectionLightSampler"+a),n.push("textureProjectionMatrix"+a));i.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},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,c=0;c<n;c++)t.push(e.VertexBuffer.PositionKind+c),a&&t.push(e.VertexBuffer.NormalKind+c),l&&t.push(e.VertexBuffer.TangentKind+c),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),c=0;c<l;c++){var u=r._lightSources[c],h=c.toString(),d=u.getScaledIntensity();u._uniformBuffer.bindToEffect(n,"Light"+c),t.BindLightProperties(u,n,c),u.diffuse.scaleToRef(d,e.Tmp.Color3[0]),u._uniformBuffer.updateColor4("vLightDiffuse",e.Tmp.Color3[0],a?u.radius:u.range,h),o.SPECULARTERM&&(u.specular.scaleToRef(d,e.Tmp.Color3[1]),u._uniformBuffer.updateColor3("vLightSpecular",e.Tmp.Color3[1],h)),i.shadowsEnabled&&this.BindLightShadow(u,i,r,h,n),u._uniformBuffer.update()}},t.BindFogParameters=function(t,i,r,n){void 0===n&&(n=!1),t.fogEnabled&&i.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(r.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),n?(t.fogColor.toLinearSpaceToRef(this._tempFogColor),r.setColor3("vFogColor",this._tempFogColor)):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)}if(t.clipPlane2){i=t.clipPlane2;e.setFloat4("vClipPlane2",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane3){i=t.clipPlane3;e.setFloat4("vClipPlane3",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane4){i=t.clipPlane4;e.setFloat4("vClipPlane4",i.normal.x,i.normal.y,i.normal.z,i.d)}},t._tempFogColor=e.Color3.Black(),t}();e.MaterialHelper=t}(a||(a={})),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}(a||(a={})),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.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!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_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.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.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.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=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t<i.length;t++){var r=i[t];this[r]=r===e}},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._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}),Object.defineProperty(r.prototype,"hasRenderTargetTextures",{get:function(){return!!(r.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(r.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},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)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"),a.REFLECTIONMAP_SKYBOX_TRANSFORMED=!this._reflectionTexture.getReflectionTextureMatrix().isIdentity();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&&this._imageProcessingConfiguration){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 c=new e.EffectFallbacks;a.REFLECTION&&c.addFallback(0,"REFLECTION"),a.SPECULAR&&c.addFallback(0,"SPECULAR"),a.BUMP&&c.addFallback(0,"BUMP"),a.PARALLAX&&c.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&c.addFallback(1,"FOG"),a.POINTSIZE&&c.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,c,this._maxSimultaneousLights),a.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&c.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&c.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&c.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&c.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&c.addFallback(4,"FRESNEL");var u=[e.VertexBuffer.PositionKind];a.NORMAL&&u.push(e.VertexBuffer.NormalKind),a.UV1&&u.push(e.VertexBuffer.UVKind),a.UV2&&u.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,i,a,c),e.MaterialHelper.PrepareAttributesForInstances(u,a),e.MaterialHelper.PrepareAttributesForMorphTargets(u,i,a);var h="default",d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff"],f=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareUniforms(d,a),e.ImageProcessingConfiguration.PrepareSamplers(f,a)),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,d,p,f,a));var m=a.toString();n.setEffect(s.getEngine().createEffect(h,{attributes:u,uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:m,fallbacks:c,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 c=this._reflectionTexture;this._uniformBuffer.updateVector3("vReflectionPosition",c.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",c.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 u=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,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)){u=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&&!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}(a||(a={})),function(e){var t=function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var i=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t.FromHarmonics=function(e){var i=new t;return i.x=e.l11.scale(1.02333),i.y=e.l1_1.scale(1.02333),i.z=e.l10.scale(1.02333),i.xx=e.l00.scale(.886277).subtract(e.l20.scale(.247708)).add(e.lL22.scale(.429043)),i.yy=e.l00.scale(.886277).subtract(e.l20.scale(.247708)).subtract(e.lL22.scale(.429043)),i.zz=e.l00.scale(.886277).add(e.l20.scale(.495417)),i.yz=e.l2_1.scale(.858086),i.zx=e.l21.scale(.858086),i.xy=e.l2_2.scale(.858086),i.scale(1/Math.PI),i},t.FromArray=function(i){var r=new t;return e.Vector3.FromArrayToRef(i[0],0,r.x),e.Vector3.FromArrayToRef(i[1],0,r.y),e.Vector3.FromArrayToRef(i[2],0,r.z),e.Vector3.FromArrayToRef(i[3],0,r.xx),e.Vector3.FromArrayToRef(i[4],0,r.yy),e.Vector3.FromArrayToRef(i[5],0,r.zz),e.Vector3.FromArrayToRef(i[6],0,r.yz),e.Vector3.FromArrayToRef(i[7],0,r.zx),e.Vector3.FromArrayToRef(i[8],0,r.xy),r},t}();e.SphericalPolynomial=t;var i=function(){function t(){this.l00=e.Vector3.Zero(),this.l1_1=e.Vector3.Zero(),this.l10=e.Vector3.Zero(),this.l11=e.Vector3.Zero(),this.l2_2=e.Vector3.Zero(),this.l2_1=e.Vector3.Zero(),this.l20=e.Vector3.Zero(),this.l21=e.Vector3.Zero(),this.lL22=e.Vector3.Zero()}return t.prototype.addLight=function(t,i,r){var n=new e.Vector3(i.r,i.g,i.b).scale(r);this.l00=this.l00.add(n.scale(.282095)),this.l1_1=this.l1_1.add(n.scale(.488603*t.y)),this.l10=this.l10.add(n.scale(.488603*t.z)),this.l11=this.l11.add(n.scale(.488603*t.x)),this.l2_2=this.l2_2.add(n.scale(1.092548*t.x*t.y)),this.l2_1=this.l2_1.add(n.scale(1.092548*t.y*t.z)),this.l21=this.l21.add(n.scale(1.092548*t.x*t.z)),this.l20=this.l20.add(n.scale(.315392*(3*t.z*t.z-1))),this.lL22=this.lL22.add(n.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.l00=this.l00.scale(e),this.l1_1=this.l1_1.scale(e),this.l10=this.l10.scale(e),this.l11=this.l11.scale(e),this.l2_2=this.l2_2.scale(e),this.l2_1=this.l2_1.scale(e),this.l20=this.l20.scale(e),this.l21=this.l21.scale(e),this.lL22=this.lL22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.l00=this.l00.scale(3.141593),this.l1_1=this.l1_1.scale(2.094395),this.l10=this.l10.scale(2.094395),this.l11=this.l11.scale(2.094395),this.l2_2=this.l2_2.scale(.785398),this.l2_1=this.l2_1.scale(.785398),this.l20=this.l20.scale(.785398),this.l21=this.l21.scale(.785398),this.lL22=this.lL22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.FromPolynomial=function(e){var i=new t;return i.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),i.l1_1=e.y.scale(.977204),i.l10=e.z.scale(.977204),i.l11=e.x.scale(.977204),i.l2_2=e.xy.scale(1.16538),i.l2_1=e.yz.scale(1.16538),i.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),i.l21=e.zx.scale(1.16538),i.lL22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),i.scale(Math.PI),i},t.FromArray=function(i){var r=new t;return e.Vector3.FromArrayToRef(i[0],0,r.l00),e.Vector3.FromArrayToRef(i[1],0,r.l1_1),e.Vector3.FromArrayToRef(i[2],0,r.l10),e.Vector3.FromArrayToRef(i[3],0,r.l11),e.Vector3.FromArrayToRef(i[4],0,r.l2_2),e.Vector3.FromArrayToRef(i[5],0,r.l2_1),e.Vector3.FromArrayToRef(i[6],0,r.l20),e.Vector3.FromArrayToRef(i[7],0,r.l21),e.Vector3.FromArrayToRef(i[8],0,r.lL22),r},t}();e.SphericalHarmonics=i}(a||(a={})),function(e){var t=function(){return function(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}}(),i=function(){function i(){}return i.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var i,r,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(i=t.readPixels(3),r=t.readPixels(2)):(i=t.readPixels(2),r=t.readPixels(3));var a=t.readPixels(4),l=t.readPixels(5),c=t.gammaSpace,u=e.Engine.TEXTUREFORMAT_RGBA,h=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(h=e.Engine.TEXTURETYPE_FLOAT);var d={size:n,right:o,left:s,up:i,down:r,front:a,back:l,format:u,type:h,gammaSpace:c};return this.ConvertCubeMapToSphericalPolynomial(d)},i.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var l=this.FileFaces[a],c=t[l.name],u=s,h=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,d=0;d<t.size;d++){for(var f=s,p=0;p<t.size;p++){var m=l.worldAxisForFileX.scale(f).add(l.worldAxisForFileY.scale(u)).add(l.worldAxisForNormal);m.normalize();var g=Math.pow(1+f*f+u*u,-1.5),_=c[d*t.size*h+p*h+0],v=c[d*t.size*h+p*h+1],A=c[d*t.size*h+p*h+2];t.type===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(_/=255,v/=255,A/=255),t.gammaSpace&&(_=Math.pow(e.Scalar.Clamp(_),e.ToLinearSpace),v=Math.pow(e.Scalar.Clamp(v),e.ToLinearSpace),A=Math.pow(e.Scalar.Clamp(A),e.ToLinearSpace));var y=new e.Color3(_,v,A);i.addLight(m,y,g),r+=g,f+=n}u+=o}var b=6*(4*Math.PI)/6/r;return i.scale(b),i.convertIncidentRadianceToIrradiance(),i.convertIrradianceToLambertianRadiance(),e.SphericalPolynomial.FromHarmonics(i)},i.FileFaces=[new t("right",new e.Vector3(1,0,0),new e.Vector3(0,0,-1),new e.Vector3(0,-1,0)),new t("left",new e.Vector3(-1,0,0),new e.Vector3(0,0,1),new e.Vector3(0,-1,0)),new t("up",new e.Vector3(0,1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,1)),new t("down",new e.Vector3(0,-1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,-1)),new t("front",new e.Vector3(0,0,1),new e.Vector3(1,0,0),new e.Vector3(0,-1,0)),new t("back",new e.Vector3(0,0,-1),new e.Vector3(-1,0,0),new e.Vector3(0,-1,0))],i}();e.CubeMapToSphericalPolynomialTools=i}(a||(a={})),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_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.RADIANCEOCCLUSION=!1,t.HORIZONOCCLUSION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.RGBDREFRACTION=!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.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!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,n){var o=i.call(this,t,n)||this;return o._directIntensity=1,o._emissiveIntensity=1,o._environmentIntensity=1,o._specularIntensity=1,o._lightingInfos=new e.Vector4(o._directIntensity,o._emissiveIntensity,o._environmentIntensity,o._specularIntensity),o._disableBumpMap=!1,o._ambientTextureStrength=1,o._ambientTextureImpactOnAnalyticalLights=e.PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,o._ambientColor=new e.Color3(0,0,0),o._albedoColor=new e.Color3(1,1,1),o._reflectivityColor=new e.Color3(1,1,1),o._reflectionColor=new e.Color3(1,1,1),o._emissiveColor=new e.Color3(0,0,0),o._microSurface=.9,o._indexOfRefraction=.66,o._invertRefractionY=!1,o._linkRefractionWithTransparency=!1,o._useLightmapAsShadowmap=!1,o._useHorizonOcclusion=!0,o._useRadianceOcclusion=!0,o._useAlphaFromAlbedoTexture=!1,o._useSpecularOverAlpha=!0,o._useMicroSurfaceFromReflectivityMapAlpha=!1,o._useRoughnessFromMetallicTextureAlpha=!0,o._useRoughnessFromMetallicTextureGreen=!1,o._useMetallnessFromMetallicTextureBlue=!1,o._useAmbientOcclusionFromMetallicTextureRed=!1,o._useAmbientInGrayScale=!1,o._useAutoMicroSurfaceFromReflectivityMap=!1,o._lightFalloff=r.LIGHTFALLOFF_PHYSICAL,o._useRadianceOverAlpha=!0,o._useObjectSpaceNormalMap=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o._parallaxScaleBias=.05,o._disableLighting=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._alphaCutOff=.4,o._forceAlphaTest=!1,o._useAlphaFresnel=!1,o._useLinearAlphaFresnel=!1,o._transparencyMode=null,o._environmentBRDFTexture=null,o._forceIrradianceInFragment=!1,o._forceNormalForward=!1,o._enableSpecularAntiAliasing=!1,o._renderTargets=new e.SmartArray(16),o._globalAmbientColor=new e.Color3(0,0,0),o._unlit=!1,o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&o._refractionTexture&&o._refractionTexture.isRenderTarget&&o._renderTargets.push(o._refractionTexture),o._renderTargets},o._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(n),o}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._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(r.prototype,"hasRenderTargetTextures",{get:function(){return!!(e.StandardMaterial.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(e.StandardMaterial.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),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 c=this._getRefractionTexture();if(c&&e.StandardMaterial.RefractionTextureEnabled&&!c.isReadyOrNotBlocking())return!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(o._areImageProcessingDirty&&this._imageProcessingConfiguration&&!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 u=this._prepareEffect(i,o,this.onCompiled,this.onError,n);return u&&(s.resetCachedMaterial(),r.setEffect(u,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().getEngine(),l=new e.EffectFallbacks,c=0;i.USESPHERICALINVERTEX&&l.addFallback(c++,"USESPHERICALINVERTEX"),i.FOG&&l.addFallback(c,"FOG"),i.SPECULARAA&&l.addFallback(c,"SPECULARAA"),i.POINTSIZE&&l.addFallback(c,"POINTSIZE"),i.LOGARITHMICDEPTH&&l.addFallback(c,"LOGARITHMICDEPTH"),i.PARALLAX&&l.addFallback(c,"PARALLAX"),i.PARALLAXOCCLUSION&&l.addFallback(c++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&l.addFallback(c++,"ENVIRONMENTBRDF"),i.TANGENT&&l.addFallback(c++,"TANGENT"),i.BUMP&&l.addFallback(c++,"BUMP"),c=e.MaterialHelper.HandleFallbacksForShadows(i,l,this._maxSimultaneousLights,c++),i.SPECULARTERM&&l.addFallback(c++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&l.addFallback(c++,"USESPHERICALFROMREFLECTIONMAP"),i.LIGHTMAP&&l.addFallback(c++,"LIGHTMAP"),i.NORMAL&&l.addFallback(c++,"NORMAL"),i.AMBIENT&&l.addFallback(c++,"AMBIENT"),i.EMISSIVE&&l.addFallback(c++,"EMISSIVE"),i.VERTEXCOLOR&&l.addFallback(c++,"VERTEXCOLOR"),i.NUM_BONE_INFLUENCERS>0&&l.addCPUSkinningFallback(c++,t),i.MORPHTARGETS&&l.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,l),e.MaterialHelper.PrepareAttributesForInstances(u,i),e.MaterialHelper.PrepareAttributesForMorphTargets(u,t,i);var h=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vTangentSpaceParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],f=["Material","Scene"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareUniforms(h,i),e.ImageProcessingConfiguration.PrepareSamplers(d,i)),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:f,samplers:d,defines:i,maxSimultaneousLights:this._maxSimultaneousLights});var p=i.toString();return a.createEffect("pbr",{attributes:u,uniformsNames:h,uniformBuffersNames:f,samplers:d,defines:p,fallbacks:l,onCompiled:r,onError:n,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS}},a)},r.prototype._prepareDefines=function(t,i,n,o){void 0===n&&(n=null),void 0===o&&(o=null);var s=this.getScene(),a=s.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(s,t,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){if(i._needUVs=!1,s.texturesEnabled){s.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 l=this._getReflectionTexture();if(l&&e.StandardMaterial.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=l.gammaSpace,i.RGBDREFLECTION=l.isRGBD,i.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!l.invertZ:l.invertZ,i.LODINREFLECTIONALPHA=l.lodLevelInAlpha,l.coordinatesMode===e.Texture.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=l.isCube,l.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=!!l.boundingBoxSize}l.coordinatesMode!==e.Texture.SKYBOX_MODE?l.sphericalPolynomial&&(i.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||s.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0):i.REFLECTIONMAP_SKYBOX_TRANSFORMED=!l.getReflectionTextureMatrix().isIdentity()}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_SKYBOX_TRANSFORMED=!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,i.RGBDREFLECTION=!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),s.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 c=this._getRefractionTexture();c&&e.StandardMaterial.RefractionTextureEnabled?(i.REFRACTION=!0,i.REFRACTIONMAP_3D=c.isCube,i.GAMMAREFRACTION=c.gammaSpace,i.RGBDREFRACTION=c.isRGBD,i.REFRACTIONMAP_OPPOSITEZ=c.invertZ,i.LODINREFRACTIONALPHA=c.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,this._lightFalloff===r.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===r.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.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=s.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(e.MaterialHelper.PrepareDefinesForMisc(t,s,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(s,a,i,!!n,o),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",4),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vReflectionPosition",3),this._uniformBuffer.addUniform("vReflectionSize",3),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},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,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);e.MaterialHelper.BindBonesParameters(i,this._activeEffect);var c=null;if(l){this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),c=this._getReflectionTexture();var u=this._getRefractionTexture();if(!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(o.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.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),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")),c&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",c.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",c.level,0),c.boundingBoxSize){var h=c;this._uniformBuffer.updateVector3("vReflectionPosition",h.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",h.boundingBoxSize)}var d=c.sphericalPolynomial;s.USESPHERICALFROMREFLECTIONMAP&&d&&(this._activeEffect.setFloat3("vSphericalX",d.x.x,d.x.y,d.x.z),this._activeEffect.setFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),this._activeEffect.setFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),this._activeEffect.setFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),this._activeEffect.setFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),this._activeEffect.setFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),this._activeEffect.setFloat3("vSphericalZX",d.zx.x,d.zx.y,d.zx.z)),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",c.getSize().width,c.lodGenerationScale,c.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&&o.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"),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)),u&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",u.getReflectionTextureMatrix());var f=1;u.isCube||u.depth&&(f=u.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",u.level,this._indexOfRefraction,f,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",u.getSize().width,u.lodGenerationScale,u.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.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)}o.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),c&&e.StandardMaterial.ReflectionTextureEnabled&&(s.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",c):(this._uniformBuffer.setTexture("reflectionSampler",c._lodTextureMid||c),this._uniformBuffer.setTexture("reflectionSamplerLow",c._lodTextureLow||c),this._uniformBuffer.setTexture("reflectionSamplerHigh",c._lodTextureHigh||c))),s.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),u&&e.StandardMaterial.RefractionTextureEnabled&&(s.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",u):(this._uniformBuffer.setTexture("refractionSampler",u._lodTextureMid||u),this._uniformBuffer.setTexture("refractionSamplerLow",u._lodTextureLow||u),this._uniformBuffer.setTexture("refractionSamplerHigh",u._lodTextureHigh||u))),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&&o.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,o),o.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var p=o._forcedViewPosition?o._forcedViewPosition:o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition,m=o.useRightHandedSystem===(null!=o._mirroredCameraPosition);a.setFloat4("vEyePosition",p.x,p.y,p.z,m?-1:1),a.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,this._activeEffect,s,this._maxSimultaneousLights,this._lightFalloff!==r.LIGHTFALLOFF_STANDARD),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||c)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,this._activeEffect,!0),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(s,this._activeEffect,o)),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.LIGHTFALLOFF_PHYSICAL=0,r.LIGHTFALLOFF_GLTF=1,r.LIGHTFALLOFF_STANDARD=2,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}(a||(a={})),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}(a||(a={})),function(e){var t=function(t){function i(r,n){var o=t.call(this,r,n)||this;return o.directIntensity=1,o.emissiveIntensity=1,o.environmentIntensity=1,o.specularIntensity=1,o.disableBumpMap=!1,o.ambientTextureStrength=1,o.ambientTextureImpactOnAnalyticalLights=i.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,o.ambientColor=new e.Color3(0,0,0),o.albedoColor=new e.Color3(1,1,1),o.reflectivityColor=new e.Color3(1,1,1),o.reflectionColor=new e.Color3(1,1,1),o.emissiveColor=new e.Color3(0,0,0),o.microSurface=1,o.indexOfRefraction=.66,o.invertRefractionY=!1,o.linkRefractionWithTransparency=!1,o.useLightmapAsShadowmap=!1,o.useAlphaFromAlbedoTexture=!1,o.forceAlphaTest=!1,o.alphaCutOff=.4,o.useSpecularOverAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!1,o.useRoughnessFromMetallicTextureAlpha=!0,o.useRoughnessFromMetallicTextureGreen=!1,o.useMetallnessFromMetallicTextureBlue=!1,o.useAmbientOcclusionFromMetallicTextureRed=!1,o.useAmbientInGrayScale=!1,o.useAutoMicroSurfaceFromReflectivityMap=!1,o.useRadianceOverAlpha=!0,o.useObjectSpaceNormalMap=!1,o.useParallax=!1,o.useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o.disableLighting=!1,o.forceIrradianceInFragment=!1,o.maxSimultaneousLights=4,o.invertNormalMapX=!1,o.invertNormalMapY=!1,o.twoSidedLighting=!1,o.useAlphaFresnel=!1,o.useLinearAlphaFresnel=!1,o.environmentBRDFTexture=null,o.forceNormalForward=!1,o.enableSpecularAntiAliasing=!1,o.useHorizonOcclusion=!0,o.useRadianceOcclusion=!0,o.unlit=!1,o._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(n),o}return o(i,t),Object.defineProperty(i.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===e.PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL},set:function(t){t!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=t?e.PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL:e.PBRBaseMaterial.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===e.PBRBaseMaterial.LIGHTFALLOFF_GLTF},set:function(t){t!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=t?e.PBRBaseMaterial.LIGHTFALLOFF_GLTF:e.PBRBaseMaterial.LIGHTFALLOFF_STANDARD)},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,i.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=1,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.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTextureImpactOnAnalyticalLights",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()],i.prototype,"usePhysicalLightFalloff",null),n([e.serialize()],i.prototype,"useGLTFLightFalloff",null),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("_markAllSubMeshesAsMiscDirty")],i.prototype,"unlit",void 0),i}(e.PBRBaseMaterial);e.PBRMaterial=t}(a||(a={})),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}(a||(a={})),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}(a||(a={})),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();this.attached[i]?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)for(var r in i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i,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(){for(var e in this.checkInputs=function(){},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)for(var r in this.clear(),i){if(s=e.CameraInputTypes[r]){var n=i[r],o=e.SerializationHelper.Parse(function(){return new s},n,null);this.add(o)}}else for(var r in this.attached){var s;if(s=e.CameraInputTypes[this.attached[r].getClassName()]){o=e.SerializationHelper.Parse(function(){return new s},t,null);this.remove(this.attached[r]),this.add(o)}}},t}();e.CameraInputsManager=t}(a||(a={})),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._transformedReferencePoint=e.Vector3.Zero(),s._globalCurrentTarget=e.Vector3.Zero(),s._globalCurrentUpVector=e.Vector3.Zero(),s._defaultUp=e.Vector3.Up(),s._cachedRotationZ=0,s._cachedQuaternionRotationZ=0,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(),this.position.z===t.z&&(this.position.z+=e.Epsilon),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUp,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)},i.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return e.Vector3.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},i.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!=this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},i.prototype._computeViewMatrix=function(t,i,r){if(this.parent){var n=this.parent.getWorldMatrix();e.Vector3.TransformCoordinatesToRef(t,n,this._globalPosition),e.Vector3.TransformCoordinatesToRef(i,n,this._globalCurrentTarget),e.Vector3.TransformNormalToRef(r,n,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(t),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}(a||(a={})),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 c=a.clientX-r.previousPosition.x;r.camera.getScene().useRightHandedSystem&&(c*=-1),r.camera.parent&&r.camera.parent._getWorldMatrixDeterminant()<0&&(c*=-1),r.camera.cameraRotation.y+=c/r.angularSensibility;var u=a.clientY-r.previousPosition.y;r.camera.cameraRotation.x+=u/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}(a||(a={})),function(e){var t=function(){function t(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}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,o=t.event;t.type===e.KeyboardEventTypes.KEYDOWN?-1===r.keysUp.indexOf(o.keyCode)&&-1===r.keysDown.indexOf(o.keyCode)&&-1===r.keysLeft.indexOf(o.keyCode)&&-1===r.keysRight.indexOf(o.keyCode)||(-1===(n=r._keys.indexOf(o.keyCode))&&r._keys.push(o.keyCode),i||o.preventDefault()):-1===r.keysUp.indexOf(o.keyCode)&&-1===r.keysDown.indexOf(o.keyCode)&&-1===r.keysLeft.indexOf(o.keyCode)&&-1===r.keysRight.indexOf(o.keyCode)||((n=r._keys.indexOf(o.keyCode))>=0&&r._keys.splice(n,1),i||o.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}(a||(a={})),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.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}(a||(a={})),function(e){e.Node.AddNodeConstructor("FreeCamera",function(t,i){return function(){return new e.UniversalCamera(t,e.Vector3.Zero(),i)}});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){(this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset),this._collider||(this._collider=new e.Collider),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=t;this.applyGravity&&(i=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,i,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}(a||(a={})),function(e){var t=function(){function t(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return 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,o=t.event;t.type===e.KeyboardEventTypes.KEYDOWN?(r._ctrlPressed=o.ctrlKey,r._altPressed=o.altKey,(-1!==r.keysUp.indexOf(o.keyCode)||-1!==r.keysDown.indexOf(o.keyCode)||-1!==r.keysLeft.indexOf(o.keyCode)||-1!==r.keysRight.indexOf(o.keyCode)||-1!==r.keysReset.indexOf(o.keyCode))&&(-1===(n=r._keys.indexOf(o.keyCode))&&r._keys.push(o.keyCode),o.preventDefault&&(i||o.preventDefault()))):-1===r.keysUp.indexOf(o.keyCode)&&-1===r.keysDown.indexOf(o.keyCode)&&-1===r.keysLeft.indexOf(o.keyCode)&&-1===r.keysRight.indexOf(o.keyCode)&&-1===r.keysReset.indexOf(o.keyCode)||((n=r._keys.indexOf(o.keyCode))>=0&&r._keys.splice(n,1),o.preventDefault&&(i||o.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-=this.angularSpeed:-1!==this.keysUp.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:-1!==this.keysDown.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:-1!==this.keysReset.indexOf(i)&&e.useInputToRestoreState&&e.restoreState()}},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),n([e.serialize()],t.prototype,"angularSpeed",void 0),t}();e.ArcRotateCameraKeyboardMoveInput=t,e.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=t}(a||(a={})),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}(a||(a={})),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.pinchInwards=!0,this._isPanClick=!1}return t.prototype.attachControl=function(t,i){var r,n=this,o=this.camera.getEngine(),s=null,a=null,l=0,c=0,u=0,h={x:0,y:0,isPaning:!1,isPinching:!1};this._pointerInput=function(d,f){var p=d.event,m="touch"===d.event.pointerType;if(!o.isInVRExclusivePointerMode&&(d.type===e.PointerEventTypes.POINTERMOVE||-1!==n.buttons.indexOf(p.button))){var g=p.srcElement||p.target;if(d.type===e.PointerEventTypes.POINTERDOWN&&g){try{g.setPointerCapture(p.pointerId)}catch(e){}n._isPanClick=p.button===n.camera._panningMouseButton,r={x:p.clientX,y:p.clientY,pointerId:p.pointerId,type:p.pointerType},null===s?s=r:null===a&&(a=r),i||(p.preventDefault(),t.focus())}else if(d.type===e.PointerEventTypes.POINTERDOUBLETAP)n.camera.useInputToRestoreState&&n.camera.restoreState();else if(d.type===e.PointerEventTypes.POINTERUP&&g){try{g.releasePointerCapture(p.pointerId)}catch(e){}r=null,l=0,h.isPaning=!1,h.isPinching=!1,u=0,c=0,m||(a=null),o._badOS?s=a=null:a&&s&&s.pointerId==p.pointerId?(s=a,a=null,r={x:s.x,y:s.y,pointerId:s.pointerId,type:p.pointerType}):s&&a&&a.pointerId==p.pointerId?(a=null,r={x:s.x,y:s.y,pointerId:s.pointerId,type:p.pointerType}):s=a=null,i||p.preventDefault()}else if(d.type===e.PointerEventTypes.POINTERMOVE)if(i||p.preventDefault(),s&&null===a&&r){if(0!==n.panningSensibility&&(p.ctrlKey&&n.camera._useCtrlForPanning||n._isPanClick))n.camera.inertialPanningX+=-(p.clientX-r.x)/n.panningSensibility,n.camera.inertialPanningY+=(p.clientY-r.y)/n.panningSensibility;else{var _=p.clientX-r.x,v=p.clientY-r.y;n.camera.inertialAlphaOffset-=_/n.angularSensibilityX,n.camera.inertialBetaOffset-=v/n.angularSensibilityY}r.x=p.clientX,r.y=p.clientY}else if(s&&a){var A=s.pointerId===p.pointerId?s:a;A.x=p.clientX,A.y=p.clientY;var y=n.pinchInwards?1:-1,b=s.x-a.x,T=s.y-a.y,E=b*b+T*T,x=Math.sqrt(E);if(0===l)return c=x,l=E,h.x=(s.x+a.x)/2,void(h.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)*y),0!==n.panningSensibility){var P=(s.x+a.x)/2,M=(s.y+a.y)/2,S=P-h.x,C=M-h.y;h.x=P,h.y=M,n.camera.inertialPanningX+=-S/n.panningSensibility,n.camera.inertialPanningY+=C/n.panningSensibility}}else{if(u++,h.isPinching||u<20&&Math.abs(x-c)>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)*y),h.isPaning=!1,h.isPinching=!0;else if(r&&r.pointerId===A.pointerId&&0!==n.panningSensibility&&n.multiTouchPanning){if(!h.isPaning)return h.isPaning=!0,h.isPinching=!1,h.x=A.x,void(h.y=A.y);n.camera.inertialPanningX+=-(A.x-h.x)/n.panningSensibility,n.camera.inertialPanningY+=(A.y-h.y)/n.panningSensibility}r&&r.pointerId===p.pointerId&&(h.x=A.x,h.y=A.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,h.isPaning=!1,h.isPinching=!1,u=0,r=null,c=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}(a||(a={})),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.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i}(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("ArcRotateCamera",function(i,r){return function(){return new t(i,0,0,1,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n,o,s,a,l){void 0===l&&(l=!0);var c=t.call(this,i,e.Vector3.Zero(),a,l)||this;return c.inertialAlphaOffset=0,c.inertialBetaOffset=0,c.inertialRadiusOffset=0,c.lowerAlphaLimit=null,c.upperAlphaLimit=null,c.lowerBetaLimit=.01,c.upperBetaLimit=Math.PI,c.lowerRadiusLimit=null,c.upperRadiusLimit=null,c.inertialPanningX=0,c.inertialPanningY=0,c.pinchToPanMaxDistance=20,c.panningDistanceLimit=null,c.panningOriginTarget=e.Vector3.Zero(),c.panningInertia=.9,c.zoomOnFactor=1,c.targetScreenOffset=e.Vector2.Zero(),c.allowUpsideDown=!0,c.useInputToRestoreState=!0,c._viewMatrix=new e.Matrix,c.panningAxis=new e.Vector3(1,1,0),c.onMeshTargetChangedObservable=new e.Observable,c.checkCollisions=!1,c.collisionRadius=new e.Vector3(.5,.5,.5),c._previousPosition=e.Vector3.Zero(),c._collisionVelocity=e.Vector3.Zero(),c._newPosition=e.Vector3.Zero(),c._computationVector=e.Vector3.Zero(),c._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),c.getScene().workerCollisions&&c.checkCollisions&&t.multiplyInPlace(c._collider._radius),i?(c.setPosition(t),c.onCollide&&c.onCollide(i)):c._previousPosition.copyFrom(c.position);var r=Math.cos(c.alpha),n=Math.sin(c.alpha),o=Math.cos(c.beta),s=Math.sin(c.beta);0===s&&(s=1e-4);var a=c._getTargetPosition();c._computationVector.copyFromFloats(c.radius*r*s,c.radius*o,c.radius*n*s),a.addToRef(c._computationVector,c._newPosition),c.position.copyFrom(c._newPosition);var l=c.upVector;c.allowUpsideDown&&c.beta<0&&(l=(l=l.clone()).negate()),c._computeViewMatrix(c.position,a,l),c._viewMatrix.m[12]+=c.targetScreenOffset.x,c._viewMatrix.m[13]+=c.targetScreenOffset.y,c._collisionTriggered=!1},c._target=e.Vector3.Zero(),s&&c.setTarget(s),c.alpha=r,c.beta=n,c.radius=o,c.getViewMatrix(),c.inputs=new e.ArcRotateCameraInputsManager(c),c.inputs.addKeyboard().addMouseWheel().addPointers(),c}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),e.Vector3.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*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),null!==this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),null!==this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},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=s.clone()).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){var r,n;if(void 0===i&&(i=!1),void 0===t.min){var o=t||this.getScene().meshes;r=e.Mesh.MinMax(o),n=e.Vector3.Distance(r.min,r.max)}else{r=t,n=t.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,"targetScreenOffset",void 0),n([e.serialize()],i.prototype,"allowUpsideDown",void 0),n([e.serialize()],i.prototype,"useInputToRestoreState",void 0),i}(e.TargetCamera);e.ArcRotateCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("Light_Type_3",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});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.computeWorldMatrix=function(t,i){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},i.prototype.prepareLightSpecificDefines=function(e,t){e["HEMILIGHT"+t]=!0},n([e.serializeAsColor3()],i.prototype,"groundColor",void 0),n([e.serializeAsVector3()],i.prototype,"direction",void 0),i}(e.Light);e.HemisphericLight=t}(a||(a={})),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._initCache=function(){t.prototype._initCache.call(this),this._cache.position=e.Vector3.Zero()},i.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},i.prototype.computeWorldMatrix=function(t){return!t&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminant=this._worldMatrix.determinant(),this._worldMatrix)},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}(a||(a={})),function(e){e.Node.AddNodeConstructor("Light_Type_0",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});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("vLightFalloff",4),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._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this},i.prototype.prepareLightSpecificDefines=function(e,t){e["POINTLIGHT"+t]=!0},n([e.serialize()],i.prototype,"shadowAngle",null),i}(e.ShadowLight);e.PointLight=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("Light_Type_1",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});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().boundingBox,c=0;c<l.vectorsWorld.length;c++)e.Vector3.TransformCoordinatesToRef(l.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,h=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ: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},i.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},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}(a||(a={})),function(e){e.Node.AddNodeConstructor("Light_Type_2",function(i,r){return function(){return new t(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)}});var t=function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,a)||this;return l._innerAngle=0,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._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},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("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},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,this._cosHalfAngle,i),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,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()},i.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!!this.projectionTexture},n([e.serialize()],i.prototype,"angle",null),n([e.serialize()],i.prototype,"innerAngle",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}(a||(a={})),function(e){var t=function(){return function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=e.Animation.ANIMATIONLOOPMODE_CYCLE}}();e.AnimationPropertiesOverride=t}(a||(a={})),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.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}();e.AnimationEvent=i;var r,n=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=n,function(e){e[e.STEP=1]="STEP"}(r=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,c){var u=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?u=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?u=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?u=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?u=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?u=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(u=i.ANIMATIONTYPE_SIZE),void 0==u)return null;var h=new i(t,r,n,u,l),d=[{frame:0,value:s},{frame:o,value:a}];return h.setKeys(d),void 0!==c&&h.setEasingFunction(c),h},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,c,u){var h=i._PrepareAnimation(e,r,n,o,s,a,l,c);return h?t.getScene().beginDirectAnimation(t,[h],0,o,1===h.loopMode,1,u):null},i.CreateAndStartHierarchyAnimation=function(e,t,r,n,o,s,a,l,c,u,h){var d=i._PrepareAnimation(e,n,o,s,a,l,c,u);return d?t.getScene().beginDirectHierarchyAnimation(t,r,[d],0,s,1===d.loopMode,1,h):null},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,l,c,u){var h=i._PrepareAnimation(e,r,n,o,s,a,l,c);return h?(t.animations.push(h),t.getScene().beginAnimation(t,0,o,1===h.loopMode,1,u)):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 c=r.beginAnimation(i,0,l,!1);return c.onAnimationEnd=a,c},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,n,o,s,a){if(o===i.ANIMATIONLOOPMODE_CONSTANT&&t>0)return a.clone?a.clone():a;var l=this.getKeys(),c=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[c].frame>=e)for(;c-1>=0&&l[c].frame>=e;)c--;for(var u=c;u<l.length;u++){var h=l[u+1];if(h.frame>=e){var d=l[u],f=this._getKeyValue(d.value);if(d.interpolation===r.STEP)return f;var p=this._getKeyValue(h.value),m=void 0!==d.outTangent&&void 0!==h.inTangent,g=h.frame-d.frame,_=(e-d.frame)/g,v=this.getEasingFunction();switch(null!=v&&(_=v.ease(_)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var A=m?this.floatInterpolateFunctionWithTangents(f,d.outTangent*g,p,h.inTangent*g,_):this.floatInterpolateFunction(f,p,_);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return A;case i.ANIMATIONLOOPMODE_RELATIVE:return s*t+A}break;case i.ANIMATIONTYPE_QUATERNION:var y=m?this.quaternionInterpolateFunctionWithTangents(f,d.outTangent.scale(g),p,h.inTangent.scale(g),_):this.quaternionInterpolateFunction(f,p,_);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return y;case i.ANIMATIONLOOPMODE_RELATIVE:return y.addInPlace(s.scale(t))}return y;case i.ANIMATIONTYPE_VECTOR3:var b=m?this.vector3InterpolateFunctionWithTangents(f,d.outTangent.scale(g),p,h.inTangent.scale(g),_):this.vector3InterpolateFunction(f,p,_);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return b;case i.ANIMATIONLOOPMODE_RELATIVE:return b.add(s.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var T=m?this.vector2InterpolateFunctionWithTangents(f,d.outTangent.scale(g),p,h.inTangent.scale(g),_):this.vector2InterpolateFunction(f,p,_);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(f,p,_);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(f,p,_).add(s.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(f,p,_);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(f,p,_).add(s.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(i.AllowMatricesInterpolation)return this.matrixInterpolateFunction(f,p,_,n);case i.ANIMATIONLOOPMODE_RELATIVE:return f}}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)for(var t in e._ranges={},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)}for(var a in e.ranges=[],this._ranges){var l=this._ranges[a];if(l){var c={};c.name=a,c.from=l.from,c.to=l.to,e.ranges.push(c)}}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,c,u=t.keys[n];switch(s){case i.ANIMATIONTYPE_FLOAT:r=u.values[0],u.values.length>=1&&(l=u.values[1]),u.values.length>=2&&(c=u.values[2]);break;case i.ANIMATIONTYPE_QUATERNION:if(r=e.Quaternion.FromArray(u.values),u.values.length>=8){var h=e.Quaternion.FromArray(u.values.slice(4,8));h.equals(e.Quaternion.Zero())||(l=h)}if(u.values.length>=12){var d=e.Quaternion.FromArray(u.values.slice(8,12));d.equals(e.Quaternion.Zero())||(c=d)}break;case i.ANIMATIONTYPE_MATRIX:r=e.Matrix.FromArray(u.values);break;case i.ANIMATIONTYPE_COLOR3:r=e.Color3.FromArray(u.values);break;case i.ANIMATIONTYPE_VECTOR3:default:r=e.Vector3.FromArray(u.values)}var f={};f.frame=u.frame,f.value=r,void 0!=l&&(f.inTangent=l),void 0!=c&&(f.outTangent=c),a.push(f)}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}(a||(a={})),function(e){var t=function(){return function(){}}();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.onAnimationGroupEndObservable=new e.Observable,this.onAnimationGroupPauseObservable=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].animation.getKeys(),n=r[0],o=r[r.length-1];if(n.frame>e){var s={frame:e,value:n.value,inTangent:n.inTangent,outTangent:n.outTangent,interpolation:n.interpolation};r.splice(0,0,s)}if(o.frame<t){s={frame:t,value:o.value,inTangent:o.outTangent,outTangent:o.outTangent,interpolation:o.interpolation};r.push(s)}}return this._from=e,this._to=t,this},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=function(o){var a=s._scene.beginDirectAnimation(o.target,[o.animation],void 0!==i?i:s._from,void 0!==r?r:s._to,e,t);a.onAnimationEnd=function(){n.onAnimationEndObservable.notifyObservers(o),n._checkAnimationGroupEnded(a)},s._animatables.push(a)},s=this,a=0,l=this._targetedAnimations;a<l.length;a++){o(l[a])}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.onAnimationGroupPauseObservable.notifyObservers(this),this},t.prototype.play=function(e){if(this.isStarted&&this._animatables.length===this._targetedAnimations.length){if(void 0!==e)for(var t=0;t<this._animatables.length;t++){this._animatables[t].loopAnimation=e}this.restart()}else this.stop(),this.start(e,this._speedRatio);return this},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=this._animatables.slice(),t=0;t<e.length;t++)e[t].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.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},t.Parse=function(t,i){for(var r=new e.AnimationGroup(t.name,i),n=0;n<t.targetedAnimations.length;n++){var o=t.targetedAnimations[n],s=e.Animation.Parse(o.animation),a=o.targetId,l=i.getNodeByID(a);null!=l&&r.addTargetedAnimation(s,l)}return null!==t.from&&null!==t.from&&r.normalize(t.from,t.to),r},t.prototype.getClassName=function(){return"AnimationGroup"},t.prototype.toString=function(e){var t="Name: "+this.name;return t+=", type: "+this.getClassName(),e&&(t+=", from: "+this._from,t+=", to: "+this._to,t+=", isStarted: "+this._isStarted,t+=", speedRatio: "+this._speedRatio,t+=", targetedAnimations length: "+this._targetedAnimations.length,t+=", animatables length: "+this._animatables),t},t}();e.AnimationGroup=i}(a||(a={})),function(e){var t=Object.freeze(new e.Quaternion(0,0,0,0)),i=Object.freeze(e.Vector3.Zero()),r=Object.freeze(e.Vector2.Zero()),n=Object.freeze(e.Size.Zero()),o=Object.freeze(e.Color3.Black()),s=function(){function s(e,t,i,r){var n=this;this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._targetPath="",this._weight=1,this._ratioOffset=0,this._previousDelay=0,this._previousRatio=0,this._animation=t,this._target=e,this._scene=i,this._host=r,t._runtimeAnimations.push(this);var o=t.getEvents();o&&o.length>0&&o.forEach(function(e){n._events.push(e._clone())})}return Object.defineProperty(s.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"target",{get:function(){return this._activeTarget},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),s.prototype.reset=function(e){if(void 0===e&&(e=!1),e)if(this._target instanceof Array)for(var t=0,i=0,r=this._target;i<r.length;i++){var n=r[i];void 0!==this._originalValue[t]&&this._setValue(n,this._originalValue[t],-1),t++}else void 0!==this._originalValue[0]&&this._setValue(this._target,this._originalValue[0],-1);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0,this._originalValue=new Array;for(t=0;t<this._events.length;t++)this._events[t].isDone=!1},s.prototype.isStopped=function(){return this._stopped},s.prototype.dispose=function(){var e=this._animation.runtimeAnimations.indexOf(this);e>-1&&this._animation.runtimeAnimations.splice(e,1)},s.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)},s.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)},s.prototype._setValue=function(t,i,r,n){var o,s;void 0===n&&(n=0);var a=this._animation.targetPropertyPath;if(a.length>1){for(var l=t[a[0]],c=1;c<a.length-1;c++)l=l[a[c]];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 u=void 0;(u=s.getRestPose&&"_matrix"===o?s.getRestPose():s[o])&&u.clone?this._originalValue[n]=u.clone():this._originalValue[n]=u}if((t&&t.animationPropertiesOverride?t.animationPropertiesOverride.enableBlending:this._animation.enableBlending)&&this._blendingFactor<=1){if(!this._originalBlendValue)(u=s[o]).clone?this._originalBlendValue=u.clone():this._originalBlendValue=u;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 h=t&&t.animationPropertiesOverride?t.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=h}else this._currentValue=i;-1!==r?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[n]):s[o]=this._currentValue,t.markAsDirty&&t.markAsDirty(this._animation.targetProperty)},s.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},s.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)},s.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},s.prototype.animate=function(s,a,l,c,u,h){void 0===h&&(h=-1);var d=this._animation.targetPropertyPath;if(!d||d.length<1)return this._stopped=!0,!1;var f=!0,p=this._animation.getKeys();if(0!==p[0].frame){var m={frame:0,value:p[0].value};p.splice(0,0,m)}else if(1===p.length){m={frame:.001,value:p[0].value};p.push(m)}(a<p[0].frame||a>p[p.length-1].frame)&&(a=p[0].frame),(l<p[0].frame||l>p[p.length-1].frame)&&(l=p[p.length-1].frame),a===l&&(a>p[0].frame?a--:l<p[p.length-1].frame&&l++);var g,_=l-a,v=s*(this._animation.framePerSecond*u)/1e3+this._ratioOffset,A=0;if(this._previousDelay=s,this._previousRatio=v,(l>a&&v>=_||a>l&&v<=_)&&!c)f=!1,A=this._animation._getKeyValue(p[p.length-1].value);else if(this._getCorrectLoopMode()!==e.Animation.ANIMATIONLOOPMODE_CYCLE){var y=l.toString()+a.toString();if(!this._offsetsCache[y]){var b=this._interpolate(a,0,e.Animation.ANIMATIONLOOPMODE_CYCLE),T=this._interpolate(l,0,e.Animation.ANIMATIONLOOPMODE_CYCLE);switch(this._animation.dataType){case e.Animation.ANIMATIONTYPE_FLOAT:this._offsetsCache[y]=T-b;break;case e.Animation.ANIMATIONTYPE_QUATERNION:this._offsetsCache[y]=T.subtract(b);break;case e.Animation.ANIMATIONTYPE_VECTOR3:this._offsetsCache[y]=T.subtract(b);case e.Animation.ANIMATIONTYPE_VECTOR2:this._offsetsCache[y]=T.subtract(b);case e.Animation.ANIMATIONTYPE_SIZE:this._offsetsCache[y]=T.subtract(b);case e.Animation.ANIMATIONTYPE_COLOR3:this._offsetsCache[y]=T.subtract(b)}this._highLimitsCache[y]=T}A=this._highLimitsCache[y],g=this._offsetsCache[y]}if(void 0===g)switch(this._animation.dataType){case e.Animation.ANIMATIONTYPE_FLOAT:g=0;break;case e.Animation.ANIMATIONTYPE_QUATERNION:g=t;break;case e.Animation.ANIMATIONTYPE_VECTOR3:g=i;break;case e.Animation.ANIMATIONTYPE_VECTOR2:g=r;break;case e.Animation.ANIMATIONTYPE_SIZE:g=n;break;case e.Animation.ANIMATIONTYPE_COLOR3:g=o}var E=v/_>>0,x=f?a+v%_:l;if(this._host&&this._host.syncRoot){var P=this._host.syncRoot;x=a+(l-a)*((P.masterFrame-P.fromFrame)/(P.toFrame-P.fromFrame))}var M=this._events;if(_>0&&this.currentFrame>x||_<0&&this.currentFrame<x)for(var S=0;S<M.length;S++)M[S].onlyOnce||(M[S].isDone=!1);var C=this._interpolate(x,E,this._getCorrectLoopMode(),g,A);this.setValue(C,h);for(S=0;S<M.length;S++)if(_>0&&x>=M[S].frame&&M[S].frame>=a||_<0&&x<=M[S].frame&&M[S].frame<=a){var R=M[S];R.isDone||(R.onlyOnce&&(M.splice(S,1),S--),R.isDone=!0,R.action(x))}return f||(this._stopped=!0),f},s}();e.RuntimeAnimation=s}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o,s,a,l){void 0===r&&(r=0),void 0===n&&(n=100),void 0===o&&(o=!1),void 0===s&&(s=1),this.target=i,this.fromFrame=r,this.toFrame=n,this.loopAnimation=o,this.onAnimationEnd=a,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new e.Observable,this._scene=t,l&&this.appendAnimations(i,l),this._speedRatio=s,t._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){this._weight=-1!==e?Math.min(Math.max(e,0),1):-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=1e3*(e-t[0].currentFrame)/(i*this.speedRatio);null===this._localDelayOffset&&(this._localDelayOffset=0),this._localDelayOffset-=r}for(var n=0;n<t.length;n++)t[n].goToFrame(e)},t.prototype.pause=function(){this._paused||(this._paused=!0)},t.prototype.restart=function(){this._paused=!1},t.prototype._raiseOnAnimationEnd=function(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)},t.prototype.stop=function(e,t){if(e||t){var i=this._scene._activeAnimatables.indexOf(this);if(i>-1){for(var r=(o=this._runtimeAnimations).length-1;r>=0;r--){var n=o[r];e&&n.animation.name!=e||(t&&!t(n.target)||(n.dispose(),o.splice(r,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if((r=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(r,1);var o=this._runtimeAnimations;for(r=0;r<o.length;r++)o[r].dispose();this._raiseOnAnimationEnd()}}},t.prototype.waitAsync=function(){var e=this;return new Promise(function(t,i){e.onAnimationEndObservable.add(function(){t(e)},void 0,void 0,e,!0)})},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].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);i=i||n}if(this.animationStarted=i,!i){if(this.disposeOnEnd)for(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1),t=0;t<r.length;t++)r[t].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationEndObservable.clear())}return i},t}();e.Animatable=t}(a||(a={})),function(e){var t=function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}();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),c=l+1,u=(1-Math.pow(i,l))/(n*o),h=.5*(u+(1-Math.pow(i,c))/(n*o)),d=e-h,f=h-u;return-Math.pow(1/i,t-l)/(f*f)*(d-f)*(d+f)},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 c=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=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},t}(t);e.QuadraticEase=u;var h=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=h;var d=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=d;var f=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=f;var p=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=p}(a||(a={})),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}(a||(a={})),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):t.trigger?this.trigger=t.trigger: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}(a||(a={})),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 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.hasSpecificTriggers2=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(e==r.trigger||t==r.trigger)return!0}return!1},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))if(parseInt(i)===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&&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,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];var c=new Array;for(l=0;l<a.length;l++)c.push(parseFloat(a[l]));return r instanceof e.Vector3?e.Vector3.FromArray(c):r instanceof e.Vector4?e.Vector4.FromArray(c):r instanceof e.Color3?e.Color3.FromArray(c):r instanceof e.Color4?e.Color4.FromArray(c):parseFloat(a[0])},a=function(i,r,l,c,u){if(void 0===u&&(u=null),!i.detached){var h=new Array,d=null,f=null,p=i.combine&&i.combine.length>0;if(2===i.type?h.push(o):h.push(r),p){for(var m=new Array,g=0;g<i.combine.length;g++)a(i.combine[g],t.NothingTrigger,l,c,m);h.push(m)}else for(var _=0;_<i.properties.length;_++){var v=i.properties[_].value,A=i.properties[_].name,y=i.properties[_].targetType;"target"===A?v=d=null!==y&&"SceneProperties"===y?n:n.getNodeByName(v):"parent"===A?v=n.getNodeByName(v):"sound"===A?n.getSoundByName&&(v=n.getSoundByName(v)):"propertyPath"!==A?v=2===i.type&&"operator"===A?e.ValueCondition[v]:s(0,v,d,"value"===A?f:null):f=v,h.push(v)}if(null===u?h.push(l):h.push(null),"InterpolateValueAction"===i.name){var b=h[h.length-2];h[h.length-1]=b,h[h.length-2]=l}var T=function(t,i){var r=Object.create(e.Tools.Instantiate("BABYLON."+t).prototype);return r.constructor.apply(r,i),r}(i.name,h);if(T instanceof e.Condition&&null!==l){var E=new e.DoNothingAction(r,l);c?c.then(E):o.registerAction(E),c=E}null===u?T instanceof e.Condition?(l=T,T=c):(l=null,c?c.then(T):o.registerAction(T)):u.push(T);for(_=0;_<i.children.length;_++)a(i.children[_],r,l,T,null)}},l=0;l<i.children.length;l++){var c,u=i.children[l];if(u.properties.length>0){var h=u.properties[0].value,d=null===u.properties[0].targetType?h:n.getMeshByName(h);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:t[u.name],parameter:d}}else c=t[u.name];for(var f=0;f<u.children.length;f++)u.detached||a(u.children[f],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.OnPickOutTrigger=16,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.Triggers={},t}();e.ActionManager=i}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===s&&(s=1e3);var u=t.call(this,i,a)||this;return u.duration=1e3,u.onInterpolationDoneObservable=new e.Observable,u.propertyPath=n,u.value=o,u.duration=s,u.stopOtherAnimations=l,u.onInterpolationDone=c,u._target=u._effectiveTarget=r,u}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);r.beginDirectAnimation(this._effectiveTarget,[o],0,100,!1,1,function(){i.onInterpolationDoneObservable.notifyObservers(i),i.onInterpolationDone&&i.onInterpolationDone()})},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}(a||(a={})),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 c=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=c;var u=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=u;var h=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=h}(a||(a={})),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={},o._getComponent(e.SceneComponentConstants.NAME_SPRITE)||o._addComponent(new e.SpriteSceneComponent(o)),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=[],c=0,u=0;u<r;u++)l.push(c),l.push(c+1),l.push(c+2),l.push(c),l.push(c+2),l.push(c+3),c+=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 h=this._buffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,4),d=this._buffer.createVertexBuffer("options",4,4),f=this._buffer.createVertexBuffer("cellInfo",8,4),p=this._buffer.createVertexBuffer(e.VertexBuffer.ColorKind,12,4);this._vertexBuffers[e.VertexBuffer.PositionKind]=h,this._vertexBuffers.options=d,this._vertexBuffers.cellInfo=f,this._vertexBuffers[e.VertexBuffer.ColorKind]=p,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,c=null,u=e.Vector3.Zero(),h=i.getViewMatrix(),d=0;d<o;d++){var f=this.sprites[d];if(f){if(r){if(!r(f))continue}else if(!f.isPickable)continue;if(e.Vector3.TransformCoordinatesToRef(f.position,h,u),s.copyFromFloats(u.x-f.width/2,u.y-f.height/2,u.z),a.copyFromFloats(u.x+f.width/2,u.y+f.height/2,u.z),t.intersectsBoxMinMax(s,a)){var p=e.Vector3.Distance(u,t.origin);if(l>p&&(l=p,c=f,n))break}}}if(c){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=c,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.isVisible&&(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 c=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c=this._effectFog),t.enableEffect(c);var u=this._scene.getViewMatrix();c.setTexture("diffuseSampler",this._spriteTexture),c.setMatrix("view",u),c.setMatrix("projection",this._scene.getProjectionMatrix()),c.setFloat2("textureInfos",this.cellWidth/i.width,this.cellHeight/i.height),this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),c.setColor3("vFogColor",this._scene.fogColor)),t.bindBuffers(this._vertexBuffers,this._indexBuffer,c),t.setDepthFunctionToLessOrEqual(),c.setBool("alphaTest",!0),t.setColorWrite(!1),t.drawElementsType(e.Material.TriangleFillMode,0,s/4*6),t.setColorWrite(!0),c.setBool("alphaTest",!1),t.setAlphaMode(e.Engine.ALPHA_COMBINE),t.drawElementsType(e.Material.TriangleFillMode,0,s/4*6),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}(a||(a={})),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.isVisible=!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}(a||(a={})),function(e){e.Scene.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},e.Scene.prototype.pickSprite=function(e,t,i,r,n){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,n),this._internalPickSprites(this._tempSpritePickingRay,i,r,n)},e.Scene.prototype.pickSpriteWithRay=function(t,i,r,n){if(!this._tempSpritePickingRay)return null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}return e.Ray.TransformToRef(t,n.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,i,r,n)},e.Scene.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)))},e.Scene.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_SPRITE,this.scene=t,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=e.Ray?e.Ray.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new e.Observable,this.scene.onAfterSpritesRenderingObservable=new e.Observable,this._spritePredicate=function(e){return!!e.actionManager&&(e.isPickable&&e.actionManager.hasPointerTriggers)}}return t.prototype.register=function(){this.scene._pointerMoveStage.registerStep(e.SceneComponentConstants.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(e.SceneComponentConstants.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(e.SceneComponentConstants.STEP_POINTERUP_SPRITE,this,this._pointerUp)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();for(var e=this.scene.spriteManagers;e.length;)e[0].dispose()},t.prototype._pickSpriteButKeepRay=function(e,t,i,r,n){var o=this.scene.pickSprite(t,i,this._spritePredicate,r,n);return o&&(o.ray=e?e.ray:null),o},t.prototype._pointerMove=function(e,t,i,r,n){var o=this.scene;return r?o.setPointerOverSprite(null):(i=this._pickSpriteButKeepRay(i,e,t,!1,o.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite?(o.setPointerOverSprite(i.pickedSprite),o._pointerOverSprite&&o._pointerOverSprite.actionManager&&o._pointerOverSprite.actionManager.hoverCursor?n.style.cursor=o._pointerOverSprite.actionManager.hoverCursor:n.style.cursor=o.hoverCursor):o.setPointerOverSprite(null),i},t.prototype._pointerDown=function(t,i,r,n){var o=this.scene;if(o._pickedDownSprite=null,o.spriteManagers.length>0&&(r=o.pickSprite(t,i,this._spritePredicate,!1,o.cameraToUseForPointers||void 0))&&r.hit&&r.pickedSprite&&r.pickedSprite.actionManager){switch(o._pickedDownSprite=r.pickedSprite,n.button){case 0:r.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(r.pickedSprite,o,n));break;case 1:r.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(r.pickedSprite,o,n));break;case 2:r.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(r.pickedSprite,o,n))}r.pickedSprite.actionManager&&r.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(r.pickedSprite,o,n))}return r},t.prototype._pointerUp=function(t,i,r,n){var o=this.scene;if(o.spriteManagers.length>0){var s=o.pickSprite(t,i,this._spritePredicate,!1,o.cameraToUseForPointers||void 0);s&&(s.hit&&s.pickedSprite&&s.pickedSprite.actionManager&&(s.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(s.pickedSprite,o,n)),s.pickedSprite.actionManager&&(this.scene._isPointerSwiping()||s.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(s.pickedSprite,o,n)))),o._pickedDownSprite&&o._pickedDownSprite.actionManager&&o._pickedDownSprite!==s.pickedSprite&&o._pickedDownSprite.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNewFromSprite(o._pickedDownSprite,o,n)))}return r},t}();e.SpriteSceneComponent=t}(a||(a={})),function(e){var t=function(){return function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}();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,this.originMesh=null,this.ray=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,n=this.pickedMesh.getIndices();if(!n)return null;if(i){var o=this.pickedMesh.getVerticesData(e.VertexBuffer.NormalKind),s=e.Vector3.FromArray(o,3*n[3*this.faceId]),a=e.Vector3.FromArray(o,3*n[3*this.faceId+1]),l=e.Vector3.FromArray(o,3*n[3*this.faceId+2]);s=s.scale(this.bu),a=a.scale(this.bv),l=l.scale(1-this.bu-this.bv),r=new e.Vector3(s.x+a.x+l.x,s.y+a.y+l.y,s.z+a.z+l.z)}else{var c=this.pickedMesh.getVerticesData(e.VertexBuffer.PositionKind),u=e.Vector3.FromArray(c,3*n[3*this.faceId]),h=e.Vector3.FromArray(c,3*n[3*this.faceId+1]),d=e.Vector3.FromArray(c,3*n[3*this.faceId+2]),f=u.subtract(h),p=d.subtract(h);r=e.Vector3.Cross(f,p)}if(t){var m=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(e.Tmp.Matrix[0].copyFrom(m),(m=e.Tmp.Matrix[0]).setTranslationFromFloats(0,0,0),m.invert(),m.transposeToRef(e.Tmp.Matrix[1]),m=e.Tmp.Matrix[1]),r=e.Vector3.TransformNormal(r,m)}return r.normalize(),r},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}(a||(a={})),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)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,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)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,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)===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),(s=Math.max(r,s))>(a=Math.min(n,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)<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,c=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),u=r.subtract(i),h=c.subtract(this.origin),d=i.subtract(this.origin),f=e.Vector3.Dot(u,u),p=e.Vector3.Dot(u,h),m=e.Vector3.Dot(h,h),g=e.Vector3.Dot(u,d),_=e.Vector3.Dot(h,d),v=f*m-p*p,A=v,y=v;v<t.smallnum?(s=0,A=1,l=_,y=m):(l=f*_-p*g,(s=p*_-m*g)<0?(s=0,l=_,y=m):s>A&&(s=A,l=_+p,y=m)),l<0?(l=0,-g<0?s=0:-g>f?s=A:(s=-g,A=f)):l>y&&(l=y,-g+p<0?s=0:-g+p>f?s=A:(s=-g+p,A=f)),o=Math.abs(s)<t.smallnum?0:s/A,a=Math.abs(l)<t.smallnum?0:l/y;var b=h.multiplyByFloats(a,a,a),T=d.add(u.multiplyByFloats(o,o,o)).subtract(b);return a>0&&a<=this.length&&T.lengthSquared()<n*n?b.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}(a||(a={})),function(e){var t=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 c=l;l=a,a=c}return a>0&&a<n?(e.root=a,e.found=!0,e):l>0&&l<n?(e.root=l,e.found=!0,e):e}}(),i=function(){function i(){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(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,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!0,configurable:!0}),i.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},i.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))},i.prototype._canDoCollision=function(t,i,r,n){var o=e.Vector3.Distance(this._basePointWorld,t),s=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(o>this._velocityWorldLength+s+i)&&!!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)}(r,n,this._basePointWorld,this._velocityWorldLength+s)},i.prototype._testTriangle=function(i,r,n,o,s,a){var l,c=!1;r||(r=[]),r[i]||(r[i]=new e.Plane(0,0,0,0),r[i].copyFromPoints(n,o,s));var u=r[i];if(a||u.isFrontFacingTo(this._normalizedVelocity,0)){var h=u.signedDistanceTo(this._basePoint),d=e.Vector3.Dot(u.normal,this._velocity);if(0==d){if(Math.abs(h)>=1)return;c=!0,l=0}else{var f=(1-h)/d;if((l=(-1-h)/d)>f){var p=f;f=l,l=p}if(l>1||f<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,g=1;if(c||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,u.normal)&&(m=!0,g=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var _=this._velocity.lengthSquared(),v=_;this._basePoint.subtractToRef(n,this._tempVector);var A=2*e.Vector3.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,b=t(v,A,y,g);b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(o,this._tempVector),A=2*e.Vector3.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=t(v,A,y,g)).found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(o)),this._basePoint.subtractToRef(s,this._tempVector),A=2*e.Vector3.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=t(v,A,y,g)).found&&(g=b.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),x=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=T*-_+E*E,A=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=t(v,A,y,g)).found){var P=(E*b.root-x)/T;P>=0&&P<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(P),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),x=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-_+E*E,A=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=t(v,A,y,g)).found&&(P=(E*b.root-x)/T)>=0&&P<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(P),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),x=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-_+E*E,A=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=t(v,A,y,g)).found&&(P=(E*b.root-x)/T)>=0&&P<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint))}if(m){var M=g*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)}}},i.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;a<n;a+=3){var l=t[i[a]-o],c=t[i[a+1]-o],u=t[i[a+2]-o];this._testTriangle(a,e,u,c,l,s)}},i.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)},i}();e.Collider=i}(a||(a={})),function(e){var t,i;e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(t=e.WorkerTaskType||(e.WorkerTaskType={})),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)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}else e.Tools.Warn("error returned from worker!")},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={payload:{collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r._radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},taskType:t.COLLIDE};this._worker.postMessage(l)}},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)r=(n=t.geometry)?n.id:null;else if(t instanceof e.InstancedMesh){var n;r=(n=t.sourceMesh&&t.sourceMesh.geometry)?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)o.copyFrom(t);else{var l=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var c=0;c<this._scene.meshes.length;c++){var u=this._scene.meshes[c];u.isEnabled()&&u.checkCollisions&&u.subMeshes&&u!==s&&0!=(l&u.collisionGroup)&&u._checkCollision(r)}r.collisionFound?(0===i.x&&0===i.y&&0===i.z||r._getResponse(t,i),i.length()<=a?o.copyFrom(t):(r._retry++,this._collideWithWorld(t,i,r,n,o,s))):t.addToRef(i,o)}},t}();e.CollisionCoordinatorLegacy=n}(a||(a={})),function(e){var t=function(){function t(i){this.particleSystem=i,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.scale=new e.Vector2(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new e.Color4(0,0,0,0),this._currentColor2=new e.Color4(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=t._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return t.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},t.prototype.updateCellIndex=function(){var t=this.age,i=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===i?(i=1,t=this._randomCellOffset):t+=this._randomCellOffset);var r=this._initialEndSpriteCellID-this._initialStartSpriteCellID,n=e.Scalar.Clamp(t*i%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+n*r|0},t.prototype._inheritParticleInfoToSubEmitter=function(t){if(t.particleSystem.emitter.position){var i=t.particleSystem.emitter;i.position.copyFrom(this.position),t.inheritDirection&&(i.position.subtractToRef(this.direction,e.Tmp.Vector3[0]),i.lookAt(e.Tmp.Vector3[0],0,Math.PI/2))}else{t.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(t.inheritedVelocityAmount/2,e.Tmp.Vector3[0]),t.particleSystem._inheritedVelocityOffset.copyFrom(e.Tmp.Vector3[0])},t.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach(function(t){e._inheritParticleInfoToSubEmitter(t)})},t.prototype._reset=function(){this.age=0,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},t.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&e.remapData.copyFrom(this.remapData),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},t._Count=0,t}();e.Particle=t}(a||(a={})),function(e){var t=function(){function t(t){this.animations=[],this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.noiseStrength=new e.Vector3(10,10,10),this.onAnimationEnd=null,this.blendMode=e.ParticleSystem.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteRandomStartCell=!1,this.translationPivot=new e.Vector2(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.gravity=e.Vector3.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new 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._isSubEmitter=!1,this.billboardMode=e.ParticleSystem.BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new e.ImageProcessingConfigurationDefines,this.id=t,this.name=t}return Object.defineProperty(t.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},t.prototype.getDragGradients=function(){return this._dragGradients},t.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},t.prototype.getColorGradients=function(){return this._colorGradients},t.prototype.getSizeGradients=function(){return this._sizeGradients},t.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},t.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},t.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},t.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},t.prototype.getVelocityGradients=function(){return this._velocityGradients},t.prototype.getStartSizeGradients=function(){return this._startSizeGradients},t.prototype.getEmitRateGradients=function(){return this._emitRateGradients},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,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},t.prototype._reset=function(){},t.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var r=0,n=0,o=t;n<o.length;n++){if(o[n].gradient===e){t.splice(r,1);break}r++}return i&&i.dispose(),this},t.prototype.createPointEmitter=function(t,i){var r=new e.PointParticleEmitter;return r.direction1=t,r.direction2=i,this.particleEmitterType=r,r},t.prototype.createHemisphericEmitter=function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);var r=new e.HemisphericParticleEmitter(t,i);return this.particleEmitterType=r,r},t.prototype.createSphereEmitter=function(t,i){void 0===t&&(t=1),void 0===i&&(i=1);var r=new e.SphereParticleEmitter(t,i);return this.particleEmitterType=r,r},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.createCylinderEmitter=function(t,i,r,n){void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=0);var o=new e.CylinderParticleEmitter(t,i,r,n);return this.particleEmitterType=o,o},t.prototype.createDirectedCylinderEmitter=function(t,i,r,n,o){void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=new e.Vector3(0,1,0)),void 0===o&&(o=new e.Vector3(0,1,0));var s=new e.CylinderDirectedParticleEmitter(t,i,r,n,o);return this.particleEmitterType=s,s},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.BLENDMODE_ONEONE=0,t.BLENDMODE_STANDARD=1,t.BLENDMODE_ADD=2,t.BLENDMODE_MULTIPLY=3,t.BLENDMODE_MULTIPLYADD=4,t}();e.BaseParticleSystem=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a){void 0===o&&(o=null),void 0===s&&(s=!1),void 0===a&&(a=.01);var l=t.call(this,i)||this;return l._inheritedVelocityOffset=new e.Vector3,l.onDisposeObservable=new e.Observable,l._particles=new Array,l._stockParticles=new Array,l._newPartsExcess=0,l._vertexBuffers={},l._scaledColorStep=new e.Color4(0,0,0,0),l._colorDiff=new e.Color4(0,0,0,0),l._scaledDirection=e.Vector3.Zero(),l._scaledGravity=e.Vector3.Zero(),l._currentRenderId=-1,l._useInstancing=!1,l._started=!1,l._stopped=!1,l._actualFrame=0,l._currentEmitRate1=0,l._currentEmitRate2=0,l._currentStartSize1=0,l._currentStartSize2=0,l._rawTextureWidth=256,l._useRampGradients=!1,l._disposeEmitterOnDispose=!1,l.recycleParticle=function(e){var t=l._particles.pop();t!==e&&t.copyTo(e),l._stockParticles.push(t)},l._createParticle=function(){var t;if(0!==l._stockParticles.length?(t=l._stockParticles.pop())._reset():t=new e.Particle(l),l._subEmitters&&l._subEmitters.length>0){var i=l._subEmitters[Math.floor(Math.random()*l._subEmitters.length)];t._attachedSubEmitters=[],i.forEach(function(i){if(i.type===e.SubEmitterType.ATTACHED){var r=i.clone();t._attachedSubEmitters.push(r),r.particleSystem.start()}})}return t},l._emitFromParticle=function(t){if(l._subEmitters&&0!==l._subEmitters.length){var i=Math.floor(Math.random()*l._subEmitters.length);l._subEmitters[i].forEach(function(i){if(i.type===e.SubEmitterType.END){var r=i.clone();t._inheritParticleInfoToSubEmitter(r),r.particleSystem._rootParticleSystem=l,l.activeSubSystems.push(r.particleSystem),r.particleSystem.start()}})}},l._capacity=r,l._epsilon=a,l._isAnimationSheetEnabled=s,l._scene=n||e.Engine.LastCreatedScene,l._attachImageProcessingConfiguration(null),l._customEffect=o,l._scene.particleSystems.push(l),l._useInstancing=l._scene.getEngine().getCaps().instancedArrays,l._createIndexBuffer(),l._createVertexBuffers(),l.particleEmitterType=new e.BoxParticleEmitter,l.updateFunction=function(t){var i=null,r=null;l.noiseTexture&&(i=l.noiseTexture.getSize(),r=l.noiseTexture.getContent());for(var n,o=function(){n=t[s];var o=l._scaledUpdateSpeed,a=n.age;if(n.age+=o,n.age>n.lifeTime){var c=n.age-a;o=(n.lifeTime-a)*o/c,n.age=n.lifeTime}var u=n.age/n.lifeTime;l._colorGradients&&l._colorGradients.length>0?e.Tools.GetCurrentGradient(u,l._colorGradients,function(t,i,r){t!==n._currentColorGradient&&(n._currentColor1.copyFrom(n._currentColor2),i.getColorToRef(n._currentColor2),n._currentColorGradient=t),e.Color4.LerpToRef(n._currentColor1,n._currentColor2,r,n.color)}):(n.colorStep.scaleToRef(o,l._scaledColorStep),n.color.addInPlace(l._scaledColorStep),n.color.a<0&&(n.color.a=0)),l._angularSpeedGradients&&l._angularSpeedGradients.length>0&&e.Tools.GetCurrentGradient(u,l._angularSpeedGradients,function(t,i,r){t!==n._currentAngularSpeedGradient&&(n._currentAngularSpeed1=n._currentAngularSpeed2,n._currentAngularSpeed2=i.getFactor(),n._currentAngularSpeedGradient=t),n.angularSpeed=e.Scalar.Lerp(n._currentAngularSpeed1,n._currentAngularSpeed2,r)}),n.angle+=n.angularSpeed*o;var h=o;if(l._velocityGradients&&l._velocityGradients.length>0&&e.Tools.GetCurrentGradient(u,l._velocityGradients,function(t,i,r){t!==n._currentVelocityGradient&&(n._currentVelocity1=n._currentVelocity2,n._currentVelocity2=i.getFactor(),n._currentVelocityGradient=t),h*=e.Scalar.Lerp(n._currentVelocity1,n._currentVelocity2,r)}),n.direction.scaleToRef(h,l._scaledDirection),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&e.Tools.GetCurrentGradient(u,l._limitVelocityGradients,function(t,i,r){t!==n._currentLimitVelocityGradient&&(n._currentLimitVelocity1=n._currentLimitVelocity2,n._currentLimitVelocity2=i.getFactor(),n._currentLimitVelocityGradient=t);var o=e.Scalar.Lerp(n._currentLimitVelocity1,n._currentLimitVelocity2,r);n.direction.length()>o&&n.direction.scaleInPlace(l.limitVelocityDamping)}),l._dragGradients&&l._dragGradients.length>0&&e.Tools.GetCurrentGradient(u,l._dragGradients,function(t,i,r){t!==n._currentDragGradient&&(n._currentDrag1=n._currentDrag2,n._currentDrag2=i.getFactor(),n._currentDragGradient=t);var o=e.Scalar.Lerp(n._currentDrag1,n._currentDrag2,r);l._scaledDirection.scaleInPlace(1-o)}),n.position.addInPlace(l._scaledDirection),r&&i){var d=l._fetchR(n._randomNoiseCoordinates1.x,n._randomNoiseCoordinates1.y,i.width,i.height,r),f=l._fetchR(n._randomNoiseCoordinates1.z,n._randomNoiseCoordinates2.x,i.width,i.height,r),p=l._fetchR(n._randomNoiseCoordinates2.y,n._randomNoiseCoordinates2.z,i.width,i.height,r),m=e.Tmp.Vector3[0],g=e.Tmp.Vector3[1];m.copyFromFloats((2*d-1)*l.noiseStrength.x,(2*f-1)*l.noiseStrength.y,(2*p-1)*l.noiseStrength.z),m.scaleToRef(o,g),n.direction.addInPlace(g)}if(l.gravity.scaleToRef(o,l._scaledGravity),n.direction.addInPlace(l._scaledGravity),l._sizeGradients&&l._sizeGradients.length>0&&e.Tools.GetCurrentGradient(u,l._sizeGradients,function(t,i,r){t!==n._currentSizeGradient&&(n._currentSize1=n._currentSize2,n._currentSize2=i.getFactor(),n._currentSizeGradient=t),n.size=e.Scalar.Lerp(n._currentSize1,n._currentSize2,r)}),l._useRampGradients&&(l._colorRemapGradients&&l._colorRemapGradients.length>0&&e.Tools.GetCurrentGradient(u,l._colorRemapGradients,function(t,i,r){var o=e.Scalar.Lerp(t.factor1,i.factor1,r),s=e.Scalar.Lerp(t.factor2,i.factor2,r);n.remapData.x=o,n.remapData.y=s-o}),l._alphaRemapGradients&&l._alphaRemapGradients.length>0&&e.Tools.GetCurrentGradient(u,l._alphaRemapGradients,function(t,i,r){var o=e.Scalar.Lerp(t.factor1,i.factor1,r),s=e.Scalar.Lerp(t.factor2,i.factor2,r);n.remapData.z=o,n.remapData.w=s-o})),l._isAnimationSheetEnabled&&n.updateCellIndex(),n._inheritParticleInfoToSubEmitters(),n.age>=n.lifeTime)return l._emitFromParticle(n),n._attachedSubEmitters&&(n._attachedSubEmitters.forEach(function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()}),n._attachedSubEmitters=null),l.recycleParticle(n),s--,"continue"},s=0;s<t.length;s++)o()},l}return o(i,t),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,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"particles",{get:function(){return this._particles},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"ParticleSystem"},i.prototype._addFactorGradient=function(t,i,r,n){var o=new e.FactorGradient;o.gradient=i,o.factor1=r,o.factor2=n,t.push(o),t.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})},i.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,r=0,n=e;r<n.length;r++){if(n[r].gradient===t){e.splice(i,1);break}i++}},i.prototype.addLifeTimeGradient=function(e,t,i){return this._lifeTimeGradients||(this._lifeTimeGradients=[]),this._addFactorGradient(this._lifeTimeGradients,e,t,i),this},i.prototype.removeLifeTimeGradient=function(e){return this._removeFactorGradient(this._lifeTimeGradients,e),this},i.prototype.addSizeGradient=function(e,t,i){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t,i),this},i.prototype.removeSizeGradient=function(e){return this._removeFactorGradient(this._sizeGradients,e),this},i.prototype.addColorRemapGradient=function(e,t,i){return this._colorRemapGradients||(this._colorRemapGradients=[]),this._addFactorGradient(this._colorRemapGradients,e,t,i),this},i.prototype.removeColorRemapGradient=function(e){return this._removeFactorGradient(this._colorRemapGradients,e),this},i.prototype.addAlphaRemapGradient=function(e,t,i){return this._alphaRemapGradients||(this._alphaRemapGradients=[]),this._addFactorGradient(this._alphaRemapGradients,e,t,i),this},i.prototype.removeAlphaRemapGradient=function(e){return this._removeFactorGradient(this._alphaRemapGradients,e),this},i.prototype.addAngularSpeedGradient=function(e,t,i){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t,i),this},i.prototype.removeAngularSpeedGradient=function(e){return this._removeFactorGradient(this._angularSpeedGradients,e),this},i.prototype.addVelocityGradient=function(e,t,i){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t,i),this},i.prototype.removeVelocityGradient=function(e){return this._removeFactorGradient(this._velocityGradients,e),this},i.prototype.addLimitVelocityGradient=function(e,t,i){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t,i),this},i.prototype.removeLimitVelocityGradient=function(e){return this._removeFactorGradient(this._limitVelocityGradients,e),this},i.prototype.addDragGradient=function(e,t,i){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t,i),this},i.prototype.removeDragGradient=function(e){return this._removeFactorGradient(this._dragGradients,e),this},i.prototype.addEmitRateGradient=function(e,t,i){return this._emitRateGradients||(this._emitRateGradients=[]),this._addFactorGradient(this._emitRateGradients,e,t,i),this},i.prototype.removeEmitRateGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},i.prototype.addStartSizeGradient=function(e,t,i){return this._startSizeGradients||(this._startSizeGradients=[]),this._addFactorGradient(this._startSizeGradients,e,t,i),this},i.prototype.removeStartSizeGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},i.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture){for(var t=new Uint8Array(4*this._rawTextureWidth),i=e.Tmp.Color3[0],r=0;r<this._rawTextureWidth;r++){var n=r/this._rawTextureWidth;e.Tools.GetCurrentGradient(n,this._rampGradients,function(n,o,s){e.Color3.LerpToRef(n.color,o.color,s,i),t[4*r]=255*i.r,t[4*r+1]=255*i.g,t[4*r+2]=255*i.b,t[4*r+3]=255})}this._rampGradientsTexture=e.RawTexture.CreateRGBATexture(t,this._rawTextureWidth,1,this._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}},i.prototype.getRampGradients=function(){return this._rampGradients},i.prototype.addRampGradient=function(t,i){this._rampGradients||(this._rampGradients=[]);var r=new e.Color3Gradient;return r.gradient=t,r.color=i,this._rampGradients.push(r),this._rampGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture(),this},i.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},i.prototype.addColorGradient=function(t,i,r){this._colorGradients||(this._colorGradients=[]);var n=new e.ColorGradient;return n.gradient=t,n.color1=i,n.color2=r,this._colorGradients.push(n),this._colorGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this},i.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,i=0,r=this._colorGradients;i<r.length;i++){if(r[i].gradient===e){this._colorGradients.splice(t,1);break}t++}return this},i.prototype._fetchR=function(e,t,i,r,n){return n[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((t=.5*Math.abs(t)+.5)*r%r|0)*i)]/255},i.prototype._reset=function(){this._resetEffect()},i.prototype._resetEffect=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._createVertexBuffers()},i.prototype._createVertexBuffers=function(){this._vertexBufferSize=this._useInstancing?10:12,this._isAnimationSheetEnabled&&(this._vertexBufferSize+=1),this._isBillboardBased&&this.billboardMode!==i.BILLBOARDMODE_STRETCHED||(this._vertexBufferSize+=3),this._useRampGradients&&(this._vertexBufferSize+=4);var t=this._scene.getEngine();this._vertexData=new Float32Array(this._capacity*this._vertexBufferSize*(this._useInstancing?1:4)),this._vertexBuffer=new e.Buffer(t,this._vertexData,!0,this._vertexBufferSize);var r=0,n=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.PositionKind,r,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[e.VertexBuffer.PositionKind]=n,r+=3;var o=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.ColorKind,r,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[e.VertexBuffer.ColorKind]=o,r+=4;var s=this._vertexBuffer.createVertexBuffer("angle",r,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=s,r+=1;var a,l=this._vertexBuffer.createVertexBuffer("size",r,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=l,r+=2,this._isAnimationSheetEnabled){var c=this._vertexBuffer.createVertexBuffer("cellIndex",r,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.cellIndex=c,r+=1}if(!this._isBillboardBased||this.billboardMode===i.BILLBOARDMODE_STRETCHED){var u=this._vertexBuffer.createVertexBuffer("direction",r,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.direction=u,r+=3}if(this._useRampGradients){var h=this._vertexBuffer.createVertexBuffer("remapData",r,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.remapData=h,r+=4}if(this._useInstancing){var d=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new e.Buffer(t,d,!1,2),a=this._spriteBuffer.createVertexBuffer("offset",0,2)}else a=this._vertexBuffer.createVertexBuffer("offset",r,2,this._vertexBufferSize,this._useInstancing),r+=2;this._vertexBuffers.offset=a},i.prototype._createIndexBuffer=function(){if(!this._useInstancing){for(var e=[],t=0,i=0;i<this._capacity;i++)e.push(t),e.push(t+1),e.push(t+2),e.push(t),e.push(t+2),e.push(t+3),t+=4;this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype._prepareSubEmitterInternalArray=function(){var t=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEach(function(r){r instanceof i?t._subEmitters.push([new e.SubEmitter(r)]):r instanceof e.SubEmitter?t._subEmitters.push([r]):r instanceof Array&&t._subEmitters.push(r)})},i.prototype.start=function(t){var i=this;if(void 0===t&&(t=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";if(t)setTimeout(function(){i.start(0)},t);else{if(this._prepareSubEmitterInternalArray(),this._started=!0,this._stopped=!1,this._actualFrame=0,this._subEmitters&&0!=this._subEmitters.length&&(this.activeSubSystems=new Array),this._emitRateGradients&&(this._emitRateGradients.length>0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){this.emitter instanceof e.AbstractMesh&&this.emitter.computeWorldMatrix(!0);var r=this.noiseTexture;if(r&&r.onGeneratedObservable)r.onGeneratedObservable.addOnce(function(){setTimeout(function(){for(var e=0;e<i.preWarmCycles;e++)i.animate(!0),r.render()})});else for(var n=0;n<this.preWarmCycles;n++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},i.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},i.prototype.reset=function(){this._stockParticles=[],this._particles=[]},i.prototype._appendParticleVertex=function(e,t,r,n){var o=e*this._vertexBufferSize;this._vertexData[o++]=t.position.x,this._vertexData[o++]=t.position.y,this._vertexData[o++]=t.position.z,this._vertexData[o++]=t.color.r,this._vertexData[o++]=t.color.g,this._vertexData[o++]=t.color.b,this._vertexData[o++]=t.color.a,this._vertexData[o++]=t.angle,this._vertexData[o++]=t.scale.x*t.size,this._vertexData[o++]=t.scale.y*t.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=t.cellIndex),this._isBillboardBased?this.billboardMode===i.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=t.direction.x,this._vertexData[o++]=t.direction.y,this._vertexData[o++]=t.direction.z):t._initialDirection?(this._vertexData[o++]=t._initialDirection.x,this._vertexData[o++]=t._initialDirection.y,this._vertexData[o++]=t._initialDirection.z):(this._vertexData[o++]=t.direction.x,this._vertexData[o++]=t.direction.y,this._vertexData[o++]=t.direction.z),this._useRampGradients&&(this._vertexData[o++]=t.remapData.x,this._vertexData[o++]=t.remapData.y,this._vertexData[o++]=t.remapData.z,this._vertexData[o++]=t.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),0===n?n=this._epsilon:1===n&&(n=1-this._epsilon)),this._vertexData[o++]=r,this._vertexData[o++]=n)},i.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach(function(e){e.stop(!0)}),this.activeSubSystems=new Array)},i.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},i.prototype._update=function(t){var i,r=this;if(this._alive=this._particles.length>0,this.emitter.position){var n=this.emitter;this._emitterWorldMatrix=n.getWorldMatrix()}else{var o=this.emitter;this._emitterWorldMatrix=e.Matrix.Translation(o.x,o.y,o.z)}this.updateFunction(this._particles);for(var s,a=function(){if(l._particles.length===l._capacity)return"break";i=l._createParticle(),l._particles.push(i);var t=e.Scalar.RandomRange(l.minEmitPower,l.maxEmitPower);if(l.startPositionFunction?l.startPositionFunction(l._emitterWorldMatrix,i.position,i):l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix,i.position,i),l.startDirectionFunction?l.startDirectionFunction(l._emitterWorldMatrix,i.direction,i):l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix,i.direction,i),0===t?i._initialDirection?i._initialDirection.copyFrom(i.direction):i._initialDirection=i.direction.clone():i._initialDirection=null,i.direction.scaleInPlace(t),l.targetStopDuration&&l._lifeTimeGradients&&l._lifeTimeGradients.length>0){var n=e.Scalar.Clamp(l._actualFrame/l.targetStopDuration);e.Tools.GetCurrentGradient(n,l._lifeTimeGradients,function(t,r,o){var s=t,a=r,l=s.getFactor(),c=a.getFactor(),u=(n-s.gradient)/(a.gradient-s.gradient);i.lifeTime=e.Scalar.Lerp(l,c,u)})}else i.lifeTime=e.Scalar.RandomRange(l.minLifeTime,l.maxLifeTime);if(l._sizeGradients&&0!==l._sizeGradients.length?(i._currentSizeGradient=l._sizeGradients[0],i._currentSize1=i._currentSizeGradient.getFactor(),i.size=i._currentSize1,l._sizeGradients.length>1?i._currentSize2=l._sizeGradients[1].getFactor():i._currentSize2=i._currentSize1):i.size=e.Scalar.RandomRange(l.minSize,l.maxSize),i.scale.copyFromFloats(e.Scalar.RandomRange(l.minScaleX,l.maxScaleX),e.Scalar.RandomRange(l.minScaleY,l.maxScaleY)),l._startSizeGradients&&l._startSizeGradients[0]&&l.targetStopDuration){var o=l._actualFrame/l.targetStopDuration;e.Tools.GetCurrentGradient(o,l._startSizeGradients,function(t,n,o){t!==r._currentStartSizeGradient&&(r._currentStartSize1=r._currentStartSize2,r._currentStartSize2=n.getFactor(),r._currentStartSizeGradient=t);var s=e.Scalar.Lerp(r._currentStartSize1,r._currentStartSize2,o);i.scale.scaleInPlace(s)})}l._angularSpeedGradients&&0!==l._angularSpeedGradients.length?(i._currentAngularSpeedGradient=l._angularSpeedGradients[0],i.angularSpeed=i._currentAngularSpeedGradient.getFactor(),i._currentAngularSpeed1=i.angularSpeed,l._angularSpeedGradients.length>1?i._currentAngularSpeed2=l._angularSpeedGradients[1].getFactor():i._currentAngularSpeed2=i._currentAngularSpeed1):i.angularSpeed=e.Scalar.RandomRange(l.minAngularSpeed,l.maxAngularSpeed),i.angle=e.Scalar.RandomRange(l.minInitialRotation,l.maxInitialRotation),l._velocityGradients&&l._velocityGradients.length>0&&(i._currentVelocityGradient=l._velocityGradients[0],i._currentVelocity1=i._currentVelocityGradient.getFactor(),l._velocityGradients.length>1?i._currentVelocity2=l._velocityGradients[1].getFactor():i._currentVelocity2=i._currentVelocity1),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&(i._currentLimitVelocityGradient=l._limitVelocityGradients[0],i._currentLimitVelocity1=i._currentLimitVelocityGradient.getFactor(),l._limitVelocityGradients.length>1?i._currentLimitVelocity2=l._limitVelocityGradients[1].getFactor():i._currentLimitVelocity2=i._currentLimitVelocity1),l._dragGradients&&l._dragGradients.length>0&&(i._currentDragGradient=l._dragGradients[0],i._currentDrag1=i._currentDragGradient.getFactor(),l._dragGradients.length>1?i._currentDrag2=l._dragGradients[1].getFactor():i._currentDrag2=i._currentDrag1),l._colorGradients&&0!==l._colorGradients.length?(i._currentColorGradient=l._colorGradients[0],i._currentColorGradient.getColorToRef(i.color),i._currentColor1.copyFrom(i.color),l._colorGradients.length>1?l._colorGradients[1].getColorToRef(i._currentColor2):i._currentColor2.copyFrom(i.color)):(s=e.Scalar.RandomRange(0,1),e.Color4.LerpToRef(l.color1,l.color2,s,i.color),l.colorDead.subtractToRef(i.color,l._colorDiff),l._colorDiff.scaleToRef(1/i.lifeTime,i.colorStep)),l._isAnimationSheetEnabled&&(i._initialStartSpriteCellID=l.startSpriteCellID,i._initialEndSpriteCellID=l.endSpriteCellID),i.direction.addInPlace(l._inheritedVelocityOffset),l._useRampGradients&&(i.remapData=new e.Vector4(0,1,0,1)),l.noiseTexture&&(i._randomNoiseCoordinates1?(i._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),i._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(i._randomNoiseCoordinates1=new e.Vector3(Math.random(),Math.random(),Math.random()),i._randomNoiseCoordinates2=new e.Vector3(Math.random(),Math.random(),Math.random()))),i._inheritParticleInfoToSubEmitters()},l=this,c=0;c<t;c++){if("break"===a())break}},i._GetAttributeNamesOrOptions=function(t,i,r){void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1);var n=[e.VertexBuffer.PositionKind,e.VertexBuffer.ColorKind,"angle","offset","size"];return t&&n.push("cellIndex"),i||n.push("direction"),r&&n.push("remapData"),n},i._GetEffectCreationOptions=function(e){void 0===e&&(e=!1);var t=["invView","view","projection","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","textureMask","translationPivot","eyePosition"];return e&&t.push("particlesInfos"),t},i.prototype._getEffect=function(t){if(this._customEffect)return this._customEffect;var r=[];if(this._scene.clipPlane&&r.push("#define CLIPPLANE"),this._scene.clipPlane2&&r.push("#define CLIPPLANE2"),this._scene.clipPlane3&&r.push("#define CLIPPLANE3"),this._scene.clipPlane4&&r.push("#define CLIPPLANE4"),this._isAnimationSheetEnabled&&r.push("#define ANIMATESHEET"),t===i.BLENDMODE_MULTIPLY&&r.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&r.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(r.push("#define BILLBOARD"),this.billboardMode){case i.BILLBOARDMODE_Y:r.push("#define BILLBOARDY");break;case i.BILLBOARDMODE_STRETCHED:r.push("#define BILLBOARDSTRETCHED");break;case i.BILLBOARDMODE_ALL:}this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),r.push(this._imageProcessingConfigurationDefines.toString()));var n=r.join("\n");if(this._cachedDefines!==n){this._cachedDefines=n;var o=i._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==i.BILLBOARDMODE_STRETCHED,this._useRampGradients),s=i._GetEffectCreationOptions(this._isAnimationSheetEnabled),a=["diffuseSampler","rampSampler"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareUniforms(s,this._imageProcessingConfigurationDefines),e.ImageProcessingConfiguration.PrepareSamplers(a,this._imageProcessingConfigurationDefines)),this._effect=this._scene.getEngine().createEffect("particles",o,s,a,n)}return this._effect},i.prototype.animate=function(t){var i=this;if(void 0===t&&(t=!1),this._started){if(!t){if(!this.isReady())return;if(this._currentRenderId===this._scene.getRenderId())return;this._currentRenderId=this._scene.getRenderId()}var r;if(this._scaledUpdateSpeed=this.updateSpeed*(t?this.preWarmStepOffset:this._scene.getAnimationRatio()),this.manualEmitCount>-1)r=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var n=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var o=this._actualFrame/this.targetStopDuration;e.Tools.GetCurrentGradient(o,this._emitRateGradients,function(t,r,o){t!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=r.getFactor(),i._currentEmitRateGradient=t),n=e.Scalar.Lerp(i._currentEmitRate1,i._currentEmitRate2,o)})}r=n*this._scaledUpdateSpeed>>0,this._newPartsExcess+=n*this._scaledUpdateSpeed-r}if(this._newPartsExcess>1&&(r+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?r=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(r),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!t){for(var s=0,a=0;a<this._particles.length;a++){var l=this._particles[a];this._appendParticleVertices(s,l),s+=this._useInstancing?1:4}this._vertexBuffer&&this._vertexBuffer.update(this._vertexData)}0===this.manualEmitCount&&this.disposeOnStop&&this.stop()}},i.prototype._appendParticleVertices=function(e,t){this._appendParticleVertex(e++,t,0,0),this._useInstancing||(this._appendParticleVertex(e++,t,1,0),this._appendParticleVertex(e++,t,1,1),this._appendParticleVertex(e++,t,0,1))},i.prototype.rebuild=function(){this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild()},i.prototype.isReady=function(){if(!(this.emitter&&this._imageProcessingConfiguration.isReady()&&this.particleTexture&&this.particleTexture.isReady()))return!1;if(this.blendMode!==i.BLENDMODE_MULTIPLYADD){if(!this._getEffect(this.blendMode).isReady())return!1}else{if(!this._getEffect(i.BLENDMODE_MULTIPLY).isReady())return!1;if(!this._getEffect(i.BLENDMODE_ADD).isReady())return!1}return!0},i.prototype._render=function(t){var r=this._getEffect(t),n=this._scene.getEngine();n.enableEffect(r);var o=this._scene.getViewMatrix();if(r.setTexture("diffuseSampler",this.particleTexture),r.setMatrix("view",o),r.setMatrix("projection",this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var s=this.particleTexture.getBaseSize();r.setFloat3("particlesInfos",this.spriteCellWidth/s.width,this.spriteCellHeight/s.height,s.width/this.spriteCellWidth)}if(r.setVector2("translationPivot",this.translationPivot),r.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased){var a=this._scene.activeCamera;r.setVector3("eyePosition",a.globalPosition)}if(this._rampGradientsTexture&&r.setTexture("rampSampler",this._rampGradientsTexture),this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var l=o.clone();l.invert(),r.setMatrix("invView",l),e.MaterialHelper.BindClipPlane(r,this._scene)}switch(n.bindBuffers(this._vertexBuffers,this._indexBuffer,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(r),t){case i.BLENDMODE_ADD:n.setAlphaMode(e.Engine.ALPHA_ADD);break;case i.BLENDMODE_ONEONE:n.setAlphaMode(e.Engine.ALPHA_ONEONE);break;case i.BLENDMODE_STANDARD:n.setAlphaMode(e.Engine.ALPHA_COMBINE);break;case i.BLENDMODE_MULTIPLY:n.setAlphaMode(e.Engine.ALPHA_MULTIPLY)}return this._useInstancing?n.drawArraysType(e.Material.TriangleFanDrawMode,0,4,this._particles.length):n.drawElementsType(e.Material.TriangleFillMode,0,6*this._particles.length),this._particles.length},i.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var t=this._scene.getEngine();t.setState(!1),this.forceDepthWrite&&t.setDepthWrite(!0);var r=0;return this.blendMode===i.BLENDMODE_MULTIPLYADD&&(r=this._render(i.BLENDMODE_MULTIPLY)+this._render(i.BLENDMODE_ADD)),r=this._render(this.blendMode),t.unbindInstanceAttributes(),t.setAlphaMode(e.Engine.ALPHA_DISABLE),r},i.prototype.dispose=function(e){if(void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var t=0;t<this._subEmitters.length;t++)for(var i=0,r=this._subEmitters[t];i<r.length;i++){r[i].dispose()}this._subEmitters=[],this.subEmitters=[]}this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0),(t=this._scene.particleSystems.indexOf(this))>-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},i.prototype.clone=function(t,r){var n=null,o=null;if(null!=this.customShader){var s=(o=this.customShader).shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}else this._customEffect&&(n=this._customEffect);var a=new i(t,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader","noiseTexture"]),void 0===r&&(r=this.emitter),a.noiseTexture=this.noiseTexture,a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this._colorGradients&&this._colorGradients.forEach(function(e){a.addColorGradient(e.gradient,e.color1,e.color2)}),this._dragGradients&&this._dragGradients.forEach(function(e){a.addDragGradient(e.gradient,e.factor1,e.factor2)}),this._angularSpeedGradients&&this._angularSpeedGradients.forEach(function(e){a.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)}),this._emitRateGradients&&this._emitRateGradients.forEach(function(e){a.addEmitRateGradient(e.gradient,e.factor1,e.factor2)}),this._lifeTimeGradients&&this._lifeTimeGradients.forEach(function(e){a.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)}),this._limitVelocityGradients&&this._limitVelocityGradients.forEach(function(e){a.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)}),this._sizeGradients&&this._sizeGradients.forEach(function(e){a.addSizeGradient(e.gradient,e.factor1,e.factor2)}),this._startSizeGradients&&this._startSizeGradients.forEach(function(e){a.addStartSizeGradient(e.gradient,e.factor1,e.factor2)}),this._velocityGradients&&this._velocityGradients.forEach(function(e){a.addVelocityGradient(e.gradient,e.factor1,e.factor2)}),this._rampGradients&&this._rampGradients.forEach(function(e){a.addRampGradient(e.gradient,e.color)}),this._colorRemapGradients&&this._colorRemapGradients.forEach(function(e){a.addColorRemapGradient(e.gradient,e.factor1,e.factor2)}),this._alphaRemapGradients&&this._alphaRemapGradients.forEach(function(e){a.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)}),this.preventAutoStart||a.start(),a},i.prototype.serialize=function(){var e={};if(i._Serialize(e,this),e.textureMask=this.textureMask.asArray(),e.customShader=this.customShader,e.preventAutoStart=this.preventAutoStart,this.subEmitters){e.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var t=0,r=this._subEmitters;t<r.length;t++){for(var n=[],o=0,s=r[t];o<s.length;o++){var a=s[o];n.push(a.serialize())}e.subEmitters.push(n)}}return e},i._Serialize=function(t,i){if(t.name=i.name,t.id=i.id,t.capacity=i.getCapacity(),i.emitter.position){var r=i.emitter;t.emitterId=r.id}else{var n=i.emitter;t.emitter=n.asArray()}i.particleEmitterType&&(t.particleEmitterType=i.particleEmitterType.serialize()),i.particleTexture&&(t.textureName=i.particleTexture.name,t.invertY=i.particleTexture._invertY),e.Animation.AppendSerializedAnimations(i,t),t.beginAnimationOnStart=i.beginAnimationOnStart,t.beginAnimationFrom=i.beginAnimationFrom,t.beginAnimationTo=i.beginAnimationTo,t.beginAnimationLoop=i.beginAnimationLoop,t.startDelay=i.startDelay,t.renderingGroupId=i.renderingGroupId,t.isBillboardBased=i.isBillboardBased,t.billboardMode=i.billboardMode,t.minAngularSpeed=i.minAngularSpeed,t.maxAngularSpeed=i.maxAngularSpeed,t.minSize=i.minSize,t.maxSize=i.maxSize,t.minScaleX=i.minScaleX,t.maxScaleX=i.maxScaleX,t.minScaleY=i.minScaleY,t.maxScaleY=i.maxScaleY,t.minEmitPower=i.minEmitPower,t.maxEmitPower=i.maxEmitPower,t.minLifeTime=i.minLifeTime,t.maxLifeTime=i.maxLifeTime,t.emitRate=i.emitRate,t.gravity=i.gravity.asArray(),t.noiseStrength=i.noiseStrength.asArray(),t.color1=i.color1.asArray(),t.color2=i.color2.asArray(),t.colorDead=i.colorDead.asArray(),t.updateSpeed=i.updateSpeed,t.targetStopDuration=i.targetStopDuration,t.blendMode=i.blendMode,t.preWarmCycles=i.preWarmCycles,t.preWarmStepOffset=i.preWarmStepOffset,t.minInitialRotation=i.minInitialRotation,t.maxInitialRotation=i.maxInitialRotation,t.startSpriteCellID=i.startSpriteCellID,t.endSpriteCellID=i.endSpriteCellID,t.spriteCellChangeSpeed=i.spriteCellChangeSpeed,t.spriteCellWidth=i.spriteCellWidth,t.spriteCellHeight=i.spriteCellHeight,t.spriteRandomStartCell=i.spriteRandomStartCell,t.isAnimationSheetEnabled=i.isAnimationSheetEnabled;var o=i.getColorGradients();if(o){t.colorGradients=[];for(var s=0,a=o;s<a.length;s++){var l=a[s],c={gradient:l.gradient,color1:l.color1.asArray()};l.color2&&(c.color2=l.color2.asArray()),t.colorGradients.push(c)}}var u=i.getRampGradients();if(u){t.rampGradients=[];for(var h=0,d=u;h<d.length;h++){var f=d[h];c={gradient:f.gradient,color:f.color.asArray()};t.rampGradients.push(c)}t.useRampGradients=i.useRampGradients}var p=i.getColorRemapGradients();if(p){t.colorRemapGradients=[];for(var m=0,g=p;m<g.length;m++){var _=g[m];c={gradient:_.gradient,factor1:_.factor1};void 0!==_.factor2&&(c.factor2=_.factor2),t.colorRemapGradients.push(c)}}var v=i.getAlphaRemapGradients();if(v){t.alphaRemapGradients=[];for(var A=0,y=v;A<y.length;A++){var b=y[A];c={gradient:b.gradient,factor1:b.factor1};void 0!==b.factor2&&(c.factor2=b.factor2),t.alphaRemapGradients.push(c)}}var T=i.getSizeGradients();if(T){t.sizeGradients=[];for(var E=0,x=T;E<x.length;E++){var P=x[E];c={gradient:P.gradient,factor1:P.factor1};void 0!==P.factor2&&(c.factor2=P.factor2),t.sizeGradients.push(c)}}var M=i.getAngularSpeedGradients();if(M){t.angularSpeedGradients=[];for(var S=0,C=M;S<C.length;S++){var R=C[S];c={gradient:R.gradient,factor1:R.factor1};void 0!==R.factor2&&(c.factor2=R.factor2),t.angularSpeedGradients.push(c)}}var O=i.getVelocityGradients();if(O){t.velocityGradients=[];for(var D=0,I=O;D<I.length;D++){var w=I[D];c={gradient:w.gradient,factor1:w.factor1};void 0!==w.factor2&&(c.factor2=w.factor2),t.velocityGradients.push(c)}}var L=i.getDragGradients();if(L){t.dragyGradients=[];for(var B=0,F=L;B<F.length;B++){var N=F[B];c={gradient:N.gradient,factor1:N.factor1};void 0!==N.factor2&&(c.factor2=N.factor2),t.dragGradients.push(c)}}var V=i.getEmitRateGradients();if(V){t.emitRateGradients=[];for(var U=0,G=V;U<G.length;U++){var k=G[U];c={gradient:k.gradient,factor1:k.factor1};void 0!==k.factor2&&(c.factor2=k.factor2),t.emitRateGradients.push(c)}}var z=i.getStartSizeGradients();if(z){t.startSizeGradients=[];for(var H=0,j=z;H<j.length;H++){var W=j[H];c={gradient:W.gradient,factor1:W.factor1};void 0!==W.factor2&&(c.factor2=W.factor2),t.startSizeGradients.push(c)}}var X=i.getLifeTimeGradients();if(X){t.lifeTimeGradients=[];for(var Y=0,Q=X;Y<Q.length;Y++){var K=Q[Y];c={gradient:K.gradient,factor1:K.factor1};void 0!==K.factor2&&(c.factor2=K.factor2),t.lifeTimeGradients.push(c)}}var Z=i.getLimitVelocityGradients();if(Z){t.limitVelocityGradients=[];for(var J=0,q=Z;J<q.length;J++){var $=q[J];c={gradient:$.gradient,factor1:$.factor1};void 0!==$.factor2&&(c.factor2=$.factor2),t.limitVelocityGradients.push(c)}t.limitVelocityDamping=i.limitVelocityDamping}i.noiseTexture&&(t.noiseTexture=i.noiseTexture.serialize())},i._Parse=function(t,i,r,n){if(t.textureName&&(i.particleTexture=new e.Texture(n+t.textureName,r,!1,void 0===t.invertY||t.invertY),i.particleTexture.name=t.textureName),t.emitterId||0===t.emitterId||void 0!==t.emitter?t.emitterId?i.emitter=r.getLastMeshByID(t.emitterId):i.emitter=e.Vector3.FromArray(t.emitter):i.emitter=e.Vector3.Zero(),void 0!==t.renderingGroupId&&(i.renderingGroupId=t.renderingGroupId),void 0!==t.isBillboardBased&&(i.isBillboardBased=t.isBillboardBased),void 0!==t.billboardMode&&(i.billboardMode=t.billboardMode),t.animations){for(var o=0;o<t.animations.length;o++){var s=t.animations[o];i.animations.push(e.Animation.Parse(s))}i.beginAnimationOnStart=t.beginAnimationOnStart,i.beginAnimationFrom=t.beginAnimationFrom,i.beginAnimationTo=t.beginAnimationTo,i.beginAnimationLoop=t.beginAnimationLoop}if(t.autoAnimate&&r.beginAnimation(i,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),i.startDelay=0|t.startDelay,i.minAngularSpeed=t.minAngularSpeed,i.maxAngularSpeed=t.maxAngularSpeed,i.minSize=t.minSize,i.maxSize=t.maxSize,t.minScaleX&&(i.minScaleX=t.minScaleX,i.maxScaleX=t.maxScaleX,i.minScaleY=t.minScaleY,i.maxScaleY=t.maxScaleY),void 0!==t.preWarmCycles&&(i.preWarmCycles=t.preWarmCycles,i.preWarmStepOffset=t.preWarmStepOffset),void 0!==t.minInitialRotation&&(i.minInitialRotation=t.minInitialRotation,i.maxInitialRotation=t.maxInitialRotation),i.minLifeTime=t.minLifeTime,i.maxLifeTime=t.maxLifeTime,i.minEmitPower=t.minEmitPower,i.maxEmitPower=t.maxEmitPower,i.emitRate=t.emitRate,i.gravity=e.Vector3.FromArray(t.gravity),t.noiseStrength&&(i.noiseStrength=e.Vector3.FromArray(t.noiseStrength)),i.color1=e.Color4.FromArray(t.color1),i.color2=e.Color4.FromArray(t.color2),i.colorDead=e.Color4.FromArray(t.colorDead),i.updateSpeed=t.updateSpeed,i.targetStopDuration=t.targetStopDuration,i.blendMode=t.blendMode,t.colorGradients)for(var a=0,l=t.colorGradients;a<l.length;a++){var c=l[a];i.addColorGradient(c.gradient,e.Color4.FromArray(c.color1),c.color2?e.Color4.FromArray(c.color2):void 0)}if(t.rampGradients){for(var u=0,h=t.rampGradients;u<h.length;u++){var d=h[u];i.addRampGradient(d.gradient,e.Color3.FromArray(d.color))}i.useRampGradients=t.useRampGradients}if(t.colorRemapGradients)for(var f=0,p=t.colorRemapGradients;f<p.length;f++){var m=p[f];i.addColorRemapGradient(m.gradient,void 0!==m.factor1?m.factor1:m.factor,m.factor2)}if(t.alphaRemapGradients)for(var g=0,_=t.alphaRemapGradients;g<_.length;g++){var v=_[g];i.addAlphaRemapGradient(v.gradient,void 0!==v.factor1?v.factor1:v.factor,v.factor2)}if(t.sizeGradients)for(var A=0,y=t.sizeGradients;A<y.length;A++){var b=y[A];i.addSizeGradient(b.gradient,void 0!==b.factor1?b.factor1:b.factor,b.factor2)}if(t.sizeGradients)for(var T=0,E=t.sizeGradients;T<E.length;T++){b=E[T];i.addSizeGradient(b.gradient,void 0!==b.factor1?b.factor1:b.factor,b.factor2)}if(t.angularSpeedGradients)for(var x=0,P=t.angularSpeedGradients;x<P.length;x++){var M=P[x];i.addAngularSpeedGradient(M.gradient,void 0!==M.factor1?M.factor1:M.factor,M.factor2)}if(t.velocityGradients)for(var S=0,C=t.velocityGradients;S<C.length;S++){var R=C[S];i.addVelocityGradient(R.gradient,void 0!==R.factor1?R.factor1:R.factor,R.factor2)}if(t.dragGradients)for(var O=0,D=t.dragGradients;O<D.length;O++){var I=D[O];i.addDragGradient(I.gradient,void 0!==I.factor1?I.factor1:I.factor,I.factor2)}if(t.emitRateGradients)for(var w=0,L=t.emitRateGradients;w<L.length;w++){var B=L[w];i.addEmitRateGradient(B.gradient,void 0!==B.factor1?B.factor1:B.factor,B.factor2)}if(t.startSizeGradients)for(var F=0,N=t.startSizeGradients;F<N.length;F++){var V=N[F];i.addStartSizeGradient(V.gradient,void 0!==V.factor1?V.factor1:V.factor,V.factor2)}if(t.lifeTimeGradients)for(var U=0,G=t.lifeTimeGradients;U<G.length;U++){var k=G[U];i.addLifeTimeGradient(k.gradient,void 0!==k.factor1?k.factor1:k.factor,k.factor2)}if(t.limitVelocityGradients){for(var z=0,H=t.limitVelocityGradients;z<H.length;z++){var j=H[z];i.addLimitVelocityGradient(j.gradient,void 0!==j.factor1?j.factor1:j.factor,j.factor2)}i.limitVelocityDamping=t.limitVelocityDamping}var W;if(t.noiseTexture&&(i.noiseTexture=e.ProceduralTexture.Parse(t.noiseTexture,r,n)),t.particleEmitterType){switch(t.particleEmitterType.type){case"SphereParticleEmitter":W=new e.SphereParticleEmitter;break;case"SphereDirectedParticleEmitter":W=new e.SphereDirectedParticleEmitter;break;case"ConeEmitter":case"ConeParticleEmitter":W=new e.ConeParticleEmitter;break;case"CylinderParticleEmitter":W=new e.CylinderParticleEmitter;break;case"HemisphericParticleEmitter":W=new e.HemisphericParticleEmitter;break;case"BoxEmitter":case"BoxParticleEmitter":default:W=new e.BoxParticleEmitter}W.parse(t.particleEmitterType)}else(W=new e.BoxParticleEmitter).parse(t);i.particleEmitterType=W,i.startSpriteCellID=t.startSpriteCellID,i.endSpriteCellID=t.endSpriteCellID,i.spriteCellWidth=t.spriteCellWidth,i.spriteCellHeight=t.spriteCellHeight,i.spriteCellChangeSpeed=t.spriteCellChangeSpeed,i.spriteRandomStartCell=t.spriteRandomStartCell},i.Parse=function(t,r,n,o){void 0===o&&(o=!1);var s=t.name,a=null,l=null;if(t.customShader){var c=(l=t.customShader).shaderOptions.defines.length>0?l.shaderOptions.defines.join("\n"):"";a=r.getEngine().createEffectForParticles(l.shaderPath.fragmentElement,l.shaderOptions.uniforms,l.shaderOptions.samplers,c)}var u=new i(s,t.capacity,r,a,t.isAnimationSheetEnabled);if(u.customShader=l,t.id&&(u.id=t.id),t.subEmitters){u.subEmitters=[];for(var h=0,d=t.subEmitters;h<d.length;h++){for(var f=[],p=0,m=d[h];p<m.length;p++){var g=m[p];f.push(e.SubEmitter.Parse(g,r,n))}u.subEmitters.push(f)}}return i._Parse(t,u,r,n),u.textureMask=e.Color4.FromArray(t.textureMask),t.preventAutoStart&&(u.preventAutoStart=t.preventAutoStart),o||u.preventAutoStart||u.start(),u},i.BILLBOARDMODE_Y=2,i.BILLBOARDMODE_ALL=7,i.BILLBOARDMODE_STRETCHED=8,i}(e.BaseParticleSystem);e.ParticleSystem=t}(a||(a={})),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){var n=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),o=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),s=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(n,o,s,t,i)},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"BoxParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},t.prototype.parse=function(t){e.Vector3.FromArrayToRef(t.direction1,0,this.direction1),e.Vector3.FromArrayToRef(t.direction2,0,this.direction2),e.Vector3.FromArrayToRef(t.minEmitBox,0,this.minEmitBox),e.Vector3.FromArrayToRef(t.maxEmitBox,0,this.maxEmitBox)},t}();e.BoxParticleEmitter=t}(a||(a={})),function(e){var t=function(){function t(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=r}return t.prototype.startDirectionFunction=function(t,i,r){var n=r.position.subtract(t.getTranslation()).normalize(),o=e.Scalar.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),s=Math.atan2(n.x,n.z);s+=e.Scalar.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,n.y=o,n.x=Math.sin(s),n.z=Math.cos(s),n.normalize(),e.Vector3.TransformNormalFromFloatsToRef(n.x,n.y,n.z,t,i)},t.prototype.startPositionFunction=function(t,i,r){var n=e.Scalar.RandomRange(-this.height/2,this.height/2),o=e.Scalar.RandomRange(0,2*Math.PI),s=e.Scalar.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),a=Math.sqrt(s)*this.radius,l=a*Math.cos(o),c=a*Math.sin(o);e.Vector3.TransformCoordinatesFromFloatsToRef(l,n,c,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("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t}();e.CylinderParticleEmitter=t;var i=function(t){function i(i,r,n,o,s){void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===o&&(o=new e.Vector3(0,1,0)),void 0===s&&(s=new e.Vector3(0,1,0));var a=t.call(this,i,r,n)||this;return a.direction1=o,a.direction2=s,a}return o(i,t),i.prototype.startDirectionFunction=function(t,i,r){var n=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),o=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),s=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(n,o,s,t,i)},i.prototype.clone=function(){var t=new i(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return e.Tools.DeepCopy(this,t),t},i.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},i.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"},i.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},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.CylinderDirectedParticleEmitter=i}(a||(a={})),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.directionRandomizer=i,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),t.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},t.prototype.startDirectionFunction=function(t,i,r){if(1===Math.abs(Math.cos(this._angle)))e.Vector3.TransformNormalFromFloatsToRef(0,1,0,t,i);else{var n=r.position.subtract(t.getTranslation()).normalize(),o=e.Scalar.RandomRange(0,this.directionRandomizer),s=e.Scalar.RandomRange(0,this.directionRandomizer),a=e.Scalar.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=s,n.z+=a,n.normalize(),e.Vector3.TransformNormalFromFloatsToRef(n.x,n.y,n.z,t,i)}},t.prototype.startPositionFunction=function(t,i,r){var n,o=e.Scalar.RandomRange(0,2*Math.PI);n=this.emitFromSpawnPointOnly?1e-4:1-(n=e.Scalar.RandomRange(0,this.heightRange))*n;var s=this._radius-e.Scalar.RandomRange(0,this._radius*this.radiusRange),a=(s*=n)*Math.sin(o),l=s*Math.cos(o),c=n*this._height;e.Vector3.TransformCoordinatesFromFloatsToRef(a,c,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.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},t.prototype.getClassName=function(){return"ConeParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer},t}();e.ConeParticleEmitter=t}(a||(a={})),function(e){var t=function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return t.prototype.startDirectionFunction=function(t,i,r){var n=r.position.subtract(t.getTranslation()).normalize(),o=e.Scalar.RandomRange(0,this.directionRandomizer),s=e.Scalar.RandomRange(0,this.directionRandomizer),a=e.Scalar.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=s,n.z+=a,n.normalize(),e.Vector3.TransformNormalFromFloatsToRef(n.x,n.y,n.z,t,i)},t.prototype.startPositionFunction=function(t,i,r){var n=this.radius-e.Scalar.RandomRange(0,this.radius*this.radiusRange),o=e.Scalar.RandomRange(0,1),s=e.Scalar.RandomRange(0,2*Math.PI),a=Math.acos(2*o-1),l=n*Math.cos(s)*Math.sin(a),c=n*Math.cos(a),u=n*Math.sin(s)*Math.sin(a);e.Vector3.TransformCoordinatesFromFloatsToRef(l,c,u,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("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t}();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){var n=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),o=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),s=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(n,o,s,t,i)},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.setFloat("radiusRange",this.radiusRange),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}(a||(a={})),function(e){var t=function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return t.prototype.startDirectionFunction=function(t,i,r){var n=r.position.subtract(t.getTranslation()).normalize(),o=e.Scalar.RandomRange(0,this.directionRandomizer),s=e.Scalar.RandomRange(0,this.directionRandomizer),a=e.Scalar.RandomRange(0,this.directionRandomizer);n.x+=o,n.y+=s,n.z+=a,n.normalize(),e.Vector3.TransformNormalFromFloatsToRef(n.x,n.y,n.z,t,i)},t.prototype.startPositionFunction=function(t,i,r){var n=this.radius-e.Scalar.RandomRange(0,this.radius*this.radiusRange),o=e.Scalar.RandomRange(0,1),s=e.Scalar.RandomRange(0,2*Math.PI),a=Math.acos(2*o-1),l=n*Math.cos(s)*Math.sin(a),c=n*Math.cos(a),u=n*Math.sin(s)*Math.sin(a);e.Vector3.TransformCoordinatesFromFloatsToRef(l,Math.abs(c),u,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("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},t.prototype.getClassName=function(){return"HemisphericParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t}();e.HemisphericParticleEmitter=t}(a||(a={})),function(e){var t=function(){function t(){this.direction1=new e.Vector3(0,1,0),this.direction2=new e.Vector3(0,1,0)}return t.prototype.startDirectionFunction=function(t,i,r){var n=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),o=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),s=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(n,o,s,t,i)},t.prototype.startPositionFunction=function(t,i,r){e.Vector3.TransformCoordinatesFromFloatsToRef(0,0,0,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)},t.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},t.prototype.getClassName=function(){return"PointParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(t){e.Vector3.FromArrayToRef(t.direction1,0,this.direction1),e.Vector3.FromArrayToRef(t.direction2,0,this.direction2)},t}();e.PointParticleEmitter=t}(a||(a={})),function(e){e.AbstractScene.AddParser(e.SceneComponentConstants.NAME_PARTICLESYSTEM,function(t,i,r,n){var o=e.AbstractScene.GetIndividualParser(e.SceneComponentConstants.NAME_PARTICLESYSTEM);if(o&&void 0!==t.particleSystems&&null!==t.particleSystems)for(var s=0,a=t.particleSystems.length;s<a;s++){var l=t.particleSystems[s];r.particleSystems.push(o(l,i,n))}}),e.AbstractScene.AddIndividualParser(e.SceneComponentConstants.NAME_PARTICLESYSTEM,function(t,i,r){return t.activeParticleCount?e.GPUParticleSystem.Parse(t,i,r):e.ParticleSystem.Parse(t,i,r)}),e.Engine.prototype.createEffectForParticles=function(t,i,r,n,o,s,a){void 0===i&&(i=[]),void 0===r&&(r=[]),void 0===n&&(n="");var l=e.ParticleSystem._GetAttributeNamesOrOptions(),c=e.ParticleSystem._GetEffectCreationOptions();return-1===n.indexOf(" BILLBOARD")&&(n+="\n#define BILLBOARD\n"),-1===r.indexOf("diffuseSampler")&&r.push("diffuseSampler"),this.createEffect({vertex:"particles",fragmentElement:t},l,c.concat(i),r,n,o,s,a)},e.Mesh.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},e.Mesh.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i],n=r.emitter;n.position&&-1!==t.indexOf(n)&&e.push(r)}return e}}(a||(a={})),function(e){var t;!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(t=e.SubEmitterType||(e.SubEmitterType={}));var i=function(){function i(i){this.particleSystem=i,this.type=t.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,i.emitter&&i.emitter.dispose||(i.emitter=new e.AbstractMesh("SubemitterSystemEmitter",i.getScene())),i.onDisposeObservable.add(function(){i.emitter&&i.emitter.dispose&&i.emitter.dispose()})}return i.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof e.Vector3?t=t.clone():t instanceof e.AbstractMesh&&((t=new e.Mesh("",t.getScene())).isVisible=!1):t=new e.Vector3;var r=new i(this.particleSystem.clone("",t));return r.type=this.type,r.inheritDirection=this.inheritDirection,r.inheritedVelocityAmount=this.inheritedVelocityAmount,r.particleSystem._disposeEmitterOnDispose=!0,r.particleSystem.disposeOnStop=!0,r},i.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},i.Parse=function(t,r,n){var o=t.particleSystem,s=new i(e.ParticleSystem.Parse(o,r,n));return s.type=t.type,s.inheritDirection=t.inheritDirection,s.inheritedVelocityAmount=t.inheritedVelocityAmount,s.particleSystem._isSubEmitter=!0,s},i.prototype.dispose=function(){this.particleSystem.dispose()},i}();e.SubEmitter=i}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o={});var a=t.call(this,i,r)||this;return a._textures={},a._textureArrays={},a._floats={},a._ints={},a._floatsArrays={},a._colors3={},a._colors3Arrays={},a._colors4={},a._vectors2={},a._vectors3={},a._vectors4={},a._matrices={},a._matrices3x3={},a._matrices2x2={},a._vectors2Arrays={},a._vectors3Arrays={},a._cachedWorldViewMatrix=new e.Matrix,a._shaderPath=n,a._options=s({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},o),a}return o(i,t),i.prototype.getClassName=function(){return"ShaderMaterial"},i.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},i.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce(function(e,t){return t.toArray(e,e.length),e},[]),this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.setArray2=function(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this},i.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},i.prototype._checkCache=function(e,t,i){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId()&&this._checkCache(r,t,i))return!0;for(var o=[],s=[],a=new e.EffectFallbacks,l=0;l<this._options.defines.length;l++)o.push(this._options.defines[l]);for(l=0;l<this._options.attributes.length;l++)s.push(this._options.attributes[l]);for(var c in t&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(s.push(e.VertexBuffer.ColorKind),o.push("#define VERTEXCOLOR")),i&&(o.push("#define INSTANCES"),e.MaterialHelper.PrepareAttributesForInstances(s,o)),t&&t.useBones&&t.computeBonesUsingShaders&&t.skeleton?(s.push(e.VertexBuffer.MatricesIndicesKind),s.push(e.VertexBuffer.MatricesWeightsKind),t.numBoneInfluencers>4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0"),this._textures)if(!this._textures[c].isReady())return!1;t&&this._shouldTurnAlphaTestOn(t)&&o.push("#define ALPHATEST");var u=this._effect,h=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:h,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(u!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix())))},i.prototype.bind=function(t,i){if(this.bindOnlyWorldMatrix(t),this._effect&&this.getScene().getCachedMaterial()!==this){var r;for(r in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(i,this._effect),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._ints)this._effect.setInt(r,this._ints[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)this._effect.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors2Arrays)this._effect.setArray2(r,this._vectors2Arrays[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var i in this._textures)e.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)e.push(r[n]);return e},i.prototype.hasTexture=function(e){if(t.prototype.hasTexture.call(this,e))return!0;for(var i in this._textures)if(this._textures[i]===e)return!0;for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)if(r[n]===e)return!0;return!1},i.prototype.clone=function(e){return new i(e,this.getScene(),this._shaderPath,this._options)},i.prototype.dispose=function(e,i){if(i){var r;for(r in this._textures)this._textures[r].dispose();for(r in this._textureArrays)for(var n=this._textureArrays[r],o=0;o<n.length;o++)n[o].dispose()}this._textures={},t.prototype.dispose.call(this,e,i)},i.prototype.serialize=function(){var t,i=e.SerializationHelper.Serialize(this);for(t in i.customType="BABYLON.ShaderMaterial",i.options=this._options,i.shaderPath=this._shaderPath,i.textures={},this._textures)i.textures[t]=this._textures[t].serialize();for(t in i.textureArrays={},this._textureArrays){i.textureArrays[t]=[];for(var r=this._textureArrays[t],n=0;n<r.length;n++)i.textureArrays[t].push(r[n].serialize())}for(t in i.floats={},this._floats)i.floats[t]=this._floats[t];for(t in i.FloatArrays={},this._floatsArrays)i.FloatArrays[t]=this._floatsArrays[t];for(t in i.colors3={},this._colors3)i.colors3[t]=this._colors3[t].asArray();for(t in i.colors3Arrays={},this._colors3Arrays)i.colors3Arrays[t]=this._colors3Arrays[t];for(t in i.colors4={},this._colors4)i.colors4[t]=this._colors4[t].asArray();for(t in i.vectors2={},this._vectors2)i.vectors2[t]=this._vectors2[t].asArray();for(t in i.vectors3={},this._vectors3)i.vectors3[t]=this._vectors3[t].asArray();for(t in i.vectors4={},this._vectors4)i.vectors4[t]=this._vectors4[t].asArray();for(t in i.matrices={},this._matrices)i.matrices[t]=this._matrices[t].asArray();for(t in i.matrices3x3={},this._matrices3x3)i.matrices3x3[t]=this._matrices3x3[t];for(t in i.matrices2x2={},this._matrices2x2)i.matrices2x2[t]=this._matrices2x2[t];for(t in i.vectors2Arrays={},this._vectors2Arrays)i.vectors2Arrays[t]=this._vectors2Arrays[t];for(t in i.vectors3Arrays={},this._vectors3Arrays)i.vectors3Arrays[t]=this._vectors3Arrays[t];return i},i.Parse=function(t,r,n){var o,s=e.SerializationHelper.Parse(function(){return new i(t.name,r,t.shaderPath,t.options)},t,r,n);for(o in t.textures)s.setTexture(o,e.Texture.Parse(t.textures[o],r,n));for(o in t.textureArrays){for(var a=t.textureArrays[o],l=new Array,c=0;c<a.length;c++)l.push(e.Texture.Parse(a[c],r,n));s.setTextureArray(o,l)}for(o in t.floats)s.setFloat(o,t.floats[o]);for(o in t.floatsArrays)s.setFloats(o,t.floatsArrays[o]);for(o in t.colors3)s.setColor3(o,e.Color3.FromArray(t.colors3[o]));for(o in t.colors3Arrays){var u=t.colors3Arrays[o].reduce(function(e,t,i){return i%3==0?e.push([t]):e[e.length-1].push(t),e},[]).map(function(t){return e.Color3.FromArray(t)});s.setColor3Array(o,u)}for(o in t.colors4)s.setColor4(o,e.Color4.FromArray(t.colors4[o]));for(o in t.vectors2)s.setVector2(o,e.Vector2.FromArray(t.vectors2[o]));for(o in t.vectors3)s.setVector3(o,e.Vector3.FromArray(t.vectors3[o]));for(o in t.vectors4)s.setVector4(o,e.Vector4.FromArray(t.vectors4[o]));for(o in t.matrices)s.setMatrix(o,e.Matrix.FromArray(t.matrices[o]));for(o in t.matrices3x3)s.setMatrix3x3(o,t.matrices3x3[o]);for(o in t.matrices2x2)s.setMatrix2x2(o,t.matrices2x2[o]);for(o in t.vectors2Arrays)s.setArray2(o,t.vectors2Arrays[o]);for(o in t.vectors3Arrays)s.setArray3(o,t.vectors3Arrays[o]);return s},i}(e.Material);e.ShaderMaterial=t}(a||(a={})),function(e){var t=function(t){function i(e,i){var r=t.call(this,e,i)||this;return r.generateOctree=!1,r}return o(i,t),i.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(i.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),i.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},i.prototype.getHeightAtCoordinates=function(t,i){var r=this.getWorldMatrix(),n=e.Tmp.Matrix[5];r.invertToRef(n);var o=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,n,o),t=o.x,i=o.z,t<this._minX||t>this._maxX||i<this._minZ||i>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,i),a=-(s.x*t+s.z*i+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,o),o.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,o,s),t=s.x,i=s.z,t<this._minX||t>this._maxX||i<this._minZ||i>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t<n.slope.x*e+n.slope.y?n.facet1:n.facet2},i.prototype._initHeightQuads=function(){var t=this._subdivisionsX,i=this._subdivisionsY;this._heightQuads=new Array;for(var r=0;r<i;r++)for(var n=0;n<t;n++){var o={slope:e.Vector2.Zero(),facet1:new e.Vector4(0,0,0,0),facet2:new e.Vector4(0,0,0,0)};this._heightQuads[r*t+n]=o}return this},i.prototype._computeHeightQuads=function(){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return this;for(var i=e.Tmp.Vector3[3],r=e.Tmp.Vector3[2],n=e.Tmp.Vector3[1],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[4],a=e.Tmp.Vector3[5],l=e.Tmp.Vector3[6],c=e.Tmp.Vector3[7],u=e.Tmp.Vector3[8],h=0,d=0,f=0,p=0,m=0,g=0,_=0,v=this._subdivisionsX,A=this._subdivisionsY,y=0;y<A;y++)for(var b=0;b<v;b++){h=3*b,d=y*(v+1)*3,f=(y+1)*(v+1)*3,i.x=t[d+h],i.y=t[d+h+1],i.z=t[d+h+2],r.x=t[d+h+3],r.y=t[d+h+4],r.z=t[d+h+5],n.x=t[f+h],n.y=t[f+h+1],n.z=t[f+h+2],o.x=t[f+h+3],o.y=t[f+h+4],o.z=t[f+h+5],p=(o.z-i.z)/(o.x-i.x),m=i.z-p*i.x,r.subtractToRef(i,s),n.subtractToRef(i,a),o.subtractToRef(i,l),e.Vector3.CrossToRef(l,a,c),e.Vector3.CrossToRef(s,l,u),c.normalize(),u.normalize(),g=-(c.x*i.x+c.y*i.y+c.z*i.z),_=-(u.x*r.x+u.y*r.y+u.z*r.z);var T=this._heightQuads[y*v+b];T.slope.copyFromFloats(p,m),T.facet1.copyFromFloats(c.x,c.y,c.z,g),T.facet2.copyFromFloats(u.x,u.y,u.z,_)}return this},i.prototype.serialize=function(e){t.prototype.serialize.call(this,e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height},i.Parse=function(e,t){var r=new i(e.name,t);return r._subdivisionsX=e.subdivisionsX||1,r._subdivisionsY=e.subdivisionsY||1,r._minX=e.minX,r._maxX=e.maxX,r._minZ=e.minZ,r._maxZ=e.maxZ,r._width=e.width,r._height=e.height,r},i}(e.Mesh);e.GroundMesh=t}(a||(a={})),function(e){var t=function(t){function i(e,i){var r=t.call(this,e,i.getScene())||this;return i.instances.push(r),r._sourceMesh=i,r.position.copyFrom(i.position),r.rotation.copyFrom(i.rotation),r.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(r.rotationQuaternion=i.rotationQuaternion.clone()),r.infiniteDistance=i.infiniteDistance,r.setPivotMatrix(i.getPivotMatrix()),r.refreshBoundingInfo(),r._syncSubMeshes(),r}return o(i,t),i.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(t){this._sourceMesh&&t!==this._sourceMesh.renderingGroupId&&e.Tools.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),i.prototype.isReady=function(e){return void 0===e&&(e=!1),this._sourceMesh.isReady(e,!0)},i.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},i.prototype.setVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh},i.prototype.updateVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),this.sourceMesh},i.prototype.setIndices=function(e,t){return void 0===t&&(t=null),this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),i.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getBoundingInfo();return this._boundingInfo=new e.BoundingInfo(t.minimum.clone(),t.maximum.clone()),this._updateBoundingInfo(),this},i.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},i.prototype._activate=function(e){return this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e),this},i.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype.clone=function(t,i,r){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name","subMeshes","uniqueId"],[]),this.refreshBoundingInfo(),i&&(n.parent=i),!r)for(var o=0;o<this.getScene().meshes.length;o++){var s=this.getScene().meshes[o];s.parent===this&&s.clone(s.name,n)}return n.computeWorldMatrix(!0),n},i.prototype.dispose=function(e,i){void 0===i&&(i=!1);var r=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(r,1),t.prototype.dispose.call(this,e,i)},i}(e.AbstractMesh);e.InstancedMesh=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===r&&(r=null),void 0===n&&(n=null);var c=t.call(this,i,r,n,o,s)||this;c.useVertexColor=a,c.useVertexAlpha=l,c.color=new e.Color3(1,1,1),c.alpha=1,o&&(c.color=o.color.clone(),c.alpha=o.alpha,c.useVertexColor=o.useVertexColor,c.useVertexAlpha=o.useVertexAlpha),c._intersectionThreshold=.1;var u={attributes:[e.VertexBuffer.PositionKind,"world0","world1","world2","world3"],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:[]};return!1===l&&(u.needAlphaBlending=!1),a?(u.defines.push("#define VERTEXCOLOR"),u.attributes.push(e.VertexBuffer.ColorKind)):u.uniforms.push("color"),c._colorShader=new e.ShaderMaterial("colorShader",c.getScene(),"color",u),c}return o(i,t),Object.defineProperty(i.prototype,"intersectionThreshold",{get:function(){return this._intersectionThreshold},set:function(t){this._intersectionThreshold!==t&&(this._intersectionThreshold=t,this.geometry&&(this.geometry.boundingBias=new e.Vector2(0,t)))},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(i.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype._bind=function(e,t,i){return this._geometry?(this._geometry._bind(this._colorShader.getEffect()),this.useVertexColor||this._colorShader.setColor4("color",this.color.toColor4(this.alpha)),this):this},i.prototype._draw=function(t,i,r){return this._geometry&&this._geometry.getVertexBuffers()&&(this._unIndexed||this._geometry.getIndexBuffer())?(this.getScene().getEngine().drawElementsType(e.Material.LineListDrawMode,t.indexStart,t.indexCount,r),this):this},i.prototype.dispose=function(e){this._colorShader.dispose(),t.prototype.dispose.call(this,e)},i.prototype.clone=function(e,t,r){return new i(e,this.getScene(),t,this,r)},i}(e.Mesh);e.LinesMesh=t}(a||(a={})),function(e){var t=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach(function(e,i){return t.add(e,i)})},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:((i=t(e))&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e}();e.StringDictionary=t}(a||(a={})),function(e){!function(t){var i=function(){function t(t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=1),this.skeleton=t,this.mesh=i,this.autoUpdateBonesMatrices=n,this.renderingGroupId=o,this.color=e.Color3.White(),this._debugLines=new Array,this._isEnabled=!1,this._scene=r,this.update(),this._renderFunction=this.update.bind(this)}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?this._scene.registerBeforeRender(this._renderFunction):this._scene.unregisterBeforeRender(this._renderFunction))},enumerable:!0,configurable:!0}),t.prototype._getBonePosition=function(t,i,r,n,o,s){void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0);var a=e.Tmp.Matrix[0],l=i.getParent();if(a.copyFrom(i.getLocalMatrix()),0!==n||0!==o||0!==s){var c=e.Tmp.Matrix[1];e.Matrix.IdentityToRef(c),c.m[12]=n,c.m[13]=o,c.m[14]=s,c.multiplyToRef(a,a)}l&&a.multiplyToRef(l.getAbsoluteTransform(),a),a.multiplyToRef(r,a),t.x=a.m[12],t.y=a.m[13],t.z=a.m[14]},t.prototype._getLinesForBonesWithLength=function(t,i){for(var r=t.length,n=this.mesh.position,o=0;o<r;o++){var s=t[o],a=this._debugLines[o];a||(a=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[o]=a),this._getBonePosition(a[0],s,i),this._getBonePosition(a[1],s,i,0,s.length,0),a[0].subtractInPlace(n),a[1].subtractInPlace(n)}},t.prototype._getLinesForBonesNoLength=function(t,i){for(var r=t.length,n=0,o=this.mesh.position,s=r-1;s>=0;s--){var a=t[s],l=a.getParent();if(l){var c=this._debugLines[n];c||(c=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=c),a.getAbsolutePositionToRef(this.mesh,c[0]),l.getAbsolutePositionToRef(this.mesh,c[1]),c[0].subtractInPlace(o),c[1].subtractInPlace(o),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t}();t.SkeletonViewer=i}(e.Debug||(e.Debug={}))}(a||(a={})),function(e){!function(t){var i=function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines;this._xmesh&&this._xmesh.position.copyFrom(t),this._ymesh&&this._ymesh.position.copyFrom(t),this._zmesh&&this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines("",this._xline,null,!1,this._xmesh),(s=this._yline[1]).x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines("",this._yline,null,!1,this._ymesh),(s=this._zline[1]).x=n.x*o,s.y=n.y*o,s.z=n.z*o,e.Mesh.CreateLines("",this._zline,null,!1,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&this._xmesh.dispose(),this._ymesh&&this._ymesh.dispose(),this._zmesh&&this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this.scene=null},t}();t.AxesViewer=i}(e.Debug||(e.Debug={}))}(a||(a={})),function(e){!function(t){var i=function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return o(i,t),i.prototype.update=function(){if(this.mesh&&this.bone){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},i.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i}(t.AxesViewer);t.BoneAxesViewer=i}(e.Debug||(e.Debug={}))}(a||(a={})),function(e){var t=function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction&&this.ray){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},t.prototype._render=function(){var t=this.ray;if(t){var i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var o=this.ray;o&&(o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh())},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._updateToMeshFunction&&this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;this._attachedToMesh&&t&&(this._attachedToMesh._isDisposed?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)))},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t}();e.RayHelper=t}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new t(this)),this._debugLayer},enumerable:!0,configurable:!0});var t=function(){function t(t){var i=this;this.BJSINSPECTOR="undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this.onPropertyChangedObservable=new e.Observable,this._scene=t,this._scene.onDisposeObservable.add(function(){i._scene._debugLayer&&i._scene._debugLayer.hide()})}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this.BJSINSPECTOR=this.BJSINSPECTOR||"undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this._inspector=new this.BJSINSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this.onPropertyChangedObservable.clear(),this._inspector=null}},t.prototype.show=function(i){void 0===i&&(i={}),void 0===this.BJSINSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t.prototype.getActiveTab=function(){return this._inspector?this._inspector.getActiveTabIndex():-1},t.InspectorURL="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js",t}();e.DebugLayer=t}(a||(a={})),function(e){!function(t){var i=function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene;var i=this._scene.getPhysicsEngine();i&&(this._physicsEnginePlugin=i.getPhysicsPlugin())}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t<this._numMeshes;t++){var i=this._impostors[t];if(i)if(i.isDisposed)this.hideImpostor(this._impostors[t--]);else{var r=this._meshes[t];r&&e&&e.syncMeshWithImpostor(r,i)}}},t.prototype.showImpostor=function(e){if(this._scene){for(var t=0;t<this._numMeshes;t++)if(this._impostors[t]==e)return;var i=this._getDebugMesh(e,this._scene);i&&(this._impostors[this._numMeshes]=e,this._meshes[this._numMeshes]=i,0===this._numMeshes&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++)}},t.prototype.hideImpostor=function(e){if(e&&this._scene){for(var t=!1,i=0;i<this._numMeshes;i++)if(this._impostors[i]==e){var r=this._meshes[i];if(!r)continue;this._scene.removeMesh(r),r.dispose(),this._numMeshes--,this._numMeshes>0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,i){var r=null;if(t.type==e.PhysicsImpostor.BoxImpostor)r=this._getDebugBoxMesh(i),t.getBoxSizeToRef(r.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){r=this._getDebugSphereMesh(i);var n=t.getRadius();r.scaling.x=2*n,r.scaling.y=2*n,r.scaling.z=2*n}return r},t.prototype.dispose=function(){for(var e=0;e<this._numMeshes;e++)this.hideImpostor(this._impostors[e]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null},t}();t.PhysicsViewer=i}(e.Debug||(e.Debug={}))}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){this._forceShowBoundingBoxes=e,e&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),e.Scene.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new t(this)),this._boundingBoxRenderer},Object.defineProperty(e.AbstractMesh.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(e){this._showBoundingBox=e,e&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_BOUNDINGBOXRENDERER,this.frontColor=new e.Color3(1,1,1),this.backColor=new e.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new e.SmartArray(32),this._vertexBuffers={},this.scene=t,t._addComponent(this)}return t.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(e.SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._activeMeshStage.registerStep(e.SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER,this,this._activeMesh),this.scene._evaluateSubMeshStage.registerStep(e.SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},t.prototype._evaluateSubMesh=function(e,t){if(e.showSubMeshesBoundingBox){var i=t.getBoundingInfo();null!==i&&void 0!==i&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}},t.prototype._activeMesh=function(e,t){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var i=e.getBoundingInfo();i.boundingBox._tag=t.renderingGroupId,this.renderList.push(i.boundingBox)}},t.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new e.ShaderMaterial("colorShader",this.scene,"color",{attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection","color"]});var t=this.scene.getEngine(),i=e.VertexData.CreateBox({size:1});this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(t,i.positions,e.VertexBuffer.PositionKind,!1),this._createIndexBuffer()}},t.prototype._createIndexBuffer=function(){var e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},t.prototype.rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},t.prototype.reset=function(){this.renderList.reset()},t.prototype.render=function(t){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var i=this.scene.getEngine();i.setDepthWrite(!1),this._colorShader._preBind();for(var r=0;r<this.renderList.length;r++){var n=this.renderList.data[r];if(n._tag===t){var o=n.minimum,s=n.maximum.subtract(o),a=o.add(s.scale(.5)),l=e.Matrix.Scaling(s.x,s.y,s.z).multiply(e.Matrix.Translation(a.x,a.y,a.z)).multiply(n.getWorldMatrix());i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(i.setDepthFunctionToGreaterOrEqual(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(l),i.drawElementsType(e.Material.LineListDrawMode,0,24)),i.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(l),i.drawElementsType(e.Material.LineListDrawMode,0,24)}}this._colorShader.unbind(),i.setDepthFunctionToLessOrEqual(),i.setDepthWrite(!0)}},t.prototype.renderOcclusionBoundingBox=function(t){if(this._prepareRessources(),this._colorShader.isReady()&&t._boundingInfo){var i=this.scene.getEngine();i.setDepthWrite(!1),i.setColorWrite(!1),this._colorShader._preBind();var r=t._boundingInfo.boundingBox,n=r.minimum,o=r.maximum.subtract(n),s=n.add(o.scale(.5)),a=e.Matrix.Scaling(o.x,o.y,o.z).multiply(e.Matrix.Translation(s.x,s.y,s.z)).multiply(r.getWorldMatrix());i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),i.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.bind(a),i.drawElementsType(e.Material.LineListDrawMode,0,24),this._colorShader.unbind(),i.setDepthFunctionToLessOrEqual(),i.setDepthWrite(!0),i.setColorWrite(!0)}},t.prototype.dispose=function(){if(this._colorShader){this.renderList.dispose(),this._colorShader.dispose();var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer)}},t}();e.BoundingBoxRenderer=t}(a||(a={})),function(e){e.Engine.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},e.Engine.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},e.Engine.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},e.Engine.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},e.Engine.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},e.Engine.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},e.Engine.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e)}}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=!1);var a=t.call(this,i)||this;a.layerMask=268435455,a._accumulatedCount=0,a._targetIndex=0,a._currentRenderId=-1,a._started=!1,a._stopped=!1,a._timeDelta=0,a._attributesStrideSize=21,a._actualFrame=0,a._rawTextureWidth=256,a.onDisposeObservable=new e.Observable,a.forceDepthWrite=!1,a._preWarmDone=!1,a._scene=n||e.Engine.LastCreatedScene,a._attachImageProcessingConfiguration(null),a._engine=a._scene.getEngine(),r.randomTextureSize||delete r.randomTextureSize;var l=s({capacity:5e4,randomTextureSize:a._engine.getCaps().maxTextureSize},r),c=r;isFinite(c)&&(l.capacity=c),a._capacity=l.capacity,a._activeCount=l.capacity,a._currentActiveCount=0,a._isAnimationSheetEnabled=o,a._scene.particleSystems.push(a),a._updateEffectOptions={attributes:["position","age","life","seed","size","color","direction","initialDirection","angle","cellIndex","cellStartOffset","noiseCoordinates1","noiseCoordinates2"],uniformsNames:["currentCount","timeDelta","emitterWM","lifeTime","color1","color2","sizeRange","scaleRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","coneAngle","stopFactor","angleRange","radiusRange","cellInfos","noiseStrength","limitVelocityDamping"],uniformBuffersNames:[],samplers:["randomSampler","randomSampler2","sizeGradientSampler","angularSpeedGradientSampler","velocityGradientSampler","limitVelocityGradientSampler","noiseSampler","dragGradientSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]},a.particleEmitterType=new e.BoxParticleEmitter;for(var u=Math.min(a._engine.getCaps().maxTextureSize,l.randomTextureSize),h=[],d=0;d<u;++d)h.push(Math.random()),h.push(Math.random()),h.push(Math.random()),h.push(Math.random());a._randomTexture=new e.RawTexture(new Float32Array(h),u,1,e.Engine.TEXTUREFORMAT_RGBA,a._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE,e.Engine.TEXTURETYPE_FLOAT),a._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,a._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE,h=[];for(d=0;d<u;++d)h.push(Math.random()),h.push(Math.random()),h.push(Math.random()),h.push(Math.random());return a._randomTexture2=new e.RawTexture(new Float32Array(h),u,1,e.Engine.TEXTUREFORMAT_RGBA,a._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE,e.Engine.TEXTURETYPE_FLOAT),a._randomTexture2.wrapU=e.Texture.WRAP_ADDRESSMODE,a._randomTexture2.wrapV=e.Texture.WRAP_ADDRESSMODE,a._randomTextureSize=u,a}return o(i,t),Object.defineProperty(i,"IsSupported",{get:function(){return!!e.Engine.LastCreatedEngine&&e.Engine.LastCreatedEngine.webGLVersion>1},enumerable:!0,configurable:!0}),i.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(i.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!0,configurable:!0}),i.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._imageProcessingConfiguration.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";e?setTimeout(function(){t.start(0)},e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},i.prototype.stop=function(){this._stopped=!0},i.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},i.prototype.getClassName=function(){return"GPUParticleSystem"},i.prototype._removeGradientAndTexture=function(e,i,r){return t.prototype._removeGradientAndTexture.call(this,e,i,r),this._releaseBuffers(),this},i.prototype.addColorGradient=function(t,i,r){this._colorGradients||(this._colorGradients=[]);var n=new e.ColorGradient;return n.gradient=t,n.color1=i,this._colorGradients.push(n),this._colorGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},i.prototype._addFactorGradient=function(t,i,r){var n=new e.FactorGradient;n.gradient=i,n.factor1=r,t.push(n),t.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._releaseBuffers()},i.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},i.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},i.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},i.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},i.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._releaseBuffers(),this},i.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},i.prototype.addEmitRateGradient=function(e,t,i){return this},i.prototype.removeEmitRateGradient=function(e){return this},i.prototype.addStartSizeGradient=function(e,t,i){return this},i.prototype.removeStartSizeGradient=function(e){return this},i.prototype.addColorRemapGradient=function(e,t,i){return this},i.prototype.removeColorRemapGradient=function(e){return this},i.prototype.addAlphaRemapGradient=function(e,t,i){return this},i.prototype.removeAlphaRemapGradient=function(e){return this},i.prototype.addRampGradient=function(e,t){return this},i.prototype.removeRampGradient=function(e){return this},i.prototype.getRampGradients=function(){return null},Object.defineProperty(i.prototype,"useRampGradients",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0}),i.prototype.addLifeTimeGradient=function(e,t,i){return this},i.prototype.removeLifeTimeGradient=function(e){return this},i.prototype._reset=function(){this._releaseBuffers()},i.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3),t.age=e.createVertexBuffer("age",3,1),t.life=e.createVertexBuffer("life",4,1),t.seed=e.createVertexBuffer("seed",5,4),t.size=e.createVertexBuffer("size",9,3);var i=12;this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",i,4),i+=4),t.direction=e.createVertexBuffer("direction",i,3),i+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",i,3),i+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",i,1),i+=1):(t.angle=e.createVertexBuffer("angle",i,2),i+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",i,1),i+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1),i+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3),i+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3),i+=3);var r=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),r},i.prototype._createRenderVAO=function(t,i){var r={};r.position=t.createVertexBuffer("position",0,3,this._attributesStrideSize,!0),r.age=t.createVertexBuffer("age",3,1,this._attributesStrideSize,!0),r.life=t.createVertexBuffer("life",4,1,this._attributesStrideSize,!0),r.size=t.createVertexBuffer("size",9,3,this._attributesStrideSize,!0);var n=12;this._colorGradientsTexture||(r.color=t.createVertexBuffer("color",n,4,this._attributesStrideSize,!0),n+=4),this.billboardMode===e.ParticleSystem.BILLBOARDMODE_STRETCHED&&(r.direction=t.createVertexBuffer("direction",n,3,this._attributesStrideSize,!0)),n+=3,this._isBillboardBased||(r.initialDirection=t.createVertexBuffer("initialDirection",n,3,this._attributesStrideSize,!0),n+=3),r.angle=t.createVertexBuffer("angle",n,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?n++:n+=2,this._isAnimationSheetEnabled&&(r.cellIndex=t.createVertexBuffer("cellIndex",n,1,this._attributesStrideSize,!0),n+=1,this.spriteRandomStartCell&&(r.cellStartOffset=t.createVertexBuffer("cellStartOffset",n,1,this._attributesStrideSize,!0),n+=1)),this.noiseTexture&&(r.noiseCoordinates1=t.createVertexBuffer("noiseCoordinates1",n,3,this._attributesStrideSize,!0),n+=3,r.noiseCoordinates2=t.createVertexBuffer("noiseCoordinates2",n,3,this._attributesStrideSize,!0),n+=3),r.offset=i.createVertexBuffer("offset",0,2),r.uv=i.createVertexBuffer("uv",2,2);var o=this._engine.recordVertexArrayObject(r,null,this._renderEffect);return this._engine.bindArrayBuffer(null),o},i.prototype._initialize=function(t){if(void 0===t&&(t=!1),!this._buffer0||t){var i=this._scene.getEngine(),r=new Array;this.isBillboardBased||(this._attributesStrideSize+=3),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6);for(var 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(Math.random()),r.push(Math.random()),r.push(Math.random()),r.push(0),r.push(0),r.push(0),this._colorGradientsTexture||(r.push(0),r.push(0),r.push(0),r.push(0)),r.push(0),r.push(0),r.push(0),this.isBillboardBased||(r.push(0),r.push(0),r.push(0)),r.push(0),this._angularSpeedGradientsTexture||r.push(0),this._isAnimationSheetEnabled&&(r.push(0),this.spriteRandomStartCell&&r.push(0)),this.noiseTexture&&(r.push(Math.random()),r.push(Math.random()),r.push(Math.random()),r.push(Math.random()),r.push(Math.random()),r.push(Math.random()));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}},i.prototype._recreateUpdateEffect=function(){var t=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";this._isBillboardBased&&(t+="\n#define BILLBOARD"),this._colorGradientsTexture&&(t+="\n#define COLORGRADIENTS"),this._sizeGradientsTexture&&(t+="\n#define SIZEGRADIENTS"),this._angularSpeedGradientsTexture&&(t+="\n#define ANGULARSPEEDGRADIENTS"),this._velocityGradientsTexture&&(t+="\n#define VELOCITYGRADIENTS"),this._limitVelocityGradientsTexture&&(t+="\n#define LIMITVELOCITYGRADIENTS"),this._dragGradientsTexture&&(t+="\n#define DRAGGRADIENTS"),this.isAnimationSheetEnabled&&(t+="\n#define ANIMATESHEET",this.spriteRandomStartCell&&(t+="\n#define ANIMATESHEETRANDOMSTART")),this.noiseTexture&&(t+="\n#define NOISE"),this._updateEffect&&this._updateEffectOptions.defines===t||(this._updateEffectOptions.transformFeedbackVaryings=["outPosition","outAge","outLife","outSeed","outSize"],this._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.defines=t,this._updateEffect=new e.Effect("gpuUpdateParticles",this._updateEffectOptions,this._scene.getEngine()))},i.prototype._recreateRenderEffect=function(){var t="";if(this._scene.clipPlane&&(t="\n#define CLIPPLANE"),this._scene.clipPlane2&&(t="\n#define CLIPPLANE2"),this._scene.clipPlane3&&(t="\n#define CLIPPLANE3"),this._scene.clipPlane4&&(t="\n#define CLIPPLANE4"),this.blendMode===e.ParticleSystem.BLENDMODE_MULTIPLY&&(t="\n#define BLENDMULTIPLYMODE"),this._isBillboardBased)switch(t+="\n#define BILLBOARD",this.billboardMode){case e.ParticleSystem.BILLBOARDMODE_Y:t+="\n#define BILLBOARDY";break;case e.ParticleSystem.BILLBOARDMODE_STRETCHED:t+="\n#define BILLBOARDSTRETCHED";break;case e.ParticleSystem.BILLBOARDMODE_ALL:}if(this._colorGradientsTexture&&(t+="\n#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&(t+="\n#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),t+="\n"+this._imageProcessingConfigurationDefines.toString()),!this._renderEffect||this._renderEffect.defines!==t){var i=["view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","sheetInfos","translationPivot","eyePosition"],r=["textureSampler","colorGradientSampler"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareUniforms(i,this._imageProcessingConfigurationDefines),e.ImageProcessingConfiguration.PrepareSamplers(r,this._imageProcessingConfigurationDefines)),this._renderEffect=new e.Effect("gpuRenderParticles",["position","age","life","size","color","offset","uv","direction","initialDirection","angle","cellIndex"],i,r,this._scene.getEngine(),t)}},i.prototype.animate=function(e){void 0===e&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:this._scene.getAnimationRatio()),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()},i.prototype._createFactorGradientTexture=function(t,i){var r=this[i];if(t&&t.length&&!r){for(var n=new Float32Array(this._rawTextureWidth),o=0;o<this._rawTextureWidth;o++){var s=o/this._rawTextureWidth;e.Tools.GetCurrentGradient(s,t,function(t,i,r){n[o]=e.Scalar.Lerp(t.factor1,i.factor1,r)})}this[i]=e.RawTexture.CreateRTexture(n,this._rawTextureWidth,1,this._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}},i.prototype._createSizeGradientTexture=function(){this._createFactorGradientTexture(this._sizeGradients,"_sizeGradientsTexture")},i.prototype._createAngularSpeedGradientTexture=function(){this._createFactorGradientTexture(this._angularSpeedGradients,"_angularSpeedGradientsTexture")},i.prototype._createVelocityGradientTexture=function(){this._createFactorGradientTexture(this._velocityGradients,"_velocityGradientsTexture")},i.prototype._createLimitVelocityGradientTexture=function(){this._createFactorGradientTexture(this._limitVelocityGradients,"_limitVelocityGradientsTexture")},i.prototype._createDragGradientTexture=function(){this._createFactorGradientTexture(this._dragGradients,"_dragGradientsTexture")},i.prototype._createColorGradientTexture=function(){if(this._colorGradients&&this._colorGradients.length&&!this._colorGradientsTexture){for(var t=new Uint8Array(4*this._rawTextureWidth),i=e.Tmp.Color4[0],r=0;r<this._rawTextureWidth;r++){var n=r/this._rawTextureWidth;e.Tools.GetCurrentGradient(n,this._colorGradients,function(n,o,s){e.Color4.LerpToRef(n.color1,o.color1,s,i),t[4*r]=255*i.r,t[4*r+1]=255*i.g,t[4*r+2]=255*i.b,t[4*r+3]=255*i.a})}this._colorGradientsTexture=e.RawTexture.CreateRGBATexture(t,this._rawTextureWidth,1,this._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}},i.prototype.render=function(t){if(void 0===t&&(t=!1),!this._started)return 0;if(this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture(),this._recreateUpdateEffect(),this._recreateRenderEffect(),!this.isReady())return 0;if(!t){if(!this._preWarmDone&&this.preWarmCycles){for(var i=0;i<this.preWarmCycles;i++)this.animate(!0),this.render(!0);this._preWarmDone=!0}if(this._currentRenderId===this._scene.getRenderId())return 0;this._currentRenderId=this._scene.getRenderId()}if(this._initialize(),this._accumulatedCount+=this.emitRate*this._timeDelta,this._accumulatedCount>1){var r=0|this._accumulatedCount;this._accumulatedCount-=r,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+r)}if(!this._currentActiveCount)return 0;var n;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position){n=this.emitter.getWorldMatrix()}else{var o=this.emitter;n=e.Matrix.Translation(o.x,o.y,o.z)}if(this._updateEffect.setMatrix("emitterWM",n),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(e.Material.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!t){this._engine.enableEffect(this._renderEffect);var s=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",s),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var a=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/a.width,this.spriteCellHeight/a.height,a.width/this.spriteCellWidth)}if(this._isBillboardBased){var l=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",l.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var c=s.clone();c.invert(),this._renderEffect.setMatrix("invView",c),e.MaterialHelper.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case e.ParticleSystem.BLENDMODE_ADD:this._engine.setAlphaMode(e.Engine.ALPHA_ADD);break;case e.ParticleSystem.BLENDMODE_ONEONE:this._engine.setAlphaMode(e.Engine.ALPHA_ONEONE);break;case e.ParticleSystem.BLENDMODE_STANDARD:this._engine.setAlphaMode(e.Engine.ALPHA_COMBINE);break;case e.ParticleSystem.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(e.Engine.ALPHA_MULTIPLY)}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)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var u=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=u,this._currentActiveCount},i.prototype.rebuild=function(){this._initialize(!0)},i.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null)},i.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e<this._updateVAO.length;e++)this._engine.releaseVertexArrayObject(this._updateVAO[e]);this._updateVAO=[];for(e=0;e<this._renderVAO.length;e++)this._engine.releaseVertexArrayObject(this._renderVAO[e]);this._renderVAO=[]}},i.prototype.dispose=function(e){void 0===e&&(e=!0);var t=this._scene.particleSystems.indexOf(this);t>-1&&this._scene.particleSystems.splice(t,1),this._releaseBuffers(),this._releaseVAOs(),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=new i(t,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return e.Tools.DeepCopy(this,n),void 0===r&&(r=this.emitter),n.emitter=r,this.particleTexture&&(n.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),n},i.prototype.serialize=function(){var t={};return e.ParticleSystem._Serialize(t,this),t.activeParticleCount=this.activeParticleCount,t},i.Parse=function(t,r,n,o){void 0===o&&(o=!1);var s=new i(t.name,{capacity:t.capacity,randomTextureSize:t.randomTextureSize},r);return t.activeParticleCount&&(s.activeParticleCount=t.activeParticleCount),e.ParticleSystem._Parse(t,s,r,n),t.preventAutoStart&&(s.preventAutoStart=t.preventAutoStart),o||s.preventAutoStart||s.start(),s},i}(e.BaseParticleSystem);e.GPUParticleSystem=t}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o,s,a,l){void 0===l&&(l=null),this.idx=0,this.color=new e.Color4(1,1,1,1),this.position=e.Vector3.Zero(),this.rotation=e.Vector3.Zero(),this.scaling=e.Vector3.One(),this.uvs=new e.Vector4(0,0,1,1),this.velocity=e.Vector3.Zero(),this.pivot=e.Vector3.Zero(),this.translateFromPivot=!1,this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=e.Vector3.Zero(),this.idx=t,this._pos=i,this._ind=r,this._model=n,this.shapeId=o,this.idxInShape=s,this._sps=a,l&&(this._modelBoundingInfo=l,this._boundingInfo=new e.BoundingInfo(l.minimum,l.maximum))}return Object.defineProperty(t.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!0,configurable:!0}),t.prototype.intersectsMesh=function(t){return!(!this._boundingInfo||!t._boundingInfo)&&(this._sps._bSphereOnly?e.BoundingSphere.Intersects(this._boundingInfo.boundingSphere,t._boundingInfo.boundingSphere):this._boundingInfo.intersects(t._boundingInfo,!1))},t}();e.SolidParticle=t;var i=function(){return function(e,t,i,r,n,o){this._indicesLength=0,this.shapeID=e,this._shape=t,this._indicesLength=i,this._shapeUV=r,this._positionFunction=n,this._vertexFunction=o}}();e.ModelShape=i;var r=function(){return function(){this.ind=0,this.indicesLength=0,this.sqDistance=0}}();e.DepthSortedParticle=r}(a||(a={})),function(e){var t=function(){function t(t,i,r){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!0,this.counter=0,this.vars={},this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._shapeCounter=0,this._copy=new e.SolidParticle(0,0,0,null,0,0,this),this._color=new e.Color4(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._depthSortParticles=!0,this._cam_axisZ=e.Vector3.Zero(),this._cam_axisY=e.Vector3.Zero(),this._cam_axisX=e.Vector3.Zero(),this._axisZ=e.Axis.Z,this._camDir=e.Vector3.Zero(),this._camInvertedPosition=e.Vector3.Zero(),this._rotMatrix=new e.Matrix,this._invertMatrix=new e.Matrix,this._rotated=e.Vector3.Zero(),this._quaternion=new e.Quaternion,this._vertex=e.Vector3.Zero(),this._normal=e.Vector3.Zero(),this._yaw=0,this._pitch=0,this._roll=0,this._halfroll=0,this._halfpitch=0,this._halfyaw=0,this._sinRoll=0,this._cosRoll=0,this._sinPitch=0,this._cosPitch=0,this._sinYaw=0,this._cosYaw=0,this._mustUnrotateFixedNormals=!1,this._minimum=e.Vector3.Zero(),this._maximum=e.Vector3.Zero(),this._minBbox=e.Vector3.Zero(),this._maxBbox=e.Vector3.Zero(),this._particlesIntersect=!1,this._depthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},this._needs32Bits=!1,this._pivotBackTranslation=e.Vector3.Zero(),this._scaledPivot=e.Vector3.Zero(),this._particleHasParent=!1,this.name=t,this._scene=i||e.Engine.LastCreatedScene,this._camera=i.activeCamera,this._pickable=!!r&&r.isPickable,this._depthSort=!!r&&r.enableDepthSort,this._particlesIntersect=!!r&&r.particleIntersection,this._bSphereOnly=!!r&&r.boundingSphereOnly,this._bSphereRadiusFactor=r&&r.bSphereRadiusFactor?r.bSphereRadiusFactor:1,r&&void 0!==r.updatable?this._updatable=r.updatable:this._updatable=!0,this._pickable&&(this.pickedParticles=[]),this._depthSort&&(this.depthSortedParticles=[])}return t.prototype.buildMesh=function(){if(0===this.nbParticles){var t=e.MeshBuilder.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(t,1),t.dispose()}this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),this.recomputeNormals&&e.VertexData.ComputeNormals(this._positions32,this._indices32,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var i=new e.VertexData;i.indices=this._depthSort?this._indices:this._indices32,i.set(this._positions32,e.VertexBuffer.PositionKind),i.set(this._normals32,e.VertexBuffer.NormalKind),this._uvs32.length>0&&i.set(this._uvs32,e.VertexBuffer.UVKind),this._colors32.length>0&&i.set(this._colors32,e.VertexBuffer.ColorKind);var r=new e.Mesh(this.name,this._scene);return i.applyToMesh(r,this._updatable),this.mesh=r,this.mesh.isPickable=this._pickable,this._depthSort||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),r},t.prototype.digest=function(t,i){var r=i&&i.facetNb||1,n=i&&i.number||0,o=i&&i.delta||0,s=t.getVerticesData(e.VertexBuffer.PositionKind),a=t.getIndices(),l=t.getVerticesData(e.VertexBuffer.UVKind),c=t.getVerticesData(e.VertexBuffer.ColorKind),u=t.getVerticesData(e.VertexBuffer.NormalKind),h=0,d=a.length/3;n?(n=n>d?d:n,r=Math.round(d/n),o=0):r=r>d?d:r;for(var f=[],p=[],m=[],g=[],_=e.Vector3.Zero(),v=r;h<d;){h>d-(r=v+Math.floor((1+o)*Math.random()))&&(r=d-h),f.length=0,p.length=0,m.length=0,g.length=0;for(var A=0,y=3*h;y<3*(h+r);y++){p.push(A);var b=a[y];f.push(s[3*b],s[3*b+1],s[3*b+2]),l&&m.push(l[2*b],l[2*b+1]),c&&g.push(c[4*b],c[4*b+1],c[4*b+2],c[4*b+3]),A++}var T,E,x=this.nbParticles,P=this._posToShape(f),M=this._uvsToShapeUV(m);for(T=0;T<P.length;T++)_.addInPlace(P[T]);for(_.scaleInPlace(1/P.length),T=0;T<P.length;T++)P[T].subtractInPlace(_);this._particlesIntersect&&(E=new e.BoundingInfo(_,_));var S=new e.ModelShape(this._shapeCounter,P,3*r,M,null,null),C=this._positions.length,R=this._indices.length;this._meshBuilder(this._index,P,this._positions,p,this._indices,m,this._uvs,g,this._colors,u,this._normals,x,0,null),this._addParticle(x,C,R,S,this._shapeCounter,0,E),this.particles[this.nbParticles].position.addInPlace(_),this._index+=P.length,x++,this.nbParticles++,this._shapeCounter++,h+=r}return this},t.prototype._unrotateFixedNormals=function(){for(var t=0,i=0,r=0;r<this.particles.length;r++){this._particle=this.particles[r],this._shape=this._particle._model._shape,this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._rotMatrix.invertToRef(this._invertMatrix);for(var n=0;n<this._shape.length;n++)i=t+3*n,e.Vector3.TransformNormalFromFloatsToRef(this._normals32[i],this._normals32[i+1],this._normals32[i+2],this._invertMatrix,this._normal),this._fixedNormal32[i]=this._normal.x,this._fixedNormal32[i+1]=this._normal.y,this._fixedNormal32[i+2]=this._normal.z;t=i+3}},t.prototype._resetCopy=function(){this._copy.position.x=0,this._copy.position.y=0,this._copy.position.z=0,this._copy.rotation.x=0,this._copy.rotation.y=0,this._copy.rotation.z=0,this._copy.rotationQuaternion=null,this._copy.scaling.x=1,this._copy.scaling.y=1,this._copy.scaling.z=1,this._copy.uvs.x=0,this._copy.uvs.y=0,this._copy.uvs.z=1,this._copy.uvs.w=1,this._copy.color=null,this._copy.translateFromPivot=!1},t.prototype._meshBuilder=function(t,i,r,n,o,s,a,l,c,u,h,d,f,p){var m,g=0,_=0,v=0;for(this._resetCopy(),p&&p.positionFunction&&(p.positionFunction(this._copy,d,f),this._mustUnrotateFixedNormals=!0),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._scaledPivot.x=this._copy.pivot.x*this._copy.scaling.x,this._scaledPivot.y=this._copy.pivot.y*this._copy.scaling.y,this._scaledPivot.z=this._copy.pivot.z*this._copy.scaling.z,this._copy.translateFromPivot?this._pivotBackTranslation.copyFromFloats(0,0,0):this._pivotBackTranslation.copyFrom(this._scaledPivot),m=0;m<i.length;m++)this._vertex.x=i[m].x,this._vertex.y=i[m].y,this._vertex.z=i[m].z,p&&p.vertexFunction&&p.vertexFunction(this._copy,this._vertex,m),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,e.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),this._rotated.addInPlace(this._pivotBackTranslation),r.push(this._copy.position.x+this._rotated.x,this._copy.position.y+this._rotated.y,this._copy.position.z+this._rotated.z),s&&(a.push((this._copy.uvs.z-this._copy.uvs.x)*s[g]+this._copy.uvs.x,(this._copy.uvs.w-this._copy.uvs.y)*s[g+1]+this._copy.uvs.y),g+=2),this._copy.color?this._color=this._copy.color:l&&void 0!==l[_]?(this._color.r=l[_],this._color.g=l[_+1],this._color.b=l[_+2],this._color.a=l[_+3]):(this._color.r=1,this._color.g=1,this._color.b=1,this._color.a=1),c.push(this._color.r,this._color.g,this._color.b,this._color.a),_+=4,!this.recomputeNormals&&u&&(this._normal.x=u[v],this._normal.y=u[v+1],this._normal.z=u[v+2],e.Vector3.TransformNormalToRef(this._normal,this._rotMatrix,this._normal),h.push(this._normal.x,this._normal.y,this._normal.z),v+=3);for(m=0;m<n.length;m++){var A=t+n[m];o.push(A),A>65535&&(this._needs32Bits=!0)}if(this._pickable){var y=n.length/3;for(m=0;m<y;m++)this.pickedParticles.push({idx:d,faceId:m})}return this._depthSort&&this.depthSortedParticles.push(new e.DepthSortedParticle),this._copy},t.prototype._posToShape=function(t){for(var i=[],r=0;r<t.length;r+=3)i.push(new e.Vector3(t[r],t[r+1],t[r+2]));return i},t.prototype._uvsToShapeUV=function(e){var t=[];if(e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},t.prototype._addParticle=function(t,i,r,n,o,s,a){void 0===a&&(a=null);var l=new e.SolidParticle(t,i,r,n,o,s,this,a);return this.particles.push(l),l},t.prototype.addShape=function(t,i,r){var n,o=t.getVerticesData(e.VertexBuffer.PositionKind),s=t.getIndices(),a=t.getVerticesData(e.VertexBuffer.UVKind),l=t.getVerticesData(e.VertexBuffer.ColorKind),c=t.getVerticesData(e.VertexBuffer.NormalKind);this._particlesIntersect&&(n=t.getBoundingInfo());for(var u,h,d=this._posToShape(o),f=this._uvsToShapeUV(a),p=r?r.positionFunction:null,m=r?r.vertexFunction:null,g=new e.ModelShape(this._shapeCounter,d,s.length,f,p,m),_=this.nbParticles,v=0;v<i;v++){var A=this._positions.length,y=this._indices.length;h=this._meshBuilder(this._index,d,this._positions,s,this._indices,a,this._uvs,l,this._colors,c,this._normals,_,v,r),this._updatable&&((u=this._addParticle(_,A,y,g,this._shapeCounter,v,n)).position.copyFrom(h.position),u.rotation.copyFrom(h.rotation),h.rotationQuaternion&&u.rotationQuaternion&&u.rotationQuaternion.copyFrom(h.rotationQuaternion),h.color&&u.color&&u.color.copyFrom(h.color),u.scaling.copyFrom(h.scaling),u.uvs.copyFrom(h.uvs)),this._index+=d.length,_++}return this.nbParticles+=i,this._shapeCounter++,this._shapeCounter-1},t.prototype._rebuildParticle=function(t){this._resetCopy(),t._model._positionFunction&&t._model._positionFunction(this._copy,t.idx,t.idxInShape),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._scaledPivot.x=this._particle.pivot.x*this._particle.scaling.x,this._scaledPivot.y=this._particle.pivot.y*this._particle.scaling.y,this._scaledPivot.z=this._particle.pivot.z*this._particle.scaling.z,this._copy.translateFromPivot?this._pivotBackTranslation.copyFromFloats(0,0,0):this._pivotBackTranslation.copyFrom(this._scaledPivot),this._shape=t._model._shape;for(var i=0;i<this._shape.length;i++)this._vertex.x=this._shape[i].x,this._vertex.y=this._shape[i].y,this._vertex.z=this._shape[i].z,t._model._vertexFunction&&t._model._vertexFunction(this._copy,this._vertex,i),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,e.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),this._rotated.addInPlace(this._pivotBackTranslation),this._positions32[t._pos+3*i]=this._copy.position.x+this._rotated.x,this._positions32[t._pos+3*i+1]=this._copy.position.y+this._rotated.y,this._positions32[t._pos+3*i+2]=this._copy.position.z+this._rotated.z;t.position.x=0,t.position.y=0,t.position.z=0,t.rotation.x=0,t.rotation.y=0,t.rotation.z=0,t.rotationQuaternion=null,t.scaling.x=1,t.scaling.y=1,t.scaling.z=1,t.uvs.x=0,t.uvs.y=0,t.uvs.z=1,t.uvs.w=1,t.pivot.x=0,t.pivot.y=0,t.pivot.z=0,t.translateFromPivot=!1,t.parentId=null},t.prototype.rebuildMesh=function(){for(var t=0;t<this.particles.length;t++)this._rebuildParticle(this.particles[t]);return this.mesh.updateVerticesData(e.VertexBuffer.PositionKind,this._positions32,!1,!1),this},t.prototype.setParticles=function(t,i,r){if(void 0===t&&(t=0),void 0===i&&(i=this.nbParticles-1),void 0===r&&(r=!0),!this._updatable)return this;if(this.beforeUpdateParticles(t,i,r),this._cam_axisX.x=1,this._cam_axisX.y=0,this._cam_axisX.z=0,this._cam_axisY.x=0,this._cam_axisY.y=1,this._cam_axisY.z=0,this._cam_axisZ.x=0,this._cam_axisZ.y=0,this._cam_axisZ.z=1,(this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(this._invertMatrix)),this.billboard){this._camera.getDirectionToRef(this._axisZ,this._camDir),e.Vector3.TransformNormalToRef(this._camDir,this._invertMatrix,this._cam_axisZ),this._cam_axisZ.normalize();var n=this._camera.getViewMatrix(!0);e.Vector3.TransformNormalFromFloatsToRef(n.m[1],n.m[5],n.m[9],this._invertMatrix,this._cam_axisY),e.Vector3.CrossToRef(this._cam_axisY,this._cam_axisZ,this._cam_axisX),this._cam_axisY.normalize(),this._cam_axisX.normalize()}this._depthSort&&e.Vector3.TransformCoordinatesToRef(this._camera.globalPosition,this._invertMatrix,this._camInvertedPosition),e.Matrix.IdentityToRef(this._rotMatrix);var o=0,s=0,a=0,l=0,c=0,u=0,h=0;this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),i=i>=this.nbParticles?this.nbParticles-1:i,this._computeBoundingBox&&(0==t&&i==this.nbParticles-1?(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):this.mesh._boundingInfo&&(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum)));var d=(s=this.particles[t]._pos)/3|0;l=4*d,u=2*d;for(var f=t;f<=i;f++){if(this._particle=this.particles[f],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._depthSort&&this._depthSortParticles){var p=this.depthSortedParticles[f];p.ind=this._particle._ind,p.indicesLength=this._particle._model._indicesLength,p.sqDistance=e.Vector3.DistanceSquared(this._particle.position,this._camInvertedPosition)}if(!this._particle.alive||this._particle._stillInvisible&&!this._particle.isVisible)s+=3*(h=this._shape.length),l+=4*h,u+=2*h;else{if(this._particle.isVisible)for(this._particle._stillInvisible=!1,this._particleHasParent=null!==this._particle.parentId,this._scaledPivot.x=this._particle.pivot.x*this._particle.scaling.x,this._scaledPivot.y=this._particle.pivot.y*this._particle.scaling.y,this._scaledPivot.z=this._particle.pivot.z*this._particle.scaling.z,this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),this._particleHasParent?(this._parent=this.particles[this._particle.parentId],this._rotated.x=this._particle.position.x*this._parent._rotationMatrix[0]+this._particle.position.y*this._parent._rotationMatrix[3]+this._particle.position.z*this._parent._rotationMatrix[6],this._rotated.y=this._particle.position.x*this._parent._rotationMatrix[1]+this._particle.position.y*this._parent._rotationMatrix[4]+this._particle.position.z*this._parent._rotationMatrix[7],this._rotated.z=this._particle.position.x*this._parent._rotationMatrix[2]+this._particle.position.y*this._parent._rotationMatrix[5]+this._particle.position.z*this._parent._rotationMatrix[8],this._particle._globalPosition.x=this._parent._globalPosition.x+this._rotated.x,this._particle._globalPosition.y=this._parent._globalPosition.y+this._rotated.y,this._particle._globalPosition.z=this._parent._globalPosition.z+this._rotated.z,(this._computeParticleRotation||this.billboard)&&(this._particle._rotationMatrix[0]=this._rotMatrix.m[0]*this._parent._rotationMatrix[0]+this._rotMatrix.m[1]*this._parent._rotationMatrix[3]+this._rotMatrix.m[2]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[1]=this._rotMatrix.m[0]*this._parent._rotationMatrix[1]+this._rotMatrix.m[1]*this._parent._rotationMatrix[4]+this._rotMatrix.m[2]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[2]=this._rotMatrix.m[0]*this._parent._rotationMatrix[2]+this._rotMatrix.m[1]*this._parent._rotationMatrix[5]+this._rotMatrix.m[2]*this._parent._rotationMatrix[8],this._particle._rotationMatrix[3]=this._rotMatrix.m[4]*this._parent._rotationMatrix[0]+this._rotMatrix.m[5]*this._parent._rotationMatrix[3]+this._rotMatrix.m[6]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[4]=this._rotMatrix.m[4]*this._parent._rotationMatrix[1]+this._rotMatrix.m[5]*this._parent._rotationMatrix[4]+this._rotMatrix.m[6]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[5]=this._rotMatrix.m[4]*this._parent._rotationMatrix[2]+this._rotMatrix.m[5]*this._parent._rotationMatrix[5]+this._rotMatrix.m[6]*this._parent._rotationMatrix[8],this._particle._rotationMatrix[6]=this._rotMatrix.m[8]*this._parent._rotationMatrix[0]+this._rotMatrix.m[9]*this._parent._rotationMatrix[3]+this._rotMatrix.m[10]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[7]=this._rotMatrix.m[8]*this._parent._rotationMatrix[1]+this._rotMatrix.m[9]*this._parent._rotationMatrix[4]+this._rotMatrix.m[10]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[8]=this._rotMatrix.m[8]*this._parent._rotationMatrix[2]+this._rotMatrix.m[9]*this._parent._rotationMatrix[5]+this._rotMatrix.m[10]*this._parent._rotationMatrix[8])):(this._particle._globalPosition.x=this._particle.position.x,this._particle._globalPosition.y=this._particle.position.y,this._particle._globalPosition.z=this._particle.position.z,(this._computeParticleRotation||this.billboard)&&(this._particle._rotationMatrix[0]=this._rotMatrix.m[0],this._particle._rotationMatrix[1]=this._rotMatrix.m[1],this._particle._rotationMatrix[2]=this._rotMatrix.m[2],this._particle._rotationMatrix[3]=this._rotMatrix.m[4],this._particle._rotationMatrix[4]=this._rotMatrix.m[5],this._particle._rotationMatrix[5]=this._rotMatrix.m[6],this._particle._rotationMatrix[6]=this._rotMatrix.m[8],this._particle._rotationMatrix[7]=this._rotMatrix.m[9],this._particle._rotationMatrix[8]=this._rotMatrix.m[10])),this._particle.translateFromPivot?(this._pivotBackTranslation.x=0,this._pivotBackTranslation.y=0,this._pivotBackTranslation.z=0):(this._pivotBackTranslation.x=this._scaledPivot.x,this._pivotBackTranslation.y=this._scaledPivot.y,this._pivotBackTranslation.z=this._scaledPivot.z),h=0;h<this._shape.length;h++)o=s+3*h,a=l+4*h,c=u+2*h,this._vertex.x=this._shape[h].x,this._vertex.y=this._shape[h].y,this._vertex.z=this._shape[h].z,this._computeParticleVertex&&this.updateParticleVertex(this._particle,this._vertex,h),this._vertex.x*=this._particle.scaling.x,this._vertex.y*=this._particle.scaling.y,this._vertex.z*=this._particle.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,this._rotated.x=this._vertex.x*this._particle._rotationMatrix[0]+this._vertex.y*this._particle._rotationMatrix[3]+this._vertex.z*this._particle._rotationMatrix[6],this._rotated.y=this._vertex.x*this._particle._rotationMatrix[1]+this._vertex.y*this._particle._rotationMatrix[4]+this._vertex.z*this._particle._rotationMatrix[7],this._rotated.z=this._vertex.x*this._particle._rotationMatrix[2]+this._vertex.y*this._particle._rotationMatrix[5]+this._vertex.z*this._particle._rotationMatrix[8],this._rotated.x+=this._pivotBackTranslation.x,this._rotated.y+=this._pivotBackTranslation.y,this._rotated.z+=this._pivotBackTranslation.z,this._positions32[o]=this._particle._globalPosition.x+this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._positions32[o+1]=this._particle._globalPosition.y+this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._positions32[o+2]=this._particle._globalPosition.z+this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z,this._computeBoundingBox&&(this._positions32[o]<this._minimum.x&&(this._minimum.x=this._positions32[o]),this._positions32[o]>this._maximum.x&&(this._maximum.x=this._positions32[o]),this._positions32[o+1]<this._minimum.y&&(this._minimum.y=this._positions32[o+1]),this._positions32[o+1]>this._maximum.y&&(this._maximum.y=this._positions32[o+1]),this._positions32[o+2]<this._minimum.z&&(this._minimum.z=this._positions32[o+2]),this._positions32[o+2]>this._maximum.z&&(this._maximum.z=this._positions32[o+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[o],this._normal.y=this._fixedNormal32[o+1],this._normal.z=this._fixedNormal32[o+2],this._rotated.x=this._normal.x*this._particle._rotationMatrix[0]+this._normal.y*this._particle._rotationMatrix[3]+this._normal.z*this._particle._rotationMatrix[6],this._rotated.y=this._normal.x*this._particle._rotationMatrix[1]+this._normal.y*this._particle._rotationMatrix[4]+this._normal.z*this._particle._rotationMatrix[7],this._rotated.z=this._normal.x*this._particle._rotationMatrix[2]+this._normal.y*this._particle._rotationMatrix[5]+this._normal.z*this._particle._rotationMatrix[8],this._normals32[o]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[o+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[o+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&this._particle.color&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[c]=this._shapeUV[2*h]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[c+1]=this._shapeUV[2*h+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(this._particle._stillInvisible=!0,h=0;h<this._shape.length;h++)o=s+3*h,a=l+4*h,c=u+2*h,this._positions32[o]=0,this._positions32[o+1]=0,this._positions32[o+2]=0,this._normals32[o]=0,this._normals32[o+1]=0,this._normals32[o+2]=0,this._computeParticleColor&&this._particle.color&&(this._colors32[a]=this._particle.color.r,this._colors32[a+1]=this._particle.color.g,this._colors32[a+2]=this._particle.color.b,this._colors32[a+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[c]=this._shapeUV[2*h]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[c+1]=this._shapeUV[2*h+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);if(this._particlesIntersect){var m=this._particle._boundingInfo,g=m.boundingBox,_=m.boundingSphere;if(!this._bSphereOnly){for(var v=0;v<g.vectors.length;v++)this._vertex.x=this._particle._modelBoundingInfo.boundingBox.vectors[v].x*this._particle.scaling.x,this._vertex.y=this._particle._modelBoundingInfo.boundingBox.vectors[v].y*this._particle.scaling.y,this._vertex.z=this._particle._modelBoundingInfo.boundingBox.vectors[v].z*this._particle.scaling.z,this._rotated.x=this._vertex.x*this._particle._rotationMatrix[0]+this._vertex.y*this._particle._rotationMatrix[3]+this._vertex.z*this._particle._rotationMatrix[6],this._rotated.y=this._vertex.x*this._particle._rotationMatrix[1]+this._vertex.y*this._particle._rotationMatrix[4]+this._vertex.z*this._particle._rotationMatrix[7],this._rotated.z=this._vertex.x*this._particle._rotationMatrix[2]+this._vertex.y*this._particle._rotationMatrix[5]+this._vertex.z*this._particle._rotationMatrix[8],g.vectors[v].x=this._particle.position.x+this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,g.vectors[v].y=this._particle.position.y+this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,g.vectors[v].z=this._particle.position.z+this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z;g._update(this.mesh._worldMatrix)}this._minBbox.x=this._particle._modelBoundingInfo.minimum.x*this._particle.scaling.x,this._minBbox.y=this._particle._modelBoundingInfo.minimum.y*this._particle.scaling.y,this._minBbox.z=this._particle._modelBoundingInfo.minimum.z*this._particle.scaling.z,this._maxBbox.x=this._particle._modelBoundingInfo.maximum.x*this._particle.scaling.x,this._maxBbox.y=this._particle._modelBoundingInfo.maximum.y*this._particle.scaling.y,this._maxBbox.z=this._particle._modelBoundingInfo.maximum.z*this._particle.scaling.z,_.center.x=this._particle._globalPosition.x+.5*(this._minBbox.x+this._maxBbox.x),_.center.y=this._particle._globalPosition.y+.5*(this._minBbox.y+this._maxBbox.y),_.center.z=this._particle._globalPosition.z+.5*(this._minBbox.z+this._maxBbox.z),_.radius=.5*this._bSphereRadiusFactor*Math.sqrt((this._maxBbox.x-this._minBbox.x)*(this._maxBbox.x-this._minBbox.x)+(this._maxBbox.y-this._minBbox.y)*(this._maxBbox.y-this._minBbox.y)+(this._maxBbox.z-this._minBbox.z)*(this._maxBbox.z-this._minBbox.z)),_._update(this.mesh._worldMatrix)}s=o+3,l=a+4,u=c+2}}if(r){if(this._computeParticleColor&&this.mesh.updateVerticesData(e.VertexBuffer.ColorKind,this._colors32,!1,!1),this._computeParticleTexture&&this.mesh.updateVerticesData(e.VertexBuffer.UVKind,this._uvs32,!1,!1),this.mesh.updateVerticesData(e.VertexBuffer.PositionKind,this._positions32,!1,!1),!this.mesh.areNormalsFrozen||this.mesh.isFacetDataEnabled){if(this._computeParticleVertex||this.mesh.isFacetDataEnabled){var A=this.mesh.isFacetDataEnabled?this.mesh.getFacetDataParameters():null;e.VertexData.ComputeNormals(this._positions32,this._indices32,this._normals32,A);for(var y=0;y<this._normals32.length;y++)this._fixedNormal32[y]=this._normals32[y]}this.mesh.areNormalsFrozen||this.mesh.updateVerticesData(e.VertexBuffer.NormalKind,this._normals32,!1,!1)}if(this._depthSort&&this._depthSortParticles){this.depthSortedParticles.sort(this._depthSortFunction);var b=this.depthSortedParticles.length,T=0,E=0,x=0,P=0;for(T=0;T<b;T++){E=this.depthSortedParticles[T].indicesLength,x=this.depthSortedParticles[T].ind;for(y=0;y<E;y++)this._indices32[P]=this._indices[x+y],P++}this.mesh.updateIndices(this._indices32)}}return this._computeBoundingBox&&(this.mesh._boundingInfo=new e.BoundingInfo(this._minimum,this._maximum),this.mesh._boundingInfo.update(this.mesh._worldMatrix)),this.afterUpdateParticles(t,i,r),this},t.prototype._quaternionRotationYPR=function(){this._halfroll=.5*this._roll,this._halfpitch=.5*this._pitch,this._halfyaw=.5*this._yaw,this._sinRoll=Math.sin(this._halfroll),this._cosRoll=Math.cos(this._halfroll),this._sinPitch=Math.sin(this._halfpitch),this._cosPitch=Math.cos(this._halfpitch),this._sinYaw=Math.sin(this._halfyaw),this._cosYaw=Math.cos(this._halfyaw),this._quaternion.x=this._cosYaw*this._sinPitch*this._cosRoll+this._sinYaw*this._cosPitch*this._sinRoll,this._quaternion.y=this._sinYaw*this._cosPitch*this._cosRoll-this._cosYaw*this._sinPitch*this._sinRoll,this._quaternion.z=this._cosYaw*this._cosPitch*this._sinRoll-this._sinYaw*this._sinPitch*this._cosRoll,this._quaternion.w=this._cosYaw*this._cosPitch*this._cosRoll+this._sinYaw*this._sinPitch*this._sinRoll},t.prototype._quaternionToRotationMatrix=function(){this._rotMatrix.m[0]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.z*this._quaternion.z),this._rotMatrix.m[1]=2*(this._quaternion.x*this._quaternion.y+this._quaternion.z*this._quaternion.w),this._rotMatrix.m[2]=2*(this._quaternion.z*this._quaternion.x-this._quaternion.y*this._quaternion.w),this._rotMatrix.m[3]=0,this._rotMatrix.m[4]=2*(this._quaternion.x*this._quaternion.y-this._quaternion.z*this._quaternion.w),this._rotMatrix.m[5]=1-2*(this._quaternion.z*this._quaternion.z+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[6]=2*(this._quaternion.y*this._quaternion.z+this._quaternion.x*this._quaternion.w),this._rotMatrix.m[7]=0,this._rotMatrix.m[8]=2*(this._quaternion.z*this._quaternion.x+this._quaternion.y*this._quaternion.w),this._rotMatrix.m[9]=2*(this._quaternion.y*this._quaternion.z-this._quaternion.x*this._quaternion.w),this._rotMatrix.m[10]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[11]=0,this._rotMatrix.m[12]=0,this._rotMatrix.m[13]=0,this._rotMatrix.m[14]=0,this._rotMatrix.m[15]=1},t.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null},t.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},t.prototype.setVisibilityBox=function(t){var i=t/2;this.mesh._boundingInfo=new e.BoundingInfo(new e.Vector3(-i,-i,-i),new e.Vector3(i,i,i))},Object.defineProperty(t.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(e){this._isVisibilityBoxLocked=e,this.mesh.getBoundingInfo().isLocked=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(e){this._computeParticleVertex=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(e){this._depthSortParticles=e},enumerable:!0,configurable:!0}),t.prototype.initParticles=function(){},t.prototype.recycleParticle=function(e){return e},t.prototype.updateParticle=function(e){return e},t.prototype.updateParticleVertex=function(e,t,i){return t},t.prototype.beforeUpdateParticles=function(e,t,i){},t.prototype.afterUpdateParticles=function(e,t,i){},t}();e.SolidParticleSystem=t}(a||(a={})),function(e){var t=function(){function t(){}return t.updateSideOrientation=function(t){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(i,r,n){void 0===n&&(n=null);var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateBox(r).applyToMesh(o,r.updatable),o},t.CreateSphere=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateSphere(r).applyToMesh(o,r.updatable),o},t.CreateDisc=function(i,r,n){void 0===n&&(n=null);var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateDisc(r).applyToMesh(o,r.updatable),o},t.CreateIcoSphere=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateIcoSphere(r).applyToMesh(o,r.updatable),o},t.CreateRibbon=function(i,r,n){void 0===n&&(n=null);var o=r.pathArray,s=r.closeArray,a=r.closePath,l=t.updateSideOrientation(r.sideOrientation),c=r.instance,u=r.updatable;if(c){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var h=c.getVerticesData(e.VertexBuffer.PositionKind);if(function(t){for(var i=o[0].length,r=c,n=0,s=r._originalBuilderSideOrientation===e.Mesh.DOUBLESIDE?2:1,a=1;a<=s;a++)for(var l=0;l<o.length;l++){var u=o[l],h=u.length;i=i<h?i:h;for(var d=0;d<i;)t[n]=u[d].x,t[n+1]=u[d].y,t[n+2]=u[d].z,u[d].x<e.Tmp.Vector3[0].x&&(e.Tmp.Vector3[0].x=u[d].x),u[d].x>e.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=u[d].x),u[d].y<e.Tmp.Vector3[0].y&&(e.Tmp.Vector3[0].y=u[d].y),u[d].y>e.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=u[d].y),u[d].z<e.Tmp.Vector3[0].z&&(e.Tmp.Vector3[0].z=u[d].z),u[d].z>e.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=u[d].z),d++,n+=3;r._creationDataStorage&&r._creationDataStorage.closePath&&(t[n]=u[0].x,t[n+1]=u[0].y,t[n+2]=u[0].z,n+=3)}}(h),c._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[2],e.Tmp.Vector3[3]),c._boundingInfo.update(c._worldMatrix),c.updateVerticesData(e.VertexBuffer.PositionKind,h,!1,!1),r.colors){for(var d=c.getVerticesData(e.VertexBuffer.ColorKind),f=0;f<r.colors.length;f++)d[4*f]=r.colors[f].r,d[4*f+1]=r.colors[f].g,d[4*f+2]=r.colors[f].b,d[4*f+3]=r.colors[f].a;c.updateVerticesData(e.VertexBuffer.ColorKind,d,!1,!1)}if(r.uvs){for(var p=c.getVerticesData(e.VertexBuffer.UVKind),m=0;m<r.uvs.length;m++)p[2*m]=r.uvs[m].x,p[2*m+1]=r.uvs[m].y;c.updateVerticesData(e.VertexBuffer.UVKind,p,!1,!1)}if(!c.areNormalsFrozen||c.isFacetDataEnabled){var g=c.getIndices(),_=c.getVerticesData(e.VertexBuffer.NormalKind),v=c.isFacetDataEnabled?c.getFacetDataParameters():null;if(e.VertexData.ComputeNormals(h,g,_,v),c._creationDataStorage&&c._creationDataStorage.closePath)for(var A=0,y=0,b=0;b<o.length;b++)A=3*c._creationDataStorage.idx[b],y=b+1<o.length?3*(c._creationDataStorage.idx[b+1]-1):_.length-3,_[A]=.5*(_[A]+_[y]),_[A+1]=.5*(_[A+1]+_[y+1]),_[A+2]=.5*(_[A+2]+_[y+2]),_[y]=_[A],_[y+1]=_[A+1],_[y+2]=_[A+2];c.areNormalsFrozen||c.updateVerticesData(e.VertexBuffer.NormalKind,_,!1,!1)}return c}var T=new e.Mesh(i,n);T._originalBuilderSideOrientation=l,T._creationDataStorage=new e._CreationDataStorage;var E=e.VertexData.CreateRibbon(r);return a&&(T._creationDataStorage.idx=E._idx),T._creationDataStorage.closePath=a,T._creationDataStorage.closeArray=s,E.applyToMesh(T,u),T},t.CreateCylinder=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateCylinder(r).applyToMesh(o,r.updatable),o},t.CreateTorus=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateTorus(r).applyToMesh(o,r.updatable),o},t.CreateTorusKnot=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreateTorusKnot(r).applyToMesh(o,r.updatable),o},t.CreateLineSystem=function(t,i,r){var n=i.instance,o=i.lines,s=i.colors;if(n){var a,l,c=n.getVerticesData(e.VertexBuffer.PositionKind);s&&(a=n.getVerticesData(e.VertexBuffer.ColorKind));for(var u=0,h=0,d=0;d<o.length;d++)for(var f=o[d],p=0;p<f.length;p++)c[u]=f[p].x,c[u+1]=f[p].y,c[u+2]=f[p].z,s&&a&&(l=s[d],a[h]=l[p].r,a[h+1]=l[p].g,a[h+2]=l[p].b,a[h+3]=l[p].a,h+=4),u+=3;return n.updateVerticesData(e.VertexBuffer.PositionKind,c,!1,!1),s&&a&&n.updateVerticesData(e.VertexBuffer.ColorKind,a,!1,!1),n}var m=!!s,g=new e.LinesMesh(t,r,null,void 0,void 0,m,i.useVertexAlpha);return e.VertexData.CreateLineSystem(i).applyToMesh(g,i.updatable),g},t.CreateLines=function(e,i,r){void 0===r&&(r=null);var n=i.colors?[i.colors]:null;return t.CreateLineSystem(e,{lines:[i.points],updatable:i.updatable,instance:i.instance,colors:n,useVertexAlpha:i.useVertexAlpha},r)},t.CreateDashedLines=function(t,i,r){void 0===r&&(r=null);var n=i.points,o=i.instance,s=i.gapSize||1,a=i.dashSize||3;if(o){return o.updateMeshPositions(function(t){var i,r,s=e.Vector3.Zero(),a=t.length/6,l=0,c=0,u=0,h=0,d=0,f=0;for(d=0;d<n.length-1;d++)n[d+1].subtractToRef(n[d],s),l+=s.length();i=l/a;var p=o._creationDataStorage.dashSize;for(r=p*i/(p+o._creationDataStorage.gapSize),d=0;d<n.length-1;d++)for(n[d+1].subtractToRef(n[d],s),c=Math.floor(s.length()/i),s.normalize(),f=0;f<c&&h<t.length;)u=i*f,t[h]=n[d].x+u*s.x,t[h+1]=n[d].y+u*s.y,t[h+2]=n[d].z+u*s.z,t[h+3]=n[d].x+(u+r)*s.x,t[h+4]=n[d].y+(u+r)*s.y,t[h+5]=n[d].z+(u+r)*s.z,h+=6,f++;for(;h<t.length;)t[h]=n[d].x,t[h+1]=n[d].y,t[h+2]=n[d].z,h+=3},!1),o}var l=new e.LinesMesh(t,r);return e.VertexData.CreateDashedLines(i).applyToMesh(l,i.updatable),l._creationDataStorage=new e._CreationDataStorage,l._creationDataStorage.dashSize=a,l._creationDataStorage.gapSize=s,l},t.ExtrudeShape=function(i,r,n){void 0===n&&(n=null);var o=r.path,s=r.shape,a=r.scale||1,l=r.rotation||0,c=0===r.cap?0:r.cap||e.Mesh.NO_CAP,u=r.updatable,h=t.updateSideOrientation(r.sideOrientation),d=r.instance||null,f=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,s,o,a,l,null,null,!1,!1,c,!1,n,!!u,h,d,f,r.frontUVs||null,r.backUVs||null)},t.ExtrudeShapeCustom=function(i,r,n){var o=r.path,s=r.shape,a=r.scaleFunction||function(){return 1},l=r.rotationFunction||function(){return 0},c=r.ribbonCloseArray||!1,u=r.ribbonClosePath||!1,h=0===r.cap?0:r.cap||e.Mesh.NO_CAP,d=r.updatable,f=t.updateSideOrientation(r.sideOrientation),p=r.instance,m=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,s,o,null,null,a,l,c,u,h,!0,n,!!d,f,p||null,m,r.frontUVs||null,r.backUVs||null)},t.CreateLathe=function(i,r,n){var o,s=r.arc?r.arc<=0||r.arc>1?1:r.arc:1,a=void 0===r.closed||r.closed,l=r.shape,c=r.radius||1,u=r.tessellation||64,h=r.clip||0,d=r.updatable,f=t.updateSideOrientation(r.sideOrientation),p=r.cap||e.Mesh.NO_CAP,m=2*Math.PI,g=new Array,_=r.invertUV||!1,v=0,A=0,y=m/u*s,b=new Array;for(v=0;v<=u-h;v++){b=[];for(p!=e.Mesh.CAP_START&&p!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(0,l[0].y,0)),b.push(new e.Vector3(Math.cos(v*y)*l[0].x*c,l[0].y,Math.sin(v*y)*l[0].x*c))),A=0;A<l.length;A++)o=new e.Vector3(Math.cos(v*y)*l[A].x*c,l[A].y,Math.sin(v*y)*l[A].x*c),b.push(o);p!=e.Mesh.CAP_END&&p!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(Math.cos(v*y)*l[l.length-1].x*c,l[l.length-1].y,Math.sin(v*y)*l[l.length-1].x*c)),b.push(new e.Vector3(0,l[l.length-1].y,0))),g.push(b)}return t.CreateRibbon(i,{pathArray:g,closeArray:a,sideOrientation:f,updatable:d,invertUV:_,frontUVs:r.frontUVs,backUVs:r.backUVs},n)},t.CreatePlane=function(i,r,n){var o=new e.Mesh(i,n);if(r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreatePlane(r).applyToMesh(o,r.updatable),r.sourcePlane){o.translate(r.sourcePlane.normal,r.sourcePlane.d);var s=Math.acos(e.Vector3.Dot(r.sourcePlane.normal,e.Axis.Z)),a=e.Vector3.Cross(e.Axis.Z,r.sourcePlane.normal);a.lengthSquared()>e.Epsilon&&o.rotate(a,s)}return o},t.CreateGround=function(t,i,r){var n=new e.GroundMesh(t,r);return n._setReady(!1),n._subdivisionsX=i.subdivisionsX||i.subdivisions||1,n._subdivisionsY=i.subdivisionsY||i.subdivisions||1,n._width=i.width||1,n._height=i.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,e.VertexData.CreateGround(i).applyToMesh(n,i.updatable),n._setReady(!0),n},t.CreateTiledGround=function(t,i,r){var n=new e.Mesh(t,r);return e.VertexData.CreateTiledGround(i).applyToMesh(n,i.updatable),n},t.CreateGroundFromHeightMap=function(t,i,r,n){var o=r.width||10,s=r.height||10,a=r.subdivisions||1,l=r.minHeight||0,c=r.maxHeight||1,u=r.colorFilter||new e.Color3(.3,.59,.11),h=r.alphaFilter||0,d=r.updatable,f=r.onReady,p=new e.GroundMesh(t,n);p._subdivisionsX=a,p._subdivisionsY=a,p._width=o,p._height=s,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return e.Tools.LoadImage(i,function(t){var i=document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!n.isDisposed){var m=t.width,g=t.height;i.width=m,i.height=g,r.drawImage(t,0,0);var _=r.getImageData(0,0,m,g).data;e.VertexData.CreateGroundFromHeightMap({width:o,height:s,subdivisions:a,minHeight:l,maxHeight:c,colorFilter:u,buffer:_,bufferWidth:m,bufferHeight:g,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}},function(){},n.database),p},t.CreatePolygon=function(i,r,n){r.sideOrientation=t.updateSideOrientation(r.sideOrientation);for(var o=r.shape,s=r.holes||[],a=r.depth||0,l=[],c=[],u=0;u<o.length;u++)l[u]=new e.Vector2(o[u].x,o[u].z);l[0].equalsWithEpsilon(l[l.length-1],1e-8)&&l.pop();for(var h=new e.PolygonMeshBuilder(i,l,n),d=0;d<s.length;d++){c=[];for(var f=0;f<s[d].length;f++)c.push(new e.Vector2(s[d][f].x,s[d][f].z));h.addHole(c)}var p=h.build(r.updatable,a);return p._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreatePolygon(p,r.sideOrientation,r.faceUV,r.faceColors,r.frontUVs,r.backUVs).applyToMesh(p,r.updatable),p},t.ExtrudePolygon=function(e,i,r){return t.CreatePolygon(e,i,r)},t.CreateTube=function(i,r,n){var o=r.path,s=r.instance,a=1;void 0!==r.radius?a=r.radius:s&&(a=s._creationDataStorage.radius);var l=r.tessellation||64,c=r.radiusFunction||null,u=r.cap||e.Mesh.NO_CAP,h=r.invertUV||!1,d=r.updatable,f=t.updateSideOrientation(r.sideOrientation);r.arc=r.arc&&(r.arc<=0||r.arc>1)?1:r.arc||1;var p,m,g=function(t,i,r,n,o,s,a,l){for(var c,u,h,d,f=i.getTangents(),p=i.getNormals(),m=i.getDistances(),g=2*Math.PI/o*l,_=s||function(){return n},v=e.Tmp.Matrix[0],A=a===e.Mesh.NO_CAP||a===e.Mesh.CAP_END?0:2,y=0;y<t.length;y++){u=_(y,m[y]),c=Array(),h=p[y];for(var b=0;b<o;b++)e.Matrix.RotationAxisToRef(f[y],g*b,v),d=c[b]?c[b]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(h,v,d),d.scaleInPlace(u).addInPlace(t[y]),c[b]=d;r[A]=c,A++}var T=function(e,i){for(var r=Array(),n=0;n<e;n++)r.push(t[i]);return r};switch(a){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:r[0]=T(o,0),r[1]=r[2].slice(0);break;case e.Mesh.CAP_END:r[A]=r[A-1].slice(0),r[A+1]=T(o,t.length-1);break;case e.Mesh.CAP_ALL:r[0]=T(o,0),r[1]=r[2].slice(0),r[A]=r[A-1].slice(0),r[A+1]=T(o,t.length-1)}return r};if(s){var _=s._creationDataStorage,v=r.arc||_.arc;return m=g(o,p=_.path3D.update(o),_.pathArray,a,_.tessellation,c,_.cap,v),s=t.CreateRibbon("",{pathArray:m,instance:s}),_.path3D=p,_.pathArray=m,_.arc=v,_.radius=a,s}m=g(o,p=new e.Path3D(o),new Array,a,l,c,u=u<0||u>3?0:u,r.arc);var A=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:d,sideOrientation:f,invertUV:h,frontUVs:r.frontUVs,backUVs:r.backUVs},n);return A._creationDataStorage.pathArray=m,A._creationDataStorage.path3D=p,A._creationDataStorage.tessellation=l,A._creationDataStorage.cap=u,A._creationDataStorage.arc=r.arc,A._creationDataStorage.radius=a,A},t.CreatePolyhedron=function(i,r,n){var o=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation),o._originalBuilderSideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(o,r.updatable),o},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),l=r.normal||e.Vector3.Up(),c=r.size||e.Vector3.One(),u=r.angle||0;if(!l){var h=new e.Vector3(0,0,1),d=i.getScene().activeCamera,f=e.Vector3.TransformCoordinates(h,d.getWorldMatrix());l=d.globalPosition.subtract(f)}var p=-Math.atan2(l.z,l.x)-Math.PI/2,m=Math.sqrt(l.x*l.x+l.z*l.z),g=Math.atan2(l.y,m),_=e.Matrix.RotationYawPitchRoll(p,g,u).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(_),A=i.getWorldMatrix().multiply(v),y=new e.VertexData;y.indices=[],y.positions=[],y.normals=[],y.uvs=[];for(var b=0,T=function(t){var i=new e.PositionNormalVertex;if(!n||!o||!s)return i;var r=n[t];return i.position=new e.Vector3(o[3*r],o[3*r+1],o[3*r+2]),i.position=e.Vector3.TransformCoordinates(i.position,A),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,A),i},E=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(c,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s<t.length;s+=3){var a,l,u,h=null,d=null,f=null,p=null,m=e.Vector3.Dot(t[s].position,i)-r;switch(l=e.Vector3.Dot(t[s+1].position,i)-r>0,u=e.Vector3.Dot(t[s+2].position,i)-r>0,((a=m>0)?1:0)+(l?1:0)+(u?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(h=t[s+1],d=t[s+2],f=n(t[s],h),p=n(t[s],d)),l){h=t[s],d=t[s+2],f=n(t[s+1],h),p=n(t[s+1],d),o.push(f),o.push(d.clone()),o.push(h.clone()),o.push(d.clone()),o.push(f.clone()),o.push(p);break}u&&(h=t[s],d=t[s+1],f=n(t[s+2],h),p=n(t[s+2],d)),h&&d&&f&&p&&(o.push(h.clone()),o.push(d.clone()),o.push(f),o.push(p),o.push(f.clone()),o.push(d.clone()));break;case 2:a||(d=n(h=t[s].clone(),t[s+1]),f=n(h,t[s+2]),o.push(h),o.push(d),o.push(f)),l||(d=n(h=t[s+1].clone(),t[s+2]),f=n(h,t[s]),o.push(h),o.push(d),o.push(f)),u||(d=n(h=t[s+2].clone(),t[s]),f=n(h,t[s+1]),o.push(h),o.push(d),o.push(f))}}return o},x=0;x<n.length;x+=3){var P=new Array;if(P.push(T(x)),P.push(T(x+1)),P.push(T(x+2)),0!==(P=E(P=E(P=E(P=E(P=E(P=E(P,new e.Vector3(1,0,0)),new e.Vector3(-1,0,0)),new e.Vector3(0,1,0)),new e.Vector3(0,-1,0)),new e.Vector3(0,0,1)),new e.Vector3(0,0,-1))).length)for(var M=0;M<P.length;M++){var S=P[M];y.indices.push(b),S.position.toArray(y.positions,3*b),S.normal.toArray(y.normals,3*b),y.uvs.push(.5+S.position.x/c.x),y.uvs.push(.5+S.position.y/c.y),b++}}var C=new e.Mesh(t,i.getScene());return y.applyToMesh(C),C.position=a.clone(),C.rotation=new e.Vector3(g,p,u),C},t._ExtrudeShapeGeneric=function(i,r,n,o,s,a,l,c,u,h,d,f,p,m,g,_,v,A){var y,b,T=function(t,i,r,n,o,s,a,l,c,u){for(var h=r.getTangents(),d=r.getNormals(),f=r.getBinormals(),p=r.getDistances(),m=0,g=u&&l?l:function(){return null!==s?s:0},_=u&&a?a:function(){return null!==o?o:1},v=c===e.Mesh.NO_CAP||c===e.Mesh.CAP_END?0:2,A=e.Tmp.Matrix[0],y=0;y<i.length;y++){for(var b=new Array,T=g(y,p[y]),E=_(y,p[y]),x=0;x<t.length;x++){e.Matrix.RotationAxisToRef(h[y],m,A);var P=h[y].scale(t[x].z).add(d[y].scale(t[x].x)).add(f[y].scale(t[x].y)),M=b[x]?b[x]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(P,A,M),M.scaleInPlace(E).addInPlace(i[y]),b[x]=M}n[v]=b,m+=T,v++}var S=function(t){var i,r=Array(),n=e.Vector3.Zero();for(i=0;i<t.length;i++)n.addInPlace(t[i]);for(n.scaleInPlace(1/t.length),i=0;i<t.length;i++)r.push(n);return r};switch(c){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:n[0]=S(n[2]),n[1]=n[2];break;case e.Mesh.CAP_END:n[v]=n[v-1],n[v+1]=S(n[v-1]);break;case e.Mesh.CAP_ALL:n[0]=S(n[2]),n[1]=n[2],n[v]=n[v-1],n[v+1]=S(n[v-1])}return n};if(g){var E=g._creationDataStorage;return y=E.path3D.update(n),b=T(r,n,E.path3D,E.pathArray,o,s,a,l,E.cap,d),g=e.Mesh.CreateRibbon("",b,!1,!1,0,f||void 0,!1,0,g)}b=T(r,n,y=new e.Path3D(n),new Array,o,s,a,l,h=h<0||h>3?0:h,d);var x=t.CreateRibbon(i,{pathArray:b,closeArray:c,closePath:u,updatable:p,sideOrientation:m,invertUV:_,frontUVs:v||void 0,backUVs:A||void 0},f);return x._creationDataStorage.pathArray=b,x._creationDataStorage.path3D=y,x._creationDataStorage.cap=h,x},t}();e.MeshBuilder=t}(a||(a={})),function(e){var t=function(){function t(){}return Object.defineProperty(t,"DecoderAvailable",{get:function(){if("undefined"!=typeof DracoDecoderModule)return!0;var e=t.Configuration.decoder;if(e){if(e.wasmUrl&&e.wasmBinaryUrl&&"object"==typeof WebAssembly)return!0;if(e.fallbackUrl)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){},t.prototype.decodeMeshAsync=function(i,r){var n=i instanceof ArrayBuffer?new Uint8Array(i):i;return t._GetDecoderModule().then(function(t){var i=t.module,o=new e.VertexData,s=new i.DecoderBuffer;s.Init(n,n.byteLength);var a,l,c=new i.Decoder;try{var u=c.GetEncodedGeometryType(s);switch(u){case i.TRIANGULAR_MESH:a=new i.Mesh,l=c.DecodeBufferToMesh(s,a);break;case i.POINT_CLOUD:a=new i.PointCloud,l=c.DecodeBufferToPointCloud(s,a);break;default:throw new Error("Invalid geometry type "+u)}if(!l.ok()||!a.ptr)throw new Error(l.error_msg());var h=a.num_points();if(u===i.TRIANGULAR_MESH){var d=a.num_faces(),f=new i.DracoInt32Array;try{for(var p=new Uint32Array(3*d),m=0;m<d;m++){c.GetFaceFromMesh(a,m,f);var g=3*m;p[g+0]=f.GetValue(0),p[g+1]=f.GetValue(1),p[g+2]=f.GetValue(2)}o.indices=p}finally{i.destroy(f)}}for(var _ in r){var v=r[_],A=c.GetAttributeByUniqueId(a,v),y=new i.DracoFloat32Array;try{c.GetAttributeFloatForAllPoints(a,A,y);var b=new Float32Array(h*A.num_components());for(m=0;m<b.length;m++)b[m]=y.GetValue(m);o.set(b,_)}finally{i.destroy(y)}}}finally{a&&i.destroy(a),i.destroy(c),i.destroy(s)}return o})},t._GetDecoderModule=function(){if(!t._DecoderModulePromise){var e=null,i={};if("undefined"!=typeof DracoDecoderModule)e=Promise.resolve();else{var r=t.Configuration.decoder;r&&(r.wasmUrl&&r.wasmBinaryUrl&&"object"==typeof WebAssembly?e=Promise.all([t._LoadScriptAsync(r.wasmUrl),t._LoadFileAsync(r.wasmBinaryUrl).then(function(e){i.wasmBinary=e})]):r.fallbackUrl&&(e=t._LoadScriptAsync(r.fallbackUrl)))}if(!e)throw new Error("Draco decoder module is not available");t._DecoderModulePromise=e.then(function(){return new Promise(function(e){i.onModuleLoaded=function(t){e({module:t})},DracoDecoderModule(i)})})}return t._DecoderModulePromise},t._LoadScriptAsync=function(t){return new Promise(function(i,r){e.Tools.LoadScript(t,function(){i()},function(e){r(new Error(e))})})},t._LoadFileAsync=function(t){return new Promise(function(i,r){e.Tools.LoadFile(t,function(e){i(e)},void 0,void 0,!0,function(e,t){r(t)})})},t.Configuration={decoder:{wasmUrl:"https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",wasmBinaryUrl:"https://preview.babylonjs.com/draco_decoder_gltf.wasm",fallbackUrl:"https://preview.babylonjs.com/draco_decoder_gltf.js"}},t}();e.DracoCompression=t}(a||(a={})),function(e){e.Engine.AudioEngineFactory=function(e){return new t(e)};var t=function(){function t(t){void 0===t&&(t=null);var i=this;this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!0,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new e.Observable,this.onAudioLockedObservable=new e.Observable,this._tryToRun=!1,this._onResize=function(){i._moveButtonToTopLeft()},void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var r=document.createElement("audio");this._hostElement=t;try{r&&r.canPlayType&&r.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{r&&r.canPlayType&&r.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized?this.unlocked||this._muteButton||this._displayMuteButton():this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype.lock=function(){this._triggerSuspendedState()},t.prototype.unlock=function(){this._triggerRunningState()},t.prototype._resumeAudioContext=function(){var e;return this._audioContext.resume&&(e=this._audioContext.resume()),e||Promise.resolve()},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0,"running"===this._audioContext.state&&this._triggerRunningState())}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype._triggerRunningState=function(){var e=this;this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then(function(){e._tryToRun=!1,e._muteButton&&e._hideMuteButton()}).catch(function(){e._tryToRun=!1,e.unlocked=!1}),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this))},t.prototype._triggerSuspendedState=function(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()},t.prototype._displayMuteButton=function(){var e=this;if(!this.useCustomUnlockedButton){this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";var t=document.createElement("style");t.appendChild(document.createTextNode(".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }")),document.getElementsByTagName("head")[0].appendChild(t),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",function(){e._triggerRunningState()},!0),this._muteButton.addEventListener("click",function(){e._triggerRunningState()},!0),window.addEventListener("resize",this._onResize)}},t.prototype._moveButtonToTopLeft=function(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")},t.prototype._hideMuteButton=function(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t}();e.AudioEngine=t}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o){void 0===n&&(n=null);var s=this;this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.onEndedObservable=new e.Observable,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._positionInEmitterSpace=!1,this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r;var a=r._getComponent(e.SceneComponentConstants.NAME_AUDIO);if(a||(a=new e.AudioSceneComponent(r),r._addComponent(a)),this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return t<i?e*(1-t/i):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,void 0!==o.volume&&(this._volume=o.volume),this.spatialSound=o.spatialSound||!1,this.maxDistance=o.maxDistance||100,this.useCustomAttenuation=o.useCustomAttenuation||!1,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=o.streaming||!1),e.Engine.audioEngine.canUseWebAudio&&e.Engine.audioEngine.audioContext){this._soundGain=e.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this);var l=!0;if(i)try{"string"==typeof i?this._urlType="String":i instanceof ArrayBuffer?this._urlType="ArrayBuffer":i instanceof MediaStream?this._urlType="MediaStream":Array.isArray(i)&&(this._urlType="Array");var c=[],u=!1;switch(this._urlType){case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=e.Engine.audioEngine.audioContext.createMediaElementSource(i),this.autoplay&&this.play(),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":i.byteLength>0&&(u=!0,this._soundLoaded(i));break;case"String":c.push(i);case"Array":0===c.length&&(c=i);for(var h=0;h<c.length;h++){var d=c[h];if(-1!==d.indexOf(".mp3",d.length-4)&&e.Engine.audioEngine.isMP3supported&&(u=!0),-1!==d.indexOf(".ogg",d.length-4)&&e.Engine.audioEngine.isOGGsupported&&(u=!0),-1!==d.indexOf(".wav",d.length-4)&&(u=!0),-1!==d.indexOf("blob:")&&(u=!0),u){this._streaming?(this._htmlAudioElement=new Audio(d),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,e.Tools.SetCorsBehavior(d,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){s._isReadyToPlay=!0,s.autoplay&&s.play(),s._readyToPlayCallback&&s._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(d,function(e){s._soundLoaded(e)},void 0,!0,!0,function(t){t&&e.Tools.Error("XHR "+t.status+" error on: "+d+"."),e.Tools.Error("Sound creation aborted."),s._scene.mainSoundTrack.RemoveSound(s)});break}}break;default:l=!1}l?u||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback&&s._readyToPlayCallback()},1e3)):e.Tools.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch(t){e.Tools.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.RemoveSound(this)}}else this._scene.mainSoundTrack.AddSound(this),e.Engine.audioEngine.WarnedWebAudioUnsupported||(e.Tools.Error("Web Audio is not supported by your browser."),e.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback&&s._readyToPlayCallback()},1e3)}return t.prototype.dispose=function(){e.Engine.audioEngine.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._streamingSource&&this._streamingSource.disconnect(),this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},t.prototype.isReady=function(){return this._isReadyToPlay},t.prototype._soundLoaded=function(t){var i=this;e.Engine.audioEngine.audioContext&&e.Engine.audioEngine.audioContext.decodeAudioData(t,function(e){i._audioBuffer=e,i._isReadyToPlay=!0,i.autoplay&&i.play(),i._readyToPlayCallback&&i._readyToPlayCallback()},function(t){e.Tools.Error("Error while decoding audio data for: "+i.name+" / Error: "+t)})},t.prototype.setAudioBuffer=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},t.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate)))},t.prototype._createSpatialParameters=function(){e.Engine.audioEngine.canUseWebAudio&&e.Engine.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=e.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner)},t.prototype._updateSpatialParameters=function(){this.spatialSound&&this._soundPanner&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},t.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},t.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},t.prototype._switchPanningModel=function(){e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},t.prototype.connectToSoundTrackAudioNode=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(t),this._isOutputConnected=!0)},t.prototype.setDirectionalCone=function(t,i,r){i<t?e.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=i,this._coneOuterGain=r,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play()))},Object.defineProperty(t.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){if(t!=this._coneInnerAngle){if(this._coneOuterAngle<t)return void e.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){if(t!=this._coneOuterAngle){if(t<this._coneInnerAngle)return void e.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!0,configurable:!0}),t.prototype.setPosition=function(t){this._position=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},t.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},t.prototype._updateDirection=function(){if(this._connectedMesh&&this._soundPanner){var t=this._connectedMesh.getWorldMatrix(),i=e.Vector3.TransformNormal(this._localDirection,t);i.normalize(),this._soundPanner.setOrientation(i.x,i.y,i.z)}},t.prototype.updateDistanceFromListener=function(){if(e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){var t=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},t.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},t.prototype.play=function(t,i){var r=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&e.Engine.audioEngine.audioContext)try{this._startOffset<0&&(t=-this._startOffset,this._startOffset=0);var n=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;if(this._soundSource&&this._streamingSource||this.spatialSound&&this._soundPanner&&(isNaN(this._position.x)||isNaN(this._position.y)||isNaN(this._position.z)||this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming){if(this._streamingSource||(this._streamingSource=e.Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){r._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement){var o=function(){if(e.Engine.audioEngine.unlocked){var t=r._htmlAudioElement.play();void 0!==t&&t.catch(function(t){e.Engine.audioEngine.lock(),e.Engine.audioEngine.onAudioUnlockedObservable.addOnce(function(){o()})})}else e.Engine.audioEngine.onAudioUnlockedObservable.addOnce(function(){o()})};o()}}else this._soundSource=e.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=function(){r._onended()},this._soundSource.buffer&&this._soundSource.start(n,this.isPaused?this._startOffset%this._soundSource.buffer.duration:i||0);this._startTime=n,this.isPlaying=!0,this.isPaused=!1}catch(t){e.Tools.Error("Error while trying to play audio: "+this.name+", "+t.message)}},t.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},t.prototype.stop=function(t){if(this.isPlaying){if(this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect();else if(e.Engine.audioEngine.audioContext&&this._soundSource){var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=function(){},this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():e.Engine.audioEngine.audioContext&&(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&this._soundGain&&(i&&e.Engine.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){if(t.getBoundingInfo){var i=t;if(this._positionInEmitterSpace)i.worldMatrixFromCache.invertToRef(e.Tmp.Matrix[0]),this.setPosition(e.Tmp.Matrix[0].getTranslation());else{var r=i.getBoundingInfo();this.setPosition(r.boundingSphere.centerWorld)}e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var l,c={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var u=function(){o._isReadyToPlay?(l._audioBuffer=o.getAudioBuffer(),l._isReadyToPlay=!0,l.autoplay&&l.play()):window.setTimeout(u,300)};l=new t(a,new ArrayBuffer(0),r,null,c),u()}else l=new t(a,s,r,function(){r._removePendingData(l)},c),r._addPendingData(l);if(i.position){var h=e.Vector3.FromArray(i.position);l.setPosition(h)}if(i.isDirectional&&(l.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var d=e.Vector3.FromArray(i.localDirectionToMesh);l.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=r.getMeshByID(i.connectedMeshId);f&&l.attachToMesh(f)}return l},t}();e.Sound=t}(a||(a={})),function(e){var t=function(){function t(e,t){void 0===t&&(t={}),this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._isMainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&e.Engine.audioEngine.audioContext&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine&&e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks&&this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToHRTF()},t.prototype.switchPanningModelToEqualPower=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToEqualPower()},t.prototype.connectToAnalyser=function(t){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=t,e.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,e.Engine.audioEngine.masterGain))},t}();e.SoundTrack=t}(a||(a={})),function(e){var t=function(){function t(t){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=t,this._audioEngine=e.Engine.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return t.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},t.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},t.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},t.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},t.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var i=0;i<this.getFrequencyBinCount();i++){var r=t[i]/this.BARGRAPHAMPLITUDE,n=this.DEBUGCANVASSIZE.height*r,o=this.DEBUGCANVASSIZE.height-n-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),a=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+a+", 100%, 50%)",this._debugCanvasContext.fillRect(i*s,o,s,n)}}},t.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._registerFunc&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null),document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},t.prototype.connectAudioNodes=function(e,t){this._audioEngine.canUseWebAudio&&(e.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(t))},t.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},t}();e.Analyser=t}(a||(a={})),function(e){var t=function(){function t(e,t,i){var r=this;if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],t.length!==i.length)throw new Error("Sounds length does not equal weights length");this.loop=e,this._weights=i;for(var n=0,o=0,s=i;o<s.length;o++){n+=s[o]}for(var a=n>0?1/n:0,l=0;l<this._weights.length;l++)this._weights[l]*=a;this._sounds=t;for(var c=0,u=this._sounds;c<u.length;c++){u[c].onEndedObservable.add(function(){r._onended()})}}return Object.defineProperty(t.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(t){if(t!==this._coneInnerAngle){if(this._coneOuterAngle<t)return void e.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=t;for(var i=0,r=this._sounds;i<r.length;i++){r[i].directionalConeInnerAngle=t}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(t){if(t!==this._coneOuterAngle){if(t<this._coneInnerAngle)return void e.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=t;for(var i=0,r=this._sounds;i<r.length;i++){r[i].directionalConeOuterAngle=t}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"volume",{get:function(){return this._volume},set:function(e){if(e!==this._volume)for(var t=0,i=this._sounds;t<i.length;t++){i[t].setVolume(e)}},enumerable:!0,configurable:!0}),t.prototype._onended=function(){void 0!==this._currentIndex&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1},t.prototype.pause=function(){this.isPaused=!0,void 0!==this._currentIndex&&this._sounds[this._currentIndex].pause()},t.prototype.stop=function(){this.isPlaying=!1,void 0!==this._currentIndex&&this._sounds[this._currentIndex].stop()},t.prototype.play=function(e){if(!this.isPaused){this.stop();for(var t=Math.random(),i=0,r=0;r<this._weights.length;r++)if(t<=(i+=this._weights[r])){this._currentIndex=r;break}}var n=this._sounds[this._currentIndex];n.isReady()?n.play(0,this.isPaused?void 0:e):n.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},t}();e.WeightedSound=t}(a||(a={})),function(e){e.AbstractScene.AddParser(e.SceneComponentConstants.NAME_AUDIO,function(t,i,r,n){var o,s=[];if(r.sounds=r.sounds||[],void 0!==t.sounds&&null!==t.sounds)for(var a=0,l=t.sounds.length;a<l;a++){var c=t.sounds[a];e.Engine.audioEngine.canUseWebAudio?(c.url||(c.url=c.name),s[c.url]?r.sounds.push(e.Sound.Parse(c,i,n,s[c.url])):(o=e.Sound.Parse(c,i,n),s[c.url]=o,r.sounds.push(o))):r.sounds.push(new e.Sound(c.name,null,i))}s=[]}),Object.defineProperty(e.Scene.prototype,"mainSoundTrack",{get:function(){var i=this._getComponent(e.SceneComponentConstants.NAME_AUDIO);return i||(i=new t(this),this._addComponent(i)),this._mainSoundTrack||(this._mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),e.Scene.prototype.getSoundByName=function(e){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===e)return this.mainSoundTrack.soundCollection[t];if(this.soundTracks)for(var i=0;i<this.soundTracks.length;i++)for(t=0;t<this.soundTracks[i].soundCollection.length;t++)if(this.soundTracks[i].soundCollection[t].name===e)return this.soundTracks[i].soundCollection[t];return null},Object.defineProperty(e.Scene.prototype,"audioEnabled",{get:function(){var i=this._getComponent(e.SceneComponentConstants.NAME_AUDIO);return i||(i=new t(this),this._addComponent(i)),i.audioEnabled},set:function(i){var r=this._getComponent(e.SceneComponentConstants.NAME_AUDIO);r||(r=new t(this),this._addComponent(r)),i?r.enableAudio():r.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(e.Scene.prototype,"headphone",{get:function(){var i=this._getComponent(e.SceneComponentConstants.NAME_AUDIO);return i||(i=new t(this),this._addComponent(i)),i.headphone},set:function(i){var r=this._getComponent(e.SceneComponentConstants.NAME_AUDIO);r||(r=new t(this),this._addComponent(r)),i?r.switchAudioModeForHeadphones():r.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0});var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,this.scene=t,t.soundTracks=new Array,t.sounds=new Array}return Object.defineProperty(t.prototype,"audioEnabled",{get:function(){return this._audioEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"headphone",{get:function(){return this._headphone},enumerable:!0,configurable:!0}),t.prototype.register=function(){this.scene._afterRenderStage.registerStep(e.SceneComponentConstants.STEP_AFTERRENDER_AUDIO,this,this._afterRender)},t.prototype.rebuild=function(){},t.prototype.serialize=function(e){if(e.sounds=[],this.scene.soundTracks)for(var t=0;t<this.scene.soundTracks.length;t++)for(var i=this.scene.soundTracks[t],r=0;r<i.soundCollection.length;r++)e.sounds.push(i.soundCollection[r].serialize())},t.prototype.addFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach(function(e){e.play(),e.autoplay=!0,t.scene.mainSoundTrack.AddSound(e)})},t.prototype.removeFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach(function(e){e.stop(),e.autoplay=!1,t.scene.mainSoundTrack.RemoveSound(e)})},t.prototype.dispose=function(){var e=this.scene;if(e._mainSoundTrack&&e.mainSoundTrack.dispose(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].dispose()},t.prototype.disableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!1,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].pause();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].pause()},t.prototype.enableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!0,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].isPaused&&t.mainSoundTrack.soundCollection[e].play();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].isPaused&&t.soundTracks[e].soundCollection[i].play()},t.prototype.switchAudioModeForHeadphones=function(){var e=this.scene;if(this._headphone=!0,e.mainSoundTrack.switchPanningModelToHRTF(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToHRTF()},t.prototype.switchAudioModeForNormalSpeakers=function(){var e=this.scene;if(this._headphone=!1,e.mainSoundTrack.switchPanningModelToEqualPower(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToEqualPower()},t.prototype._afterRender=function(){var t=this.scene;if(this._audioEnabled&&t._mainSoundTrack&&t.soundTracks&&(0!==t._mainSoundTrack.soundCollection.length||1!==t.soundTracks.length)){var i,r=e.Engine.audioEngine;if((i=t.activeCameras.length>0?t.activeCameras[0]:t.activeCamera)&&r.audioContext){r.audioContext.listener.setPosition(i.position.x,i.position.y,i.position.z),i.rigCameras&&i.rigCameras.length>0&&(i=i.rigCameras[0]);var n,o=e.Matrix.Invert(i.getViewMatrix()),s=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),o);for(s.normalize(),isNaN(s.x)||isNaN(s.y)||isNaN(s.z)||r.audioContext.listener.setOrientation(s.x,s.y,s.z,0,1,0),n=0;n<t.mainSoundTrack.soundCollection.length;n++){var a=t.mainSoundTrack.soundCollection[n];a.useCustomAttenuation&&a.updateDistanceFromListener()}if(t.soundTracks)for(n=0;n<t.soundTracks.length;n++)for(var l=0;l<t.soundTracks[n].soundCollection.length;l++)(a=t.soundTracks[n].soundCollection[l]).useCustomAttenuation&&a.updateDistanceFromListener()}}},t}();e.AudioSceneComponent=t}(a||(a={})),function(e){var t=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=t;var i=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=i}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h,d,f,p){void 0===n&&(n=null),void 0===o&&(o=!1),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===c&&(c=e.Engine.TEXTUREFORMAT_RGBA),void 0===u&&(u=!1),void 0===h&&(h=null),void 0===d&&(d=!1),void 0===f&&(f=.8),void 0===p&&(p=0);var m=t.call(this,r)||this;if(m.boundingBoxPosition=e.Vector3.Zero(),m._rotationY=0,m._prefiltered=!1,m.name=i,m.url=i,m._noMipmap=o,m.hasAlpha=!1,m._format=c,m.isCube=!0,m._textureMatrix=e.Matrix.Identity(),m._createPolynomials=d,m.coordinatesMode=e.Texture.CUBIC_MODE,!i&&!s)return m;var g=i.lastIndexOf("."),_=h||(g>-1?i.substring(g).toLowerCase():""),v=".dds"===_,A=".env"===_;if(A?(m.gammaSpace=!1,m._prefiltered=!1):(m._prefiltered=u,u&&(m.gammaSpace=!1)),m._texture=m._getFromCache(i,o),!s&&(A||v||n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[],n))for(var y=0;y<n.length;y++)s.push(i+n[y]);return m._files=s,m._texture?a&&(m._texture.isReady?e.Tools.SetImmediate(function(){return a()}):m._texture.onLoadedObservable.add(a)):r.useDelayedTextureLoading?m.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:m._texture=u?r.getEngine().createPrefilteredCubeTexture(i,r,f,p,a,l,c,h,m._createPolynomials):r.getEngine().createCubeTexture(i,r,s,o,a,l,m._format,h,!1,f,p),m}return o(i,t),Object.defineProperty(i.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(t){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(t)){this._boundingBoxSize=t;var i=this.getScene();i&&i.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationY",{get:function(){return this._rotationY},set:function(t){this._rotationY=t,this.setReflectionTextureMatrix(e.Matrix.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),i.CreateFromImages=function(e,t,r){var n="";return e.forEach(function(e){return n+=e}),new i(n,t,null,r,e)},i.CreateFromPrefilteredData=function(e,t,r,n){return void 0===r&&(r=null),void 0===n&&(n=!0),new i(e,t,null,!1,null,null,null,void 0,!0,r,n)},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._texture||(this._prefiltered?this._texture=t.getEngine().createPrefilteredCubeTexture(this.url,t,this.lodGenerationScale,this.lodGenerationOffset,void 0,void 0,this._format,void 0,this._createPolynomials):this._texture=t.getEngine().createCubeTexture(this.url,t,this._files,this._noMipmap,void 0,void 0,this._format)))}},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,r,n){var o=e.SerializationHelper.Parse(function(){var e=!1;return t.prefiltered&&(e=t.prefiltered),new i(n+t.name,r,t.extensions,!1,null,null,null,void 0,e)},t,r);if(t.boundingBoxPosition&&(o.boundingBoxPosition=e.Vector3.FromArray(t.boundingBoxPosition)),t.boundingBoxSize&&(o.boundingBoxSize=e.Vector3.FromArray(t.boundingBoxSize)),t.animations)for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}return o},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){var e=t.getScene();return e?new i(t.url,e,t._extensions,t._noMipmap,t._files):t},this)},n([e.serialize("rotationY")],i.prototype,"rotationY",null),i}(e.BaseTexture);e.CubeTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u){void 0===o&&(o=e.Engine.TEXTUREFORMAT_RGBA),void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1),void 0===l&&(l=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null);var h=t.call(this,"",i)||this;return h._texture=i.getEngine().createRawCubeTexture(r,n,o,s,a,l,c,u),h}return o(i,t),i.prototype.update=function(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=0),this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,i,r,n)},i.prototype.updateRGBDAsync=function(e,t,r,n){return void 0===t&&(t=null),void 0===r&&(r=.8),void 0===n&&(n=0),i._UpdateRGBDAsync(this._texture,e,t,r,n)},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){var r=t.getScene(),n=t._texture,o=new i(r,n._bufferViewArray,n.width,n.format,n.type,n.generateMipMaps,n.invertY,n.samplingMode,n._compression);return n.dataSource===e.InternalTexture.DATASOURCE_CUBERAW_RGBD&&o.updateRGBDAsync(n._bufferViewArrayArray,n._sphericalPolynomial,n._lodGenerationScale,n._lodGenerationOffset),o},this)},i._UpdateRGBDAsync=function(t,i,r,n,o){return t._dataSource=e.InternalTexture.DATASOURCE_CUBERAW_RGBD,t._bufferViewArrayArray=i,t._lodGenerationScale=n,t._lodGenerationOffset=o,t._sphericalPolynomial=r,e.EnvironmentTextureTools.UploadLevelsAsync(t,i).then(function(){t.isReady=!0})},i}(e.CubeTexture);e.RawCubeTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h,d,f){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=!0),void 0===h&&(h=!1),void 0===d&&(d=!1),void 0===f&&(f=e.Engine.TEXTUREFORMAT_RGBA);var p=t.call(this,null,n,!o)||this;return p.isCube=l,p.renderParticles=!0,p.renderSprites=!1,p.coordinatesMode=e.Texture.PROJECTION_MODE,p.ignoreCameraViewport=!1,p.onBeforeBindObservable=new e.Observable,p.onAfterUnbindObservable=new e.Observable,p.onBeforeRenderObservable=new e.Observable,p.onAfterRenderObservable=new e.Observable,p.onClearObservable=new e.Observable,p._currentRefreshId=-1,p._refreshRate=1,p._samples=1,p.boundingBoxPosition=e.Vector3.Zero(),(n=p.getScene())?(p.renderList=new Array,p._engine=n.getEngine(),p.name=i,p.isRenderTarget=!0,p._initialSizeParameter=r,p._processSizeParameter(r),p._resizeObserver=p.getScene().getEngine().onResizeObservable.add(function(){}),p._generateMipMaps=!!o,p._doNotChangeAspectRatio=s,p._renderingManager=new e.RenderingManager(n),p._renderingManager._useSceneAutoClearSetup=!0,d?p:(p._renderTargetOptions={generateMipMaps:o,type:a,format:f,samplingMode:c,generateDepthBuffer:u,generateStencilBuffer:h},c===e.Texture.NEAREST_SAMPLINGMODE&&(p.wrapU=e.Texture.CLAMP_ADDRESSMODE,p.wrapV=e.Texture.CLAMP_ADDRESSMODE),l?(p._texture=n.getEngine().createRenderTargetCubeTexture(p.getRenderSize(),p._renderTargetOptions),p.coordinatesMode=e.Texture.INVCUBIC_MODE,p._textureMatrix=e.Matrix.Identity()):p._texture=n.getEngine().createRenderTargetTexture(p._size,p._renderTargetOptions),p)):p}return o(i,t),Object.defineProperty(i.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(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=0===e.length,s=i.apply(e,r);return o&&t.getScene().meshes.forEach(function(e){e._markSubMeshesAsLightDirty()}),s};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return 0===e.length&&t.getScene().meshes.forEach(function(e){e._markSubMeshesAsLightDirty()}),o}},Object.defineProperty(i.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!0,configurable:!0}),i.prototype._onRatioRescale=function(){this._sizeRatio&&this.resize(this._initialSizeParameter)},Object.defineProperty(i.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(t){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(t)){this._boundingBoxSize=t;var i=this.getScene();i&&i.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),i.prototype.createDepthStencilTexture=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1),this.getScene()){var r=this.getScene().getEngine();this.depthStencilTexture=r.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this.isCube}),r.setFrameBufferDepthStencilTexture(this)}},i.prototype._processSizeParameter=function(e){e.ratio?(this._sizeRatio=e.ratio,this._size={width:this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(),this._sizeRatio)}):this._size=e},Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){if(this._samples!==e){var t=this.getScene();t&&(this._samples=t.getEngine().updateRenderTargetTextureSampleCount(this._texture,e))}},enumerable:!0,configurable:!0}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype.addPostProcess=function(t){if(!this._postProcessManager){var i=this.getScene();if(!i)return;this._postProcessManager=new e.PostProcessManager(i),this._postProcesses=new Array}this._postProcesses.push(t),this._postProcesses[0].autoClear=!1},i.prototype.clearPostProcesses=function(e){if(void 0===e&&(e=!1),this._postProcesses){if(e)for(var t=0,i=this._postProcesses;t<i.length;t++){i[t].dispose()}this._postProcesses=[]}},i.prototype.removePostProcess=function(e){if(this._postProcesses){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.getRenderSize=function(){return this.getRenderWidth()},i.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},i.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getRenderSize()*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture();var t=this.getScene();t&&(this._processSizeParameter(e),this.isCube?this._texture=t.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._texture=t.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions))},i.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),a=this.getScene()){var i,r=a.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n<this._waitingRenderList.length;n++){var o=this._waitingRenderList[n],s=a.getMeshByID(o);s&&this.renderList.push(s)}delete this._waitingRenderList}if(this.renderListPredicate){var a;if(this.renderList?this.renderList.splice(0):this.renderList=[],!(a=this.getScene()))return;var l=a.meshes;for(n=0;n<l.length;n++){var c=l[n];this.renderListPredicate(c)&&this.renderList.push(c)}}this.onBeforeBindObservable.notifyObservers(this),this.activeCamera?(i=this.activeCamera,r.setViewport(this.activeCamera.viewport,this.getRenderWidth(),this.getRenderHeight()),this.activeCamera!==a.activeCamera&&a.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(i=a.activeCamera)&&r.setViewport(i.viewport,this.getRenderWidth(),this.getRenderHeight()),this._renderingManager.reset();for(var u=this.renderList?this.renderList:a.getActiveMeshes().data,h=this.renderList?this.renderList.length:a.getActiveMeshes().length,d=a.getRenderId(),f=0;f<h;f++){if(c=u[f]){if(!c.isReady(0===this.refreshRate)){this.resetRefreshCounter();continue}c._preActivateForIntermediateRendering(d);var p=void 0;if(p=!(this.renderList||!i)&&0==(c.layerMask&i.layerMask),c.isEnabled()&&c.isVisible&&c.subMeshes&&!p){c._activate(d);for(var m=0;m<c.subMeshes.length;m++){var g=c.subMeshes[m];a._activeIndices.addCount(g.indexCount,!1),this._renderingManager.dispatch(g,c)}}}}for(var _=0;_<a.particleSystems.length;_++){var v=a.particleSystems[_],A=v.emitter;v.isStarted()&&A&&A.position&&A.isEnabled()&&(u.indexOf(A)>=0&&this._renderingManager.dispatchParticles(v))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,u,h,e,t),a.incrementRenderId(),a.resetCachedMaterial();else this.renderToTarget(0,u,h,e,t);this.onAfterUnbindObservable.notifyObservers(this),a.activeCamera&&(this.activeCamera&&this.activeCamera!==a.activeCamera&&a.setTransformMatrix(a.activeCamera.getViewMatrix(),a.activeCamera.getProjectionMatrix(!0)),r.setViewport(a.activeCamera.viewport)),a.resetCachedMaterial()}},i.prototype._bestReflectionRenderTargetDimension=function(t,i){var r=t*i,n=e.Tools.NearestPOT(r+16384/(128+r));return Math.min(e.Tools.FloorPOT(t),n)},i.prototype.unbindFrameBuffer=function(e,t){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(t)})},i.prototype.renderToTarget=function(t,i,r,n,o){var s=this.getScene();if(s){var a=s.getEngine();this._texture&&(this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&s.postProcessManager._prepareFrame(this._texture)||this._texture&&a.bindFramebuffer(this._texture,this.isCube?t:void 0,void 0,void 0,this.ignoreCameraViewport,this.depthStencilTexture?this.depthStencilTexture:void 0),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||s.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses,this.ignoreCameraViewport):n&&s.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||s.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),a),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&a.generateMipMapsForCubemap(this._texture),this.unbindFrameBuffer(a,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){this._renderingManager.setRenderingAutoClearDepthStencil(e,t),this._renderingManager._useSceneAutoClearSetup=!1},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(var i=0;i<this.renderList.length;i++)e.renderList.push(this.renderList[i].id);return e},i.prototype.disposeFramebufferObjects=function(){var e=this.getInternalTexture(),t=this.getScene();e&&t&&t.getEngine()._releaseFramebufferObjects(e)},i.prototype.dispose=function(){this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.renderList=null;var e=this.getScene();if(e){var i=e.customRenderTargets.indexOf(this);i>=0&&e.customRenderTargets.splice(i,1);for(var r=0,n=e.cameras;r<n.length;r++){var o=n[r];(i=o.customRenderTargets.indexOf(this))>=0&&o.customRenderTargets.splice(i,1)}t.prototype.dispose.call(this)}},i.prototype._rebuild=function(){this.refreshRate===i.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=i.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},i.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},i.REFRESHRATE_RENDER_ONCE=0,i.REFRESHRATE_RENDER_ONEVERYFRAME=1,i.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,i}(e.Texture);e.RenderTargetTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){var a=this,l=!(!s||!s.generateMipMaps)&&s.generateMipMaps,c=!(!s||!s.generateDepthTexture)&&s.generateDepthTexture,u=!s||void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if((a=t.call(this,i,r,o,l,u)||this)._engine=o.getEngine(),a.isSupported){for(var h=[],d=[],f=0;f<n;f++)s&&s.types&&void 0!==s.types[f]?h.push(s.types[f]):h.push(s&&s.defaultType?s.defaultType:e.Engine.TEXTURETYPE_UNSIGNED_INT),s&&s.samplingModes&&void 0!==s.samplingModes[f]?d.push(s.samplingModes[f]):d.push(e.Texture.BILINEAR_SAMPLINGMODE);var p=!s||void 0===s.generateDepthBuffer||s.generateDepthBuffer,m=!(!s||void 0===s.generateStencilBuffer)&&s.generateStencilBuffer;return a._size=r,a._multiRenderTargetOptions={samplingModes:d,generateMipMaps:l,generateDepthBuffer:p,generateStencilBuffer:m,generateDepthTexture:c,types:h,textureCount:n},a._createInternalTextures(),a._createTextures(),a}a.dispose()}return o(i,t),Object.defineProperty(i.prototype,"isSupported",{get:function(){return this._engine.webGLVersion>1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapU=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wrapV",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapV=e},enumerable:!0,configurable:!0}),i.prototype._rebuild=function(){this.releaseInternalTextures(),this._createInternalTextures();for(var e=0;e<this._internalTextures.length;e++){this._textures[e]._texture=this._internalTextures[e]}this._texture=this._internalTextures[0]},i.prototype._createInternalTextures=function(){this._internalTextures=this._engine.createMultipleRenderTarget(this._size,this._multiRenderTargetOptions)},i.prototype._createTextures=function(){this._textures=[];for(var t=0;t<this._internalTextures.length;t++){var i=new e.Texture(null,this.getScene());i._texture=this._internalTextures[t],this._textures.push(i)}this._texture=this._internalTextures[0]},Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures,e))},enumerable:!0,configurable:!0}),i.prototype.resize=function(e){this.releaseInternalTextures(),this._internalTextures=this._engine.createMultipleRenderTarget(e,this._multiRenderTargetOptions),this._createInternalTextures()},i.prototype.unbindFrameBuffer=function(e,t){var i=this;e.unBindMultiColorAttachmentFramebuffer(this._internalTextures,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(t)})},i.prototype.dispose=function(){this.releaseInternalTextures(),t.prototype.dispose.call(this)},i.prototype.releaseInternalTextures=function(){if(this._internalTextures)for(var e=this._internalTextures.length-1;e>=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},i}(e.RenderTargetTexture);e.MultiRenderTarget=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,l)||this;return c.scene=n,c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c._adaptiveBlurKernel=0,c._blurKernelX=0,c._blurKernelY=0,c._blurRatio=1,c.ignoreCameraViewport=!0,c._updateGammaSpace(),c._imageProcessingConfigChangeObserver=n.imageProcessingConfiguration.onUpdateParameters.add(function(){c._updateGammaSpace}),c.onBeforeRenderObservable.add(function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,c._mirrorMatrix)}),c.onAfterRenderObservable.add(function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane}),c}return o(i,t),Object.defineProperty(i.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),i.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},i.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},i.prototype._updateGammaSpace=function(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},i.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),i=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,i),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},i}(e.RenderTargetTexture);e.MirrorTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){var s=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add(function(){n.clipPlane=s.refractionPlane}),s.onAfterRenderObservable.add(function(){delete n.clipPlane}),s}return o(i,t),i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t.width,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.refractionPlane=this.refractionPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r.depth=this.depth,r},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i}(e.RenderTargetTexture);e.RefractionTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a){void 0===n&&(n=null),void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var l=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;l.name=i,l._engine=l.getScene().getEngine(),l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l._generateMipMaps=o,r.getContext?(l._canvas=r,l._texture=l._engine.createDynamicTexture(r.width,r.height,o,s)):(l._canvas=document.createElement("canvas"),r.width||0===r.width?l._texture=l._engine.createDynamicTexture(r.width,r.height,o,s):l._texture=l._engine.createDynamicTexture(r,r,o,s));var c=l.getSize();return l._canvas.width=c.width,l._canvas.height=c.height,l._context=l._canvas.getContext("2d"),l}return o(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e,t){void 0===t&&(t=!1),this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null===t||void 0===t){var c=this._context.measureText(e);t=(l.width-c.width)/2}if(null===i||void 0===i){var u=parseInt(r.replace(/\D/g,""));i=l.height/2+u/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),r=new i(this.name,t,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},i.prototype.serialize=function(){var i=this.getScene();i&&!i.isReady()&&e.Tools.Warn("The scene must be ready before serializing the dynamic texture");var r=t.prototype.serialize.call(this);return r.base64String=this._canvas.toDataURL(),r.invertY=this._invertY,r.samplingMode=this.samplingMode,r},i.prototype._rebuild=function(){this.update()},i}(e.Texture);e.DynamicTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===l&&(l={autoPlay:!0,loop:!0,autoUpdateTexture:!0});var c=t.call(this,null,n,!o,s)||this;return c._onUserActionRequestedObservable=null,c._stillImageCaptured=!1,c._poster=!1,c._createInternalTexture=function(){if(null!=c._texture){if(!c._poster)return;c._texture.dispose(),c._poster=!1}if(!c._engine.needPOTTextures||e.Tools.IsExponentOfTwo(c.video.videoWidth)&&e.Tools.IsExponentOfTwo(c.video.videoHeight)?(c.wrapU=e.Texture.WRAP_ADDRESSMODE,c.wrapV=e.Texture.WRAP_ADDRESSMODE):(c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c._generateMipMaps=!1),c._texture=c._engine.createDynamicTexture(c.video.videoWidth,c.video.videoHeight,c._generateMipMaps,c._samplingMode),c.video.autoplay)c._texture.isReady=!0,c._updateInternalTexture(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c);else{var t=c.video.onplaying,i=!1;c.video.onplaying=function(){c.video.onplaying=t,c._texture.isReady=!0,c._updateInternalTexture(),i||c.video.pause(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c)};var r=c.video.play();r?r.then(function(){}).catch(function(){i=!0,c._onUserActionRequestedObservable&&c._onUserActionRequestedObservable.hasObservers()&&c._onUserActionRequestedObservable.notifyObservers(c)}):(c.video.onplaying=t,c._texture.isReady=!0,c._updateInternalTexture(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c))}},c.reset=function(){null!=c._texture&&(c._poster||(c._texture.dispose(),c._texture=null))},c._updateInternalTexture=function(e){null!=c._texture&&c._texture.isReady&&(c.video.readyState<c.video.HAVE_CURRENT_DATA||c._engine.updateVideoTexture(c._texture,c.video,c._invertY))},c._engine=c.getScene().getEngine(),c._generateMipMaps=o,c._samplingMode=a,c.autoUpdateTexture=l.autoUpdateTexture,c.name=i||c._getName(r),c.video=c._getVideo(r),l.poster&&(c.video.poster=l.poster),void 0!==l.autoPlay&&(c.video.autoplay=l.autoPlay),void 0!==l.loop&&(c.video.loop=l.loop),c.video.setAttribute("playsinline",""),c.video.addEventListener("canplay",c._createInternalTexture),c.video.addEventListener("paused",c._updateInternalTexture),c.video.addEventListener("seeked",c._updateInternalTexture),c.video.addEventListener("emptied",c.reset),c.video.readyState>=c.video.HAVE_CURRENT_DATA&&c._createInternalTexture(),l.poster&&(c._texture=c._engine.createTexture(l.poster,!1,!0,n),c._poster=!0),c}return o(i,t),Object.defineProperty(i.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new e.Observable),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),i.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},i.prototype._getVideo=function(t){if(t instanceof HTMLVideoElement)return e.Tools.SetCorsBehavior(t.currentSrc,t),t;var i=document.createElement("video");return"string"==typeof t?(e.Tools.SetCorsBehavior(t,i),i.src=t):(e.Tools.SetCorsBehavior(t[0],i),t.forEach(function(e){var t=document.createElement("source");t.src=e,i.appendChild(t)})),i},i.prototype._rebuild=function(){this.update()},i.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},i.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},i.prototype.updateURL=function(e){this.video.src=e},i.prototype.dispose=function(){t.prototype.dispose.call(this),this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener("canplay",this._createInternalTexture),this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("emptied",this.reset),this.video.pause()},i.CreateFromWebCam=function(t,r,n){var o,s=document.createElement("video");s.setAttribute("autoplay",""),s.setAttribute("muted",""),s.setAttribute("playsinline",""),n&&n.deviceId&&(o={exact:n.deviceId}),window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:n}).then(function(e){void 0!==s.mozSrcObject?s.mozSrcObject=e:s.srcObject=e;var n=function(){r&&r(new i("video",s,t,!0,!0)),s.removeEventListener("playing",n)};s.addEventListener("playing",n),s.play()}).catch(function(t){e.Tools.Error(t.name)}):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:o,width:{min:n&&n.minWidth||256,max:n&&n.maxWidth||640},height:{min:n&&n.minHeight||256,max:n&&n.maxHeight||480}}},function(e){void 0!==s.mozSrcObject?s.mozSrcObject=e:s.src=window.URL&&window.URL.createObjectURL(e)||e,s.play(),r&&r(new i("video",s,t,!0,!0))},function(t){e.Tools.Error(t.name)}))},i}(e.Texture);e.VideoTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u){void 0===a&&(a=!0),void 0===l&&(l=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var h=t.call(this,null,s,!a,l)||this;return h.format=o,h._engine=s.getEngine(),h._texture=s.getEngine().createRawTexture(i,r,n,o,a,l,c,null,u),h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h}return o(i,t),i.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,l)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,l)},i.CreateAlphaTexture=function(t,r,n,o,s,a,l){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,l)},i.CreateRGBTexture=function(t,r,n,o,s,a,l,c){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,l,c)},i.CreateRGBATexture=function(t,r,n,o,s,a,l,c){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,l,c)},i.CreateRTexture=function(t,r,n,o,s,a,l,c){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_FLOAT),new i(t,r,n,e.Engine.TEXTUREFORMAT_R,o,s,a,l,c)},i}(e.Texture);e.RawTexture=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h){void 0===l&&(l=!0),void 0===c&&(c=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT);var d=t.call(this,null,a,!l,c)||this;return d.format=s,d._engine=a.getEngine(),d._texture=a.getEngine().createRawTexture3D(i,r,n,o,s,l,c,u,void 0,h),d.is3D=!0,d}return o(i,t),i.prototype.update=function(e){this._texture&&this._engine.updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},i}(e.Texture);e.RawTexture3D=t}(a||(a={})),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;return!!i&&(!(!(t=t||i._postProcesses.filter(function(e){return null!=e}))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!==t&&void 0!==t),!0))},t.prototype.directRender=function(t,i,r,n,o){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=0),void 0===o&&(o=0);for(var s=this._scene.getEngine(),a=0;a<t.length;a++){a<t.length-1?t[a+1].activate(this._scene.activeCamera,i):i?s.bindFramebuffer(i,n,void 0,void 0,r,void 0,o):s.restoreDefaultFramebuffer();var l=t[a],c=l.apply();c&&(l.onBeforeRenderObservable.notifyObservers(c),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,c),s.drawElementsType(e.Material.TriangleFillMode,0,6),l.onAfterRenderObservable.notifyObservers(c))}s.setDepthBuffer(!0),s.setDepthWrite(!0)},t.prototype._finalizeFrame=function(t,i,r,n,o){void 0===o&&(o=!1);var s=this._scene.activeCamera;if(s&&0!==(n=n||s._postProcesses.filter(function(e){return null!=e})).length&&this._scene.postProcessesEnabled){for(var a=this._scene.getEngine(),l=0,c=n.length;l<c;l++){var u=n[l];if(l<c-1?u._outputTexture=n[l+1].activate(s,i):i?(a.bindFramebuffer(i,r,void 0,void 0,o),u._outputTexture=i):(a.restoreDefaultFramebuffer(),u._outputTexture=null),t)break;var h=u.apply();h&&(u.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),a.bindBuffers(this._vertexBuffers,this._indexBuffer,h),a.drawElementsType(e.Material.TriangleFillMode,0,6),u.onAfterRenderObservable.notifyObservers(h))}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}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o,s,a,l,c,u,h,d,f,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=null),void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this)):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=o,this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=c||!1,this._textureType=h,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._vertexUrl=d,this._parameters=r||[],this._parameters.push("scale"),this._indexParameters=f,p||this.updateEffect(u)}return Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=e,this._textures.forEach(function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new e.SmartArray(2)),this._shareOutputWithPostProcess=null},t.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,n,o,r||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i,r){var n=this;void 0===i&&(i=null);var o=(t=t||this._camera).getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,l=(i?i.width:this._engine.getRenderWidth(!0))*this._options|0,c=(i?i.height:this._engine.getRenderHeight(!0))*this._options|0,u=t.parent;!u||u.leftCamera!=t&&u.rightCamera!=t||(l/=2);var h,d=this._options.width||l,f=this._options.height||c;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var p=s.currentViewport;p&&(d*=p.width,f*=p.height)}if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(d=s.needPOTTextures?e.Tools.GetExponentOfTwo(d,a,this.scaleMode):d),this._options.height||(f=s.needPOTTextures?e.Tools.GetExponentOfTwo(f,a,this.scaleMode):f)),this.width!==d||this.height!==f){if(this._textures.length>0){for(var m=0;m<this._textures.length;m++)this._engine._releaseTexture(this._textures.data[m]);this._textures.reset()}this.width=d,this.height=f;var g={width:this.width,height:this.height},_={generateMipMaps:!1,generateDepthBuffer:r||0===t._postProcesses.indexOf(this),generateStencilBuffer:(r||0===t._postProcesses.indexOf(this))&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType};this._textures.push(this._engine.createRenderTargetTexture(g,_)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(g,_)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}this._textures.forEach(function(e){e.samples!==n.samples&&n._engine.updateRenderTargetTextureSampleCount(e,n.samples)})}return this._shareOutputWithPostProcess?h=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?(h=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height):h=this.inputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(l/d,c/f),this._engine.bindFramebuffer(h,0,l,c,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(h,0,void 0,void 0,this.forceFullscreenViewport)),this.onActivateObservable.notifyObservers(t),this.autoClear&&this.alphaMode===e.Engine.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:o.clearColor,o._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),h},Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._effect&&this._effect.isReady()},t.prototype.apply=function(){return this._effect&&this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this._effect._bindTexture("textureSampler",e),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect):null;var e},t.prototype._disposeTextures=function(){if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this._textures.length>0)for(var e=0;e<this._textures.length;e++)this._engine._releaseTexture(this._textures.data[e]);this._textures.dispose()}},t.prototype.dispose=function(e){if(e=e||this._camera,this._disposeTextures(),this._scene){var t=this._scene.postProcesses.indexOf(this);-1!==t&&this._scene.postProcesses.splice(t,1)}else{var i=this._engine.postProcesses.indexOf(this);-1!==i&&this._engine.postProcesses.splice(i,1)}if(e){if(e.detachPostProcess(this),0===e._postProcesses.indexOf(this)&&e._postProcesses.length>0){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t}();e.PostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){return void 0===n&&(n=null),void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),t.call(this,i,"pass",null,null,r,n,o,s,a,void 0,l,void 0,null,c)||this}return o(i,t),i}(e.PostProcess);e.PassPostProcess=t}(a||(a={}));s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(e){var t=function(){function t(i,r,n){this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._filteringQuality=t.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._cachedPosition=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=i,this._light=r,this._scene=r.getScene(),r._shadowGenerator=this;var o=this._scene._getComponent(e.SceneComponentConstants.NAME_SHADOWGENERATOR);o||(o=new e.ShadowGeneratorSceneComponent(this._scene),this._scene._addComponent(o));var s=this._scene.getEngine().getCaps();n?s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(e===t.FILTER_PCF||e===t.FILTER_PCSS)return void(this.usePoissonSampling=!0)}e!==t.FILTER_PCF&&e!==t.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){(e||this.filter===t.FILTER_POISSONSAMPLING)&&(this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===t.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===t.FILTER_PCF},set:function(e){(e||this.filter===t.FILTER_PCF)&&(this.filter=e?t.FILTER_PCF:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useContactHardeningShadow",{get:function(){return this.filter===t.FILTER_PCSS},set:function(e){(e||this.filter===t.FILTER_PCSS)&&(this.filter=e?t.FILTER_PCSS:t.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.addShadowCaster=function(e,t){var i;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes()),this):this},t.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var r=0,n=e.getChildren();r<n.length;r++){var o=n[r];this.removeShadowCaster(o)}return this},t.prototype.getLight=function(){return this._light},t.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var i=this,r=this._scene.getEngine();r.webGLVersion>1?(this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(e.Engine.LESS,!0)):this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._shadowMap.onBeforeRenderObservable.add(function(e){i._currentFaceIndex=e,i._filter===t.FILTER_PCF&&r.setColorWrite(!1)}),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add(function(){if(i._filter===t.FILTER_PCF&&r.setColorWrite(!0),i.useBlurExponentialShadowMap||i.useBlurCloseExponentialShadowMap){var e=i.getShadowMapForRendering();e&&i._scene.postProcessManager.directRender(i._blurPostProcesses,e.getInternalTexture(),!0)}});var n=new e.Color4(0,0,0,0),o=new e.Color4(1,1,1,1);this._shadowMap.onClearObservable.add(function(e){i._filter===t.FILTER_PCF?e.clear(o,!1,!0,!1):i.useExponentialShadowMap||i.useBlurExponentialShadowMap?e.clear(n,!0,!0,!1):e.clear(o,!0,!0,!1)})},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,i=this._scene.getEngine(),r=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",r,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.width=r,this._kernelBlurXPostprocess.height=r,this._kernelBlurXPostprocess.onApplyObservable.add(function(e){e.setTexture("textureSampler",t._shadowMap)}),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",r,r),e.setTexture("textureSampler",t._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,i,r){var n,o=this._scene.getEngine();if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)this._renderSubMeshForShadowMap(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)this._renderSubMeshForShadowMap(e.data[n]);for(n=0;n<t.length;n++)this._renderSubMeshForShadowMap(t.data[n]);if(this._transparencyShadow)for(n=0;n<i.length;n++)this._renderSubMeshForShadowMap(i.data[n])},t.prototype._renderSubMeshForShadowMap=function(t){var i=this,r=t.getRenderingMesh(),n=this._scene,o=n.getEngine(),s=t.getMaterial();if(s){o.setState(s.backFaceCulling);var a=r._getInstancesRenderList(t._id);if(!a.mustReturn){var l=o.getCaps().instancedArrays&&null!==a.visibleInstances[t._id]&&void 0!==a.visibleInstances[t._id];if(this.isReady(t,l)){if(o.enableEffect(this._effect),r._bind(t,this._effect,e.Material.TriangleFillMode),this._effect.setFloat3("biasAndScale",this.bias,this.normalBias,this.depthScale),this._effect.setMatrix("viewProjection",this.getTransformMatrix()),this.getLight().getTypeID()===e.Light.LIGHTTYPEID_DIRECTIONALLIGHT?this._effect.setVector3("lightData",this._cachedDirection):this._effect.setVector3("lightData",this._cachedPosition),n.activeCamera&&this._effect.setFloat2("depthValues",this.getLight().getDepthMinZ(n.activeCamera),this.getLight().getDepthMinZ(n.activeCamera)+this.getLight().getDepthMaxZ(n.activeCamera)),s&&s.needAlphaTesting()){var c=s.getAlphaTestTexture();c&&(this._effect.setTexture("diffuseSampler",c),this._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()||this._defaultTextureMatrix))}r.useBones&&r.computeBonesUsingShaders&&this._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),e.MaterialHelper.BindMorphTargetParameters(r,this._effect),this.forceBackFacesOnly&&o.setState(!0,0,!1,!0),r._processRendering(t,this._effect,e.Material.TriangleFillMode,a,l,function(e,t){return i._effect.setMatrix("world",t)}),this.forceBackFacesOnly&&o.setState(!0,0,!1,!1)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}}},t.prototype._applyFilterValues=function(){this._shadowMap&&(this.filter===t.FILTER_NONE||this.filter===t.FILTER_PCSS?this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE))},t.prototype.forceCompilation=function(e,t){var i=this,r=s({useInstances:!1},t),n=this.getShadowMap();if(n){var o=n.renderList;if(o){for(var a=new Array,l=0,c=o;l<c.length;l++){var u=c[l];a.push.apply(a,u.subMeshes)}if(0!==a.length){var h=0,d=function(){if(i._scene&&i._scene.getEngine()){for(;i.isReady(a[h],r.useInstances);)if(++h>=a.length)return void(e&&e(i));setTimeout(d,16)}};d()}else e&&e(this)}else e&&e(this)}else e&&e(this)},t.prototype.forceCompilationAsync=function(e){var t=this;return new Promise(function(i){t.forceCompilation(function(){i()},e)})},t.prototype.isReady=function(t,i){var r=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&r.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?r.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&r.push("#define DEPTHTEXTURE");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(this.normalBias&&o.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(n.push(e.VertexBuffer.NormalKind),r.push("#define NORMAL"),o.nonUniformScaling&&r.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===e.Light.LIGHTTYPEID_DIRECTIONALLIGHT&&r.push("#define DIRECTIONINLIGHTDATA")),s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2")))}o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0");var l=o.morphTargetManager,c=0;l&&l.numInfluencers>0&&(r.push("#define MORPHTARGETS"),c=l.numInfluencers,r.push("#define NUM_MORPH_INFLUENCERS "+c),e.MaterialHelper.PrepareAttributesForMorphTargets(n,o,{NUM_MORPH_INFLUENCERS:c})),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var u=r.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightData","depthValues","biasAndScale","morphTargetInfluences"],["diffuseSampler"],u,void 0,void 0,void 0,{maxSimultaneousMorphTargets:c})),!!this._effect.isReady()&&((this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady())&&(!(this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady())&&!(this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())))},t.prototype.prepareDefines=function(e,i){var r=this._scene,n=this._light;r.shadowsEnabled&&n.shadowEnabled&&(e["SHADOW"+i]=!0,this.useContactHardeningShadow&&(e["SHADOWPCSS"+i]=!0,this._filteringQuality===t.QUALITY_LOW?e["SHADOWLOWQUALITY"+i]=!0:this._filteringQuality===t.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+i]=!0)),this.usePercentageCloserFiltering?(e["SHADOWPCF"+i]=!0,this._filteringQuality===t.QUALITY_LOW?e["SHADOWLOWQUALITY"+i]=!0:this._filteringQuality===t.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+i]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+i]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+i]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+i]=!0),n.needCube()&&(e["SHADOWCUBE"+i]=!0))},t.prototype.bindShadowLight=function(e,i){var r=this._light,n=this._scene;if(n.shadowsEnabled&&r.shadowEnabled){var o=n.activeCamera;if(o){var s=this.getShadowMap();s&&(r.needCube()||i.setMatrix("lightMatrix"+e,this.getTransformMatrix()),this._filter===t.FILTER_PCF?(i.setDepthStencilTexture("shadowSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),s.getSize().width,1/s.getSize().width,this.frustumEdgeFalloff,e)):this._filter===t.FILTER_PCSS?(i.setDepthStencilTexture("shadowSampler"+e,this.getShadowMapForRendering()),i.setTexture("depthSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/s.getSize().width,this._contactHardeningLightSizeUVRatio*s.getSize().width,this.frustumEdgeFalloff,e)):(i.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/s.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),r._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(o),this.getLight().getDepthMinZ(o)+this.getLight().getDepthMaxZ(o),e))}}},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;if(this._light.computeTransformedInformation()&&(i=this._light.transformedPosition),e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!i.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(i),this._cachedDirection.copyFrom(this._lightDirection),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix);var r=this.getShadowMap();if(r){var n=r.renderList;n&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,n)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},t.prototype.recreateShadowMap=function(){var e=this._shadowMap;if(e){var t=e.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=t}},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light&&(this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty())},t.prototype.serialize=function(){var e={},t=this.getShadowMap();if(!t)return e;if(e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.filteringQuality=this.filteringQuality,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.renderList=[],t.renderList)for(var i=0;i<t.renderList.length;i++){var r=t.renderList[i];e.renderList.push(r.id)}return e},t.Parse=function(e,i){for(var r=i.getLightByID(e.lightId),n=new t(e.mapSize,r),o=n.getShadowMap(),s=0;s<e.renderList.length;s++){i.getMeshesByID(e.renderList[s]).forEach(function(e){o&&(o.renderList||(o.renderList=[]),o.renderList.push(e))})}return e.usePoissonSampling?n.usePoissonSampling=!0:e.useExponentialShadowMap?n.useExponentialShadowMap=!0:e.useBlurExponentialShadowMap?n.useBlurExponentialShadowMap=!0:e.useCloseExponentialShadowMap?n.useCloseExponentialShadowMap=!0:e.useBlurCloseExponentialShadowMap?n.useBlurCloseExponentialShadowMap=!0:e.usePercentageCloserFiltering?n.usePercentageCloserFiltering=!0:e.useContactHardeningShadow&&(n.useContactHardeningShadow=!0),e.filteringQuality&&(n.filteringQuality=e.filteringQuality),e.contactHardeningLightSizeUVRatio?n.contactHardeningLightSizeUVRatio=e.contactHardeningLightSizeUVRatio:e.useVarianceShadowMap?n.useExponentialShadowMap=!0:e.useBlurVarianceShadowMap&&(n.useBlurExponentialShadowMap=!0),e.depthScale&&(n.depthScale=e.depthScale),e.blurScale&&(n.blurScale=e.blurScale),e.blurBoxOffset&&(n.blurBoxOffset=e.blurBoxOffset),e.useKernelBlur&&(n.useKernelBlur=e.useKernelBlur),e.blurKernel&&(n.blurKernel=e.blurKernel),void 0!==e.bias&&(n.bias=e.bias),void 0!==e.normalBias&&(n.normalBias=e.normalBias),void 0!==e.frustumEdgeFalloff&&(n.frustumEdgeFalloff=e.frustumEdgeFalloff),e.darkness&&n.setDarkness(e.darkness),e.transparencyShadow&&n.setTransparencyShadow(!0),n.forceBackFacesOnly=e.forceBackFacesOnly,n},t.FILTER_NONE=0,t.FILTER_EXPONENTIALSHADOWMAP=1,t.FILTER_POISSONSAMPLING=2,t.FILTER_BLUREXPONENTIALSHADOWMAP=3,t.FILTER_CLOSEEXPONENTIALSHADOWMAP=4,t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,t.FILTER_PCF=6,t.FILTER_PCSS=7,t.QUALITY_HIGH=0,t.QUALITY_MEDIUM=1,t.QUALITY_LOW=2,t}();e.ShadowGenerator=t}(a||(a={})),function(e){e.AbstractScene.AddParser(e.SceneComponentConstants.NAME_SHADOWGENERATOR,function(t,i,r,n){if(void 0!==t.shadowGenerators&&null!==t.shadowGenerators)for(var o=0,s=t.shadowGenerators.length;o<s;o++){var a=t.shadowGenerators[o];e.ShadowGenerator.Parse(a,i)}});var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_SHADOWGENERATOR,this.scene=t}return t.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(e.SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR,this,this._gatherRenderTargets)},t.prototype.rebuild=function(){},t.prototype.serialize=function(e){e.shadowGenerators=[];for(var t=0,i=this.scene.lights;t<i.length;t++){var r=i[t].getShadowGenerator();r&&e.shadowGenerators.push(r.serialize())}},t.prototype.addFromContainer=function(e){},t.prototype.removeFromContainer=function(e){},t.prototype.dispose=function(){},t.prototype._gatherRenderTargets=function(e){var t=this.scene;if(this.scene.shadowsEnabled)for(var i=0;i<t.lights.length;i++){var r=t.lights[i],n=r.getShadowGenerator();if(r.isEnabled()&&r.shadowEnabled&&n){var o=n.getShadowMap();-1!==t.textures.indexOf(o)&&e.push(o)}}},t}();e.ShadowGeneratorSceneComponent=t}(a||(a={})),function(e){var t=function(){function e(e,t,i){void 0===t&&(t=""),void 0===i&&(i="black");var r=this;this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(r._renderingCanvas).position;r._loadingDiv&&(r._loadingDiv.style.position="fixed"===t?"fixed":"absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px")}}return e.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var e=document.createElement("style");e.type="text/css";e.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(e);var t=new Image;t.src="data:image/png;base64,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",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-60px",t.style.marginTop="-60px",t.style.animation="spin1 2s infinite ease-in-out",t.style.webkitAnimation="spin1 2s infinite ease-in-out",t.style.transformOrigin="50% 50%",t.style.webkitTransformOrigin="50% 50%",this._loadingDiv.appendChild(t),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)})}},Object.defineProperty(e.prototype,"loadingUIText",{get:function(){return this._loadingText},set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e}();e.DefaultLoadingScreen=t}(a||(a={})),function(e){var t=function(){function e(e,t,i){this.lengthComputable=e,this.loaded=t,this.total=i}return e.FromProgressEvent=function(t){return new e(t.lengthComputable,t.loaded,t.total)},e}();e.SceneLoaderProgressEvent=t;var i=function(){function i(){}return Object.defineProperty(i,"ForceFullSceneLoadingForIncremental",{get:function(){return i._ForceFullSceneLoadingForIncremental},set:function(e){i._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ShowLoadingScreen",{get:function(){return i._ShowLoadingScreen},set:function(e){i._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(i,"loggingLevel",{get:function(){return i._loggingLevel},set:function(e){i._loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(i,"CleanBoneMatrixWeights",{get:function(){return i._CleanBoneMatrixWeights},set:function(e){i._CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),i._getDefaultPlugin=function(){return i._registeredPlugins[".babylon"]},i._getPluginForExtension=function(t){var r=i._registeredPlugins[t];return r||(e.Tools.Warn("Unable to find a plugin to load "+t+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: http://doc.babylonjs.com/how_to/load_from_any_file_type"),i._getDefaultPlugin())},i._getPluginForDirectLoad=function(e){for(var t in i._registeredPlugins){var r=i._registeredPlugins[t].plugin;if(r.canDirectLoad&&r.canDirectLoad(e))return i._registeredPlugins[t]}return i._getDefaultPlugin()},i._getPluginForFilename=function(e){var t=e.indexOf("?");-1!==t&&(e=e.substring(0,t));var r=e.lastIndexOf("."),n=e.substring(r,e.length).toLowerCase();return i._getPluginForExtension(n)},i._getDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},i._loadData=function(r,n,o,s,a,l,c){var u,h=i._getDirectLoad(r.name),d=c?i._getPluginForExtension(c):h?i._getPluginForDirectLoad(r.name):i._getPluginForFilename(r.name);u=d.plugin.createPlugin?d.plugin.createPlugin():d.plugin;var f,p=d.isBinary;i.OnPluginActivatedObservable.notifyObservers(u);var m=function(e,t){n.isDisposed?a("Scene has been disposed"):(n.database=f,o(u,e,t))},g=null,_=!1,v=u.onDisposeObservable;v&&v.add(function(){_=!0,g&&(g.abort(),g=null),l()});var A=function(){_||(g=e.Tools.LoadFile(r.url,m,s?function(e){s(t.FromProgressEvent(e))}:void 0,f,p,function(e,t){a("Failed to load scene."+(t?" "+t.message:""),t)}))};if(h)return m(h),u;if(-1===r.rootUrl.indexOf("file:")){var y=n.getEngine(),b=y.enableOfflineSupport;if(b){for(var T=!1,E=0,x=n.disableOfflineSupportExceptionRules;E<x.length;E++){if(x[E].test(r.url)){T=!0;break}}b=!T}b?f=new e.Database(r.url,A,y.disableManifestCheck):A()}else{var P=e.FilesInput.FilesToLoad[r.name.toLowerCase()];P?g=e.Tools.ReadFile(P,m,s,p):a("Unable to find file named "+r.name)}return u},i._getFileInfo=function(t,i){var r,n;if(i){if("/"===i.substr(0,1))return e.Tools.Error("Wrong sceneFilename parameter"),null;r=t+i,n=i}else r=t,n=e.Tools.GetFilename(t),t=e.Tools.GetFolderPath(t);return{url:r,rootUrl:t,name:n}},i.GetPluginForExtension=function(e){return i._getPluginForExtension(e).plugin},i.IsPluginForExtensionAvailable=function(e){return!!i._registeredPlugins[e]},i.RegisterPlugin=function(e){if("string"==typeof e.extensions){var t=e.extensions;i._registeredPlugins[t.toLowerCase()]={plugin:e,isBinary:!1}}else{var r=e.extensions;Object.keys(r).forEach(function(t){i._registeredPlugins[t.toLowerCase()]={plugin:e,isBinary:r[t].isBinary}})}},i.ImportMesh=function(t,r,n,o,s,a,l,c){if(void 0===n&&(n=""),void 0===o&&(o=e.Engine.LastCreatedScene),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===c&&(c=null),!o)return e.Tools.Error("No scene available to import mesh to"),null;var u=i._getFileInfo(r,n);if(!u)return null;var h={};o._addPendingData(h);var d=function(){o._removePendingData(h)},f=function(t,i){var r="Unable to import meshes from "+u.url+": "+t;l?l(o,r,i):e.Tools.Error(r),d()},p=a?function(e){try{a(e)}catch(e){f("Error in onProgress callback",e)}}:void 0,m=function(e,t,i,r){if(o.importedMeshesFiles.push(u.url),s)try{s(e,t,i,r)}catch(e){f("Error in onSuccess callback",e)}o._removePendingData(h)};return i._loadData(u,o,function(e,i,r){if(e.rewriteRootURL&&(u.rootUrl=e.rewriteRootURL(u.rootUrl,r)),e.importMesh){var n=e,s=new Array,a=new Array,l=new Array;if(!n.importMesh(t,o,i,u.rootUrl,s,a,l,f))return;o.loadingPluginName=e.name,m(s,a,l,[])}else{e.importMeshAsync(t,o,i,u.rootUrl,p,u.name).then(function(t){o.loadingPluginName=e.name,m(t.meshes,t.particleSystems,t.skeletons,t.animationGroups)}).catch(function(e){f(e.message,e)})}},p,f,d,c)},i.ImportMeshAsync=function(t,r,n,o,s,a){return void 0===n&&(n=""),void 0===o&&(o=e.Engine.LastCreatedScene),void 0===s&&(s=null),void 0===a&&(a=null),new Promise(function(e,l){i.ImportMesh(t,r,n,o,function(t,i,r,n){e({meshes:t,particleSystems:i,skeletons:r,animationGroups:n})},s,function(e,t,i){l(i||new Error(t))},a)})},i.Load=function(t,r,n,o,s,a,l){return void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),i.Append(t,r,new e.Scene(n),o,s,a,l)},i.LoadAsync=function(e,t,r,n,o){return void 0===n&&(n=null),void 0===o&&(o=null),new Promise(function(s,a){i.Load(e,t,r,function(e){s(e)},n,function(e,t,i){a(i||new Error(t))},o)})},i.Append=function(t,r,n,o,s,a,l){if(void 0===r&&(r=""),void 0===n&&(n=e.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),!n)return e.Tools.Error("No scene available to append to"),null;var c=i._getFileInfo(t,r);if(!c)return null;i.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var u={};n._addPendingData(u);var h=function(){n._removePendingData(u),n.getEngine().hideLoadingUI()},d=function(t,i){var r="Unable to load from "+c.url+(t?": "+t:"");a?a(n,r,i):e.Tools.Error(r),h()},f=s?function(e){try{s(e)}catch(e){d("Error in onProgress callback",e)}}:void 0,p=function(){if(o)try{o(n)}catch(e){d("Error in onSuccess callback",e)}n._removePendingData(u)};return i._loadData(c,n,function(e,t,r){if(e.load){if(!e.load(n,t,c.rootUrl,d))return;n.loadingPluginName=e.name,p()}else{e.loadAsync(n,t,c.rootUrl,f,c.name).then(function(){n.loadingPluginName=e.name,p()}).catch(function(e){d(e.message,e)})}i.ShowLoadingScreen&&n.executeWhenReady(function(){n.getEngine().hideLoadingUI()})},f,d,h,l)},i.AppendAsync=function(t,r,n,o,s){return void 0===r&&(r=""),void 0===n&&(n=e.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(e,a){i.Append(t,r,n,function(t){e(t)},o,function(e,t,i){a(i||new Error(t))},s)})},i.LoadAssetContainer=function(t,r,n,o,s,a,l){if(void 0===r&&(r=""),void 0===n&&(n=e.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),!n)return e.Tools.Error("No scene available to load asset container to"),null;var c=i._getFileInfo(t,r);if(!c)return null;var u={};n._addPendingData(u);var h=function(){n._removePendingData(u)},d=function(t,i){var r="Unable to load assets from "+c.url+(t?": "+t:"");a?a(n,r,i):e.Tools.Error(r),h()},f=s?function(e){try{s(e)}catch(e){d("Error in onProgress callback",e)}}:void 0,p=function(e){if(o)try{o(e)}catch(e){d("Error in onSuccess callback",e)}n._removePendingData(u)};return i._loadData(c,n,function(e,t,r){if(e.loadAssetContainer){var o=e.loadAssetContainer(n,t,c.rootUrl,d);if(!o)return;n.loadingPluginName=e.name,p(o)}else if(e.loadAssetContainerAsync){e.loadAssetContainerAsync(n,t,c.rootUrl,f,c.name).then(function(t){n.loadingPluginName=e.name,p(t)}).catch(function(e){d(e.message,e)})}else d("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");i.ShowLoadingScreen&&n.executeWhenReady(function(){n.getEngine().hideLoadingUI()})},f,d,h,l)},i.LoadAssetContainerAsync=function(t,r,n,o,s){return void 0===r&&(r=""),void 0===n&&(n=e.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(e,a){i.LoadAssetContainer(t,r,n,function(t){e(t)},o,function(e,t,i){a(i||new Error(t))},s)})},i._ForceFullSceneLoadingForIncremental=!1,i._ShowLoadingScreen=!0,i._CleanBoneMatrixWeights=!1,i.NO_LOGGING=0,i.MINIMAL_LOGGING=1,i.SUMMARY_LOGGING=2,i.DETAILED_LOGGING=3,i._loggingLevel=i.NO_LOGGING,i.OnPluginActivatedObservable=new e.Observable,i._registeredPlugins={},i}();e.SceneLoader=i}(a||(a={})),function(e){var t=function(t,i,r,n){for(var o=0,s=i.materials.length;o<s;o++){var a=i.materials[o];if(a.id===t)return e.Material.Parse(a,r,n)}return null},i=function(e,t,i){for(var r in t)if(e.name===t[r])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId))&&(i.push(e.id),!0)},r=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},n=function(t,i,n,o,s){void 0===s&&(s=!1);var a=new e.AssetContainer(t),l="importScene has failed JSON parse";try{var c=JSON.parse(i);l="";var u,h,d=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;if(void 0!==c.lights&&null!==c.lights)for(u=0,h=c.lights.length;u<h;u++){var f=c.lights[u],p=e.Light.Parse(f,t);p&&(a.lights.push(p),l+=0===u?"\n\tLights:":"",l+="\n\t\t"+p.toString(d))}if(void 0!==c.animations&&null!==c.animations)for(u=0,h=c.animations.length;u<h;u++){var m=c.animations[u],g=e.Animation.Parse(m);t.animations.push(g),a.animations.push(g),l+=0===u?"\n\tAnimations:":"",l+="\n\t\t"+g.toString(d)}if(void 0!==c.materials&&null!==c.materials)for(u=0,h=c.materials.length;u<h;u++){var _=c.materials[u],v=e.Material.Parse(_,t,n);a.materials.push(v),l+=0===u?"\n\tMaterials:":"",l+="\n\t\t"+v.toString(d)}if(void 0!==c.multiMaterials&&null!==c.multiMaterials)for(u=0,h=c.multiMaterials.length;u<h;u++){var A=c.multiMaterials[u],y=e.Material.ParseMultiMaterial(A,t);a.multiMaterials.push(y),l+=0===u?"\n\tMultiMaterials:":"",l+="\n\t\t"+y.toString(d)}if(void 0!==c.morphTargetManagers&&null!==c.morphTargetManagers)for(var b=0,T=c.morphTargetManagers;b<T.length;b++){var E=T[b];a.morphTargetManagers.push(e.MorphTargetManager.Parse(E,t))}if(void 0!==c.skeletons&&null!==c.skeletons)for(u=0,h=c.skeletons.length;u<h;u++){var x=c.skeletons[u],P=e.Skeleton.Parse(x,t);a.skeletons.push(P),l+=0===u?"\n\tSkeletons:":"",l+="\n\t\t"+P.toString(d)}var M=c.geometries;if(void 0!==M&&null!==M){var S=new Array,C=M.boxes;if(void 0!==C&&null!==C)for(u=0,h=C.length;u<h;u++){var R=C[u];S.push(e.BoxGeometry.Parse(R,t))}var O=M.spheres;if(void 0!==O&&null!==O)for(u=0,h=O.length;u<h;u++){var D=O[u];S.push(e.SphereGeometry.Parse(D,t))}var I=M.cylinders;if(void 0!==I&&null!==I)for(u=0,h=I.length;u<h;u++){var w=I[u];S.push(e.CylinderGeometry.Parse(w,t))}var L=M.toruses;if(void 0!==L&&null!==L)for(u=0,h=L.length;u<h;u++){var B=L[u];S.push(e.TorusGeometry.Parse(B,t))}var F=M.grounds;if(void 0!==F&&null!==F)for(u=0,h=F.length;u<h;u++){var N=F[u];S.push(e.GroundGeometry.Parse(N,t))}var V=M.planes;if(void 0!==V&&null!==V)for(u=0,h=V.length;u<h;u++){var U=V[u];S.push(e.PlaneGeometry.Parse(U,t))}var G=M.torusKnots;if(void 0!==G&&null!==G)for(u=0,h=G.length;u<h;u++){var k=G[u];S.push(e.TorusKnotGeometry.Parse(k,t))}var z=M.vertexData;if(void 0!==z&&null!==z)for(u=0,h=z.length;u<h;u++){var H=z[u];S.push(e.Geometry.Parse(H,t,n))}S.forEach(function(e){e&&a.geometries.push(e)})}if(void 0!==c.transformNodes&&null!==c.transformNodes)for(u=0,h=c.transformNodes.length;u<h;u++){var j=c.transformNodes[u],W=e.TransformNode.Parse(j,t,n);a.transformNodes.push(W)}if(void 0!==c.meshes&&null!==c.meshes)for(u=0,h=c.meshes.length;u<h;u++){var X=c.meshes[u],Y=e.Mesh.Parse(X,t,n);a.meshes.push(Y),l+=0===u?"\n\tMeshes:":"",l+="\n\t\t"+Y.toString(d)}if(void 0!==c.cameras&&null!==c.cameras)for(u=0,h=c.cameras.length;u<h;u++){var Q=c.cameras[u],K=e.Camera.Parse(Q,t);a.cameras.push(K),l+=0===u?"\n\tCameras:":"",l+="\n\t\t"+K.toString(d)}if(void 0!==c.animationGroups&&null!==c.animationGroups)for(u=0,h=c.animationGroups.length;u<h;u++){var Z=c.animationGroups[u],J=e.AnimationGroup.Parse(Z,t);a.animationGroups.push(J),l+=0===u?"\n\tAnimationGroups:":"",l+="\n\t\t"+J.toString(d)}for(u=0,h=t.cameras.length;u<h;u++){(K=t.cameras[u])._waitingParentId&&(K.parent=t.getLastEntryByID(K._waitingParentId),K._waitingParentId=null)}for(u=0,h=t.lights.length;u<h;u++){var q=t.lights[u];q&&q._waitingParentId&&(q.parent=t.getLastEntryByID(q._waitingParentId),q._waitingParentId=null)}for(u=0,h=t.transformNodes.length;u<h;u++){var $=t.transformNodes[u];$._waitingParentId&&($.parent=t.getLastEntryByID($._waitingParentId),$._waitingParentId=null)}for(u=0,h=t.meshes.length;u<h;u++){(Y=t.meshes[u])._waitingParentId&&(Y.parent=t.getLastEntryByID(Y._waitingParentId),Y._waitingParentId=null)}for(u=0,h=t.meshes.length;u<h;u++){var ee=t.meshes[u];ee._waitingFreezeWorldMatrix?(ee.freezeWorldMatrix(),ee._waitingFreezeWorldMatrix=null):ee.computeWorldMatrix(!0)}for(u=0,h=t.lights.length;u<h;u++){var te=t.lights[u];if(te._excludedMeshesIds.length>0){for(var ie=0;ie<te._excludedMeshesIds.length;ie++){var re=t.getMeshByID(te._excludedMeshesIds[ie]);re&&te.excludedMeshes.push(re)}te._excludedMeshesIds=[]}if(te._includedOnlyMeshesIds.length>0){for(var ne=0;ne<te._includedOnlyMeshesIds.length;ne++){var oe=t.getMeshByID(te._includedOnlyMeshesIds[ne]);oe&&te.includedOnlyMeshes.push(oe)}te._includedOnlyMeshesIds=[]}}for(e.AbstractScene.Parse(c,t,a,n),u=0,h=t.meshes.length;u<h;u++){(Y=t.meshes[u])._waitingActions&&(e.ActionManager.Parse(Y._waitingActions,Y,t),Y._waitingActions=null)}void 0!==c.actions&&null!==c.actions&&e.ActionManager.Parse(c.actions,null,t),s||a.removeAllFromScene()}catch(t){var se=r("loadAssets",c?c.producer:"Unknown")+l;if(!o)throw e.Tools.Log(se),t;o(se,t)}finally{null!==l&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(r("loadAssets",c?c.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?l:""))}return a};e.SceneLoader.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(e){return-1!==e.indexOf("babylon")},importMesh:function(n,o,s,a,l,c,u,h){var d="importMesh has failed JSON parse";try{var f=JSON.parse(s);d="";var p=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;n?Array.isArray(n)||(n=[n]):n=null;var m=new Array;if(void 0!==f.meshes&&null!==f.meshes){var g,_,v,A=[],y=[];for(g=0,_=f.meshes.length;g<_;g++){var b=f.meshes[g];if(null===n||i(b,n,m)){if(null!==n&&delete n[n.indexOf(b.name)],void 0!==b.geometryId&&null!==b.geometryId&&void 0!==f.geometries&&null!==f.geometries){var T=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(t){!0!==T&&f.geometries[t]&&Array.isArray(f.geometries[t])&&f.geometries[t].forEach(function(i){if(i.id===b.geometryId){switch(t){case"boxes":e.BoxGeometry.Parse(i,o);break;case"spheres":e.SphereGeometry.Parse(i,o);break;case"cylinders":e.CylinderGeometry.Parse(i,o);break;case"toruses":e.TorusGeometry.Parse(i,o);break;case"grounds":e.GroundGeometry.Parse(i,o);break;case"planes":e.PlaneGeometry.Parse(i,o);break;case"torusKnots":e.TorusKnotGeometry.Parse(i,o);break;case"vertexData":e.Geometry.Parse(i,o,a)}T=!0}})}),!1===T&&e.Tools.Warn("Geometry not found for mesh "+b.id)}if(b.materialId){var E=-1!==y.indexOf(b.materialId);if(!1===E&&void 0!==f.multiMaterials&&null!==f.multiMaterials)for(var x=0,P=f.multiMaterials.length;x<P;x++){var M=f.multiMaterials[x];if(M.id===b.materialId){for(var S=0,C=M.materials.length;S<C;S++){var R,O=M.materials[S];y.push(O),(R=t(O,f,o,a))&&(d+="\n\tMaterial "+R.toString(p))}y.push(M.id);var D=e.Material.ParseMultiMaterial(M,o);D&&(E=!0,d+="\n\tMulti-Material "+D.toString(p));break}}if(!1===E)y.push(b.materialId),(R=t(b.materialId,f,o,a))?d+="\n\tMaterial "+R.toString(p):e.Tools.Warn("Material not found for mesh "+b.id)}if(b.skeletonId>-1&&void 0!==f.skeletons&&null!==f.skeletons)if(!1===A.indexOf(b.skeletonId)>-1)for(var I=0,w=f.skeletons.length;I<w;I++){var L=f.skeletons[I];if(L.id===b.skeletonId){var B=e.Skeleton.Parse(L,o);u.push(B),A.push(L.id),d+="\n\tSkeleton "+B.toString(p)}}if(void 0!==f.morphTargetManagers&&null!==f.morphTargetManagers)for(var F=0,N=f.morphTargetManagers;F<N.length;F++){var V=N[F];e.MorphTargetManager.Parse(V,o)}var U=e.Mesh.Parse(b,o,a);l.push(U),d+="\n\tMesh "+U.toString(p)}}for(g=0,_=o.meshes.length;g<_;g++)(v=o.meshes[g])._waitingParentId&&(v.parent=o.getLastEntryByID(v._waitingParentId),v._waitingParentId=null);for(g=0,_=o.meshes.length;g<_;g++)(v=o.meshes[g])._waitingFreezeWorldMatrix?(v.freezeWorldMatrix(),v._waitingFreezeWorldMatrix=null):v.computeWorldMatrix(!0)}if(void 0!==f.particleSystems&&null!==f.particleSystems){var G=e.AbstractScene.GetIndividualParser(e.SceneComponentConstants.NAME_PARTICLESYSTEM);if(G)for(g=0,_=f.particleSystems.length;g<_;g++){var k=f.particleSystems[g];-1!==m.indexOf(k.emitterId)&&c.push(G(k,o,a))}}return!0}catch(t){var z=r("importMesh",f?f.producer:"Unknown")+d;if(!h)throw e.Tools.Log(z),t;h(z,t)}finally{null!==d&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(r("importMesh",f?f.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?d:""))}return!1},load:function(t,i,o,s){var a="importScene has failed JSON parse";try{var l=JSON.parse(i);if(a="",void 0!==l.useDelayedTextureLoading&&null!==l.useDelayedTextureLoading&&(t.useDelayedTextureLoading=l.useDelayedTextureLoading&&!e.SceneLoader.ForceFullSceneLoadingForIncremental),void 0!==l.autoClear&&null!==l.autoClear&&(t.autoClear=l.autoClear),void 0!==l.clearColor&&null!==l.clearColor&&(t.clearColor=e.Color4.FromArray(l.clearColor)),void 0!==l.ambientColor&&null!==l.ambientColor&&(t.ambientColor=e.Color3.FromArray(l.ambientColor)),void 0!==l.gravity&&null!==l.gravity&&(t.gravity=e.Vector3.FromArray(l.gravity)),l.fogMode&&0!==l.fogMode)switch(t.fogMode=l.fogMode,t.fogColor=e.Color3.FromArray(l.fogColor),t.fogStart=l.fogStart,t.fogEnd=l.fogEnd,t.fogDensity=l.fogDensity,a+="\tFog mode for scene: ",t.fogMode){case 1:a+="exp\n";break;case 2:a+="exp2\n";break;case 3:a+="linear\n"}if(l.physicsEnabled){var c;"cannon"===l.physicsEngine?c=new e.CannonJSPlugin:"oimo"===l.physicsEngine&&(c=new e.OimoJSPlugin),a="\tPhysics engine "+(l.physicsEngine?l.physicsEngine:"oimo")+" enabled\n";var u=l.physicsGravity?e.Vector3.FromArray(l.physicsGravity):null;t.enablePhysics(u,c)}if(void 0!==l.metadata&&null!==l.metadata&&(t.metadata=l.metadata),void 0!==l.collisionsEnabled&&null!==l.collisionsEnabled&&(t.collisionsEnabled=l.collisionsEnabled),t.workerCollisions=!!l.workerCollisions,!n(t,i,o,s,!0))return!1;if(l.autoAnimate&&t.beginAnimation(t,l.autoAnimateFrom,l.autoAnimateTo,l.autoAnimateLoop,l.autoAnimateSpeed||1),void 0!==l.activeCameraID&&null!==l.activeCameraID&&t.setActiveCameraByID(l.activeCameraID),void 0!==l.environmentTexture&&null!==l.environmentTexture){if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var h=l.environmentTextureSize?l.environmentTextureSize:128,d=new e.HDRCubeTexture(o+l.environmentTexture,t,h);l.environmentTextureRotationY&&(d.rotationY=l.environmentTextureRotationY),t.environmentTexture=d}else{var f=e.CubeTexture.CreateFromPrefilteredData(o+l.environmentTexture,t);l.environmentTextureRotationY&&(f.rotationY=l.environmentTextureRotationY),t.environmentTexture=f}if(!0===l.createDefaultSkybox){var p=void 0!==t.activeCamera&&null!==t.activeCamera?(t.activeCamera.maxZ-t.activeCamera.minZ)/2:1e3,m=l.skyboxBlurLevel||0;t.createDefaultSkybox(void 0,!0,p,m)}}return!0}catch(t){var g=r("importScene",l?l.producer:"Unknown")+a;if(!s)throw e.Tools.Log(g),t;s(g,t)}finally{null!==a&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(r("importScene",l?l.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?a:""))}return!1},loadAssetContainer:function(e,t,i,r){return n(e,t,i,r)}})}(a||(a={})),function(e){var t=function(){function t(e,t,i,r,n,o,s,a,l){this.onProcessFileCallback=function(){return!0},this._engine=e,this._currentScene=t,this._sceneLoadedCallback=i,this._progressCallback=r,this._additionalRenderLoopLogicCallback=n,this._textureLoadingCallback=o,this._startingProcessingFilesCallback=s,this._onReloadCallback=a,this._errorCallback=l}return t.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._dragEnterHandler=function(e){t.drag(e)},this._dragOverHandler=function(e){t.drag(e)},this._dropHandler=function(e){t.drop(e)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},t.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},t.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._traverseFolder=function(e,t,i,r){var n=this,o=e.createReader(),s=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries(function(e){i.count+=e.length;for(var o=0,a=e;o<a.length;o++){var l=a[o];l.isFile?l.file(function(e){e.correctName=s+e.name,t.push(e),0==--i.count&&r()}):l.isDirectory&&n._traverseFolder(l,t,i,r)}--i.count&&r()})},t.prototype._processFiles=function(e){for(var i=0;i<e.length;i++){var r=e[i].correctName.toLowerCase(),n=r.split(".").pop();this.onProcessFileCallback(e[i],r,n)&&("babylon"!==n&&"stl"!==n&&"obj"!==n&&"gltf"!==n&&"glb"!==n||-1!==r.indexOf(".binary.babylon")||-1!==r.indexOf(".incremental.babylon")||(this._sceneFileToLoad=e[i]),t.FilesToLoad[r]=e[i])}},t.prototype.loadFiles=function(e){var t=this;if(e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&0!==this._filesToLoad.length&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var i=new Array,r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o<this._filesToLoad.length;o++){var s=this._filesToLoad[o],a=s.name.toLowerCase(),l=void 0;if(s.correctName=a,n){var c=n[o];c.getAsEntry?l=c.getAsEntry():c.webkitGetAsEntry&&(l=c.webkitGetAsEntry())}l&&l.isDirectory?r.push(l):i.push(s)}if(0===r.length)this._processFiles(i),this._processReload();else for(var u={count:r.length},h=0,d=r;h<d.length;h++){var f=d[h];this._traverseFolder(f,i,u,function(){t._processFiles(i),0===u.count&&t._processReload()})}}},t.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},t.prototype.reload=function(){var t=this;this._sceneFileToLoad?(this._currentScene&&(e.Tools.errorsCount>0&&e.Tools.ClearLogCache(),this._engine.stopRenderLoop()),e.SceneLoader.LoadAsync("file:",this._sceneFileToLoad.name,this._engine,function(e){t._progressCallback&&t._progressCallback(e)}).then(function(e){t._currentScene&&t._currentScene.dispose(),t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady(function(){t._engine.runRenderLoop(function(){t.renderFunction()})})}).catch(function(e){t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,e.message)})):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesToLoad={},t}();e.FilesInput=t}(a||(a={})),function(e){var t=function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return!!t._tags&&!e.Tools.IsEmpty(t._tags)},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){i&&("string"==typeof i&&i.split(" ").forEach(function(i,r,n){t._AddTagTo(e,i)}))},t._AddTagTo=function(e,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r||(""===r?t.HasTags(i):e.AndOrNotEvaluator.Eval(r,function(e){return t.HasTags(i)&&i._tags[e]}))},t}();e.Tags=t}(a||(a={})),function(e){var t=function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)}):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){var r;i=i||function(e){return"true"===e};var n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var l=0;l<a.length;++l){var c=e._SimplifyNegation(a[l].trim());if(!(r="true"!==c&&"false"!==c?"!"===c[0]?!i(c.substring(1)):i(c):"true"===c)){s="false";break}}if(r||"true"===s){r=!0;break}r="true"!==s&&"false"!==s?"!"===s[0]?!i(s.substring(1)):i(s):"true"===s}return r?"true":"false"},e._SimplifyNegation=function(e){return"!true"===(e=(e=e.replace(/^[\s!]+/,function(e){return(e=e.replace(/[\s]/g,function(){return""})).length%2?"!":""})).trim())?e="false":"!false"===e&&(e="true"),e},e}();e.AndOrNotEvaluator=t}(a||(a={})),function(e){var t=function(){function t(i,r,n){void 0===n&&(n=!1);var o=this;this.idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this.callbackManifestChecked=r,this.currentSceneUrl=t._ReturnFullUrlLocation(i),this.db=null,this._enableSceneOffline=!1,this._enableTexturesOffline=!1,this.manifestVersionFound=0,this.mustUpdateRessources=!1,this.hasReachedQuota=!1,t.IDBStorageEnabled?n?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this.manifestVersionFound=1,e.Tools.SetImmediate(function(){o.callbackManifestChecked(!0)})):this._checkManifestFile():this.callbackManifestChecked(!0)}return Object.defineProperty(t.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!0,configurable:!0}),t.prototype._checkManifestFile=function(){var t=this,i=function(){t._enableSceneOffline=!1,t._enableTexturesOffline=!1,t.callbackManifestChecked(!1)},r=!1,n=this.currentSceneUrl+".manifest",o=new XMLHttpRequest;navigator.onLine&&(r=!0,n=n+(null==n.match(/\?/)?"?":"&")+Date.now()),o.open("GET",n,!0),o.addEventListener("load",function(){if(200===o.status||e.Tools.ValidateXHRData(o,1))try{var r=JSON.parse(o.response);t._enableSceneOffline=r.enableSceneOffline,t._enableTexturesOffline=r.enableTexturesOffline,r.version&&!isNaN(parseInt(r.version))&&(t.manifestVersionFound=r.version),t.callbackManifestChecked&&t.callbackManifestChecked(!0)}catch(e){i()}else i()},!1),o.addEventListener("error",function(e){if(r){r=!1;var n=t.currentSceneUrl+".manifest";o.open("GET",n,!0),o.send()}else i()},!1);try{o.send()}catch(t){e.Tools.Error("Error on XHR send request."),this.callbackManifestChecked(!1)}},t.prototype.openAsync=function(t,i){var r=this,n=function(){r.isSupported=!1,i&&i()};if(this.idbFactory&&(this._enableSceneOffline||this._enableTexturesOffline))if(this.db)t&&t();else{this.hasReachedQuota=!1,this.isSupported=!0;var o=this.idbFactory.open("babylonjs",1);o.onerror=function(e){n()},o.onblocked=function(t){e.Tools.Error("IDB request blocked. Please reload the page."),n()},o.onsuccess=function(e){r.db=o.result,t()},o.onupgradeneeded=function(t){if(r.db=t.target.result,r.db)try{r.db.createObjectStore("scenes",{keyPath:"sceneUrl"}),r.db.createObjectStore("versions",{keyPath:"sceneUrl"}),r.db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(t){e.Tools.Error("Error while creating object stores. Exception: "+t.message),n()}}}else this.isSupported=!1,i&&i()},t.prototype.loadImageFromDB=function(e,i){var r=this,n=t._ReturnFullUrlLocation(e),o=function(){r.hasReachedQuota||null===r.db?i.src=e:r._saveImageIntoDBAsync(n,i)};this.mustUpdateRessources?o():this._loadImageFromDBAsync(n,i,o)},t.prototype._loadImageFromDBAsync=function(t,i,r){if(this.isSupported&&null!==this.db){var n,o=this.db.transaction(["textures"]);o.onabort=function(e){i.src=t},o.oncomplete=function(o){var s;if(n){var a=window.URL||window.webkitURL;s=a.createObjectURL(n.data),i.onerror=function(){e.Tools.Error("Error loading image from blob URL: "+s+" switching back to web url: "+t),i.src=t},i.src=s}else r()};var s=o.objectStore("textures").get(t);s.onsuccess=function(e){n=e.target.result},s.onerror=function(r){e.Tools.Error("Error loading texture "+t+" from DB."),i.src=t}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i.src=t},t.prototype._saveImageIntoDBAsync=function(i,r){var n=this;if(this.isSupported){var o=function(){var e;if(s){var t=window.URL||window.webkitURL;try{e=t.createObjectURL(s)}catch(i){e=t.createObjectURL(s)}}e&&(r.src=e)};if(t.IsUASupportingBlobStorage){var s,a=new XMLHttpRequest;a.open("GET",i,!0),a.responseType="blob",a.addEventListener("load",function(){if(200===a.status&&n.db){s=a.response;var e=n.db.transaction(["textures"],"readwrite");e.onabort=function(e){try{var t=(e.srcElement||e.target).error;t&&"QuotaExceededError"===t.name&&(n.hasReachedQuota=!0)}catch(e){}o()},e.oncomplete=function(e){o()};var l={textureUrl:i,data:s};try{var c=e.objectStore("textures").put(l);c.onsuccess=function(e){},c.onerror=function(e){o()}}catch(e){25===e.code&&(t.IsUASupportingBlobStorage=!1),r.src=i}}else r.src=i},!1),a.addEventListener("error",function(t){e.Tools.Error("Error in XHR request in BABYLON.Database."),r.src=i},!1),a.send()}else r.src=i}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),r.src=i},t.prototype._checkVersionFromDB=function(e,t){var i=this;this._loadVersionFromDBAsync(e,t,function(){i._saveVersionIntoDBAsync(e,t)})},t.prototype._loadVersionFromDBAsync=function(t,i,r){var n,o=this;if(this.isSupported&&this.db)try{var s=this.db.transaction(["versions"]);s.oncomplete=function(e){n?o.manifestVersionFound!==n.data?(o.mustUpdateRessources=!0,r()):i(n.data):(o.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){n=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+t.message),i(-1)}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota&&this.db)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(t){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+t.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t._ReturnFullUrlLocation(e),l=function(){s._saveFileIntoDBAsync(a,i,r,o,n)};this._checkVersionFromDB(a,function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o,n):s._loadFileFromDBAsync(a,i,l,o):n&&n()})},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported&&this.db){var o,s;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var l=a.objectStore(o).get(t);l.onsuccess=function(e){s=e.target.result},l.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n,o){var s=this;if(this.isSupported){var a;a=-1!==t.indexOf(".babylon")?"scenes":"textures";var l,c=new XMLHttpRequest;c.open("GET",t+"?"+Date.now(),!0),n&&(c.responseType="arraybuffer"),r&&(c.onprogress=r),c.addEventListener("load",function(){if(200===c.status||c.status<400&&e.Tools.ValidateXHRData(c,n?6:1))if(l=n?c.response:c.responseText,!s.hasReachedQuota&&s.db){var r,u=s.db.transaction([a],"readwrite");u.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(s.hasReachedQuota=!0)}catch(e){}i(l)},u.oncomplete=function(e){i(l)},r="scenes"===a?{sceneUrl:t,data:l,version:s.manifestVersionFound}:{textureUrl:t,data:l};try{var h=u.objectStore(a).put(r);h.onsuccess=function(e){},h.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(l)}}else i(l);else c.status>=400&&o?o(c):i()},!1),c.addEventListener("error",function(t){e.Tools.Error("error on XHR request."),i()},!1),c.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t._ParseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},t._ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?t._ParseURL(window.location.href)+e:e},t}();e.Database=t}(a||(a={})),function(e){var t=function(){function t(){this._isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag|e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor.asArray(),e.rightColor=this.rightColor.asArray(),e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t}();e.FresnelParameters=t}(a||(a={})),function(e){var t=function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r.storeEffectOnSubMeshes=!0,r}return o(i,t),Object.defineProperty(i.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),i.prototype._hookArray=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._markAllSubMeshesAsTexturesDirty(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._markAllSubMeshesAsTexturesDirty(),o}},i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getActiveTextures=function(){var e;return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map(function(e){return e?e.getActiveTextures():[]}))},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r<this.subMaterials.length;r++){var n=this.subMaterials[r];if(n){if(n.storeEffectOnSubMeshes){if(!n.isReadyForSubMesh(e,t,i))return!1;continue}if(!n.isReady(e))return!1}}return!0},i.prototype.clone=function(e,t){for(var r=new i(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o=null,s=this.subMaterials[n];o=t&&s?s.clone(e+"-"+s.name):this.subMaterials[n],r.subMaterials.push(o)}return r},i.prototype.serialize=function(){var t={};t.name=this.name,t.id=this.id,e.Tags&&(t.tags=e.Tags.GetTags(this)),t.materials=[];for(var i=0;i<this.subMaterials.length;i++){var r=this.subMaterials[i];r?t.materials.push(r.id):t.materials.push(null)}return t},i.prototype.dispose=function(e,i){var r=this.getScene();if(r){var n=r.multiMaterials.indexOf(this);n>=0&&r.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,i)}},i}(e.Material);e.MultiMaterial=t}(a||(a={})),function(e){var t=function(){function t(){this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array}return t.prototype.attachControl=function(t,i){var r=this,n=null;void 0===this._pointerInput&&(this._onLostFocus=function(e){r._offsetX=null,r._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),r._pointerPressed.push(s.pointerId),1!==r._pointerPressed.length)return;n={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){if(i||s.preventDefault(),-1===(a=r._pointerPressed.indexOf(s.pointerId)))return;if(r._pointerPressed.splice(a,1),0!=a)return;n=null,r._offsetX=null,r._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!n)return;var a;if(0!=(a=r._pointerPressed.indexOf(s.pointerId)))return;r._offsetX=s.clientX-n.x,r._offsetY=-(s.clientY-n.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onLostFocus&&t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus&&(e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null),this._pointerPressed=[],this._offsetX=null,this._offsetY=null)},t.prototype.checkInputs=function(){if(this._offsetX&&this._offsetY){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getClassName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},n([e.serialize()],t.prototype,"touchAngularSensibility",void 0),n([e.serialize()],t.prototype,"touchMoveSensibility",void 0),t}();e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("TouchCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return o(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(e.FreeCamera);e.TouchCamera=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===s&&(s=null),void 0===a&&(a=!0),void 0===l&&(l=!1);var c=t.call(this,null,o,!a)||this;c.isCube=l,c.isEnabled=!0,c.autoClear=!0,c.onGeneratedObservable=new e.Observable,c._textures={},c._currentRefreshId=-1,c._refreshRate=1,c._vertexBuffers={},c._uniforms=new Array,c._samplers=new Array,c._floats={},c._ints={},c._floatsArrays={},c._colors3={},c._colors4={},c._vectors2={},c._vectors3={},c._matrices={},c._fallbackTextureUsed=!1,c._cachedDefines="",c._contentUpdateId=-1;var u=(o=c.getScene())._getComponent(e.SceneComponentConstants.NAME_PROCEDURALTEXTURE);u||(u=new e.ProceduralTextureSceneComponent(o),o._addComponent(u)),o.proceduralTextures.push(c),c._engine=o.getEngine(),c.name=i,c.isRenderTarget=!0,c._size=r,c._generateMipMaps=a,c.setFragment(n),c._fallbackTexture=s,l?(c._texture=c._engine.createRenderTargetCubeTexture(r,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1}),c.setFloat("face",0)):c._texture=c._engine.createRenderTargetTexture(r,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1});var h=[];return h.push(1,1),h.push(-1,1),h.push(-1,-1),h.push(1,-1),c._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c._engine,h,e.VertexBuffer.PositionKind,!1,!1,2),c._createIndexBuffer(),c}return o(i,t),i.prototype.getContent=function(){return this._contentData&&this._currentRefreshId==this._contentUpdateId?this._contentData:(this._contentData=this.readPixels(0,0,this._contentData),this._contentUpdateId=this._currentRefreshId,this._contentData)},i.prototype._createIndexBuffer=function(){var e=this._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},i.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),this._createIndexBuffer(),this.refreshRate===e.RenderTargetTexture.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=e.RenderTargetTexture.REFRESHRATE_RENDER_ONCE)},i.prototype.reset=function(){void 0!==this._effect&&this._engine._releaseEffect(this._effect)},i.prototype._getDefines=function(){return""},i.prototype.isReady=function(){var t,i=this,r=this._engine;if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var n=this._getDefines();return!(!this._effect||n!==this._cachedDefines||!this._effect.isReady())||(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=n,this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,n,void 0,void 0,function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture&&i._texture.incrementReferences()),i._fallbackTextureUsed=!0}),this._effect.isReady())},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(t){var i=this.getScene();if(i){var r=this._engine;for(var n in r.enableEffect(this._effect),r.setState(!1),this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors4){var o=this._colors4[n];this._effect.setFloat4(n,o.r,o.g,o.b,o.a)}for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n]);if(this._texture){if(this.isCube)for(var s=0;s<6;s++)r.bindFramebuffer(this._texture,s,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",s),this.autoClear&&r.clear(i.clearColor,!0,!1,!1),r.drawElementsType(e.Material.TriangleFillMode,0,6),5===s&&r.generateMipMapsForCubemap(this._texture);else r.bindFramebuffer(this._texture,0,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&r.clear(i.clearColor,!0,!1,!1),r.drawElementsType(e.Material.TriangleFillMode,0,6);r.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene();if(i){var r=i.proceduralTextures.indexOf(this);r>=0&&i.proceduralTextures.splice(r,1);var n=this._vertexBuffers[e.VertexBuffer.PositionKind];n&&(n.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)}},n([e.serialize()],i.prototype,"isEnabled",void 0),n([e.serialize()],i.prototype,"autoClear",void 0),n([e.serialize()],i.prototype,"_generateMipMaps",void 0),n([e.serialize()],i.prototype,"_size",void 0),n([e.serialize()],i.prototype,"refreshRate",null),i}(e.Texture);e.ProceduralTexture=t}(a||(a={})),function(e){var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_PROCEDURALTEXTURE,this.scene=t,this.scene.proceduralTextures=new Array,t.layers=new Array}return t.prototype.register=function(){this.scene._beforeClearStage.registerStep(e.SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){},t.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var t=0;t<this.scene.proceduralTextures.length;t++){var i=this.scene.proceduralTextures[t];i._shouldRender()&&i.render()}e.Tools.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}},t}();e.ProceduralTextureSceneComponent=t}(a||(a={})),function(e){var t=function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a._loadJson(i),a.refreshRate=1,a}return o(i,t),i.prototype._loadJson=function(t){var i=this,r=function(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{i.setFragment(i._texturePath)}catch(t){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},n=t+"/config.json",o=new XMLHttpRequest;o.open("GET",n,!0),o.addEventListener("load",function(){if(200===o.status||e.Tools.ValidateXHRData(o,1))try{i._config=JSON.parse(o.response),i.updateShaderUniforms(),i.updateTextures(),i.setFragment(i._texturePath+"/custom"),i._animate=i._config.animate,i.refreshRate=i._config.refreshrate}catch(e){r()}else r()},!1),o.addEventListener("error",function(){r()},!1);try{o.send()}catch(t){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},i.prototype.render=function(e){var i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t<this._config.sampler2Ds.length;t++)this.setTexture(this._config.sampler2Ds[t].sample2Dname,new e.Texture(this._texturePath+"/"+this._config.sampler2Ds[t].textureRelativeUrl,this.getScene()))},i.prototype.updateShaderUniforms=function(){if(this._config)for(var t=0;t<this._config.uniforms.length;t++){var i=this._config.uniforms[t];switch(i.type){case"float":this.setFloat(i.name,i.value);break;case"color3":this.setColor3(i.name,new e.Color3(i.r,i.g,i.b));break;case"color4":this.setColor4(i.name,new e.Color4(i.r,i.g,i.b,i.a));break;case"vector2":this.setVector2(i.name,new e.Vector2(i.x,i.y));break;case"vector3":this.setVector3(i.name,new e.Vector3(i.x,i.y,i.z))}}this.setFloat("time",this._time)},Object.defineProperty(i.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.CustomProceduralTexture=t}(a||(a={})),function(e){var t=function(){function t(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._cameraTransform=e.Matrix.Identity(),this._deltaTransform=e.Vector3.Zero(),this._vector3=e.Vector3.Zero(),this._vector2=e.Vector2.Zero()}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=n.onGamepadConnectedObservable.add(function(t){t.type!==e.Gamepad.POSE_ENABLED&&(r.gamepad&&t.type!==e.Gamepad.XBOX||(r.gamepad=t))}),this._onGamepadDisconnectedObserver=n.onGamepadDisconnectedObservable.add(function(e){r.gamepad===e&&(r.gamepad=null)}),this.gamepad=n.getGamepadByType(e.Gamepad.XBOX)},t.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var t=this.camera,i=this.gamepad.leftStick,r=i.x/this.gamepadMoveSensibility,n=i.y/this.gamepadMoveSensibility;i.x=Math.abs(r)>.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick;if(o){var s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0}else o={x:0,y:0};t.rotationQuaternion?t.rotationQuaternion.toRotationMatrix(this._cameraTransform):e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,this._cameraTransform);var l=50*t._computeLocalCameraSpeed();this._vector3.copyFromFloats(i.x*l,0,-i.y*l),e.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),t.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(o.y,o.x),t.cameraRotation.addInPlace(this._vector2)}},t.prototype.getClassName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},n([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),n([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t}(a||(a={})),function(e){var t=function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=n.onGamepadConnectedObservable.add(function(t){t.type!==e.Gamepad.POSE_ENABLED&&(r.gamepad&&t.type!==e.Gamepad.XBOX||(r.gamepad=t))}),this._onGamepadDisconnectedObserver=n.onGamepadDisconnectedObservable.add(function(e){r.gamepad===e&&(r.gamepad=null)}),this.gamepad=n.getGamepadByType(e.Gamepad.XBOX)},t.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},n([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),n([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t}(a||(a={})),function(e){var t=function(){function t(t){var i=this;this._scene=t,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new e.Observable,e.Tools.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new e.Observable(function(e){for(var t in i._babylonGamepads){var r=i._babylonGamepads[t];r&&r._isConnected&&i.onGamepadConnectedObservable.notifyObserver(e,r)}}),this._onGamepadConnectedEvent=function(e){var t,r=e.gamepad;r.index in i._babylonGamepads&&i._babylonGamepads[r.index].isConnected||(i._babylonGamepads[r.index]?((t=i._babylonGamepads[r.index]).browserGamepad=r,t._isConnected=!0):t=i._addNewGamepad(r),i.onGamepadConnectedObservable.notifyObservers(t),i._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var t=e.gamepad;for(var r in i._babylonGamepads)if(i._babylonGamepads[r].index===t.index){var n=i._babylonGamepads[r];n._isConnected=!1,i.onGamepadDisconnectedObservable.notifyObservers(n);break}},this._gamepadSupport&&(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported?(window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1)):this._startMonitoringGamepads())}return Object.defineProperty(t.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),t.prototype.getGamepadByType=function(t){void 0===t&&(t=e.Gamepad.XBOX);for(var i=0,r=this._babylonGamepads;i<r.length;i++){var n=r[i];if(n&&n.type===t)return n}return null},t.prototype.dispose=function(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null),this._babylonGamepads.forEach(function(e){e.dispose()}),this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]},t.prototype._addNewGamepad=function(t){var i;this._oneGamepadConnected||(this._oneGamepadConnected=!0);var r=-1!==t.id.search("Xbox One");return i=r||-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new e.Xbox360Pad(t.id,t.index,t,r):t.pose?e.PoseEnabledControllerHelper.InitiateController(t):new e.GenericPad(t.id,t.index,t),this._babylonGamepads[i.index]=i,i},t.prototype._startMonitoringGamepads=function(){this._isMonitoring||(this._isMonitoring=!0,this._scene||this._checkGamepadsStatus())},t.prototype._stopMonitoringGamepads=function(){this._isMonitoring=!1},t.prototype._checkGamepadsStatus=function(){var t=this;for(var i in this._updateGamepadObjects(),this._babylonGamepads){var r=this._babylonGamepads[i];r&&r.isConnected&&r.update()}this._isMonitoring&&!this._scene&&e.Tools.QueueNewFrame(function(){t._checkGamepadsStatus()})},t.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++){var i=e[t];if(i)if(this._babylonGamepads[i.index])this._babylonGamepads[t].browserGamepad=i,this._babylonGamepads[t].isConnected||(this._babylonGamepads[t]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));else{var r=this._addNewGamepad(i);this.onGamepadConnectedObservable.notifyObservers(r)}}},t}();e.GamepadManager=t}(a||(a={})),function(e){var t=function(){return function(e,t){this.x=e,this.y=t}}();e.StickValues=t;var i=function(){function e(t,i,r,n,o,s,a){void 0===n&&(n=0),void 0===o&&(o=1),void 0===s&&(s=2),void 0===a&&(a=3),this.id=t,this.index=i,this.browserGamepad=r,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=e.GAMEPAD,this._leftStickAxisX=n,this._leftStickAxisY=o,this._rightStickAxisX=s,this._rightStickAxisY=a,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e}();e.Gamepad=i;var r=function(t){function r(r,n,o){var s=t.call(this,r,n,o)||this;return s.onButtonDownObservable=new e.Observable,s.onButtonUpObservable=new e.Observable,s.type=i.GENERIC,s._buttons=new Array(o.buttons.length),s}return o(r,t),r.prototype.onbuttondown=function(e){this._onbuttondown=e},r.prototype.onbuttonup=function(e){this._onbuttonup=e},r.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},r.prototype.update=function(){t.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._buttons[e]=this._setButtonValue(this.browserGamepad.buttons[e].value,this._buttons[e],e)},r.prototype.dispose=function(){t.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()},r}(i);e.GenericPad=r}(a||(a={})),function(e){var t,i;!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.Start=4]="Start",e[e.Back=5]="Back",e[e.LB=6]="LB",e[e.RB=7]="RB",e[e.LeftStick=8]="LeftStick",e[e.RightStick=9]="RightStick"}(t=e.Xbox360Button||(e.Xbox360Button={})),function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(i=e.Xbox360Dpad||(e.Xbox360Dpad={}));var r=function(r){function n(t,i,n,o){void 0===o&&(o=!1);var s=r.call(this,t,i,n,0,1,2,3)||this;return s._leftTrigger=0,s._rightTrigger=0,s.onButtonDownObservable=new e.Observable,s.onButtonUpObservable=new e.Observable,s.onPadDownObservable=new e.Observable,s.onPadUpObservable=new e.Observable,s._buttonA=0,s._buttonB=0,s._buttonX=0,s._buttonY=0,s._buttonBack=0,s._buttonStart=0,s._buttonLB=0,s._buttonRB=0,s._buttonLeftStick=0,s._buttonRightStick=0,s._dPadUp=0,s._dPadDown=0,s._dPadLeft=0,s._dPadRight=0,s._isXboxOnePad=!1,s.type=e.Gamepad.XBOX,s._isXboxOnePad=o,s}return o(n,r),n.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},n.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(n.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!0,configurable:!0}),n.prototype.onbuttondown=function(e){this._onbuttondown=e},n.prototype.onbuttonup=function(e){this._onbuttonup=e},n.prototype.ondpaddown=function(e){this._ondpaddown=e},n.prototype.ondpadup=function(e){this._ondpadup=e},n.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},n.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(n.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,t.A)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,t.B)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,t.X)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,t.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,t.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,t.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,t.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,t.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,t.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,t.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,i.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,i.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,i.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,i.Right)},enumerable:!0,configurable:!0}),n.prototype.update=function(){r.prototype.update.call(this),this._isXboxOnePad?(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.axes[2],this.rightTrigger=this.browserGamepad.axes[5],this.buttonBack=this.browserGamepad.buttons[9].value,this.buttonStart=this.browserGamepad.buttons[8].value,this.buttonLeftStick=this.browserGamepad.buttons[6].value,this.buttonRightStick=this.browserGamepad.buttons[7].value,this.dPadUp=this.browserGamepad.buttons[11].value,this.dPadDown=this.browserGamepad.buttons[12].value,this.dPadLeft=this.browserGamepad.buttons[13].value,this.dPadRight=this.browserGamepad.buttons[14].value):(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value)},n.prototype.dispose=function(){r.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},n}(e.Gamepad);e.Xbox360Pad=r}(a||(a={})),function(e){var t;!function(e){e[e.VIVE=0]="VIVE",e[e.OCULUS=1]="OCULUS",e[e.WINDOWS=2]="WINDOWS",e[e.GEAR_VR=3]="GEAR_VR",e[e.DAYDREAM=4]="DAYDREAM",e[e.GENERIC=5]="GENERIC"}(t=e.PoseEnabledControllerType||(e.PoseEnabledControllerType={}));var i=function(){function t(){}return t.InitiateController=function(t){return-1!==t.id.indexOf("Oculus Touch")?new e.OculusTouchController(t):0===t.id.indexOf(e.WindowsMotionController.GAMEPAD_ID_PREFIX)?new e.WindowsMotionController(t):-1!==t.id.toLowerCase().indexOf("openvr")?new e.ViveController(t):0===t.id.indexOf(e.GearVRController.GAMEPAD_ID_PREFIX)||-1!==t.id.indexOf("Oculus Go")?new e.GearVRController(t):0===t.id.indexOf(e.DaydreamController.GAMEPAD_ID_PREFIX)?new e.DaydreamController(t):new e.GenericController(t)},t}();e.PoseEnabledControllerHelper=i;var r=function(i){function r(r){var n=i.call(this,r.id,r.index,r)||this;return n._deviceRoomPosition=e.Vector3.Zero(),n._deviceRoomRotationQuaternion=new e.Quaternion,n.devicePosition=e.Vector3.Zero(),n.deviceRotationQuaternion=new e.Quaternion,n.deviceScaleFactor=1,n._trackPosition=!0,n._maxRotationDistFromHeadset=Math.PI/5,n._draggedRoomRotation=0,n._leftHandSystemQuaternion=new e.Quaternion,n._deviceToWorld=e.Matrix.Identity(),n._pointingPoseNode=null,n._workingMatrix=e.Matrix.Identity(),n._meshAttachedObservable=new e.Observable,n.type=e.Gamepad.POSE_ENABLED,n.controllerType=t.GENERIC,n.position=e.Vector3.Zero(),n.rotationQuaternion=new e.Quaternion,n._calculatedPosition=e.Vector3.Zero(),n._calculatedRotation=new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(Math.PI,0,0,n._leftHandSystemQuaternion),n}return o(r,i),r.prototype._disableTrackPosition=function(e){this._trackPosition&&(this._calculatedPosition.copyFrom(e),this._trackPosition=!1)},r.prototype.update=function(){i.prototype.update.call(this),this._updatePoseAndMesh()},r.prototype._updatePoseAndMesh=function(){var t=this.browserGamepad.pose;if((this.updateFromDevice(t),!this._trackPosition&&e.Engine.LastCreatedScene&&e.Engine.LastCreatedScene.activeCamera&&e.Engine.LastCreatedScene.activeCamera.devicePosition)&&((i=e.Engine.LastCreatedScene.activeCamera)._computeDevicePosition(),this._deviceToWorld.setTranslation(i.devicePosition),i.deviceRotationQuaternion)){var i;(i=i)._deviceRoomRotationQuaternion.toEulerAnglesToRef(e.Tmp.Vector3[0]);var r=Math.atan2(Math.sin(e.Tmp.Vector3[0].y-this._draggedRoomRotation),Math.cos(e.Tmp.Vector3[0].y-this._draggedRoomRotation));if(Math.abs(r)>this._maxRotationDistFromHeadset){var n=r-(r<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=n;var o=Math.sin(-n),s=Math.cos(-n);this._calculatedPosition.x=this._calculatedPosition.x*s-this._calculatedPosition.z*o,this._calculatedPosition.z=this._calculatedPosition.x*o+this._calculatedPosition.z*s}}e.Vector3.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),e.Quaternion.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))},r.prototype.updateFromDevice=function(e){if(e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var t=this.rawPose;e.orientation&&t.orientation&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.orientation[3]),this._mesh&&(this._mesh.getScene().useRightHandedSystem?(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1):this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion,this._deviceRoomRotationQuaternion)),this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion,this._calculatedRotation))}},r.prototype.attachToMesh=function(t){if(this._mesh&&(this._mesh.parent=null),this._mesh=t,this._poseControlledCamera&&(this._mesh.parent=this._poseControlledCamera),this._mesh.rotationQuaternion||(this._mesh.rotationQuaternion=new e.Quaternion),this._updatePoseAndMesh(),this._pointingPoseNode){for(var i=[],r=this._pointingPoseNode;r.parent;)i.push(r.parent),r=r.parent;i.reverse().forEach(function(e){e.computeWorldMatrix(!0)})}this._meshAttachedObservable.notifyObservers(t)},r.prototype.attachToPoseControlledCamera=function(e){this._poseControlledCamera=e,this._mesh&&(this._mesh.parent=this._poseControlledCamera)},r.prototype.dispose=function(){this._mesh&&this._mesh.dispose(),this._mesh=null,i.prototype.dispose.call(this)},Object.defineProperty(r.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),r.prototype.getForwardRay=function(t){if(void 0===t&&(t=100),!this.mesh)return new e.Ray(e.Vector3.Zero(),new e.Vector3(0,0,1),t);var i=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),r=i.getTranslation(),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)},r.POINTING_POSE="POINTING_POSE",r}(e.Gamepad);e.PoseEnabledController=r}(a||(a={})),function(e){var t=function(t){function i(i){var r=t.call(this,i)||this;return r.onTriggerStateChangedObservable=new e.Observable,r.onMainButtonStateChangedObservable=new e.Observable,r.onSecondaryButtonStateChangedObservable=new e.Observable,r.onPadStateChangedObservable=new e.Observable,r.onPadValuesChangedObservable=new e.Observable,r.pad={x:0,y:0},r._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},r._buttons=new Array(i.buttons.length),r.hand=i.hand,r}return o(i,t),i.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(i.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),i.prototype.update=function(){t.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._setButtonValue(this.browserGamepad.buttons[e],this._buttons[e],e);this.leftStick.x===this.pad.x&&this.leftStick.y===this.pad.y||(this.pad.x=this.leftStick.x,this.pad.y=this.leftStick.y,this.onPadValuesChangedObservable.notifyObservers(this.pad))},i.prototype._setButtonValue=function(e,t,i){e||(e={pressed:!1,touched:!1,value:0}),t?(this._checkChanges(e,t),this._changes.changed&&(this._onButtonStateChange&&this._onButtonStateChange(this.index,i,e),this._handleButtonChange(i,e,this._changes)),this._buttons[i].pressed=e.pressed,this._buttons[i].touched=e.touched,this._buttons[i].value=e.value<1e-8?0:e.value):this._buttons[i]={pressed:e.pressed,touched:e.touched,value:e.value}},i.prototype._checkChanges=function(e,t){return this._changes.pressChanged=e.pressed!==t.pressed,this._changes.touchChanged=e.touched!==t.touched,this._changes.valueChanged=e.value!==t.value,this._changes.changed=this._changes.pressChanged||this._changes.touchChanged||this._changes.valueChanged,this._changes},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.onTriggerStateChangedObservable.clear(),this.onMainButtonStateChangedObservable.clear(),this.onSecondaryButtonStateChangedObservable.clear(),this.onPadStateChangedObservable.clear(),this.onPadValuesChangedObservable.clear()},i}(e.PoseEnabledController);e.WebVRController=t}(a||(a={})),function(e){var t=function(t){function i(i){var r=t.call(this,i)||this;return r.onSecondaryTriggerStateChangedObservable=new e.Observable,r.onThumbRestChangedObservable=new e.Observable,r.controllerType=e.PoseEnabledControllerType.OCULUS,r}return o(i,t),i.prototype.initControllerMesh=function(t,r){var n,o=this;n="left"===this.hand?i.MODEL_LEFT_FILENAME:i.MODEL_RIGHT_FILENAME,e.SceneLoader.ImportMesh("",i.MODEL_BASE_URL,n,t,function(e){o._defaultModel=e[1],o.attachToMesh(o._defaultModel),r&&r(o._defaultModel)})},Object.defineProperty(i.prototype,"onAButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No A button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No B button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onXButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No X button on right hand")},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onYButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No Y button on right hand")},enumerable:!0,configurable:!0}),i.prototype._handleButtonChange=function(e,t,i){var r=t,n="right"===this.hand?-1:1;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[3].rotation.x=.2*-r.value,this._defaultModel.getChildren()[3].position.y=.005*-r.value,this._defaultModel.getChildren()[3].position.z=.005*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return this._defaultModel&&(this._defaultModel.getChildren()[4].position.x=n*r.value*.0035),void this.onSecondaryTriggerStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[1].position.y=-.001:this._defaultModel.getChildren()[1].position.y=0),void this.onMainButtonStateChangedObservable.notifyObservers(r);case 4:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r);case 5:return void this.onThumbRestChangedObservable.notifyObservers(r)}},i.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",i.MODEL_LEFT_FILENAME="left.babylon",i.MODEL_RIGHT_FILENAME="right.babylon",i}(e.WebVRController);e.OculusTouchController=t}(a||(a={})),function(e){var t=function(t){function i(i){var r=t.call(this,i)||this;return r.controllerType=e.PoseEnabledControllerType.VIVE,r._invertLeftStickY=!0,r}return o(i,t),i.prototype.initControllerMesh=function(t,r){var n=this;e.SceneLoader.ImportMesh("",i.MODEL_BASE_URL,i.MODEL_FILENAME,t,function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),r&&r(n._defaultModel)})},Object.defineProperty(i.prototype,"onLeftButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onRightButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),i.prototype._handleButtonChange=function(e,t,i){var r=t;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[6].rotation.x=.15*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return void this.onMainButtonStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r)}},i.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",i.MODEL_FILENAME="wand.babylon",i}(e.WebVRController);e.ViveController=t}(a||(a={})),function(e){var t=function(t){function i(e){return t.call(this,e)||this}return o(i,t),i.prototype.initControllerMesh=function(t,r){var n=this;e.SceneLoader.ImportMesh("",i.MODEL_BASE_URL,i.MODEL_FILENAME,t,function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),r&&r(n._defaultModel)})},i.prototype._handleButtonChange=function(e,t,i){console.log("Button id: "+e+"state: "),console.dir(t)},i.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",i.MODEL_FILENAME="generic.babylon",i}(e.WebVRController);e.GenericController=t}(a||(a={})),function(e){var t=function(){return function(){this.buttonMeshes={},this.axisMeshes={}}}(),i=function(i){function r(t){var r=i.call(this,t)||this;return r._mapping={buttons:["thumbstick","trigger","grip","menu","trackpad"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onPadStateChangedObservable",trackpad:"onTrackpadChangedObservable"},axisMeshNames:["THUMBSTICK_X","THUMBSTICK_Y","TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y"],pointingPoseMeshName:e.PoseEnabledController.POINTING_POSE},r.onTrackpadChangedObservable=new e.Observable,r.onTrackpadValuesChangedObservable=new e.Observable,r.trackpad={x:0,y:0},r.controllerType=e.PoseEnabledControllerType.WINDOWS,r._loadedMeshInfo=null,r}return o(r,i),Object.defineProperty(r.prototype,"onTriggerButtonStateChangedObservable",{get:function(){return this.onTriggerStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onGripButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onPadStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onTouchpadButtonStateChangedObservable",{get:function(){return this.onTrackpadChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onTouchpadValuesChangedObservable",{get:function(){return this.onTrackpadValuesChangedObservable},enumerable:!0,configurable:!0}),r.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.trackpad.x&&this.browserGamepad.axes[3]==this.trackpad.y||(this.trackpad.x=this.browserGamepad.axes[2],this.trackpad.y=this.browserGamepad.axes[3],this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))},r.prototype.update=function(){if(i.prototype.update.call(this),this.browserGamepad.axes&&(this._updateTrackpad(),this._loadedMeshInfo))for(var e=0;e<this._mapping.axisMeshNames.length;e++)this._lerpAxisTransform(e,this.browserGamepad.axes[e])},r.prototype._handleButtonChange=function(e,t,i){var r=this._mapping.buttons[e];if(r){this._updateTrackpad();var n=this[this._mapping.buttonObservableNames[r]];n&&n.notifyObservers(t),this._lerpButtonTransform(r,t.value)}},r.prototype._lerpButtonTransform=function(t,i){if(this._loadedMeshInfo){var r=this._loadedMeshInfo.buttonMeshes[t];r.unpressed.rotationQuaternion&&r.pressed.rotationQuaternion&&r.value.rotationQuaternion&&(e.Quaternion.SlerpToRef(r.unpressed.rotationQuaternion,r.pressed.rotationQuaternion,i,r.value.rotationQuaternion),e.Vector3.LerpToRef(r.unpressed.position,r.pressed.position,i,r.value.position))}},r.prototype._lerpAxisTransform=function(t,i){if(this._loadedMeshInfo){var r=this._loadedMeshInfo.axisMeshes[t];if(r&&r.min.rotationQuaternion&&r.max.rotationQuaternion&&r.value.rotationQuaternion){var n=.5*i+.5;e.Quaternion.SlerpToRef(r.min.rotationQuaternion,r.max.rotationQuaternion,n,r.value.rotationQuaternion),e.Vector3.LerpToRef(r.min.position,r.max.position,n,r.value.position)}}},r.prototype.initControllerMesh=function(t,i,n){var o,s,a=this;if(void 0===n&&(n=!1),e.SceneLoader.IsPluginForExtensionAvailable(".glb")){var l="default";if(this.id&&!n){var c=this.id.match(r.GAMEPAD_ID_PATTERN);l=c&&c[0]||l}s="left"===this.hand?r.MODEL_LEFT_FILENAME:r.MODEL_RIGHT_FILENAME,o=r.MODEL_BASE_URL+l+"/"}else e.Tools.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),o=e.GenericController.MODEL_BASE_URL,s=e.GenericController.MODEL_FILENAME;e.SceneLoader.ImportMesh("",o,s,t,function(e){a._loadedMeshInfo=a.processModel(t,e),a._loadedMeshInfo&&(a._defaultModel=a._loadedMeshInfo.rootNode,a.attachToMesh(a._defaultModel),i&&i(a._defaultModel))},null,function(t,r){e.Tools.Log(r),e.Tools.Warn("Failed to retrieve controller model from the remote server: "+o+s),n||a.initControllerMesh(t,i,!0)})},r.prototype.processModel=function(t,i){for(var r=null,n=new e.Mesh(this.id+" "+this.hand,t),o=null,s=0;s<i.length;s++){var a=i[s];if(!a.parent){a.isPickable=!1,o=a;break}}return o?(o.setParent(n),r=this.createMeshInfo(n)):e.Tools.Warn("Could not find root node in model file."),r},r.prototype.createMeshInfo=function(i){var r,n=new t;for(n.rootNode=i,n.buttonMeshes={},n.axisMeshes={},r=0;r<this._mapping.buttons.length;r++){var o=this._mapping.buttonMeshNames[this._mapping.buttons[r]];if(o){var s=h(i,o);if(s){var a={index:r,value:d(s,"VALUE"),pressed:d(s,"PRESSED"),unpressed:d(s,"UNPRESSED")};a.value&&a.pressed&&a.unpressed?n.buttonMeshes[this._mapping.buttons[r]]=a:e.Tools.Warn("Missing button submesh under mesh with name: "+o+"(VALUE: "+!!a.value+", PRESSED: "+!!a.pressed+", UNPRESSED:"+!!a.unpressed+")")}else e.Tools.Warn("Missing button mesh with name: "+o)}else e.Tools.Log("Skipping unknown button at index: "+r+" with mapped name: "+this._mapping.buttons[r])}for(r=0;r<this._mapping.axisMeshNames.length;r++){var l=this._mapping.axisMeshNames[r];if(l){var c=h(i,l);if(c){var u={index:r,value:d(c,"VALUE"),min:d(c,"MIN"),max:d(c,"MAX")};u.value&&u.min&&u.max?n.axisMeshes[r]=u:e.Tools.Warn("Missing axis submesh under mesh with name: "+l+"(VALUE: "+!!u.value+", MIN: "+!!u.min+", MAX:"+!!u.max+")")}else e.Tools.Warn("Missing axis mesh with name: "+l)}else e.Tools.Log("Skipping unknown axis at index: "+r)}return n.pointingPoseNode=h(i,this._mapping.pointingPoseMeshName),n.pointingPoseNode?this._pointingPoseNode=n.pointingPoseNode:e.Tools.Warn("Missing pointing pose mesh with name: "+this._mapping.pointingPoseMeshName),n;function h(e,t){return e.getChildMeshes(!1,function(e){return e.name===t})[0]}function d(e,t){return e.getChildMeshes(!0,function(e){return e.name==t})[0]}},r.prototype.getForwardRay=function(t){if(void 0===t&&(t=100),!this._loadedMeshInfo||!this._loadedMeshInfo.pointingPoseNode)return i.prototype.getForwardRay.call(this,t);var r=this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(),n=r.getTranslation(),o=new e.Vector3(0,0,-1),s=e.Vector3.TransformNormal(o,r),a=e.Vector3.Normalize(s);return new e.Ray(n,a,t)},r.prototype.dispose=function(){i.prototype.dispose.call(this),this.onTrackpadChangedObservable.clear()},r.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",r.MODEL_LEFT_FILENAME="left.glb",r.MODEL_RIGHT_FILENAME="right.glb",r.GAMEPAD_ID_PREFIX="Spatial Controller (Spatial Interaction Source) ",r.GAMEPAD_ID_PATTERN=/([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,r}(e.WebVRController);e.WindowsMotionController=i}(a||(a={})),function(e){var t=function(t){function i(i){var r=t.call(this,i)||this;return r._buttonIndexToObservableNameMap=["onTrackpadChangedObservable","onTriggerStateChangedObservable"],r.controllerType=e.PoseEnabledControllerType.GEAR_VR,r._calculatedPosition=new e.Vector3("left"==r.hand?-.15:.15,-.5,.25),r._disableTrackPosition(r._calculatedPosition),r}return o(i,t),i.prototype.initControllerMesh=function(t,r){var n=this;e.SceneLoader.ImportMesh("",i.MODEL_BASE_URL,i.MODEL_FILENAME,t,function(i){var o=new e.Mesh("",t);i[1].parent=o,i[1].position.z=-.15,n._defaultModel=o,n.attachToMesh(n._defaultModel),r&&r(n._defaultModel)})},i.prototype._handleButtonChange=function(e,t,i){if(e<this._buttonIndexToObservableNameMap.length){var r=this[this._buttonIndexToObservableNameMap[e]];r&&r.notifyObservers(t)}},i.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",i.MODEL_FILENAME="generic.babylon",i.GAMEPAD_ID_PREFIX="Gear VR",i}(e.WebVRController);e.GearVRController=t}(a||(a={})),function(e){var t=function(t){function i(i){var r=t.call(this,i)||this;return r.controllerType=e.PoseEnabledControllerType.DAYDREAM,r}return o(i,t),i.prototype.initControllerMesh=function(t,r){var n=this;e.SceneLoader.ImportMesh("",i.MODEL_BASE_URL,i.MODEL_FILENAME,t,function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),r&&r(n._defaultModel)})},i.prototype._handleButtonChange=function(t,i,r){if(0===t){var n=this.onTriggerStateChangedObservable;n&&n.notifyObservers(i)}else e.Tools.Warn("Unrecognized Daydream button index: "+t)},i.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",i.MODEL_FILENAME="generic.babylon",i.GAMEPAD_ID_PREFIX="Daydream",i}(e.WebVRController);e.DaydreamController=t}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new e.GamepadManager(this);var i=this._getComponent(e.SceneComponentConstants.NAME_GAMEPAD);i||(i=new t(this),this._addComponent(i))}return this._gamepadManager},enumerable:!0,configurable:!0}),e.FreeCameraInputsManager.prototype.addGamepad=function(){return this.add(new e.FreeCameraGamepadInput),this},e.ArcRotateCameraInputsManager.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_GAMEPAD,this.scene=t}return t.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(e.SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD,this,this._beforeCameraUpdate)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){var e=this.scene._gamepadManager;e&&(e.dispose(),this.scene._gamepadManager=null)},t.prototype._beforeCameraUpdate=function(){var e=this.scene._gamepadManager;e&&e._isMonitoring&&e._checkGamepadsStatus()},t}();e.GamepadSystemSceneComponent=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("FollowCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}}),e.Node.AddNodeConstructor("ArcFollowCamera",function(e,t){return function(){return new i(e,0,0,1,null,t)}});var t=function(t){function i(e,i,r,n){void 0===n&&(n=null);var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}return o(i,t),i.prototype._follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=e.Tools.ToRadians(this.rotationOffset)+i,o=t.getAbsolutePosition(),s=o.x+Math.sin(n)*this.radius,a=o.z+Math.cos(n)*this.radius,l=s-this.position.x,c=o.y+this.heightOffset-this.position.y,u=a-this.position.z,h=l*this.cameraAcceleration*2,d=c*this.cameraAcceleration,f=u*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(o)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},n([e.serialize()],i.prototype,"radius",void 0),n([e.serialize()],i.prototype,"rotationOffset",void 0),n([e.serialize()],i.prototype,"heightOffset",void 0),n([e.serialize()],i.prototype,"cameraAcceleration",void 0),n([e.serialize()],i.prototype,"maxCameraSpeed",void 0),n([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i}(e.TargetCamera);e.FollowCamera=t;var i=function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,e.Vector3.Zero(),a)||this;return l.alpha=r,l.beta=n,l.radius=o,l.target=s,l._cartesianCoordinates=e.Vector3.Zero(),l._follow(),l}return o(i,t),i.prototype._follow=function(){if(this.target){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this._follow()},i.prototype.getClassName=function(){return"ArcFollowCamera"},i}(e.TargetCamera);e.ArcFollowCamera=i}(a||(a={})),function(e){var t=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return o(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t}(e.TouchCamera);e.UniversalCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("GamepadCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return o(t,e),t.prototype.getClassName=function(){return"GamepadCamera"},t}(e.UniversalCamera);e.GamepadCamera=t}(a||(a={})),function(e){var t=function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e}();e.PostProcessRenderPipelineManager=t}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var i=this._getComponent(e.SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER);i||(i=new t(this),this._addComponent(i)),this._postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=t}return t.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(e.SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},t.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},t.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},t.prototype._gatherRenderTargets=function(e){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},t}();e.PostProcessRenderPipelineManagerSceneComponent=t}(a||(a={})),function(e){var t=function(){function t(e,t,i,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],i=0;i<t.length;i++)if(!t[i].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){},t.prototype._attachCameras=function(t){var i,r=this,n=e.Tools.MakeArray(t||this._cameras);if(n)for(var o=0;o<n.length;o++){var s=n[o],a=s.name;if(i=this._singleInstance?0:a,!this._postProcesses[i]){var l=this._getPostProcesses();l&&(this._postProcesses[i]=Array.isArray(l)?l:[l])}this._indicesForCamera[a]||(this._indicesForCamera[a]=[]),this._postProcesses[i].forEach(function(e){var t=s.attachPostProcess(e);r._indicesForCamera[a].push(t)}),this._cameras[a]||(this._cameras[a]=s)}},t.prototype._detachCameras=function(t){var i=e.Tools.MakeArray(t||this._cameras);if(i)for(var r=0;r<i.length;r++){var n=i[r],o=n.name;this._postProcesses[this._singleInstance?0:o].forEach(function(e){n.detachPostProcess(e)}),this._cameras[o]&&(this._cameras[o]=null)}},t.prototype._enable=function(t){var i=this,r=e.Tools.MakeArray(t||this._cameras);if(r)for(var n=0;n<r.length;n++)for(var o=r[n],s=o.name,a=0;a<this._indicesForCamera[s].length;a++)void 0!==o._postProcesses[this._indicesForCamera[s][a]]&&null!==o._postProcesses[this._indicesForCamera[s][a]]||this._postProcesses[this._singleInstance?0:s].forEach(function(e){r[n].attachPostProcess(e,i._indicesForCamera[s][a])})},t.prototype._disable=function(t){var i=e.Tools.MakeArray(t||this._cameras);if(i)for(var r=0;r<i.length;r++){var n=i[r],o=n.name;this._postProcesses[this._singleInstance?0:o].forEach(function(e){n.detachPostProcess(e)})}},t.prototype.getPostProcesses=function(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null},t}();e.PostProcessRenderEffect=t}(a||(a={})),function(e){var t=function(){function t(e,t){this.engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return t.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._renderEffects)if(this._renderEffects.hasOwnProperty(e)&&!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype.addEffect=function(e){this._renderEffects[e._name]=e},t.prototype._rebuild=function(){},t.prototype._enableEffect=function(t,i){var r=this._renderEffects[t];r&&r._enable(e.Tools.MakeArray(i||this._cameras))},t.prototype._disableEffect=function(t,i){var r=this._renderEffects[t];r&&r._disable(e.Tools.MakeArray(i||this._cameras))},t.prototype._attachCameras=function(t,i){var r=e.Tools.MakeArray(t||this._cameras);if(r){var n,o=[];for(n=0;n<r.length;n++){var s=r[n],a=s.name;-1===this._cameras.indexOf(s)?this._cameras[a]=s:i&&o.push(n)}for(n=0;n<o.length;n++)t.splice(o[n],1);for(var l in this._renderEffects)this._renderEffects.hasOwnProperty(l)&&this._renderEffects[l]._attachCameras(r)}},t.prototype._detachCameras=function(t){var i=e.Tools.MakeArray(t||this._cameras);if(i){for(var r in this._renderEffects)this._renderEffects.hasOwnProperty(r)&&this._renderEffects[r]._detachCameras(i);for(var n=0;n<i.length;n++)this._cameras.splice(this._cameras.indexOf(i[n]),1)}},t.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects.hasOwnProperty(e)&&this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t].name;this._renderEffectsForIsolatedPass[i]&&this._renderEffectsForIsolatedPass[i]._update()}},t.prototype._reset=function(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array},t.prototype._enableMSAAOnFirstPostProcess=function(e){var t=Object.keys(this._renderEffects);if(this.engine.webGLVersion>=2&&t.length>0){var i=this._renderEffects[t[0]].getPostProcesses();if(i)return i[0].samples=e,!0}return!1},t.prototype.dispose=function(){},n([e.serialize()],t.prototype,"_name",void 0),t}();e.PostProcessRenderPipeline=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){void 0===i&&(i=e.Engine.TEXTURETYPE_FLOAT),void 0===r&&(r=null);var n=this;this.useOnlyInActiveCamera=!1,this._scene=t;var o=t._getComponent(e.SceneComponentConstants.NAME_DEPTHRENDERER);o||(o=new e.DepthRendererSceneComponent(t),t._addComponent(o)),this._camera=r;var s=t.getEngine();this._depthMap=new e.RenderTargetTexture("depthMap",{width:s.getRenderWidth(),height:s.getRenderHeight()},this._scene,!1,!0,i),this._depthMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(function(t){t.clear(new e.Color4(1,1,1,1),!0,!0,!0)});var a=function(t){var i=t.getRenderingMesh(),r=n._scene,o=r.getEngine(),s=t.getMaterial();if(s){o.setState(s.backFaceCulling,0,!1,r.useRightHandedSystem);var a=i._getInstancesRenderList(t._id);if(!a.mustReturn){var l=o.getCaps().instancedArrays&&null!==a.visibleInstances[t._id],c=n._camera||r.activeCamera;if(n.isReady(t,l)&&c){if(o.enableEffect(n._effect),i._bind(t,n._effect,e.Material.TriangleFillMode),n._effect.setMatrix("viewProjection",r.getTransformMatrix()),n._effect.setFloat2("depthValues",c.minZ,c.minZ+c.maxZ),s&&s.needAlphaTesting()){var u=s.getAlphaTestTexture();u&&(n._effect.setTexture("diffuseSampler",u),n._effect.setMatrix("diffuseMatrix",u.getTextureMatrix()))}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&n._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),i._processRendering(t,n._effect,e.Material.TriangleFillMode,a,l,function(e,t){return n._effect.setMatrix("world",t)})}}}};this._depthMap.customRenderFunction=function(e,t,i,r){var n;if(r.length){for(s.setColorWrite(!1),n=0;n<r.length;n++)a(r.data[n]);s.setColorWrite(!0)}for(n=0;n<e.length;n++)a(e.data[n]);for(n=0;n<t.length;n++)a(t.data[n])}}return t.prototype.isReady=function(t,i){var r=t.getMaterial();if(r.disableDepthWrite)return!1;var n=[],o=[e.VertexBuffer.PositionKind],s=t.getMesh();r&&r.needAlphaTesting()&&r.getAlphaTestTexture()&&(n.push("#define ALPHATEST"),s.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),s.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),s.useBones&&s.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),s.numBoneInfluencers>4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t}();e.DepthRenderer=t}(a||(a={})),function(e){e.Scene.prototype.enableDepthRenderer=function(t){if(!(t=t||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[t.id]){var i=0;if(this.getEngine().getCaps().textureHalfFloatRender)i=e.Engine.TEXTURETYPE_HALF_FLOAT;else{if(!this.getEngine().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]},e.Scene.prototype.disableDepthRenderer=function(e){(e=e||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[e.id]&&(this._depthRenderer[e.id].dispose(),delete this._depthRenderer[e.id])};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_DEPTHRENDERER,this.scene=t}return t.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(e.SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(e.SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){for(var e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()},t.prototype._gatherRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera||e.push(i.getDepthMap())}},t.prototype._gatherActiveCameraRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}},t}();e.DepthRendererSceneComponent=t}(a||(a={})),function(e){var t=function(){function t(t,i){void 0===i&&(i=1),this._enablePosition=!1,this._scene=t,this._ratio=i;var r=t._getComponent(e.SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER);r||(r=new e.GeometryBufferRendererSceneComponent(t),t._addComponent(r)),this._createRenderTargets()}return Object.defineProperty(t.prototype,"renderList",{set:function(e){this._multiRenderTarget.renderList=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),t.prototype.isReady=function(t,i){var r=t.getMaterial();if(r&&r.disableDepthWrite)return!1;var n=[],o=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],s=t.getMesh();r&&r.needAlphaTesting()&&(n.push("#define ALPHATEST"),s.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),s.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),this._enablePosition&&n.push("#define POSITION"),s.useBones&&s.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),s.numBoneInfluencers>4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",o,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],a,void 0,void 0,void 0,{buffersCount:this._enablePosition?3:2})),this._effect.isReady()},t.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(t.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.getGBuffer().dispose()},t.prototype._createRenderTargets=function(){var t=this,i=this._scene.getEngine(),r=this._enablePosition?3:2;if(this._multiRenderTarget=new e.MultiRenderTarget("gBuffer",{width:i.getRenderWidth()*this._ratio,height:i.getRenderHeight()*this._ratio},r,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:e.Engine.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add(function(t){t.clear(new e.Color4(0,0,0,1),!0,!0,!0)});var n=function(i){var r=i.getRenderingMesh(),n=t._scene,o=n.getEngine(),s=i.getMaterial();if(s){o.setState(s.backFaceCulling,0,!1,n.useRightHandedSystem);var a=r._getInstancesRenderList(i._id);if(!a.mustReturn){var l=o.getCaps().instancedArrays&&null!==a.visibleInstances[i._id];if(t.isReady(i,l)){if(o.enableEffect(t._effect),r._bind(i,t._effect,e.Material.TriangleFillMode),t._effect.setMatrix("viewProjection",n.getTransformMatrix()),t._effect.setMatrix("view",n.getViewMatrix()),s&&s.needAlphaTesting()){var c=s.getAlphaTestTexture();c&&(t._effect.setTexture("diffuseSampler",c),t._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}r.useBones&&r.computeBonesUsingShaders&&r.skeleton&&t._effect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),r._processRendering(i,t._effect,e.Material.TriangleFillMode,a,l,function(e,i){return t._effect.setMatrix("world",i)})}}}};this._multiRenderTarget.customRenderFunction=function(e,t,r,o){var s;if(o.length){for(i.setColorWrite(!1),s=0;s<o.length;s++)n(o.data[s]);i.setColorWrite(!0)}for(s=0;s<e.length;s++)n(e.data[s]);for(s=0;s<t.length;s++)n(t.data[s])}}},t}();e.GeometryBufferRenderer=t}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"geometryBufferRenderer",{get:function(){this._geometryBufferRenderer},set:function(e){e&&e.isSupported&&(this._geometryBufferRenderer=e)},enumerable:!0,configurable:!0}),e.Scene.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)},e.Scene.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER,this.scene=t}return t.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(e.SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){},t.prototype._gatherRenderTargets=function(e){this.scene._geometryBufferRenderer&&e.push(this.scene._geometryBufferRenderer.getGBuffer())},t}();e.GeometryBufferRendererSceneComponent=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,l=n.combineRatio||n;return s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",l,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(l),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return o(i,t),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i<this._scene.cameras.length;i++){var r=this._scene.cameras[i];this._originalColorPostProcess.dispose(r),this._ssaoPostProcess.dispose(r),this._blurHPostProcess.dispose(r),this._blurVPostProcess.dispose(r),this._ssaoCombinePostProcess.dispose(r)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),t.prototype.dispose.call(this)},i.prototype._createBlurPostProcess=function(t){var i=this;this._blurHPostProcess=new e.BlurPostProcess("BlurH",new e.Vector2(1,0),16,t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new e.BlurPostProcess("BlurV",new e.Vector2(0,1),16,t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._blurHPostProcess.onActivateObservable.add(function(){var e=i._blurHPostProcess.width/i._scene.getEngine().getRenderWidth();i._blurHPostProcess.kernel=16*e}),this._blurVPostProcess.onActivateObservable.add(function(){var e=i._blurVPostProcess.height/i._scene.getEngine().getRenderHeight();i._blurVPostProcess.kernel=16*e})},i.prototype._rebuild=function(){this._firstUpdate=!0,t.prototype._rebuild.call(this)},i.prototype._createSSAOPostProcess=function(t){var i=this,r=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new e.PostProcess("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES 16\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){i._firstUpdate&&(e.setArray3("sampleSphere",r),e.setFloat("samplesFactor",1/16),e.setFloat("randTextureTiles",4)),e.setFloat("totalStrength",i.totalStrength),e.setFloat("radius",i.radius),e.setFloat("area",i.area),e.setFloat("fallOff",i.fallOff),e.setFloat("base",i.base),e.setTexture("textureSampler",i._depthTexture),e.setTexture("randomSampler",i._randomTexture)}},i.prototype._createSSAOCombinePostProcess=function(t){var i=this;this._ssaoCombinePostProcess=new e.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(t){t.setVector4("viewport",e.Tmp.Vector4[0].copyFromFloats(0,0,1,1)),t.setTextureFromPostProcess("originalColor",i._originalColorPostProcess)}},i.prototype._createRandomTexture=function(){this._randomTexture=new e.DynamicTexture("SSAORandomTexture",512,this._scene,!1,e.Texture.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var t=this._randomTexture.getContext(),i=function(e,t){return Math.random()*(t-e)+e},r=e.Vector3.Zero(),n=0;n<512;n++)for(var o=0;o<512;o++)r.x=Math.floor(255*i(-1,1)),r.y=Math.floor(255*i(-1,1)),r.z=Math.floor(255*i(-1,1)),t.fillStyle="rgb("+r.x+", "+r.y+", "+r.z+")",t.fillRect(n,o,1,1);this._randomTexture.update(!1)},n([e.serialize()],i.prototype,"totalStrength",void 0),n([e.serialize()],i.prototype,"radius",void 0),n([e.serialize()],i.prototype,"area",void 0),n([e.serialize()],i.prototype,"fallOff",void 0),n([e.serialize()],i.prototype,"base",void 0),i}(e.PostProcessRenderPipeline);e.SSAORenderingPipeline=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){var s=t.call(this,r.getEngine(),i)||this;if(s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.maxZ=100,s.minZAspect=.2,s._samples=8,s._textureSamples=1,s._expensiveBlur=!0,s.radius=2,s.base=0,s._firstUpdate=!0,s._bits=new Uint32Array(1),s._scene=r,s._ratio=n,!s.isSupported)return e.Tools.Error("SSAO 2 needs WebGL 2 support."),s;var a=s._ratio.ssaoRatio||n,l=s._ratio.blurRatio||n,c=r.enableGeometryBufferRenderer();return s._createRandomTexture(),s._depthTexture=c.getGBuffer().textures[0],s._normalTexture=c.getGBuffer().textures[1],s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),s._originalColorPostProcess.samples=s.textureSamples,s._createSSAOPostProcess(1),s._createBlurPostProcess(a,l),s._createSSAOCombinePostProcess(l),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}return o(i,t),Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){this._ssaoPostProcess.updateEffect("#define SAMPLES "+e+"\n#define SSAO"),this._samples=e,this._sampleSphere=this._generateHemisphere(),this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureSamples",{get:function(){return this._textureSamples},set:function(e){this._textureSamples=e,this._originalColorPostProcess.samples=e,this._blurHPostProcess.samples=e,this._blurVPostProcess.samples=e,this._ssaoPostProcess.samples=e,this._ssaoCombinePostProcess.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"expensiveBlur",{get:function(){return this._expensiveBlur},set:function(e){this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._expensiveBlur=e,this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsSupported",{get:function(){var t=e.Engine.LastCreatedEngine;return!!t&&t.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var i=0;i<this._scene.cameras.length;i++){var r=this._scene.cameras[i];this._originalColorPostProcess.dispose(r),this._ssaoPostProcess.dispose(r),this._blurHPostProcess.dispose(r),this._blurVPostProcess.dispose(r),this._ssaoCombinePostProcess.dispose(r)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),t.prototype.dispose.call(this)},i.prototype._createBlurPostProcess=function(t,i){var r=this;this._samplerOffsets=[];for(var n=this.expensiveBlur,o=-8;o<8;o++)this._samplerOffsets.push(2*o+.5);this._blurHPostProcess=new e.PostProcess("BlurH","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"1":"0")+"\n"),this._blurHPostProcess.onApply=function(e){r._scene.activeCamera&&(e.setFloat("outSize",r._ssaoCombinePostProcess.width>0?r._ssaoCombinePostProcess.width:r._originalColorPostProcess.width),e.setFloat("near",r._scene.activeCamera.minZ),e.setFloat("far",r._scene.activeCamera.maxZ),e.setFloat("radius",r.radius),e.setTexture("depthSampler",r._depthTexture),r._firstUpdate&&e.setArray("samplerOffsets",r._samplerOffsets))},this._blurVPostProcess=new e.PostProcess("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],i,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){r._scene.activeCamera&&(e.setFloat("outSize",r._ssaoCombinePostProcess.height>0?r._ssaoCombinePostProcess.height:r._originalColorPostProcess.height),e.setFloat("near",r._scene.activeCamera.minZ),e.setFloat("far",r._scene.activeCamera.maxZ),e.setFloat("radius",r.radius),e.setTexture("depthSampler",r._depthTexture),r._firstUpdate&&(e.setArray("samplerOffsets",r._samplerOffsets),r._firstUpdate=!1))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},i.prototype._rebuild=function(){this._firstUpdate=!0,t.prototype._rebuild.call(this)},i.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,2.3283064365386963e-10*this._bits[0]},i.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},i.prototype._hemisphereSample_uniform=function(t,i){var r=2*i*Math.PI,n=1-(.85*t+.15),o=Math.sqrt(1-n*n);return new e.Vector3(Math.cos(r)*o,Math.sin(r)*o,n)},i.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],r=0;r<t;){if(t<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var n=this._hammersley(r,t);e=this._hemisphereSample_uniform(n[0],n[1])}i.push(e.x,e.y,e.z),r++}return i},i.prototype._createSSAOPostProcess=function(t){var i=this,r=this.samples;this._sampleSphere=this._generateHemisphere(),this._ssaoPostProcess=new e.PostProcess("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","far","texelSize","xViewport","yViewport","maxZ","minZAspect"],["randomSampler","normalSampler"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES "+r+"\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){i._firstUpdate&&(e.setArray3("sampleSphere",i._sampleSphere),e.setFloat("randTextureTiles",32)),i._scene.activeCamera&&(e.setFloat("samplesFactor",1/i.samples),e.setFloat("totalStrength",i.totalStrength),e.setFloat2("texelSize",1/i._ssaoPostProcess.width,1/i._ssaoPostProcess.height),e.setFloat("radius",i.radius),e.setFloat("maxZ",i.maxZ),e.setFloat("minZAspect",i.minZAspect),e.setFloat("base",i.base),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("xViewport",Math.tan(i._scene.activeCamera.fov/2)*i._scene.getEngine().getAspectRatio(i._scene.activeCamera,!0)),e.setFloat("yViewport",Math.tan(i._scene.activeCamera.fov/2)),e.setMatrix("projection",i._scene.getProjectionMatrix()),e.setTexture("textureSampler",i._depthTexture),e.setTexture("normalSampler",i._normalTexture),e.setTexture("randomSampler",i._randomTexture))},this._ssaoPostProcess.samples=this.textureSamples},i.prototype._createSSAOCombinePostProcess=function(t){var i=this;this._ssaoCombinePostProcess=new e.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(t){var r=i._scene.activeCamera.viewport;t.setVector4("viewport",e.Tmp.Vector4[0].copyFromFloats(r.x,r.y,r.width,r.height)),t.setTextureFromPostProcess("originalColor",i._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples},i.prototype._createRandomTexture=function(){this._randomTexture=new e.DynamicTexture("SSAORandomTexture",128,this._scene,!1,e.Texture.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var t=this._randomTexture.getContext(),i=function(e,t){return Math.random()*(t-e)+e},r=e.Vector3.Zero(),n=0;n<128;n++)for(var o=0;o<128;o++)r.x=i(0,1),r.y=i(0,1),r.z=0,r.normalize(),r.scaleInPlace(255),r.x=Math.floor(r.x),r.y=Math.floor(r.y),t.fillStyle="rgb("+r.x+", "+r.y+", "+r.z+")",t.fillRect(n,o,1,1);this._randomTexture.update(!1)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="SSAO2RenderingPipeline",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse(function(){return new i(t._name,r,t._ratio)},t,r,n)},n([e.serialize()],i.prototype,"totalStrength",void 0),n([e.serialize()],i.prototype,"maxZ",void 0),n([e.serialize()],i.prototype,"minZAspect",void 0),n([e.serialize("samples")],i.prototype,"_samples",void 0),n([e.serialize("textureSamples")],i.prototype,"_textureSamples",void 0),n([e.serialize()],i.prototype,"_ratio",void 0),n([e.serialize("expensiveBlur")],i.prototype,"_expensiveBlur",void 0),n([e.serialize()],i.prototype,"radius",void 0),n([e.serialize()],i.prototype,"base",void 0),i}(e.PostProcessRenderPipeline);e.SSAO2RenderingPipeline=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===o&&(o=1);var a=t.call(this,n.getEngine(),i)||this;return a.LensChromaticAberrationEffect="LensChromaticAberrationEffect",a.HighlightsEnhancingEffect="HighlightsEnhancingEffect",a.LensDepthOfFieldEffect="LensDepthOfFieldEffect",a._scene=n,a._depthTexture=n.enableDepthRenderer().getDepthMap(),r.grain_texture?a._grainTexture=r.grain_texture:a._createGrainTexture(),a._edgeBlur=r.edge_blur?r.edge_blur:0,a._grainAmount=r.grain_amount?r.grain_amount:0,a._chromaticAberration=r.chromatic_aberration?r.chromatic_aberration:0,a._distortion=r.distortion?r.distortion:0,a._highlightsGain=void 0!==r.dof_gain?r.dof_gain:-1,a._highlightsThreshold=r.dof_threshold?r.dof_threshold:1,a._dofDistance=void 0!==r.dof_focus_distance?r.dof_focus_distance:-1,a._dofAperture=r.dof_aperture?r.dof_aperture:1,a._dofDarken=r.dof_darken?r.dof_darken:0,a._dofPentagon=void 0===r.dof_pentagon||r.dof_pentagon,a._blurNoise=void 0===r.blur_noise||r.blur_noise,a._createChromaticAberrationPostProcess(o),a._createHighlightsPostProcess(o),a._createDepthOfFieldPostProcess(o/4),a.addEffect(new e.PostProcessRenderEffect(n.getEngine(),a.LensChromaticAberrationEffect,function(){return a._chromaticAberrationPostProcess},!0)),a.addEffect(new e.PostProcessRenderEffect(n.getEngine(),a.HighlightsEnhancingEffect,function(){return a._highlightsPostProcess},!0)),a.addEffect(new e.PostProcessRenderEffect(n.getEngine(),a.LensDepthOfFieldEffect,function(){return a._depthOfFieldPostProcess},!0)),-1===a._highlightsGain&&a._disableEffect(a.HighlightsEnhancingEffect,null),n.postProcessRenderPipelineManager.addPipeline(a),s&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s),a}return o(i,t),i.prototype.setEdgeBlur=function(e){this._edgeBlur=e},i.prototype.disableEdgeBlur=function(){this._edgeBlur=0},i.prototype.setGrainAmount=function(e){this._grainAmount=e},i.prototype.disableGrain=function(){this._grainAmount=0},i.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},i.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},i.prototype.setEdgeDistortion=function(e){this._distortion=e},i.prototype.disableEdgeDistortion=function(){this._distortion=0},i.prototype.setFocusDistance=function(e){this._dofDistance=e},i.prototype.disableDepthOfField=function(){this._dofDistance=-1},i.prototype.setAperture=function(e){this._dofAperture=e},i.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},i.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect("#define PENTAGON\n")},i.prototype.disablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect()},i.prototype.enableNoiseBlur=function(){this._blurNoise=!0},i.prototype.disableNoiseBlur=function(){this._blurNoise=!1},i.prototype.setHighlightsGain=function(e){this._highlightsGain=e},i.prototype.setHighlightsThreshold=function(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},i.prototype.disableHighlights=function(){this._highlightsGain=-1},i.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},i.prototype._createChromaticAberrationPostProcess=function(t){var i=this;this._chromaticAberrationPostProcess=new e.PostProcess("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat("chromatic_aberration",i._chromaticAberration),e.setFloat("screen_width",i._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",i._scene.getEngine().getRenderHeight()),e.setFloat("radialIntensity",1),e.setFloat2("direction",17,17),e.setFloat2("centerPosition",.5,.5)}},i.prototype._createHighlightsPostProcess=function(t){var i=this;this._highlightsPostProcess=new e.PostProcess("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?"#define PENTAGON\n":""),this._highlightsPostProcess.onApply=function(e){e.setFloat("gain",i._highlightsGain),e.setFloat("threshold",i._highlightsThreshold),e.setTextureFromPostProcess("textureSampler",i._chromaticAberrationPostProcess),e.setFloat("screen_width",i._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",i._scene.getEngine().getRenderHeight())}},i.prototype._createDepthOfFieldPostProcess=function(t){var i=this;this._depthOfFieldPostProcess=new e.PostProcess("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture("depthSampler",i._depthTexture),e.setTexture("grainSampler",i._grainTexture),e.setTextureFromPostProcess("textureSampler",i._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",i._depthOfFieldPostProcess),e.setFloat("grain_amount",i._grainAmount),e.setBool("blur_noise",i._blurNoise),e.setFloat("screen_width",i._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",i._scene.getEngine().getRenderHeight()),e.setFloat("distortion",i._distortion),e.setBool("dof_enabled",-1!==i._dofDistance),e.setFloat("screen_distance",1/(.1-1/i._dofDistance)),e.setFloat("aperture",i._dofAperture),e.setFloat("darken",i._dofDarken),e.setFloat("edge_blur",i._edgeBlur),e.setBool("highlights",-1!==i._highlightsGain),i._scene.activeCamera&&(e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ))}},i.prototype._createGrainTexture=function(){this._grainTexture=new e.DynamicTexture("LensNoiseTexture",512,this._scene,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._grainTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var t,i=this._grainTexture.getContext(),r=function(e,t){return Math.random()*(t-e)+e},n=0;n<512;n++)for(var o=0;o<512;o++)t=Math.floor(255*r(.42,.58)),i.fillStyle="rgb("+t+", "+t+", "+t+")",i.fillRect(n,o,1,1);this._grainTexture.update(!1)},i}(e.PostProcessRenderPipeline);e.LensRenderingPipeline=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===o&&(o=null);var a=t.call(this,r.getEngine(),i)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.blurHPostProcesses=[],a.blurVPostProcesses=[],a.textureAdderPostProcess=null,a.volumetricLightPostProcess=null,a.volumetricLightSmoothXPostProcess=null,a.volumetricLightSmoothYPostProcess=null,a.volumetricLightMergePostProces=null,a.volumetricLightFinalPostProcess=null,a.luminancePostProcess=null,a.luminanceDownSamplePostProcesses=[],a.hdrPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlareFinalPostProcess=null,a.hdrFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.motionBlurPostProcess=null,a.depthOfFieldPostProcess=null,a.fxaaPostProcess=null,a.brightThreshold=1,a.blurWidth=512,a.horizontalBlur=!1,a.exposure=1,a.lensTexture=null,a.volumetricLightCoefficient=.2,a.volumetricLightPower=4,a.volumetricLightBlurScale=64,a.sourceLight=null,a.hdrMinimumLuminance=1,a.hdrDecreaseRate=.5,a.hdrIncreaseRate=.5,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.depthOfFieldBlurWidth=64,a.motionStrength=1,a.animations=[],a._currentDepthOfFieldSource=null,a._hdrCurrentLuminance=1,a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._vlsEnabled=!1,a._lensFlareEnabled=!1,a._hdrEnabled=!1,a._motionBlurEnabled=!1,a._fxaaEnabled=!1,a._motionBlurSamples=64,a._volumetricLightStepsCount=50,a._samples=1,a._cameras=s||[],a._scene=r,a._basePostProcess=o,a._ratio=n,a._floatTextureType=r.getEngine().getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT,r.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return o(i,t),Object.defineProperty(i.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(t){if(this._vlsEnabled!==t){if(t)if(!this._scene.enableGeometryBufferRenderer())return void e.Tools.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=t,this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1)),this._motionBlurSamples=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),i.prototype._buildPipeline=function(){var t=this,i=this._ratio,r=this._scene;this._disposePostProcesses(),this._reset(),this._basePostProcess?this.originalPostProcess=this._basePostProcess:(this.originalPostProcess=new e.PostProcess("HDRPass","standard",[],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.onApply=function(e){t._currentDepthOfFieldSource=t.originalPostProcess}),(this._bloomEnabled||this._vlsEnabled||this._lensFlareEnabled||this._depthOfFieldEnabled||this._motionBlurEnabled)&&this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPassPostProcess",function(){return t.originalPostProcess},!0)),this._currentDepthOfFieldSource=this.originalPostProcess,this._bloomEnabled&&(this._createDownSampleX4PostProcess(r,i/2),this._createBrightPassPostProcess(r,i/2),this._createBlurPostProcesses(r,i/4,1),this._createTextureAdderPostProcess(r,i),this.textureAdderFinalPostProcess=new e.PostProcess("HDRDepthOfFieldSource","standard",[],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRBaseDepthOfFieldSource",function(){return t.textureAdderFinalPostProcess},!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(r,i),this.volumetricLightFinalPostProcess=new e.PostProcess("HDRVLSFinal","standard",[],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRVLSFinal",function(){return t.volumetricLightFinalPostProcess},!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(r,i),this.lensFlareFinalPostProcess=new e.PostProcess("HDRPostLensFlareDepthOfFieldSource","standard",[],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPostLensFlareDepthOfFieldSource",function(){return t.lensFlareFinalPostProcess},!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(r,this._floatTextureType),this._createHdrPostProcess(r,i),this.hdrFinalPostProcess=new e.PostProcess("HDRPostHDReDepthOfFieldSource","standard",[],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPostHDReDepthOfFieldSource",function(){return t.hdrFinalPostProcess},!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(r,i/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(r,i)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(r,i),this._fxaaEnabled&&(this.fxaaPostProcess=new e.FxaaPostProcess("fxaa",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRFxaa",function(){return t.fxaaPostProcess},!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&e.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this.downSampleX4PostProcess=new e.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DOWN_SAMPLE_X4",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=r.downSampleX4PostProcess.width,o=r.downSampleX4PostProcess.height,s=-2;s<2;s++)for(var a=-2;a<2;a++)n[t]=(s+.5)*(1/i),n[t+1]=(a+.5)*(1/o),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDownSampleX4",function(){return r.downSampleX4PostProcess},!0))},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this.brightPassPostProcess=new e.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define BRIGHT_PASS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){var t=1/r.brightPassPostProcess.width,i=1/r.brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*i,n[2]=.5*t,n[3]=.5*i,n[4]=-.5*t,n[5]=-.5*i,n[6]=.5*t,n[7]=-.5*i,e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",r.brightThreshold)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},!0))},i.prototype._createBlurPostProcesses=function(t,i,r,n){var o=this;void 0===n&&(n="blurWidth");var s=t.getEngine(),a=new e.BlurPostProcess("HDRBlurH_"+r,new e.Vector2(1,0),this[n],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,e.Engine.TEXTURETYPE_UNSIGNED_INT),l=new e.BlurPostProcess("HDRBlurV_"+r,new e.Vector2(0,1),this[n],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,e.Engine.TEXTURETYPE_UNSIGNED_INT);a.onActivateObservable.add(function(){var e=a.width/s.getRenderWidth();a.kernel=o[n]*e}),l.onActivateObservable.add(function(){var e=l.height/s.getRenderHeight();l.kernel=o.horizontalBlur?64*e:o[n]*e}),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBlurH"+r,function(){return a},!0)),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBlurV"+r,function(){return l},!0)),this.blurHPostProcesses.push(a),this.blurVPostProcesses.push(l)},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this.textureAdderPostProcess=new e.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define TEXTURE_ADDER",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._vlsEnabled?r._currentDepthOfFieldSource:r.originalPostProcess),e.setTexture("lensSampler",r.lensTexture),e.setFloat("exposure",r.exposure),r._currentDepthOfFieldSource=r.textureAdderFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRTextureAdder",function(){return r.textureAdderPostProcess},!0))},i.prototype._createVolumetricLightPostProcess=function(t,i){var r=this,n=t.enableGeometryBufferRenderer();n.enablePosition=!0;var o=n.getGBuffer();this.volumetricLightPostProcess=new e.PostProcess("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],i/8,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var s=e.Vector2.Zero();this.volumetricLightPostProcess.onApply=function(e){if(r.sourceLight&&r.sourceLight.getShadowGenerator()&&r._scene.activeCamera){var t=r.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",o.textures[2]),e.setColor3("sunColor",r.sourceLight.diffuse),e.setVector3("sunDirection",r.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",r._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",r.volumetricLightCoefficient),e.setFloat("scatteringPower",r.volumetricLightPower),s.x=r.sourceLight.getDepthMinZ(r._scene.activeCamera),s.y=r.sourceLight.getDepthMaxZ(r._scene.activeCamera),e.setVector2("depthValues",s)}},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRVLS",function(){return r.volumetricLightPostProcess},!0)),this._createBlurPostProcesses(t,i/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new e.PostProcess("HDRVLSMerge","standard",[],["originalSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",r._bloomEnabled?r.textureAdderFinalPostProcess:r.originalPostProcess),r._currentDepthOfFieldSource=r.volumetricLightFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRVLSMerge",function(){return r.volumetricLightMergePostProces},!0))},i.prototype._createLuminancePostProcesses=function(t,r){var n=this,o=Math.pow(3,i.LuminanceSteps);this.luminancePostProcess=new e.PostProcess("HDRLuminance","standard",["lumOffsets"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LUMINANCE",r);var s=[];this.luminancePostProcess.onApply=function(e){var t=1/n.luminancePostProcess.width,i=1/n.luminancePostProcess.height;s[0]=-.5*t,s[1]=.5*i,s[2]=.5*t,s[3]=.5*i,s[4]=-.5*t,s[5]=-.5*i,s[6]=.5*t,s[7]=-.5*i,e.setArray2("lumOffsets",s)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminance",function(){return n.luminancePostProcess},!0));for(var a=i.LuminanceSteps-1;a>=0;a--){o=Math.pow(3,a);var l="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(l+="#define FINAL_DOWN_SAMPLER");var c=new e.PostProcess("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:o,height:o},null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,l,r);this.luminanceDownSamplePostProcesses.push(c)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach(function(i,r){var o=new Array(18);i.onApply=function(e){if(u){for(var t=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)o[t]=s/u.width,o[t+1]=a/u.height,t+=2;e.setArray2("dsOffsets",o),e.setFloat("halfDestPixelSize",.5/u.width),u=r===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:i}},r===n.luminanceDownSamplePostProcesses.length-1&&(i.onAfterRender=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100}),n.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLuminanceDownSample"+r,function(){return i},!0))})},i.prototype._createHdrPostProcess=function(t,i){var r=this;this.hdrPostProcess=new e.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR",e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(i){if(i.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=t.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var a=(s-o)/1e3;r._hdrCurrentLuminance<n+r.hdrDecreaseRate*a?n+=r.hdrDecreaseRate*a:r._hdrCurrentLuminance>n-r.hdrIncreaseRate*a?n-=r.hdrIncreaseRate*a:n=r._hdrCurrentLuminance}n=e.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),i.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},!0)),this._createBlurPostProcesses(t,i/4,2),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},!0));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r._bloomEnabled?r.blurHPostProcesses[0]:r.originalPostProcess),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){if(r._scene.activeCamera){t.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var l=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),c=s.multiply(l).multiply(o);t.setMatrix("lensStarMatrix",c),r._currentDepthOfFieldSource=r.lensFlareFinalPostProcess}}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._currentDepthOfFieldSource),e.setTexture("depthSampler",r._getDepthTexture()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},!0))},i.prototype._createMotionBlurPostProcess=function(t,i){var r=this;this.motionBlurPostProcess=new e.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),e.Engine.TEXTURETYPE_UNSIGNED_INT);var n=0,o=e.Matrix.Identity(),s=e.Matrix.Identity(),a=e.Matrix.Identity(),l=e.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){(a=t.getProjectionMatrix().multiply(t.getViewMatrix())).invertToRef(s),e.setMatrix("inverseViewProjection",s),e.setMatrix("prevViewProjection",o),o=a,l.x=r.motionBlurPostProcess.width,l.y=r.motionBlurPostProcess.height,e.setVector2("screenSize",l),n=t.getEngine().getFps()/60,e.setFloat("motionScale",n),e.setFloat("motionStrength",r.motionStrength),e.setTexture("depthSampler",r._getDepthTexture())},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return r.motionBlurPostProcess},!0))},i.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},i.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var t=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(t),this.textureAdderFinalPostProcess&&this.textureAdderFinalPostProcess.dispose(t),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(t),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(t),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(t),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(t),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(t),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(t),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(t);for(var i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(t);this.luminancePostProcess&&this.luminancePostProcess.dispose(t),this.hdrPostProcess&&this.hdrPostProcess.dispose(t),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(t),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(t),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(t),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(t);for(i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(t);for(i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(t)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.luminanceDownSamplePostProcesses=[],this.blurHPostProcesses=[],this.blurVPostProcesses=[]},i.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),t.prototype.dispose.call(this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return this.sourceLight&&(t.sourceLightId=this.sourceLight.id),t.customType="StandardRenderingPipeline",t},i.Parse=function(t,r,n){var o=e.SerializationHelper.Parse(function(){return new i(t._name,r,t._ratio)},t,r,n);return t.sourceLightId&&(o.sourceLight=r.getLightByID(t.sourceLightId)),o},i.LuminanceSteps=6,n([e.serialize()],i.prototype,"brightThreshold",void 0),n([e.serialize()],i.prototype,"blurWidth",void 0),n([e.serialize()],i.prototype,"horizontalBlur",void 0),n([e.serialize()],i.prototype,"exposure",void 0),n([e.serializeAsTexture("lensTexture")],i.prototype,"lensTexture",void 0),n([e.serialize()],i.prototype,"volumetricLightCoefficient",void 0),n([e.serialize()],i.prototype,"volumetricLightPower",void 0),n([e.serialize()],i.prototype,"volumetricLightBlurScale",void 0),n([e.serialize()],i.prototype,"hdrMinimumLuminance",void 0),n([e.serialize()],i.prototype,"hdrDecreaseRate",void 0),n([e.serialize()],i.prototype,"hdrIncreaseRate",void 0),n([e.serializeAsTexture("lensColorTexture")],i.prototype,"lensColorTexture",void 0),n([e.serialize()],i.prototype,"lensFlareStrength",void 0),n([e.serialize()],i.prototype,"lensFlareGhostDispersal",void 0),n([e.serialize()],i.prototype,"lensFlareHaloWidth",void 0),n([e.serialize()],i.prototype,"lensFlareDistortionStrength",void 0),n([e.serializeAsTexture("lensStarTexture")],i.prototype,"lensStarTexture",void 0),n([e.serializeAsTexture("lensFlareDirtTexture")],i.prototype,"lensFlareDirtTexture",void 0),n([e.serialize()],i.prototype,"depthOfFieldDistance",void 0),n([e.serialize()],i.prototype,"depthOfFieldBlurWidth",void 0),n([e.serialize()],i.prototype,"motionStrength",void 0),n([e.serialize()],i.prototype,"_ratio",void 0),n([e.serialize()],i.prototype,"BloomEnabled",null),n([e.serialize()],i.prototype,"DepthOfFieldEnabled",null),n([e.serialize()],i.prototype,"LensFlareEnabled",null),n([e.serialize()],i.prototype,"HDREnabled",null),n([e.serialize()],i.prototype,"VLSEnabled",null),n([e.serialize()],i.prototype,"MotionBlurEnabled",null),n([e.serialize()],i.prototype,"fxaaEnabled",null),n([e.serialize()],i.prototype,"volumetricLightStepsCount",null),n([e.serialize()],i.prototype,"motionBlurSamples",null),n([e.serialize()],i.prototype,"samples",null),i}(e.PostProcessRenderPipeline);e.StandardRenderingPipeline=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===n&&(n=null),void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT);var c=t.call(this,i,"fxaa",["texelSize"],null,r,n,o||e.Texture.BILINEAR_SAMPLINGMODE,s,a,null,l,"fxaa",void 0,!0)||this,u=c._getDefines();return c.updateEffect(u),c.onApplyObservable.add(function(e){var t=c.texelSize;e.setFloat2("texelSize",t.x,t.y)}),c}return o(i,t),i.prototype._getDefines=function(){var e=this.getEngine();if(!e)return null;var t=e.getGlInfo();return t&&t.renderer&&t.renderer.toLowerCase().indexOf("mali")>-1?"#define MALI 1\n":null},i}(e.PostProcess);e.FxaaPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=t.call(this,i,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],o,s,a,l,c,null,u,void 0,null,h)||this;return d.aberrationAmount=30,d.radialIntensity=0,d.direction=new e.Vector2(.707,.707),d.centerPosition=new e.Vector2(.5,.5),d.onApplyObservable.add(function(e){e.setFloat("chromatic_aberration",d.aberrationAmount),e.setFloat("screen_width",r),e.setFloat("screen_height",n),e.setFloat("radialIntensity",d.radialIntensity),e.setFloat2("direction",d.direction.x,d.direction.y),e.setFloat2("centerPosition",d.centerPosition.x,d.centerPosition.y)}),d}return o(i,t),i}(e.PostProcess);e.ChromaticAberrationPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=t.call(this,i,"grain",["intensity","animatedSeed"],[],r,n,o,s,a,null,l,void 0,null,c)||this;return u.intensity=30,u.animated=!1,u.onApplyObservable.add(function(e){e.setFloat("intensity",u.intensity),e.setFloat("animatedSeed",u.animated?Math.random()+1:1)}),u}return o(i,t),i}(e.PostProcess);e.GrainPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=t.call(this,i,"sharpen",["sharpnessAmounts","screenSize"],null,r,n,o,s,a,null,l,void 0,null,c)||this;return u.colorAmount=1,u.edgeAmount=.3,u.onApply=function(e){e.setFloat2("screenSize",u.width,u.height),e.setFloat2("sharpnessAmounts",u.edgeAmount,u.colorAmount)},u}return o(i,t),i}(e.PostProcess);e.SharpenPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h,d){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=""),void 0===d&&(d=!1);var f=t.call(this,i,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],o,s,a,l,c,null,u,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return f.direction=r,f.blockCompilation=d,f._packedFloat=!1,f._staticDefines="",f._staticDefines=h,f.onApplyObservable.add(function(e){f._outputTexture?e.setFloat2("delta",1/f._outputTexture.width*f.direction.x,1/f._outputTexture.height*f.direction.y):e.setFloat2("delta",1/f.width*f.direction.x,1/f.height*f.direction.y)}),f.kernel=n,f}return o(i,t),Object.defineProperty(i.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),i.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(n,o)},i.prototype._updateParameters=function(e,i){for(var r=this._kernel,n=(r-1)/2,o=[],s=[],a=0,l=0;l<r;l++){var c=l/(r-1),u=this._gaussianWeight(2*c-1);o[l]=l-n,s[l]=u,a+=u}for(l=0;l<s.length;l++)s[l]/=a;var h=[],d=[],f=[];for(l=0;l<=n;l+=2){var p=Math.min(l+1,Math.floor(n));if(l===p)f.push({o:o[l],w:s[l]});else{var m=p===n,g=s[l]+s[p]*(m?.5:1),_=o[l]+1/(1+s[l]/s[p]);0===_?(f.push({o:o[l],w:s[l]}),f.push({o:o[l+1],w:s[l+1]})):(f.push({o:_,w:g}),f.push({o:-_,w:g}))}}for(l=0;l<f.length;l++)d[l]=f[l].o,h[l]=f[l].w;o=d,s=h;var v=this.getEngine().getCaps().maxVaryingVectors,A=Math.max(v,0)-1,y=Math.min(o.length,A),b="";b+=this._staticDefines,-1!=this._staticDefines.indexOf("DOF")&&(b+="#define CENTER_WEIGHT "+this._glslFloat(s[y-1])+"\r\n",y--);for(l=0;l<y;l++)b+="#define KERNEL_OFFSET"+l+" "+this._glslFloat(o[l])+"\r\n",b+="#define KERNEL_WEIGHT"+l+" "+this._glslFloat(s[l])+"\r\n";var T=0;for(l=A;l<o.length;l++)b+="#define KERNEL_DEP_OFFSET"+T+" "+this._glslFloat(o[l])+"\r\n",b+="#define KERNEL_DEP_WEIGHT"+T+" "+this._glslFloat(s[l])+"\r\n",T++;this.packedFloat&&(b+="#define PACKEDFLOAT 1"),this.blockCompilation=!1,t.prototype.updateEffect.call(this,b,null,null,{varyingCount:y,depCount:T},e,i)},i.prototype._nearestBestKernel=function(e){for(var t=Math.round(e),i=0,r=[t,t-1,t+1,t-2,t+2];i<r.length;i++){var n=r[i];if(n%2!=0&&Math.floor(n/2)%2==0&&n>0)return Math.max(n,3)}return Math.max(t,3)},i.prototype._gaussianWeight=function(e){var t=-e*e/(1/3*2*(1/3));return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(t)},i.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},i}(e.PostProcess);e.BlurPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h,d,f,p){void 0===c&&(c=null),void 0===u&&(u=e.Texture.BILINEAR_SAMPLINGMODE),void 0===f&&(f=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===p&&(p=!1);var m=t.call(this,i,n,o,s,a,u=e.Texture.BILINEAR_SAMPLINGMODE,h,d,f=e.Engine.TEXTURETYPE_UNSIGNED_INT,"#define DOF 1\r\n",p)||this;return m.direction=n,m.onApplyObservable.add(function(e){null!=c&&e.setTextureFromPostProcess("textureSampler",c),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",l),r.activeCamera&&e.setFloat2("cameraMinMaxZ",r.activeCamera.minZ,r.activeCamera.maxZ)}),m}return o(i,t),i}(e.BlurPostProcess);e.DepthOfFieldBlurPostProcess=t}(a||(a={})),function(e){var t=function(){return function(){}}();e.DepthOfFieldMergePostProcessOptions=t;var i=function(t){function i(i,r,n,o,s,a,l,c,u,h,d){void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d=!1);var f=t.call(this,i,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],s,a,l,c,u,null,h,void 0,null,!0)||this;return f.blurSteps=o,f.onApplyObservable.add(function(e){e.setTextureFromPostProcess("textureSampler",r),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",n),o.forEach(function(t,i){e.setTextureFromPostProcessOutput("blurStep"+(o.length-i-1),t)})}),d||f.updateEffect(),f}return o(i,t),i.prototype.updateEffect=function(e,i,r,n,o,s){void 0===e&&(e=null),void 0===i&&(i=null),void 0===r&&(r=null),e||(e="",e+="#define BLUR_LEVEL "+(this.blurSteps.length-1)+"\n"),t.prototype.updateEffect.call(this,e,i,r,n,o,s)},i}(e.PostProcess);e.DepthOfFieldMergePostProcess=i}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u){void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1);var h=t.call(this,i,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],n,o,s,a,l,null,c,void 0,null,u)||this;return h.lensSize=50,h.fStop=1.4,h.focusDistance=2e3,h.focalLength=50,h._depthTexture=null,h._depthTexture=r,h.onApplyObservable.add(function(t){if(h._depthTexture){t.setTexture("depthSampler",h._depthTexture);var i=h.lensSize/h.fStop*h.focalLength/(h.focusDistance-h.focalLength);t.setFloat("focusDistance",h.focusDistance),t.setFloat("cocPrecalculation",i),t.setFloat2("cameraMinMaxZ",h._depthTexture.activeCamera.minZ,h._depthTexture.activeCamera.maxZ)}else e.Tools.Warn("No depth texture set on CircleOfConfusionPostProcess")}),h}return o(i,t),Object.defineProperty(i.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!0,configurable:!0}),i}(e.PostProcess);e.CircleOfConfusionPostProcess=t}(a||(a={})),function(e){var t;!function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(t=e.DepthOfFieldEffectBlurLevel||(e.DepthOfFieldEffectBlurLevel={}));var i=function(i){function r(r,n,o,s,a){void 0===o&&(o=t.Low),void 0===s&&(s=0),void 0===a&&(a=!1);var l=i.call(this,r.getEngine(),"depth of field",function(){return l._effects},!0)||this;l._effects=[],l._circleOfConfusion=new e.CircleOfConfusionPostProcess("circleOfConfusion",n,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,s,a),l._depthOfFieldBlurY=[],l._depthOfFieldBlurX=[];var c=1,u=15;switch(o){case t.High:c=3,u=51;break;case t.Medium:c=2,u=31;break;default:u=15,c=1}for(var h=u/Math.pow(2,c-1),d=1,f=0;f<c;f++){var p=new e.DepthOfFieldBlurPostProcess("verticle blur",r,new e.Vector2(0,1),h,d,null,l._circleOfConfusion,0==f?l._circleOfConfusion:null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,s,a);p.autoClear=!1,d=.75/Math.pow(2,f);var m=new e.DepthOfFieldBlurPostProcess("horizontal blur",r,new e.Vector2(1,0),h,d,null,l._circleOfConfusion,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,s,a);m.autoClear=!1,l._depthOfFieldBlurY.push(p),l._depthOfFieldBlurX.push(m)}l._effects=[l._circleOfConfusion];for(f=0;f<l._depthOfFieldBlurX.length;f++)l._effects.push(l._depthOfFieldBlurY[f]),l._effects.push(l._depthOfFieldBlurX[f]);return l._dofMerge=new e.DepthOfFieldMergePostProcess("dofMerge",l._circleOfConfusion,l._circleOfConfusion,l._depthOfFieldBlurX,d,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,s,a),l._dofMerge.autoClear=!1,l._effects.push(l._dofMerge),l}return o(r,i),Object.defineProperty(r.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!0,configurable:!0}),r.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},r.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},r.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},r}(e.PostProcessRenderEffect);e.DepthOfFieldEffect=i}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h,d){void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d=!1);var f=t.call(this,i,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],s,a,l,c,u,null,h,void 0,null,!0)||this;return f.weight=o,f.onApplyObservable.add(function(e){e.setTextureFromPostProcess("textureSampler",r),e.setTextureFromPostProcessOutput("bloomBlur",n),e.setFloat("bloomWeight",f.weight)}),d||f.updateEffect(),f}return o(i,t),i}(e.PostProcess);e.BloomMergePostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=t.call(this,i,"extractHighlights",["threshold","exposure"],null,r,n,o,s,a,null,l,void 0,null,c)||this;return u.threshold=.9,u._exposure=1,u._inputPostProcess=null,u.onApplyObservable.add(function(t){u._inputPostProcess&&t.setTextureFromPostProcess("textureSampler",u._inputPostProcess),t.setFloat("threshold",Math.pow(u.threshold,e.ToGammaSpace)),t.setFloat("exposure",u._exposure)}),u}return o(i,t),i}(e.PostProcess);e.ExtractHighlightsPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a){void 0===s&&(s=0),void 0===a&&(a=!1);var l=t.call(this,i.getEngine(),"bloom",function(){return l._effects},!0)||this;return l.bloomScale=r,l._effects=[],l._downscale=new e.ExtractHighlightsPostProcess("highlights",1,null,e.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,s,a),l._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),10,r,null,e.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,s,void 0,a),l._blurX.alwaysForcePOT=!0,l._blurX.autoClear=!1,l._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),10,r,null,e.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,s,void 0,a),l._blurY.alwaysForcePOT=!0,l._blurY.autoClear=!1,l.kernel=o,l._effects=[l._downscale,l._blurX,l._blurY],l._merge=new e.BloomMergePostProcess("bloomMerge",l._downscale,l._blurY,n,r,null,e.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,s,a),l._merge.autoClear=!1,l._effects.push(l._merge),l}return o(i,t),Object.defineProperty(i.prototype,"threshold",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"kernel",{get:function(){return this._blurX.kernel/this.bloomScale},set:function(e){this._blurX.kernel=e*this.bloomScale,this._blurY.kernel=e*this.bloomScale},enumerable:!0,configurable:!0}),i.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},i.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},i.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},i}(e.PostProcessRenderEffect);e.BloomEffect=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===i&&(i=""),void 0===r&&(r=!0),void 0===n&&(n=e.Engine.LastCreatedScene),void 0===s&&(s=!0);var a=t.call(this,n.getEngine(),i)||this;a._camerasToBeAttached=[],a.SharpenPostProcessId="SharpenPostProcessEffect",a.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",a.FxaaPostProcessId="FxaaPostProcessEffect",a.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",a.GrainPostProcessId="GrainPostProcessEffect",a._glowLayer=null,a.animations=[],a._imageProcessingConfigurationObserver=null,a._sharpenEnabled=!1,a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._depthOfFieldBlurLevel=e.DepthOfFieldEffectBlurLevel.Low,a._fxaaEnabled=!1,a._imageProcessingEnabled=!0,a._bloomScale=.5,a._chromaticAberrationEnabled=!1,a._grainEnabled=!1,a._buildAllowed=!0,a._resizeObserver=null,a._hardwareScaleLevel=1,a._bloomKernel=64,a._bloomWeight=.15,a._bloomThreshold=.9,a._samples=1,a._hasCleared=!1,a._prevPostProcess=null,a._prevPrevPostProcess=null,a._depthOfFieldSceneObserver=null,a._cameras=o||n.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._buildAllowed=s,a._scene=n;var l=a._scene.getEngine().getCaps();a._hdr=r&&(l.textureHalfFloatRender||l.textureFloatRender),a._hdr?l.textureHalfFloatRender?a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender&&(a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_FLOAT):a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(a);var c=a._scene.getEngine();return a.sharpen=new e.SharpenPostProcess("sharpen",1,null,e.Texture.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._sharpenEffect=new e.PostProcessRenderEffect(c,a.SharpenPostProcessId,function(){return a.sharpen},!0),a.depthOfField=new e.DepthOfFieldEffect(a._scene,null,a._depthOfFieldBlurLevel,a._defaultPipelineTextureType,!0),a.bloom=new e.BloomEffect(a._scene,a._bloomScale,a._bloomWeight,a.bloomKernel,a._defaultPipelineTextureType,!0),a.chromaticAberration=new e.ChromaticAberrationPostProcess("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,e.Texture.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._chromaticAberrationEffect=new e.PostProcessRenderEffect(c,a.ChromaticAberrationPostProcessId,function(){return a.chromaticAberration},!0),a.grain=new e.GrainPostProcess("Grain",1,null,e.Texture.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._grainEffect=new e.PostProcessRenderEffect(c,a.GrainPostProcessId,function(){return a.grain},!0),a._resizeObserver=c.onResizeObservable.add(function(){a._hardwareScaleLevel=c.getHardwareScalingLevel(),a.bloomKernel=a.bloomKernel}),a._imageProcessingConfigurationObserver=a._scene.imageProcessingConfiguration.onUpdateParameters.add(function(){a.bloom._downscale._exposure=a._scene.imageProcessingConfiguration.exposure}),a._buildPipeline(),a}return o(i,t),Object.defineProperty(i.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),i.prototype._rebuildBloom=function(){var t=this.bloom;this.bloom=new e.BloomEffect(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=t.threshold;for(var i=0;i<this._cameras.length;i++)t.disposeEffects(this._cameras[i])},Object.defineProperty(i.prototype,"depthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"depthOfFieldBlurLevel",{get:function(){return this._depthOfFieldBlurLevel},set:function(t){if(this._depthOfFieldBlurLevel!==t){this._depthOfFieldBlurLevel=t;var i=this.depthOfField;this.depthOfField=new e.DepthOfFieldEffect(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=i.focalLength,this.depthOfField.focusDistance=i.focusDistance,this.depthOfField.fStop=i.fStop,this.depthOfField.lensSize=i.lensSize;for(var r=0;r<this._cameras.length;r++)i.disposeEffects(this._cameras[r]);this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._imageProcessingEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"glowLayerEnabled",{get:function(){return null==this._glowLayer},set:function(t){t&&!this._glowLayer?this._glowLayer=new e.GlowLayer("",this._scene):!t&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),i.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e},i.prototype._setAutoClearAndTextureSharing=function(e,t){void 0===t&&(t=!1),this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)},i.prototype._buildPipeline=function(){var t=this;if(this._buildAllowed){this._scene.autoClear=!0;var i=this._scene.getEngine();if(this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(var r=0,n=this._cameras;r<n.length;r++){var o=n[r];(s=this._scene.enableDepthRenderer(o)).useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(function(e){t._cameras.indexOf(e.activeCamera)>-1&&(t.depthOfField.depthTexture=e.enableDepthRenderer(e.activeCamera).getDepthMap())})}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var s=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=s.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new e.ImageProcessingPostProcess("imageProcessing",1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new e.PostProcessRenderEffect(i,this.ImageProcessingPostProcessId,function(){return t.imageProcessing},!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new e.FxaaPostProcess("fxaa",1,null,e.Texture.BILINEAR_SAMPLINGMODE,i,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(i,this.FxaaPostProcessId,function(){return t.fxaa},!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&e.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},i.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)},i.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},i.prototype.removeCamera=function(e){var t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()},i.prototype.dispose=function(){this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),t.prototype.dispose.call(this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="DefaultRenderingPipeline",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse(function(){return new i(t._name,t._name._hdr,r)},t,r,n)},n([e.serialize()],i.prototype,"sharpenEnabled",null),n([e.serialize()],i.prototype,"bloomKernel",null),n([e.serialize()],i.prototype,"_bloomWeight",void 0),n([e.serialize()],i.prototype,"_bloomThreshold",void 0),n([e.serialize()],i.prototype,"_hdr",void 0),n([e.serialize()],i.prototype,"bloomWeight",null),n([e.serialize()],i.prototype,"bloomThreshold",null),n([e.serialize()],i.prototype,"bloomScale",null),n([e.serialize()],i.prototype,"bloomEnabled",null),n([e.serialize()],i.prototype,"depthOfFieldEnabled",null),n([e.serialize()],i.prototype,"depthOfFieldBlurLevel",null),n([e.serialize()],i.prototype,"fxaaEnabled",null),n([e.serialize()],i.prototype,"samples",null),n([e.serialize()],i.prototype,"imageProcessingEnabled",null),n([e.serialize()],i.prototype,"glowLayerEnabled",null),n([e.serialize()],i.prototype,"chromaticAberrationEnabled",null),n([e.serialize()],i.prototype,"grainEnabled",null),i}(e.PostProcessRenderPipeline);e.DefaultRenderingPipeline=t}(a||(a={})),function(e){var t=function(e){function t(){var t=e.call(this)||this;return t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return o(t,e),t}(e.MaterialDefines);e.ImageProcessingConfigurationDefines=t;var i=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._toneMappingType=t.TONEMAPPING_STANDARD,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,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=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,"toneMappingType",{get:function(){return this._toneMappingType},set:function(e){this._toneMappingType!==e&&(this._toneMappingType=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.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.IMAGEPROCESSING=!1,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);switch(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===t._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,e.TONEMAPPING=this.toneMappingEnabled,this._toneMappingType){case t.TONEMAPPING_ACES:e.TONEMAPPING_ACES=!0}e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.IMAGEPROCESSING=e.VIGNETTE||e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING},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 c=this.colorGradingTexture.getSize().height;t.setFloat4("colorTransformSettings",(c-1)/c,.5/c,c,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.TONEMAPPING_STANDARD=0,t.TONEMAPPING_ACES=1,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("colorGradingTexture")],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,"_toneMappingType",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=i}(a||(a={})),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"),c=0,u=0,h=0,d=0,f=0,p=0;p<l.length;p++)if(o=l[p],i._noneEmptyLineRegex.test(o)&&0!==o.indexOf("#")){var m=o.split(" ");if(0!==c){if(0!=c){var g=Math.max(parseInt(m[0]),0),_=Math.max(parseInt(m[1]),0),v=Math.max(parseInt(m[2]),0);f=Math.max(g,f),f=Math.max(_,f),f=Math.max(v,f);var A=4*(u+d*c+h*c*c);a&&(a[A+0]=g,a[A+1]=_,a[A+2]=v),++h%c==0&&(h=0,++d%c==0&&(u++,d=0))}}else c=m.length,s=new Uint8Array(c*c*c*4),a=new Float32Array(c*c*c*4)}if(a&&s)for(p=0;p<a.length;p++)if(p>0&&(p+1)%4==0)s[p]=255;else{var y=a[p];s[p]=y/f*255}t.is3D?(t.updateSize(c,c,c),r.updateRawTexture3D(t,s,e.Engine.TEXTUREFORMAT_RGBA,!1)):(t.updateSize(c*c,c),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)).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}(a||(a={})),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,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=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),c=o-l,u=a*(1-s),h=a*(1-s*c),d=a*(1-s*(1-c));switch(l){case 0:n.r=a,n.g=d,n.b=u;break;case 1:n.r=h,n.g=a,n.b=u;break;case 2:n.r=u,n.g=a,n.b=d;break;case 3:n.r=u,n.g=h,n.b=a;break;case 4:n.r=d,n.g=u,n.b=a;break;default:n.r=a,n.g=u,n.b=h}}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}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u,h){var d=t.call(this,i,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],a,l,c,u,h)||this;return d.color=n,d.depth=o,d.colorLevel=s,d._ownRefractionTexture=!0,d.onActivateObservable.add(function(t){d._refTexture=d._refTexture||new e.Texture(r,t.getScene())}),d.onApplyObservable.add(function(e){e.setColor3("baseColor",d.color),e.setFloat("depth",d.depth),e.setFloat("colorLevel",d.colorLevel),e.setTexture("refractionSampler",d._refTexture)}),d}return o(i,t),Object.defineProperty(i.prototype,"refractionTexture",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),t.prototype.dispose.call(this,e)},i}(e.PostProcess);e.RefractionPostProcess=t}(a||(a={})),function(e){var t=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"blackAndWhite",["degree"],null,i,r,n,o,s)||this;return a.degree=1,a.onApplyObservable.add(function(e){e.setFloat("degree",a.degree)}),a}return o(t,e),t}(e.PostProcess);e.BlackAndWhitePostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT);var u=t.call(this,i,"convolution",["kernel","screenSize"],null,n,o,s,a,l,null,c)||this;return u.kernel=r,u.onApply=function(e){e.setFloat2("screenSize",u.width,u.height),e.setArray("kernel",u.kernel)},u}return o(i,t),i.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],i.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],i.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],i.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],i.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],i.GaussianKernel=[0,1,0,1,1,1,0,1,0],i}(e.PostProcess);e.ConvolutionPostProcess=t}(a||(a={})),function(e){var t=function(e){function t(t,i,r,n,o,s,a){var l=e.call(this,t,"filter",["kernelMatrix"],null,r,n,o,s,a)||this;return l.kernelMatrix=i,l.onApply=function(e){e.setMatrix("kernelMatrix",l.kernelMatrix)},l}return o(t,e),t}(e.PostProcess);e.FilterPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(r,n,o,s,a,l,c,u,h){void 0===a&&(a=100),void 0===l&&(l=e.Texture.BILINEAR_SAMPLINGMODE);var d=t.call(this,r,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,o,l,c,u,"#define NUM_SAMPLES "+a)||this;return d._screenCoordinates=e.Vector2.Zero(),d.customMeshPosition=e.Vector3.Zero(),d.useCustomMeshPosition=!1,d.invert=!0,d.excludedMeshes=new Array,d.exposure=.3,d.decay=.96815,d.weight=.58767,d.density=.926,c=(h=null===o?h:o.getScene()).getEngine(),d._viewPort=new e.Viewport(0,0,1,1).toGlobal(c.getRenderWidth(),c.getRenderHeight()),d.mesh=null!==s?s:i.CreateDefaultMesh("VolumetricLightScatteringMesh",h),d._createPass(h,n.passRatio||n),d.onActivate=function(e){d.isSupported||d.dispose(e),d.onActivate=null},d.onApplyObservable.add(function(e){d._updateMeshScreenCoordinates(h),e.setTexture("lightScatteringSampler",d._volumetricLightScatteringRTT),e.setFloat("exposure",d.exposure),e.setFloat("decay",d.decay),e.setFloat("weight",d.weight),e.setFloat("density",d.density),e.setVector2("meshPositionOnScreen",d._screenCoordinates)}),d}return o(i,t),Object.defineProperty(i.prototype,"useDiffuseColor",{get:function(){return e.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(t){e.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"VolumetricLightScatteringPostProcess"},i.prototype._isReady=function(t,i){var r=t.getMesh();if(r===this.mesh&&r.material)return r.material.isReady(r);var n=[],o=[e.VertexBuffer.PositionKind],s=t.getMaterial();s&&(s.needAlphaTesting()&&n.push("#define ALPHATEST"),r.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),r.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),r.useBones&&r.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),n.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),n.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._volumetricLightScatteringPass=r.getScene().getEngine().createEffect({vertexElement:"depth",fragmentElement:"volumetricLightScatteringPass"},o,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],a)),this._volumetricLightScatteringPass.isReady()},i.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},i.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},i.prototype.dispose=function(e){var i=e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==i&&e.getScene().customRenderTargets.splice(i,1),this._volumetricLightScatteringRTT.dispose(),t.prototype.dispose.call(this,e)},i.prototype.getPass=function(){return this._volumetricLightScatteringRTT},i.prototype._meshExcluded=function(e){return this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var o=this.getCamera();o?o.customRenderTargets.push(this._volumetricLightScatteringRTT):t.customRenderTargets.push(this._volumetricLightScatteringRTT);var s,a=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=t.getMaterial();if(n){var o=i.getScene(),s=o.getEngine();s.setState(n.backFaceCulling);var a=i._getInstancesRenderList(t._id);if(!a.mustReturn){var l=s.getCaps().instancedArrays&&null!==a.visibleInstances[t._id];if(r._isReady(t,l)){var c=r._volumetricLightScatteringPass;if(i===r.mesh&&(c=t.effect?t.effect:n.getEffect()),s.enableEffect(c),i._bind(t,c,e.Material.TriangleFillMode),i===r.mesh)n.bind(i.getWorldMatrix(),i);else{if(r._volumetricLightScatteringPass.setMatrix("viewProjection",o.getTransformMatrix()),n&&n.needAlphaTesting()){var u=n.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",u),u&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",u.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,a,l,function(e,t){return c.setMatrix("world",t)})}}}}},l=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function(){s=t.clearColor,t.clearColor=l}),this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function(){t.clearColor=s}),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n,o){var s,l=t.getEngine();if(o.length){for(l.setColorWrite(!1),s=0;s<o.length;s++)a(o.data[s]);l.setColorWrite(!0)}for(s=0;s<i.length;s++)a(i.data[s]);for(s=0;s<r.length;s++)a(r.data[s]);if(n.length){for(s=0;s<n.length;s++){var c=n.data[s],u=c.getBoundingInfo();u&&t.activeCamera&&(c._alphaIndex=c.getMesh().alphaIndex,c._distanceToCamera=u.boundingSphere.centerWorld.subtract(t.activeCamera.position).length())}var h=n.data.slice(0,n.length);for(h.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),l.setAlphaMode(e.Engine.ALPHA_COMBINE),s=0;s<h.length;s++)a(h[s]);l.setAlphaMode(e.Engine.ALPHA_DISABLE)}}},i.prototype._updateMeshScreenCoordinates=function(t){var i,r=t.getTransformMatrix();i=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var n=e.Vector3.Project(i,e.Matrix.Identity(),r,this._viewPort);this._screenCoordinates.x=n.x/this._viewPort.width,this._screenCoordinates.y=n.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},i.CreateDefaultMesh=function(t,i){var r=e.Mesh.CreatePlane(t,1,i);r.billboardMode=e.AbstractMesh.BILLBOARDMODE_ALL;var n=new e.StandardMaterial(t+"Material",i);return n.emissiveColor=new e.Color3(1,1,1),r.material=n,r},n([e.serializeAsVector3()],i.prototype,"customMeshPosition",void 0),n([e.serialize()],i.prototype,"useCustomMeshPosition",void 0),n([e.serialize()],i.prototype,"invert",void 0),n([e.serializeAsMeshReference()],i.prototype,"mesh",void 0),n([e.serialize()],i.prototype,"excludedMeshes",void 0),n([e.serialize()],i.prototype,"exposure",void 0),n([e.serialize()],i.prototype,"decay",void 0),n([e.serialize()],i.prototype,"weight",void 0),n([e.serialize()],i.prototype,"density",void 0),i}(e.PostProcess);e.VolumetricLightScatteringPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){var c=t.call(this,i,"colorCorrection",null,["colorTable"],n,o,s,a,l)||this;return c._colorTableTexture=new e.Texture(r,o.getScene(),!0,!1,e.Texture.TRILINEAR_SAMPLINGMODE),c._colorTableTexture.anisotropicFilteringLevel=1,c._colorTableTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,c._colorTableTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,c.onApply=function(e){e.setTexture("colorTable",c._colorTableTexture)},c}return o(i,t),i}(e.PostProcess);e.ColorCorrectionPostProcess=t}(a||(a={})),function(e){var t;!function(e){e[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic"}(t=e.TonemappingOperator||(e.TonemappingOperator={}));var i=function(i){function r(r,n,o,s,a,l,c){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT);var u=i.call(this,r,"tonemap",["_ExposureAdjustment"],null,1,s,a,l,!0,null,c)||this;u._operator=n,u.exposureAdjustment=o;var h="#define ";return u._operator===t.Hable?h+="HABLE_TONEMAPPING":u._operator===t.Reinhard?h+="REINHARD_TONEMAPPING":u._operator===t.HejiDawson?h+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":u._operator===t.Photographic&&(h+="PHOTOGRAPHIC_TONEMAPPING"),u.updateEffect(h),u.onApply=function(e){e.setFloat("_ExposureAdjustment",u.exposureAdjustment)},u}return o(r,i),r}(e.PostProcess);e.TonemapPostProcess=i}(a||(a={})),function(e){var t=function(e){function t(t,i,r,n,o,s){return e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,r,n,o,s)||this}return o(t,e),t}(e.PostProcess);e.DisplayPassPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){return void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,i,"highlights",null,null,r,n,o,s,a,null,l)||this}return o(i,t),i}(e.PostProcess);e.HighlightsPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===n&&(n=null),void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT);var u=t.call(this,i,"imageProcessing",[],[],r,n,o,s,a,null,l,"postprocess",null,!0)||this;return u._fromLinearSpace=!0,u._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},c?(c.applyByPostProcess=!0,u._attachImageProcessingConfiguration(c,!0),u.fromLinearSpace=!1):(u._attachImageProcessingConfiguration(null,!0),u.imageProcessingConfiguration.applyByPostProcess=!0),u.onApply=function(e){u.imageProcessingConfiguration.bind(e,u.aspectRatio)},u}return o(i,t),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),i.prototype._attachImageProcessingConfiguration=function(t,i){var r=this;if(void 0===i&&(i=!1),t!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),t)this._imageProcessingConfiguration=t;else{var n=null,o=this.getEngine(),s=this.getCamera();if(s)n=s.getScene();else if(o&&o.scenes){var a=o.scenes;n=a[a.length-1]}else n=e.Engine.LastCreatedScene;this._imageProcessingConfiguration=n.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(e){r._updateParameters()})),i||this._updateParameters()}},Object.defineProperty(i.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"ImageProcessingPostProcess"},i.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var t="";for(var i in this._defines)this._defines[i]&&(t+="#define "+i+";\r\n");var r=["textureSampler"],n=["scale"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareSamplers(r,this._defines),e.ImageProcessingConfiguration.PrepareUniforms(n,this._defines)),this.updateEffect(t,n,r)},i.prototype.dispose=function(e){t.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},n([e.serialize()],i.prototype,"_fromLinearSpace",void 0),i}(e.PostProcess);e.ImageProcessingPostProcess=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l){void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var c=t.call(this,i,r.getScene())||this;return c.name=i,c.children=new Array,c.animations=new Array,c._index=null,c._absoluteTransform=new e.Matrix,c._invertedAbsoluteTransform=new e.Matrix,c._scalingDeterminant=1,c._worldTransform=new e.Matrix,c._needToDecompose=!0,c._needToCompose=!1,c._skeleton=r,c._localMatrix=o?o.clone():e.Matrix.Identity(),c._restPose=s||c._localMatrix.clone(),c._baseMatrix=a||c._localMatrix.clone(),c._index=l,r.bones.push(c),c.setParent(n,!1),(a||o)&&c._updateDifferenceMatrix(),c}return o(i,t),Object.defineProperty(i.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!0,configurable:!0}),i.prototype.getSkeleton=function(){return this._skeleton},i.prototype.getParent=function(){return this._parent},i.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix(),this.markAsDirty()}},i.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(i.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!0,configurable:!0}),i.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=e.Vector3.Zero(),this._localRotation=e.Quaternion.Zero(),this._localPosition=e.Vector3.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},i.prototype._compose=function(){this._needToCompose&&(this._needToCompose=!1,e.Matrix.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix))},i.prototype.updateMatrix=function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),i?(this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},i.prototype._updateDifferenceMatrix=function(e,t){if(void 0===t&&(t=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),t)for(var i=0;i<this.children.length;i++)this.children[i]._updateDifferenceMatrix();this._scalingDeterminant=this._absoluteTransform.determinant()<0?-1:1},i.prototype.markAsDirty=function(){this._currentRenderId++,this._childRenderId++,this._skeleton._markAsDirty()},i.prototype._markAsDirtyAndCompose=function(){this.markAsDirty(),this._needToCompose=!0},i.prototype._markAsDirtyAndDecompose=function(){this.markAsDirty(),this._needToDecompose=!0},i.prototype.copyAnimationRange=function(t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=null),0===this.animations.length&&(this.animations.push(new e.Animation(this.name,"_matrix",t.animations[0].framePerSecond,e.Animation.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var s=t.animations[0].getRange(i);if(!s)return!1;for(var a,l,c,u=s.from,h=s.to,d=t.animations[0].getKeys(),f=t.length,p=t.getParent(),m=this.getParent(),g=n&&p&&f&&this.length&&f!==this.length,_=g&&m&&p?m.length/p.length:1,v=n&&!m&&o&&(1!==o.x||1!==o.y||1!==o.z),A=this.animations[0].getKeys(),y=0,b=d.length;y<b;y++)(a=d[y]).frame>=u&&a.frame<=h&&(n?(c=a.value.clone(),g?(l=c.getTranslation(),c.setTranslation(l.scaleInPlace(_))):v&&o?(l=c.getTranslation(),c.setTranslation(l.multiplyInPlace(o))):c=a.value):c=a.value,A.push({frame:a.frame+r,value:c}));return this.animations[0].createRange(i,u+r,h+r),!0},i.prototype.translate=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]+=t.x,o.m[13]+=t.y,o.m[14]+=t.z;else{var s=null;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];this._parent&&(n&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.m[12]=0,a.m[13]=0,a.m[14]=0,a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]+=l.x,o.m[13]+=l.y,o.m[14]+=l.z}this._markAsDirtyAndDecompose()},i.prototype.setPosition=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix();if(r==e.Space.LOCAL)o.m[12]=t.x,o.m[13]=t.y,o.m[14]=t.z;else{var s=null;n&&(s=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0],l=i._tmpVecs[0];this._parent&&(n&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.invert(),e.Vector3.TransformCoordinatesToRef(t,a,l),o.m[12]=l.x,o.m[13]=l.y,o.m[14]=l.z}this._markAsDirtyAndDecompose()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.scale=function(t,r,n,o){void 0===o&&(o=!1);var s=this.getLocalMatrix(),a=i._tmpMats[0];e.Matrix.ScalingToRef(t,r,n,a),a.multiplyToRef(s,s),a.invert();for(var l=0,c=this.children;l<c.length;l++){var u=(f=c[l]).getLocalMatrix();u.multiplyToRef(a,u),u.m[12]*=t,u.m[13]*=r,u.m[14]*=n,f._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),o)for(var h=0,d=this.children;h<d.length;h++){var f;(f=d[h]).scale(t,r,n,o)}},i.prototype.setScale=function(e){this._decompose(),this._localScaling.copyFrom(e),this._markAsDirtyAndCompose()},i.prototype.getScale=function(){return this._decompose(),this._localScaling},i.prototype.getScaleToRef=function(e){this._decompose(),e.copyFrom(this._localScaling)},i.prototype.setYawPitchRoll=function(t,r,n,o,s){if(void 0===o&&(o=e.Space.LOCAL),o===e.Space.LOCAL){var a=i._tmpQuat;return e.Quaternion.RotationYawPitchRollToRef(t,r,n,a),void this.setRotationQuaternion(a,o,s)}var l=i._tmpMats[0];if(this._getNegativeRotationToRef(l,s)){var c=i._tmpMats[1];e.Matrix.RotationYawPitchRollToRef(t,r,n,c),l.multiplyToRef(c,c),this._rotateWithMatrix(c,o,s)}},i.prototype.rotate=function(t,r,n,o){void 0===n&&(n=e.Space.LOCAL);var s=i._tmpMats[0];s.m[12]=0,s.m[13]=0,s.m[14]=0,e.Matrix.RotationAxisToRef(t,r,s),this._rotateWithMatrix(s,n,o)},i.prototype.setAxisAngle=function(t,r,n,o){if(void 0===n&&(n=e.Space.LOCAL),n===e.Space.LOCAL){var s=i._tmpQuat;return e.Quaternion.RotationAxisToRef(t,r,s),void this.setRotationQuaternion(s,n,o)}var a=i._tmpMats[0];if(this._getNegativeRotationToRef(a,o)){var l=i._tmpMats[1];e.Matrix.RotationAxisToRef(t,r,l),a.multiplyToRef(l,l),this._rotateWithMatrix(l,n,o)}},i.prototype.setRotation=function(t,i,r){void 0===i&&(i=e.Space.LOCAL),this.setYawPitchRoll(t.y,t.x,t.z,i,r)},i.prototype.setRotationQuaternion=function(t,r,n){if(void 0===r&&(r=e.Space.LOCAL),r===e.Space.LOCAL)return this._decompose(),this._localRotation.copyFrom(t),void this._markAsDirtyAndCompose();var o=i._tmpMats[0];if(this._getNegativeRotationToRef(o,n)){var s=i._tmpMats[1];e.Matrix.FromQuaternionToRef(t,s),o.multiplyToRef(s,s),this._rotateWithMatrix(s,r,n)}},i.prototype.setRotationMatrix=function(t,r,n){if(void 0===r&&(r=e.Space.LOCAL),r===e.Space.LOCAL){var o=i._tmpQuat;return e.Quaternion.FromRotationMatrixToRef(t,o),void this.setRotationQuaternion(o,r,n)}var s=i._tmpMats[0];if(this._getNegativeRotationToRef(s,n)){var a=i._tmpMats[1];a.copyFrom(t),s.multiplyToRef(t,a),this._rotateWithMatrix(a,r,n)}},i.prototype._rotateWithMatrix=function(t,r,n){void 0===r&&(r=e.Space.LOCAL);var o=this.getLocalMatrix(),s=o.m[12],a=o.m[13],l=o.m[14],c=this.getParent(),u=i._tmpMats[3],h=i._tmpMats[4];c&&r==e.Space.WORLD?(n?(u.copyFrom(n.getWorldMatrix()),c.getAbsoluteTransform().multiplyToRef(u,u)):u.copyFrom(c.getAbsoluteTransform()),h.copyFrom(u),h.invert(),o.multiplyToRef(u,o),o.multiplyToRef(t,o),o.multiplyToRef(h,o)):r==e.Space.WORLD&&n?(u.copyFrom(n.getWorldMatrix()),h.copyFrom(u),h.invert(),o.multiplyToRef(u,o),o.multiplyToRef(t,o),o.multiplyToRef(h,o)):o.multiplyToRef(t,o),o.m[12]=s,o.m[13]=a,o.m[14]=l,this.computeAbsoluteTransforms(),this._markAsDirtyAndDecompose()},i.prototype._getNegativeRotationToRef=function(t,r){var n=i._tmpMats[2];return t.copyFrom(this.getAbsoluteTransform()),r&&(t.multiplyToRef(r.getWorldMatrix(),t),e.Matrix.ScalingToRef(r.scaling.x,r.scaling.y,r.scaling.z,n)),t.invert(),!isNaN(t.m[0])&&(n.m[0]*=this._scalingDeterminant,t.multiplyToRef(n,t),!0)},i.prototype.getPosition=function(t,i){void 0===t&&(t=e.Space.LOCAL),void 0===i&&(i=null);var r=e.Vector3.Zero();return this.getPositionToRef(t,i,r),r},i.prototype.getPositionToRef=function(t,r,n){if(void 0===t&&(t=e.Space.LOCAL),t==e.Space.LOCAL){var o=this.getLocalMatrix();n.x=o.m[12],n.y=o.m[13],n.z=o.m[14]}else{var s=null;r&&(s=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=i._tmpMats[0];r&&s?(a.copyFrom(this.getAbsoluteTransform()),a.multiplyToRef(s,a)):a=this.getAbsoluteTransform(),n.x=a.m[12],n.y=a.m[13],n.z=a.m[14]}},i.prototype.getAbsolutePosition=function(t){void 0===t&&(t=null);var i=e.Vector3.Zero();return this.getPositionToRef(e.Space.WORLD,t,i),i},i.prototype.getAbsolutePositionToRef=function(t,i){this.getPositionToRef(e.Space.WORLD,t,i)},i.prototype.computeAbsoluteTransforms=function(){if(this._compose(),this._parent)this._localMatrix.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform);else{this._absoluteTransform.copyFrom(this._localMatrix);var e=this._skeleton.getPoseMatrix();e&&this._absoluteTransform.multiplyToRef(e,this._absoluteTransform)}for(var t=this.children,i=t.length,r=0;r<i;r++)t[r].computeAbsoluteTransforms()},i.prototype.getDirection=function(t,i){void 0===i&&(i=null);var r=e.Vector3.Zero();return this.getDirectionToRef(t,i,r),r},i.prototype.getDirectionToRef=function(t,r,n){void 0===r&&(r=null);var o=null;r&&(o=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=i._tmpMats[0];s.copyFrom(this.getAbsoluteTransform()),r&&o&&s.multiplyToRef(o,s),e.Vector3.TransformNormalToRef(t,s,n),n.normalize()},i.prototype.getRotation=function(t,i){void 0===t&&(t=e.Space.LOCAL),void 0===i&&(i=null);var r=e.Vector3.Zero();return this.getRotationToRef(t,i,r),r},i.prototype.getRotationToRef=function(t,r,n){void 0===t&&(t=e.Space.LOCAL),void 0===r&&(r=null);var o=i._tmpQuat;this.getRotationQuaternionToRef(t,r,o),o.toEulerAnglesToRef(n)},i.prototype.getRotationQuaternion=function(t,i){void 0===t&&(t=e.Space.LOCAL),void 0===i&&(i=null);var r=e.Quaternion.Identity();return this.getRotationQuaternionToRef(t,i,r),r},i.prototype.getRotationQuaternionToRef=function(t,r,n){if(void 0===t&&(t=e.Space.LOCAL),void 0===r&&(r=null),t==e.Space.LOCAL)this._decompose(),n.copyFrom(this._localRotation);else{var o=i._tmpMats[0],s=this.getAbsoluteTransform();r?s.multiplyToRef(r.getWorldMatrix(),o):o.copyFrom(s),o.m[0]*=this._scalingDeterminant,o.m[1]*=this._scalingDeterminant,o.m[2]*=this._scalingDeterminant,o.decompose(void 0,n,void 0)}},i.prototype.getRotationMatrix=function(t,i){void 0===t&&(t=e.Space.LOCAL);var r=e.Matrix.Identity();return this.getRotationMatrixToRef(t,i,r),r},i.prototype.getRotationMatrixToRef=function(t,r,n){if(void 0===t&&(t=e.Space.LOCAL),t==e.Space.LOCAL)this.getLocalMatrix().getRotationMatrixToRef(n);else{var o=i._tmpMats[0],s=this.getAbsoluteTransform();r?s.multiplyToRef(r.getWorldMatrix(),o):o.copyFrom(s),o.m[0]*=this._scalingDeterminant,o.m[1]*=this._scalingDeterminant,o.m[2]*=this._scalingDeterminant,o.getRotationMatrixToRef(n)}},i.prototype.getAbsolutePositionFromLocal=function(t,i){void 0===i&&(i=null);var r=e.Vector3.Zero();return this.getAbsolutePositionFromLocalToRef(t,i,r),r},i.prototype.getAbsolutePositionFromLocalToRef=function(t,r,n){void 0===r&&(r=null);var o=null;r&&(o=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=i._tmpMats[0];r&&o?(s.copyFrom(this.getAbsoluteTransform()),s.multiplyToRef(o,s)):s=this.getAbsoluteTransform(),e.Vector3.TransformCoordinatesToRef(t,s,n)},i.prototype.getLocalPositionFromAbsolute=function(t,i){void 0===i&&(i=null);var r=e.Vector3.Zero();return this.getLocalPositionFromAbsoluteToRef(t,i,r),r},i.prototype.getLocalPositionFromAbsoluteToRef=function(t,r,n){void 0===r&&(r=null);var o=null;r&&(o=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=i._tmpMats[0];s.copyFrom(this.getAbsoluteTransform()),r&&o&&s.multiplyToRef(o,s),s.invert(),e.Vector3.TransformCoordinatesToRef(t,s,n)},i._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero()],i._tmpQuat=e.Quaternion.Identity(),i._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity()],i}(e.Node);e.Bone=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){if(this.targetPosition=e.Vector3.Zero(),this.poleTargetPosition=e.Vector3.Zero(),this.poleTargetLocalOffset=e.Vector3.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=e.Quaternion.Identity(),this._bone1Mat=e.Matrix.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=e.Vector3.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=i,this._bone1=i.getParent(),this._bone1){this.mesh=t;var n=i.getPosition();if(i.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var o=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*o.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(t),l=this._bone2.getAbsolutePosition(t),c=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(a,l),this._bone2Length=e.Vector3.Distance(l,c)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var i=this._bone1;if(i){var r=this.targetPosition,n=this.poleTargetPosition,o=t._tmpMats[0],s=t._tmpMats[1];this.targetMesh&&r.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var a=t._tmpVecs[0],l=t._tmpVecs[1],c=t._tmpVecs[2],u=t._tmpVecs[3],h=t._tmpVecs[4],d=t._tmpQuat;i.getAbsolutePositionToRef(this.mesh,a),n.subtractToRef(a,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),r.subtractToRef(a,u),u.normalize(),e.Vector3.CrossToRef(u,h,l),l.normalize(),e.Vector3.CrossToRef(u,l,c),c.normalize(),e.Matrix.FromXYZAxesToRef(c,u,l,o);var f=this._bone1Length,p=this._bone2Length,m=e.Vector3.Distance(a,r);this._maxReach>0&&(m=Math.min(this._maxReach,m));var g=(p*p+m*m-f*f)/(2*p*m),_=(m*m+f*f-p*p)/(2*m*f);g>1&&(g=1),_>1&&(_=1),g<-1&&(g=-1),_<-1&&(_=-1);var v=Math.acos(g),A=Math.acos(_),y=-v-A;if(this._rightHandedSystem)e.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(o,o),e.Matrix.RotationAxisToRef(this._bendAxis,A,s),s.multiplyToRef(o,o);else{var b=t._tmpVecs[5];b.copyFrom(this._bendAxis),b.x*=-1,e.Matrix.RotationAxisToRef(b,-A,s),s.multiplyToRef(o,o)}this.poleAngle&&(e.Matrix.RotationAxisToRef(u,this.poleAngle,s),o.multiplyToRef(s,o)),this._bone1&&(this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(o,d),e.Quaternion.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(o),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,y,e.Space.LOCAL),this._bone2Ang=y}},t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity()],t}();e.BoneIKController=t}(a||(a={})),function(e){var t=function(){function t(t,i,r,n){if(this.upAxis=e.Vector3.Up(),this.upAxisSpace=e.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=e.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=e.Vector3.Forward(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var o=e.Axis.Y,s=e.Axis.X;null!=n.yawAxis&&(o=n.yawAxis.clone()).normalize(),null!=n.pitchAxis&&(s=n.pitchAxis.clone()).normalize();var a=e.Vector3.Cross(s,o);this._transformYawPitch=e.Matrix.Identity(),e.Matrix.FromXYZAxesToRef(s,o,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}i.getParent()||this.upAxisSpace!=e.Space.BONE||(this.upAxisSpace=e.Space.LOCAL)}return Object.defineProperty(t.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),t.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var i=this.bone,r=t._tmpVecs[0];i.getAbsolutePositionToRef(this.mesh,r);var n=this.target,o=t._tmpMats[0],s=t._tmpMats[1],a=this.mesh,l=i.getParent(),c=t._tmpVecs[1];c.copyFrom(this.upAxis),this.upAxisSpace==e.Space.BONE&&l?(this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(c,this._transformYawPitchInv,c),l.getDirectionToRef(c,this.mesh,c)):this.upAxisSpace==e.Space.LOCAL&&(a.getDirectionToRef(c,c),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||c.normalize());var u=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),u||h){var d=t._tmpMats[2],f=t._tmpMats[3];if(this.upAxisSpace==e.Space.BONE&&1==c.y&&l)l.getRotationMatrixToRef(e.Space.WORLD,this.mesh,d);else if(this.upAxisSpace!=e.Space.LOCAL||1!=c.y||l){(m=t._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(m,this._transformYawPitchInv,m),l?l.getDirectionToRef(m,this.mesh,m):a.getDirectionToRef(m,m);var p=e.Vector3.Cross(c,m);p.normalize();var m=e.Vector3.Cross(p,c);e.Matrix.FromXYZAxesToRef(p,c,m,d)}else d.copyFrom(a.getWorldMatrix());d.invertToRef(f);var g=null;if(h){var _=t._tmpVecs[3];n.subtractToRef(r,_),e.Vector3.TransformCoordinatesToRef(_,f,_),g=Math.sqrt(_.x*_.x+_.z*_.z);var v=Math.atan2(_.y,g),A=v;v>this._maxPitch?(_.y=this._maxPitchTan*g,A=this._maxPitch):v<this._minPitch&&(_.y=this._minPitchTan*g,A=this._minPitch),v!=A&&(e.Vector3.TransformCoordinatesToRef(_,d,_),_.addInPlace(r),n=_)}if(u){_=t._tmpVecs[4];n.subtractToRef(r,_),e.Vector3.TransformCoordinatesToRef(_,f,_);var y=Math.atan2(_.x,_.z),b=y;if((y>this._maxYaw||y<this._minYaw)&&(null==g&&(g=Math.sqrt(_.x*_.x+_.z*_.z)),this._yawRange>Math.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(_.z=this._maxYawCos*g,_.x=this._maxYawSin*g,b=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(_.z=this._minYawCos*g,_.x=this._minYawSin*g,b=this._minYaw):y>this._maxYaw?(_.z=this._maxYawCos*g,_.x=this._maxYawSin*g,b=this._maxYaw):y<this._minYaw&&(_.z=this._minYawCos*g,_.x=this._minYawSin*g,b=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var T=t._tmpVecs[8];T.copyFrom(e.Axis.Z),this._transformYawPitch&&e.Vector3.TransformCoordinatesToRef(T,this._transformYawPitchInv,T);var E=t._tmpMats[4];this._boneQuat.toRotationMatrix(E),this.mesh.getWorldMatrix().multiplyToRef(E,E),e.Vector3.TransformCoordinatesToRef(T,E,T),e.Vector3.TransformCoordinatesToRef(T,f,T);var x=Math.atan2(T.x,T.z);if(this._getAngleBetween(x,y)>this._getAngleBetween(x,this._midYawConstraint)){null==g&&(g=Math.sqrt(_.x*_.x+_.z*_.z));var P=this._getAngleBetween(x,this._maxYaw);this._getAngleBetween(x,this._minYaw)<P?(b=x+.75*Math.PI,_.z=Math.cos(b)*g,_.x=Math.sin(b)*g):(b=x-.75*Math.PI,_.z=Math.cos(b)*g,_.x=Math.sin(b)*g)}}y!=b&&(e.Vector3.TransformCoordinatesToRef(_,d,_),_.addInPlace(r),n=_)}}var M=t._tmpVecs[5],S=t._tmpVecs[6],C=t._tmpVecs[7],R=t._tmpQuat;n.subtractToRef(r,M),M.normalize(),e.Vector3.CrossToRef(c,M,S),S.normalize(),e.Vector3.CrossToRef(M,S,C),C.normalize(),e.Matrix.FromXYZAxesToRef(S,C,M,o),0===S.x&&0===S.y&&0===S.z||0===C.x&&0===C.y&&0===C.z||0===M.x&&0===M.y&&0===M.z||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,s),s.multiplyToRef(o,o)),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(e.Space.WORLD,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(o,o),e.Quaternion.FromRotationMatrixToRef(o,R),e.Quaternion.SlerpToRef(this._boneQuat,R,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(o,o),this.bone.setRotationMatrix(o,e.Space.WORLD,this.mesh),this._slerping=!1))}},t.prototype._getAngleDiff=function(e,t){var i=t-e;return(i%=2*Math.PI)>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},t.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},t.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&e<i)return!0}else if(e>i&&e<t)return!0;return!1},t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t._tmpMats=[e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity(),e.Matrix.Identity()],t}();e.BoneLookController=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){this.name=t,this.id=i,this.bones=new Array,this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=e.Matrix.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this.doNotSerialize=!1,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new e.Observable,this.bones=[],this._scene=r||e.Engine.LastCreatedScene,r.skeletons.push(this),this._isDirty=!0}return 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.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},t.prototype.getScene=function(){return this._scene},t.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},t.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t<i;t++)if(this.bones[t].name===e)return t;return-1},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.bones.length;n<o;n++)this.bones[n].animations[0]&&this.bones[n].animations[0].createRange(t,i,r)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.bones.length;i<r;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].deleteRange(e,t);this._ranges[e]=null},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.getAnimationRanges=function(){var e,t=[],i=0;for(e in this._ranges)t[i]=this._ranges[e],i++;return t},t.prototype.copyAnimationRange=function(t,i,r){if(void 0===r&&(r=!1),this._ranges[i]||!t.getAnimationRange(i))return!1;var n,o,s=!0,a=this._getHighestAnimationFrame()+1,l={},c=t.bones;for(o=0,n=c.length;o<n;o++)l[c[o].name]=c[o];this.bones.length!==c.length&&(e.Tools.Warn("copyAnimationRange: this rig has "+this.bones.length+" bones, while source as "+c.length),s=!1);var u=r&&this.dimensionsAtRest&&t.dimensionsAtRest?this.dimensionsAtRest.divide(t.dimensionsAtRest):null;for(o=0,n=this.bones.length;o<n;o++){var h=this.bones[o].name,d=l[h];d?s=s&&this.bones[o].copyAnimationRange(d,i,a,r,u):(e.Tools.Warn("copyAnimationRange: not same rig, missing source bone "+h),s=!1)}var f=t.getAnimationRange(i);return f&&(this._ranges[i]=new e.AnimationRange(i,f.from+a,f.to+a)),s},t.prototype.returnToRest=function(){for(var e=0;e<this.bones.length;e++)this.bones[e].returnToRest()},t.prototype._getHighestAnimationFrame=function(){for(var e=0,t=0,i=this.bones.length;t<i;t++)if(this.bones[t].animations[0]){var r=this.bones[t].animations[0].getHighestFrame();e<r&&(e=r)}return e},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._markAsDirty=function(){this._isDirty=!0},t.prototype._registerMeshWithPoseMatrix=function(e){this._meshesWithPoseMatrix.push(e)},t.prototype._unregisterMeshWithPoseMatrix=function(e){var t=this._meshesWithPoseMatrix.indexOf(e);t>-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i<this.bones.length;i++){var r=this.bones[i],n=r.getParent();if(n?r.getLocalMatrix().multiplyToRef(n.getWorldMatrix(),r.getWorldMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getWorldMatrix()):r.getWorldMatrix().copyFrom(r.getLocalMatrix()),-1!==r._index){var o=null===r._index?i:r._index;r.getInvertedAbsoluteTransform().multiplyToArray(r.getWorldMatrix(),e,16*o)}}this._identity.copyToArray(e,16*this.bones.length)},t.prototype.prepare=function(){if(this._isDirty){if(this.needInitialSkinMatrix)for(var t=0;t<this._meshesWithPoseMatrix.length;t++){var i=this._meshesWithPoseMatrix[t],r=i.getPoseMatrix();if(i._bonesTransformMatrices&&i._bonesTransformMatrices.length===16*(this.bones.length+1)||(i._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1))),this._synchronizedWithMesh!==i){this._synchronizedWithMesh=i;for(var n=0;n<this.bones.length;n++){var o=this.bones[n];if(!o.getParent())o.getBaseMatrix().multiplyToRef(r,e.Tmp.Matrix[1]),o._updateDifferenceMatrix(e.Tmp.Matrix[1])}}this._computeTransformMatrices(i._bonesTransformMatrices,r)}else this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1))),this._computeTransformMatrices(this._transformMatrices,null);this._isDirty=!1,this._scene._activeBones.addCount(this.bones.length,!1)}},t.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var e=0;e<this.bones.length;e++)this._animatables.push(this.bones[e])}return this._animatables},t.prototype.clone=function(i,r){var n=new t(i,r||i,this._scene);n.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var o=0;o<this.bones.length;o++){var s=this.bones[o],a=null,l=s.getParent();if(l){var c=this.bones.indexOf(l);a=n.bones[c]}var u=new e.Bone(s.name,n,a,s.getBaseMatrix().clone(),s.getRestPose().clone());e.Tools.DeepCopy(s.animations,u.animations)}if(this._ranges)for(var h in n._ranges={},this._ranges){var d=this._ranges[h];d&&(n._ranges[h]=d.clone())}return this._isDirty=!0,n},t.prototype.enableBlending=function(e){void 0===e&&(e=.01),this.bones.forEach(function(t){t.animations.forEach(function(t){t.enableBlending=!0,t.blendingSpeed=e})})},t.prototype.dispose=function(){this._meshesWithPoseMatrix=[],this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this)},t.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var t=0;t<this.bones.length;t++){var i=this.bones[t],r=i.getParent(),n={parentBoneIndex:r?this.bones.indexOf(r):-1,name:i.name,matrix:i.getBaseMatrix().toArray(),rest:i.getRestPose().toArray()};for(var o in e.bones.push(n),i.length&&(n.length=i.length),i.metadata&&(n.metadata=i.metadata),i.animations&&i.animations.length>0&&(n.animation=i.animations[0].serialize()),e.ranges=[],this._ranges){var s=this._ranges[o];if(s){var a={};a.name=o,a.from=s.from,a.to=s.to,e.ranges.push(a)}}}return e},t.Parse=function(i,r){var n,o=new t(i.name,i.id,r);for(i.dimensionsAtRest&&(o.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),o.needInitialSkinMatrix=i.needInitialSkinMatrix,n=0;n<i.bones.length;n++){var s=i.bones[n],a=null;s.parentBoneIndex>-1&&(a=o.bones[s.parentBoneIndex]);var l=s.rest?e.Matrix.FromArray(s.rest):null,c=new e.Bone(s.name,o,a,e.Matrix.FromArray(s.matrix),l);void 0!==s.id&&null!==s.id&&(c.id=s.id),s.length&&(c.length=s.length),s.metadata&&(c.metadata=s.metadata),s.animation&&c.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(n=0;n<i.ranges.length;n++){var u=i.ranges[n];o.createAnimationRange(u.name,u.from,u.to)}return o},t.prototype.computeAbsoluteTransforms=function(e){void 0===e&&(e=!1);var t=this._scene.getRenderId();(this._lastAbsoluteTransformsUpdateId!=t||e)&&(this.bones[0].computeAbsoluteTransforms(),this._lastAbsoluteTransformsUpdateId=t)},t.prototype.getPoseMatrix=function(){var e=null;return this._meshesWithPoseMatrix.length>0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},t.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i<this.bones.length;i++)this._sortBones(i,e,t);this.bones=e},t.prototype._sortBones=function(e,t,i){if(!i[e]){i[e]=!0;var r=this.bones[e];void 0===r._index&&(r._index=e);var n=r.getParent();n&&this._sortBones(this.bones.indexOf(n),t,i),t.push(r)}},t}();e.Skeleton=t}(a||(a={})),function(e){var t=function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n<e.length-t&&"\n"!=(r=String.fromCharCode(e[n]));n++)i+=r;return i},t.RGBE_ReadHeader=function(e){var t,i,r=this.readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var n=!1,o=!1,s=0;do{s+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this.readStringLine(e,s))?o=!0:0==r.length&&(n=!0)}while(!n);if(!o)throw"HDR Bad header format, unsupported FORMAT";s+=r.length+1,r=this.readStringLine(e,s);var a=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!a||a.length<3)throw"HDR Bad header format, no size";if(i=parseInt(a[2]),t=parseInt(a[1]),i<8||i>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:s+=r.length+1}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,l=t.width,c=t.dataPosition,u=0,h=0,d=0,f=new ArrayBuffer(4*l),p=new Uint8Array(f),m=new ArrayBuffer(t.width*t.height*4*3),g=new Float32Array(m);a>0;){if(i=e[c++],r=e[c++],n=e[c++],o=e[c++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(h=(d+1)*l;u<h;)if(i=e[c++],r=e[c++],i>128){if(0==(s=i-128)||s>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[u++]=r}else{if(0==(s=i)||s>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=r,--s>0)for(var _=0;_<s;_++)p[u++]=e[c++]}for(d=0;d<l;d++)i=p[d],r=p[d+l],n=p[d+2*l],o=p[d+3*l],this.Rgbe2float(g,i,r,n,o,(t.height-a)*l*3+3*d);a--}return g},t}();e.HDRTools=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a,l,c,u){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=!1),void 0===c&&(c=null),void 0===u&&(u=null);var h=t.call(this,r)||this;return h._generateHarmonics=!0,h._onLoad=null,h._onError=null,h.coordinatesMode=e.Texture.CUBIC_MODE,h._isBlocking=!0,h._rotationY=0,h.boundingBoxPosition=e.Vector3.Zero(),i?(h.name=i,h.url=i,h.hasAlpha=!1,h.isCube=!0,h._textureMatrix=e.Matrix.Identity(),h._onLoad=c,h._onError=u,h.gammaSpace=a,h._noMipmap=o,h._size=n,h._texture=h._getFromCache(i,h._noMipmap),h._texture||(r.useDelayedTextureLoading?h.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:h.loadTexture()),h):h}return o(i,t),Object.defineProperty(i.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationY",{get:function(){return this._rotationY},set:function(t){this._rotationY=t,this.setReflectionTextureMatrix(e.Matrix.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(t){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(t)){this._boundingBoxSize=t;var i=this.getScene();i&&i.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),i.prototype.loadTexture=function(){var t=this,r=this.getScene();r&&(this._texture=r.getEngine().createRawCubeTextureFromUrl(this.url,r,this._size,e.Engine.TEXTUREFORMAT_RGB,r.getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,function(r){t.lodGenerationOffset=0,t.lodGenerationScale=.8;var n=t.getScene();if(!n)return null;var o=e.HDRTools.GetCubeMapTextureData(r,t._size);if(t._generateHarmonics){var s=e.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(o);t.sphericalPolynomial=s}for(var a=[],l=null,c=0;c<6;c++){if(!n.getEngine().getCaps().textureFloat){var u=new ArrayBuffer(t._size*t._size*3);l=new Uint8Array(u)}var h=o[i._facesMapping[c]];if(t.gammaSpace||l)for(var d=0;d<t._size*t._size;d++)if(t.gammaSpace&&(h[3*d+0]=Math.pow(h[3*d+0],e.ToGammaSpace),h[3*d+1]=Math.pow(h[3*d+1],e.ToGammaSpace),h[3*d+2]=Math.pow(h[3*d+2],e.ToGammaSpace)),l){var f=Math.max(255*h[3*d+0],0),p=Math.max(255*h[3*d+1],0),m=Math.max(255*h[3*d+2],0),g=Math.max(Math.max(f,p),m);if(g>255){var _=255/g;f*=_,p*=_,m*=_}l[3*d+0]=f,l[3*d+1]=p,l[3*d+2]=m}l?a.push(l):a.push(h)}return a},null,this._onLoad,this._onError))},i.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=new i(this.url,e,this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},i.Parse=function(t,r,n){var o=null;return t.name&&!t.isRenderTarget&&((o=new i(n+t.name,r,t.size,t.noMipmap,t.generateHarmonics,t.useInGammaSpace)).name=t.name,o.hasAlpha=t.hasAlpha,o.level=t.level,o.coordinatesMode=t.coordinatesMode,o.isBlocking=t.isBlocking),o&&(t.boundingBoxPosition&&(o.boundingBoxPosition=e.Vector3.FromArray(t.boundingBoxPosition)),t.boundingBoxSize&&(o.boundingBoxSize=e.Vector3.FromArray(t.boundingBoxSize)),t.rotationY&&(o.rotationY=t.rotationY)),o},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e},i._facesMapping=["right","left","up","down","front","back"],i}(e.BaseTexture);e.HDRCubeTexture=t}(a||(a={})),function(e){var t=function(){function t(){}return t.ConvertPanoramaToCubemap=function(t,i,r,n){if(!t)throw"ConvertPanoramaToCubemap: input cannot be null";if(t.length!=i*r*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(n,this.FACE_FRONT,t,i,r),back:this.CreateCubemapTexture(n,this.FACE_BACK,t,i,r),left:this.CreateCubemapTexture(n,this.FACE_LEFT,t,i,r),right:this.CreateCubemapTexture(n,this.FACE_RIGHT,t,i,r),up:this.CreateCubemapTexture(n,this.FACE_UP,t,i,r),down:this.CreateCubemapTexture(n,this.FACE_DOWN,t,i,r),size:n,type:e.Engine.TEXTURETYPE_FLOAT,format:e.Engine.TEXTUREFORMAT_RGB,gammaSpace:!1}},t.CreateCubemapTexture=function(e,t,i,r,n){for(var o=new ArrayBuffer(e*e*4*3),s=new Float32Array(o),a=t[1].subtract(t[0]).scale(1/e),l=t[3].subtract(t[2]).scale(1/e),c=1/e,u=0,h=0;h<e;h++){for(var d=t[0],f=t[2],p=0;p<e;p++){var m=f.subtract(d).scale(u).add(d);m.normalize();var g=this.CalcProjectionSpherical(m,i,r,n);s[h*e*3+3*p+0]=g.r,s[h*e*3+3*p+1]=g.g,s[h*e*3+3*p+2]=g.b,d=d.add(a),f=f.add(l)}u+=c}return s},t.CalcProjectionSpherical=function(e,t,i,r){for(var n=Math.atan2(e.z,e.x),o=Math.acos(e.y);n<-Math.PI;)n+=2*Math.PI;for(;n>Math.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var l=Math.round(s*i);l<0?l=0:l>=i&&(l=i-1);var c=Math.round(a*r);c<0?c=0:c>=r&&(c=r-1);var u=r-c-1;return{r:t[u*i*3+3*l+0],g:t[u*i*3+3*l+1],b:t[u*i*3+3*l+2]}},t.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],t.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],t.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],t.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],t.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],t.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t}();e.PanoramaToCubeMapTools=t}(a||(a={})),function(e){var t=function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return o(t,e),t}(e.Vector2),i=function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach(function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}}),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(e){e.x<t.x?t.x=e.x:e.x>i.x&&(i.x=e.x),e.y<t.y?t.y=e.y:e.y>i.y&&(i.y=e.y)}),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i}(),n=function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,l=0;l<n;l++)o.push(new e.Vector2(i+Math.cos(s)*t,r+Math.sin(s)*t)),s-=a;return o},t.Parse=function(t){var i,r=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),n=[];for(i=0;i<(2147483646&r.length);i+=2)n.push(new e.Vector2(r[i],r[i+1]));return n},t.StartingAt=function(t,i){return e.Path2.StartingAt(t,i)},t}();e.Polygon=n;var s=function(){function t(t,n,o){var s;this._points=new i,this._outlinepoints=new i,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this._name=t,this._scene=o,s=n instanceof e.Path2?n.getPoints():n,this._addToepoint(s),this._points.add(s),this._outlinepoints.add(s),void 0===r&&e.Tools.Warn("Earcut was not found, the polygon will not be built.")}return t.prototype._addToepoint=function(e){for(var t=0,i=e;t<i.length;t++){var r=i[t];this._epoints.push(r.x,r.y)}},t.prototype.addHole=function(e){this._points.add(e);var t=new i;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this},t.prototype.build=function(t,i){var n=this;void 0===t&&(t=!1),void 0===i&&(i=0);var o=new e.Mesh(this._name,this._scene),s=new Array,a=new Array,l=new Array,c=this._points.computeBounds();this._points.elements.forEach(function(e){s.push(0,1,0),a.push(e.x,0,e.y),l.push((e.x-c.min.x)/c.width,(e.y-c.min.y)/c.height)});for(var u=new Array,h=r(this._epoints,this._eholes,2),d=0;d<h.length;d++)u.push(h[d]);if(i>0){var f=a.length/3;this._points.elements.forEach(function(e){s.push(0,-1,0),a.push(e.x,-i,e.y),l.push(1-(e.x-c.min.x)/c.width,1-(e.y-c.min.y)/c.height)});var p=u.length;for(d=0;d<p;d+=3){var m=u[d+0],g=u[d+1],_=u[d+2];u.push(_+f),u.push(g+f),u.push(m+f)}this.addSide(a,s,l,u,c,this._outlinepoints,i,!1),this._holes.forEach(function(e){n.addSide(a,s,l,u,c,e,i,!0)})}return o.setVerticesData(e.VertexBuffer.PositionKind,a,t),o.setVerticesData(e.VertexBuffer.NormalKind,s,t),o.setVerticesData(e.VertexBuffer.UVKind,l,t),o.setIndices(u),o},t.prototype.addSide=function(t,i,r,n,o,s,a,l){for(var c=t.length/3,u=0,h=0;h<s.elements.length;h++){var d,f=s.elements[h];d=h+1>s.elements.length-1?s.elements[0]:s.elements[h+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),m=new e.Vector3(d.x,0,d.y).subtract(p),g=new e.Vector3(0,1,0),_=e.Vector3.Cross(m,g);_=_.normalize(),r.push(u/o.width,0),r.push(u/o.width,1),u+=m.length(),r.push(u/o.width,0),r.push(u/o.width,1),l?(i.push(_.x,_.y,_.z),i.push(_.x,_.y,_.z),i.push(_.x,_.y,_.z),i.push(_.x,_.y,_.z),n.push(c),n.push(c+2),n.push(c+1),n.push(c+1),n.push(c+2),n.push(c+3)):(i.push(-_.x,-_.y,-_.z),i.push(-_.x,-_.y,-_.z),i.push(-_.x,-_.y,-_.z),i.push(-_.x,-_.y,-_.z),n.push(c),n.push(c+1),n.push(c+2),n.push(c+1),n.push(c+3),n.push(c+2)),c+=4}},t}();e.PolygonMeshBuilder=s}(a||(a={})),function(e){var t=0,i=function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t}(),r=function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var l,c,u=0,h=[];for(l=0;l<i.vertices.length;l++){var d=(c=e.Vector3.Dot(this.normal,i.vertices[l].pos)-this.w)<-t.EPSILON?2:c>t.EPSILON?1:0;u|=d,h.push(d)}switch(u){case 0:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case 1:s.push(i);break;case 2:a.push(i);break;case 3:var f,p=[],m=[];for(l=0;l<i.vertices.length;l++){var g=(l+1)%i.vertices.length,_=h[l],v=h[g],A=i.vertices[l],y=i.vertices[g];if(2!==_&&p.push(A),1!==_&&m.push(2!==_?A.clone():A),3==(_|v)){c=(this.w-e.Vector3.Dot(this.normal,A.pos))/e.Vector3.Dot(this.normal,y.pos.subtract(A.pos));var b=A.interpolate(y,c);p.push(b),m.push(b.clone())}}p.length>=3&&(f=new n(p,i.shared)).plane&&s.push(f),m.length>=3&&(f=new n(m,i.shared)).plane&&a.push(f)}},t.EPSILON=1e-5,t}(),n=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map(function(e){return e.clone()}),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map(function(e){e.flip()}),this.plane.flip()},e}(),o=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map(function(e){return e.clone()}),t},e.prototype.invert=function(){for(var e=0;e<this.polygons.length;e++)this.polygons[e].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var t=this.front;this.front=this.back,this.back=t},e.prototype.clipPolygons=function(e){if(!this.plane)return e.slice();for(var t=new Array,i=new Array,r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),i=this.back?this.back.clipPolygons(i):[],t.concat(i)},e.prototype.clipTo=function(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)},e.prototype.allPolygons=function(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e},e.prototype.build=function(t){if(t.length){this.plane||(this.plane=t[0].plane.clone());for(var i=new Array,r=new Array,n=0;n<t.length;n++)this.plane.splitPolygon(t[n],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new e),this.front.build(i)),r.length&&(this.back||(this.back=new e),this.back.build(r))}},e}(),s=function(){function r(){this.polygons=new Array}return r.FromMesh=function(o){var s,a,l,c,u,h,d,f,p,m,g=new Array,_=null;if(!(o instanceof e.Mesh))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";o.computeWorldMatrix(!0),d=o.getWorldMatrix(),f=o.position.clone(),p=o.rotation.clone(),o.rotationQuaternion&&(_=o.rotationQuaternion.clone()),m=o.scaling.clone();for(var v=o.getIndices(),A=o.getVerticesData(e.VertexBuffer.PositionKind),y=o.getVerticesData(e.VertexBuffer.NormalKind),b=o.getVerticesData(e.VertexBuffer.UVKind),T=o.subMeshes,E=0,x=T.length;E<x;E++)for(var P=T[E].indexStart,M=T[E].indexCount+T[E].indexStart;P<M;P+=3){h=[];for(var S=0;S<3;S++){var C=new e.Vector3(y[3*v[P+S]],y[3*v[P+S]+1],y[3*v[P+S]+2]);l=new e.Vector2(b[2*v[P+S]],b[2*v[P+S]+1]);var R=new e.Vector3(A[3*v[P+S]],A[3*v[P+S]+1],A[3*v[P+S]+2]);c=e.Vector3.TransformCoordinates(R,d),a=e.Vector3.TransformNormal(C,d),s=new i(c,a,l),h.push(s)}(u=new n(h,{subMeshId:E,meshId:t,materialIndex:T[E].materialIndex})).plane&&g.push(u)}var O=r.FromPolygons(g);return O.matrix=d,O.position=f,O.rotation=p,O.scaling=m,O.rotationQuaternion=_,t++,O},r.FromPolygons=function(e){var t=new r;return t.polygons=e,t},r.prototype.clone=function(){var e=new r;return e.polygons=this.polygons.map(function(e){return e.clone()}),e.copyTransformAttributes(this),e},r.prototype.union=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},r.prototype.subtract=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.intersect=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},r.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},r.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},r.prototype.buildMeshGeometry=function(t,i,r){var n=this.matrix.clone();n.invert();var o,s,a,l=new e.Mesh(t,i),c=[],u=[],h=[],d=[],f=e.Vector3.Zero(),p=e.Vector3.Zero(),m=e.Vector2.Zero(),g=this.polygons,_=[0,0,0],v={},A=0,y={};r&&g.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var b=0,T=g.length;b<T;b++){y[(o=g[b]).shared.meshId]||(y[o.shared.meshId]={}),y[o.shared.meshId][o.shared.subMeshId]||(y[o.shared.meshId][o.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:o.shared.materialIndex}),a=y[o.shared.meshId][o.shared.subMeshId];for(var E=2,x=o.vertices.length;E<x;E++){_[0]=0,_[1]=E-1,_[2]=E;for(var P=0;P<3;P++){f.copyFrom(o.vertices[_[P]].pos),p.copyFrom(o.vertices[_[P]].normal),m.copyFrom(o.vertices[_[P]].uv);var M=e.Vector3.TransformCoordinates(f,n),S=e.Vector3.TransformNormal(p,n);void 0!==(s=v[M.x+","+M.y+","+M.z])&&h[3*s]===S.x&&h[3*s+1]===S.y&&h[3*s+2]===S.z&&d[2*s]===m.x&&d[2*s+1]===m.y||(c.push(M.x,M.y,M.z),d.push(m.x,m.y),h.push(p.x,p.y,p.z),s=v[M.x+","+M.y+","+M.z]=c.length/3-1),u.push(s),a.indexStart=Math.min(A,a.indexStart),a.indexEnd=Math.max(A,a.indexEnd),A++}}}if(l.setVerticesData(e.VertexBuffer.PositionKind,c),l.setVerticesData(e.VertexBuffer.NormalKind,h),l.setVerticesData(e.VertexBuffer.UVKind,d),l.setIndices(u,null),r){var C,R=0;for(var O in l.subMeshes=new Array,y){for(var D in C=-1,y[O])a=y[O][D],e.SubMesh.CreateFromIndices(a.materialIndex+R,a.indexStart,a.indexEnd-a.indexStart+1,l),C=Math.max(a.materialIndex,C);R+=++C}}return l},r.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},r}();e.CSG=s}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o){this.size=t,this.position=i,this.alphaMode=e.Engine.ALPHA_ONEONE,this.color=r||new e.Color3(1,1,1),this.texture=n?new e.Texture(n,o.getScene(),!0):null,this._system=o,o.lensFlares.push(this)}return t.AddFlare=function(e,i,r,n,o){return new t(e,i,r,n,o)},t.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},t}();e.LensFlare=t}(a||(a={})),function(e){e.AbstractScene.AddParser(e.SceneComponentConstants.NAME_LENSFLARESYSTEM,function(t,i,r,n){if(void 0!==t.lensFlareSystems&&null!==t.lensFlareSystems){r.lensFlareSystems||(r.lensFlareSystems=new Array);for(var o=0,s=t.lensFlareSystems.length;o<s;o++){var a=t.lensFlareSystems[o],l=e.LensFlareSystem.Parse(a,i,n);r.lensFlareSystems.push(l)}}}),e.AbstractScene.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},e.AbstractScene.prototype.getLensFlareSystemByID=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===e)return this.lensFlareSystems[t];return null},e.AbstractScene.prototype.removeLensFlareSystem=function(e){var t=this.lensFlareSystems.indexOf(e);return-1!==t&&this.lensFlareSystems.splice(t,1),t},e.AbstractScene.prototype.addLensFlareSystem=function(e){this.lensFlareSystems.push(e)};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_LENSFLARESYSTEM,this.scene=t,t.lensFlareSystems=new Array}return t.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM,this,this._draw)},t.prototype.rebuild=function(){},t.prototype.addFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach(function(e){t.scene.addLensFlareSystem(e)})},t.prototype.removeFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach(function(e){t.scene.removeLensFlareSystem(e)})},t.prototype.serialize=function(e){e.lensFlareSystems=[];for(var t=0,i=this.scene.lensFlareSystems;t<i.length;t++){var r=i[t];e.lensFlareSystems.push(r.serialize())}},t.prototype.dispose=function(){for(var e=this.scene.lensFlareSystems;e.length;)e[0].dispose()},t.prototype._draw=function(t){if(this.scene.lensFlaresEnabled){var i=this.scene.lensFlareSystems;e.Tools.StartPerformanceCounter("Lens flares",i.length>0);for(var r=0,n=i;r<n.length;r++){var o=n[r];0!=(t.layerMask&o.layerMask)&&o.render()}e.Tools.EndPerformanceCounter("Lens flares",i.length>0)}},t}();e.LensFlareSystemSceneComponent=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||e.Engine.LastCreatedScene;var n=this._scene._getComponent(e.SceneComponentConstants.NAME_LENSFLARESYSTEM);n||(n=new e.LensFlareSystemSceneComponent(this._scene),r._addComponent(n)),this._emitter=i,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return r.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&r.activeCamera.layerMask)};var o=r.getEngine(),s=[];s.push(1,1),s.push(-1,1),s.push(-1,-1),s.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(o,s,e.VertexBuffer.PositionKind,!1,!1,2);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=o.createIndexBuffer(a),this._effect=o.createEffect("lensFlare",[e.VertexBuffer.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEmitter=function(){return this._emitter},t.prototype.setEmitter=function(e){this._emitter=e},t.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},t.prototype.computeEffectivePosition=function(t){var i=this.getEmitterPosition();return i=e.Vector3.Project(i,e.Matrix.Identity(),this._scene.getTransformMatrix(),t),this._positionX=i.x,this._positionY=i.y,i=e.Vector3.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionX<t.x+t.width&&this._positionY>t.y&&(this._positionY,t.y,t.height),!0)},t.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var t=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),i=t.length();t.normalize();var r=new e.Ray(this._scene.activeCamera.globalPosition,t),n=this._scene.pickWithRay(r,this.meshesSelectionPredicate,!0);return!n||!n.hit||n.distance>i},t.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var t,i,r=this._scene.getEngine(),n=this._scene.activeCamera.viewport.toGlobal(r.getRenderWidth(!0),r.getRenderHeight(!0));if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var o=(t=this._positionX<this.borderLimit+n.x?this.borderLimit+n.x-this._positionX:this._positionX>n.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0)>(i=this._positionY<this.borderLimit+n.y?this.borderLimit+n.y-this._positionY:this._positionY>n.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0)?t:i;(o-=this.viewportBorder)>this.borderLimit&&(o=this.borderLimit);var s=1-e.Scalar.Clamp(o/this.borderLimit,0,1);if(s<0)return!1;s>1&&(s=1),this.viewportBorder>0&&(n.x+=this.viewportBorder,n.y+=this.viewportBorder,n.width-=2*this.viewportBorder,n.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var a=n.x+n.width/2,l=n.y+n.height/2,c=a-this._positionX,u=l-this._positionY;r.enableEffect(this._effect),r.setState(!1),r.setDepthBuffer(!1),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h<this.lensFlares.length;h++){var d=this.lensFlares[h];r.setAlphaMode(d.alphaMode);var f=a-c*d.position,p=l-u*d.position,m=d.size,g=d.size*r.getAspectRatio(this._scene.activeCamera,!0),_=f/(n.width+2*n.x)*2-1,v=1-p/(n.height+2*n.y)*2,A=e.Matrix.FromValues(m/2,0,0,0,0,g/2,0,0,0,0,1,0,_,v,0,1);this._effect.setMatrix("viewportMatrix",A),this._effect.setTexture("textureSampler",d.texture),this._effect.setFloat4("color",d.color.r*s,d.color.g*s,d.color.b*s,1),r.drawElementsType(e.Material.TriangleFillMode,0,6)}return r.setDepthBuffer(!0),r.setAlphaMode(e.Engine.ALPHA_DISABLE),!0},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];for(t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var i=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(i,1)},t.Parse=function(i,r,n){var o=r.getLastEntryByID(i.emitterId),s=i.name||"lensFlareSystem#"+i.emitterId,a=new t(s,o,r);a.id=i.id||s,a.borderLimit=i.borderLimit;for(var l=0;l<i.flares.length;l++){var c=i.flares[l];e.LensFlare.AddFlare(c.size,c.position,e.Color3.FromArray(c.color),c.textureName?n+c.textureName:"",a)}return a},t.prototype.serialize=function(){var t={};t.id=this.id,t.name=this.name,t.emitterId=this.getEmitter().id,t.borderLimit=this.borderLimit,t.flares=[];for(var i=0;i<this.lensFlares.length;i++){var r=this.lensFlares[i];t.flares.push({size:r.size,position:r.position,color:r.color.asArray(),textureName:e.Tools.GetFilename(r.texture?r.texture.name:"")})}return t},t}();e.LensFlareSystem=t}(a||(a={})),function(e){var t=function(){function e(e,t){this.type=e,this.jointData=t,t.nativeParams=t.nativeParams||{}}return Object.defineProperty(e.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(e){this._physicsJoint,this._physicsJoint=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsPlugin",{set:function(e){this._physicsPlugin=e},enumerable:!0,configurable:!0}),e.prototype.executeNativeFunction=function(e){e(this._physicsPlugin.world,this._physicsJoint)},e.DistanceJoint=0,e.HingeJoint=1,e.BallAndSocketJoint=2,e.WheelJoint=3,e.SliderJoint=4,e.PrismaticJoint=5,e.UniversalJoint=6,e.Hinge2Joint=e.WheelJoint,e.PointToPointJoint=8,e.SpringJoint=9,e.LockJoint=10,e}();e.PhysicsJoint=t;var i=function(e){function i(i){return e.call(this,t.DistanceJoint,i)||this}return o(i,e),i.prototype.updateDistance=function(e,t){this._physicsPlugin.updateDistanceJoint(this,e,t)},i}(t);e.DistanceJoint=i;var r=function(e){function t(t,i){return e.call(this,t,i)||this}return o(t,e),t.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},t.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},t}(t);e.MotorEnabledJoint=r;var n=function(e){function i(i){return e.call(this,t.HingeJoint,i)||this}return o(i,e),i.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},i.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},i}(r);e.HingeJoint=n;var s=function(e){function i(i){return e.call(this,t.Hinge2Joint,i)||this}return o(i,e),i.prototype.setMotor=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setMotor(this,e||0,t,i)},i.prototype.setLimit=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setLimit(this,e,t,i)},i}(r);e.Hinge2Joint=s}(a||(a={})),function(e){var t=function(){function t(t,i,r,n){void 0===r&&(r={mass:0});var o=this;this.object=t,this.type=i,this._options=r,this._scene=n,this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=e.Vector3.Zero(),this._isDisposed=!1,this._tmpQuat=new e.Quaternion,this._tmpQuat2=new e.Quaternion,this.beforeStep=function(){o._physicsEngine&&(o.object.translate(o._deltaPosition,-1),o._deltaRotationConjugated&&o.object.rotationQuaternion&&o.object.rotationQuaternion.multiplyToRef(o._deltaRotationConjugated,o.object.rotationQuaternion),o.object.computeWorldMatrix(!1),o.object.parent&&o.object.rotationQuaternion?(o.getParentsRotation(),o._tmpQuat.multiplyToRef(o.object.rotationQuaternion,o._tmpQuat)):o._tmpQuat.copyFrom(o.object.rotationQuaternion||new e.Quaternion),o._options.disableBidirectionalTransformation||o.object.rotationQuaternion&&o._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(o,o.object.getAbsolutePivotPoint(),o._tmpQuat),o._onBeforePhysicsStepCallbacks.forEach(function(e){e(o)}))},this.afterStep=function(){o._physicsEngine&&(o._onAfterPhysicsStepCallbacks.forEach(function(e){e(o)}),o._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(o),o.object.parent&&o.object.rotationQuaternion&&(o.getParentsRotation(),o._tmpQuat.conjugateInPlace(),o._tmpQuat.multiplyToRef(o.object.rotationQuaternion,o.object.rotationQuaternion)),o.object.setAbsolutePosition(o.object.position),o._deltaRotation&&o.object.rotationQuaternion&&o.object.rotationQuaternion.multiplyToRef(o._deltaRotation,o.object.rotationQuaternion),o.object.translate(o._deltaPosition,1))},this.onCollideEvent=null,this.onCollide=function(e){if((o._onPhysicsCollideCallbacks.length||o.onCollideEvent)&&o._physicsEngine){var t=o._physicsEngine.getImpostorWithPhysicsBody(e.body);t&&(o.onCollideEvent&&o.onCollideEvent(o,t),o._onPhysicsCollideCallbacks.filter(function(e){return-1!==e.otherImpostors.indexOf(t)}).forEach(function(e){e.callback(o,t)}))}},this.object?(!this._scene&&t.getScene&&(this._scene=t.getScene()),this._scene&&(this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new e.Quaternion),this._options.mass=void 0===r.mass?0:r.mass,this._options.friction=void 0===r.friction?.2:r.friction,this._options.restitution=void 0===r.restitution?.2:r.restitution,this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&e.Tools.Warn("You must affect impostors to children before affecting impostor to parent.")):e.Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):e.Tools.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!0,configurable:!0}),t.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},t.prototype._getPhysicsParent=function(){return this.object.parent instanceof e.AbstractMesh?this.object.parent.physicsImpostor:null},t.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},t.prototype.setScalingUpdated=function(e){this.forceUpdate()},t.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(t.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),t.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},t.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var e=this.object.rotationQuaternion;this.object.rotationQuaternion=t.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var i=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=e,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),i}return t.DEFAULT_OBJECT_SIZE},t.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},t.prototype.getParam=function(e){return this._options[e]},t.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},t.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},t.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):e.Vector3.Zero()},t.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},t.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):e.Vector3.Zero()},t.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},t.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},t.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},t.prototype.unregisterBeforePhysicsStep=function(t){var i=this._onBeforePhysicsStepCallbacks.indexOf(t);i>-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=-1;this._onPhysicsCollideCallbacks.some(function(e,t){if(e.callback===i&&e.otherImpostors.length===r.length){var o=e.otherImpostors.every(function(e){return r.indexOf(e)>-1});return o&&(n=t),o}return!1})?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.getParentsRotation=function(){var t=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);t;)t.rotationQuaternion?this._tmpQuat2.copyFrom(t.rotationQuaternion):e.Quaternion.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,t.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),t=t.parent;return this._tmpQuat},t.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},t.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);return this.addJoint(t,n),this},t.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},t.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},t.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach(function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},t.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},t.prototype.syncBoneWithImpostor=function(i,r,n,o,s){var a=t._tmpVecs[0],l=this.object;if(l.rotationQuaternion)if(s){var c=t._tmpQuat;l.rotationQuaternion.multiplyToRef(s,c),i.setRotationQuaternion(c,e.Space.WORLD,r)}else i.setRotationQuaternion(l.rotationQuaternion,e.Space.WORLD,r);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,i.getDirectionToRef(a,r,a),void 0!==o&&null!==o||(o=n.length()),a.x*=o,a.y*=o,a.z*=o),i.getParent()?(a.addInPlace(l.getAbsolutePosition()),i.setAbsolutePosition(a,r)):(r.setAbsolutePosition(l.getAbsolutePosition()),r.position.x-=a.x,r.position.y-=a.y,r.position.z-=a.z)},t.prototype.syncImpostorWithBone=function(i,r,n,o,s,a){var l=this.object;if(l.rotationQuaternion)if(s){var c=t._tmpQuat;i.getRotationQuaternionToRef(e.Space.WORLD,r,c),c.multiplyToRef(s,l.rotationQuaternion)}else i.getRotationQuaternionToRef(e.Space.WORLD,r,l.rotationQuaternion);var u=t._tmpVecs[0],h=t._tmpVecs[1];a||((a=t._tmpVecs[2]).x=0,a.y=1,a.z=0),i.getDirectionToRef(a,r,h),i.getAbsolutePositionToRef(r,u),void 0!==o&&null!==o||!n||(o=n.length()),void 0!==o&&null!==o&&(u.x+=h.x*o,u.y+=h.y*o,u.z+=h.z*o),l.setAbsolutePosition(u)},t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.IDENTITY_QUATERNION=e.Quaternion.Identity(),t._tmpVecs=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()],t._tmpQuat=e.Quaternion.Identity(),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,t}();e.PhysicsImpostor=t}(a||(a={})),function(e){var t=function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},t.prototype.dispose=function(){this._impostors.forEach(function(e){e.dispose()}),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter(function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e});r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach(function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)}),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostors=function(){return this._impostors},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].object===e)return this._impostors[t];return null},t.prototype.getImpostorWithPhysicsBody=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].physicsBody===e)return this._impostors[t];return null},t.Epsilon=.001,t}();e.PhysicsEngine=t}(a||(a={})),function(e){var t=function(){function t(t){this._scene=t,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||e.Tools.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return t.prototype.applyRadialExplosionImpulse=function(t,r,n,s){if(void 0===s&&(s=o.Constant),!this._physicsEngine)return e.Tools.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var a=this._physicsEngine.getImpostors();if(0===a.length)return null;var l=new i(this._scene);return a.forEach(function(e){var i=l.getImpostorForceAndContactPoint(e,t,r,n,s);i&&e.applyImpulse(i.force,i.contactPoint)}),l.dispose(!1),l},t.prototype.applyRadialExplosionForce=function(t,r,n,s){if(void 0===s&&(s=o.Constant),!this._physicsEngine)return e.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var a=this._physicsEngine.getImpostors();if(0===a.length)return null;var l=new i(this._scene);return a.forEach(function(e){var i=l.getImpostorForceAndContactPoint(e,t,r,n,s);i&&e.applyForce(i.force,i.contactPoint)}),l.dispose(!1),l},t.prototype.gravitationalField=function(t,i,n,s){if(void 0===s&&(s=o.Constant),!this._physicsEngine)return e.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var a=new r(this,this._scene,t,i,n,s);return a.dispose(!1),a},t.prototype.updraft=function(t,i,r,o,a){if(void 0===a&&(a=s.Center),!this._physicsEngine)return e.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var l=new n(this._scene,t,i,r,o,a);return l.dispose(!1),l},t.prototype.vortex=function(t,i,r,n){if(!this._physicsEngine)return e.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var o=new a(this._scene,t,i,r,n);return o.dispose(!1),o},t}();e.PhysicsHelper=t;var i=function(){function t(e){this._sphereOptions={segments:32,diameter:1},this._rays=[],this._dataFetched=!1,this._scene=e}return t.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere,rays:this._rays}},t.prototype.getImpostorForceAndContactPoint=function(t,i,r,n,s){if(0===t.mass)return null;if(!this._intersectsWithSphere(t,i,r))return null;if("Mesh"!==t.object.getClassName()&&"InstancedMesh"!==t.object.getClassName())return null;var a=t.getObjectCenter().subtract(i),l=new e.Ray(i,a,r);this._rays.push(l);var c=l.intersectsMesh(t.object).pickedPoint;if(!c)return null;var u=e.Vector3.Distance(i,c);if(u>r)return null;var h=s===o.Constant?n:n*(1-u/r);return{force:a.multiplyByFloats(h,h,h),contactPoint:c}},t.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout(function(){t._dataFetched||t._sphere.dispose()},0)},t.prototype._prepareSphere=function(){this._sphere||(this._sphere=e.MeshBuilder.CreateSphere("radialExplosionEventSphere",this._sphereOptions,this._scene),this._sphere.isVisible=!1)},t.prototype._intersectsWithSphere=function(t,i,r){var n=t.object;return this._prepareSphere(),this._sphere.position=i,this._sphere.scaling=new e.Vector3(2*r,2*r,2*r),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(n,!0)},t}();e.PhysicsRadialExplosionEvent=i;var r=function(){function e(e,t,i,r,n,s){void 0===s&&(s=o.Constant),this._dataFetched=!1,this._physicsHelper=e,this._scene=t,this._origin=i,this._radius=r,this._strength=n,this._falloff=s,this._tickCallback=this._tick.bind(this)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout(function(){t._dataFetched||t._sphere.dispose()},0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e}();e.PhysicsGravitationalFieldEvent=r;var n=function(){function t(t,i,r,n,o,a){this._scene=t,this._origin=i,this._radius=r,this._strength=n,this._height=o,this._updraftMode=a,this._originTop=e.Vector3.Zero(),this._originDirection=e.Vector3.Zero(),this._cylinderPosition=e.Vector3.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new e.Vector3(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new e.Vector3(0,this._height,0),this._originTop),this._updraftMode===s.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this)}return t.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},t.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},t.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},t.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout(function(){t._dataFetched||t._cylinder.dispose()},0)},t.prototype.getImpostorForceAndContactPoint=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._updraftMode===s.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var r=-1*this._strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t}},t.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach(function(t){var i=e.getImpostorForceAndContactPoint(t);i&&t.applyForce(i.force,i.contactPoint)})},t.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=e.MeshBuilder.CreateCylinder("updraftEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},t.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._prepareCylinder(),this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},t}();e.PhysicsUpdraftEvent=n;var o,s,a=function(){function t(t,i,r,n,o){this._scene=t,this._origin=i,this._radius=r,this._strength=n,this._height=o,this._originTop=e.Vector3.Zero(),this._centripetalForceThreshold=.7,this._updraftMultiplier=.02,this._cylinderPosition=e.Vector3.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new e.Vector3(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new e.Vector3(0,this._height,0),this._originTop),this._tickCallback=this._tick.bind(this)}return t.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},t.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},t.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},t.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout(function(){t._dataFetched||t._cylinder.dispose()},0)},t.prototype.getImpostorForceAndContactPoint=function(t){if(0===t.mass)return null;if(!this._intersectsWithCylinder(t))return null;if("Mesh"!==t.object.getClassName()&&"InstancedMesh"!==t.object.getClassName())return null;var i=t.getObjectCenter(),r=new e.Vector3(this._origin.x,i.y,this._origin.z),n=i.subtract(r),o=new e.Ray(r,n,this._radius).intersectsMesh(t.object),s=o.pickedPoint;if(!s)return null;var a=o.distance/this._radius,l=e.Vector3.Cross(r,i).normalize(),c=s.normalize();if(a>this._centripetalForceThreshold&&(c=c.negate()),a>this._centripetalForceThreshold)var u=c.x*this._strength/8,h=c.y*this._updraftMultiplier,d=c.z*this._strength/8;else u=(l.x+c.x)/2,h=this._originTop.y*this._updraftMultiplier,d=(l.z+c.z)/2;var f=new e.Vector3(u,h,d);return{force:f=f.multiplyByFloats(this._strength,this._strength,this._strength),contactPoint:i}},t.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach(function(t){var i=e.getImpostorForceAndContactPoint(t);i&&t.applyForce(i.force,i.contactPoint)})},t.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=e.MeshBuilder.CreateCylinder("vortexEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},t.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._prepareCylinder(),this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},t}();e.PhysicsVortexEvent=a,function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(o=e.PhysicsRadialImpulseFalloff||(e.PhysicsRadialImpulseFalloff={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(s=e.PhysicsUpdraftMode||(e.PhysicsUpdraftMode={}))}(a||(a={})),function(t){var i=function(){function i(i,r){void 0===i&&(i=!0),void 0===r&&(r=10),this._useDeltaForWorldStep=i,this.name="CannonJSPlugin",this._physicsMaterials=new Array,this._fixedTimeStep=1/60,this.BJSCANNON=e,this._minus90X=new t.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new t.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=t.Vector3.Zero(),this._tmpDeltaPosition=t.Vector3.Zero(),this._tmpUnityRotation=new t.Quaternion,this.isSupported()?(this._extendNamespace(),this.world=new this.BJSCANNON.World,this.world.broadphase=new this.BJSCANNON.NaiveBroadphase,this.world.solver.iterations=r):t.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return i.prototype.setGravity=function(e){this.world.gravity.copy(e)},i.prototype.setTimeStep=function(e){this._fixedTimeStep=e},i.prototype.getTimeStep=function(){return this._fixedTimeStep},i.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?e:0,3)},i.prototype.applyImpulse=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},i.prototype.applyForce=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(n,r)},i.prototype.generatePhysicsBody=function(e){if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),n={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);e.physicsBody=new this.BJSCANNON.Body(n),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach(function(t){e.physicsBody[t].copy(i[t])}),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},i.prototype._processChildMeshes=function(e){var i=this,r=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],n=e.object.rotationQuaternion;if(r.length){var o=function(r,s){if(n&&s.rotationQuaternion){var a=s.getPhysicsImpostor();if(a)if(a.parent!==e){var l=s.getAbsolutePosition().subtract(e.object.getAbsolutePosition()),c=s.rotationQuaternion.multiply(t.Quaternion.Inverse(n));a.physicsBody&&(i.removePhysicsBody(a),a.physicsBody=null),a.parent=e,a.resetUpdateFlags(),e.physicsBody.addShape(i._createShape(a),new i.BJSCANNON.Vec3(l.x,l.y,l.z),new i.BJSCANNON.Quaternion(c.x,c.y,c.z,c.w)),e.physicsBody.mass+=a.getParam("mass")}n.multiplyInPlace(s.rotationQuaternion),s.getChildMeshes(!0).filter(function(e){return!!e.physicsImpostor}).forEach(o.bind(i,s.getAbsolutePosition()))}};r.filter(function(e){return!!e.physicsImpostor}).forEach(o.bind(this,e.object.getAbsolutePosition()))}},i.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},i.prototype.generateJoint=function(e){var i=e.mainImpostor.physicsBody,r=e.connectedImpostor.physicsBody;if(i&&r){var n,o=e.joint.jointData,s={pivotA:o.mainPivot?(new this.BJSCANNON.Vec3).copy(o.mainPivot):null,pivotB:o.connectedPivot?(new this.BJSCANNON.Vec3).copy(o.connectedPivot):null,axisA:o.mainAxis?(new this.BJSCANNON.Vec3).copy(o.mainAxis):null,axisB:o.connectedAxis?(new this.BJSCANNON.Vec3).copy(o.connectedAxis):null,maxForce:o.nativeParams.maxForce,collideConnected:!!o.collision};switch(e.joint.type){case t.PhysicsJoint.HingeJoint:case t.PhysicsJoint.Hinge2Joint:n=new this.BJSCANNON.HingeConstraint(i,r,s);break;case t.PhysicsJoint.DistanceJoint:n=new this.BJSCANNON.DistanceConstraint(i,r,o.maxDistance||2);break;case t.PhysicsJoint.SpringJoint:var a=o;n=new this.BJSCANNON.Spring(i,r,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:s.pivotA,localAnchorB:s.pivotB});break;case t.PhysicsJoint.LockJoint:n=new this.BJSCANNON.LockConstraint(i,r,s);break;case t.PhysicsJoint.PointToPointJoint:case t.PhysicsJoint.BallAndSocketJoint:default:n=new this.BJSCANNON.PointToPointConstraint(i,s.pivotA,r,s.pivotA,s.maxForce)}n.collideConnected=!!o.collision,e.joint.physicsJoint=n,e.joint.type!==t.PhysicsJoint.SpringJoint?this.world.addConstraint(n):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){n.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},i.prototype.removeJoint=function(e){e.joint.type!==t.PhysicsJoint.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},i.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r<this._physicsMaterials.length;r++)if((n=this._physicsMaterials[r]).friction===t&&n.restitution===i)return n;var o=new this.BJSCANNON.Material(e);return o.friction=t,o.restitution=i,this._physicsMaterials.push(o),o},i.prototype._checkWithEpsilon=function(e){return e<t.PhysicsEngine.Epsilon?t.PhysicsEngine.Epsilon:e},i.prototype._createShape=function(e){var i,r=e.object,n=e.getObjectExtendSize();switch(e.type){case t.PhysicsImpostor.SphereImpostor:var o=n.x,s=n.y,a=n.z;i=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(o),this._checkWithEpsilon(s),this._checkWithEpsilon(a))/2);break;case t.PhysicsImpostor.CylinderImpostor:i=new this.BJSCANNON.Cylinder(this._checkWithEpsilon(n.x)/2,this._checkWithEpsilon(n.x)/2,this._checkWithEpsilon(n.y),16);break;case t.PhysicsImpostor.BoxImpostor:var l=n.scale(.5);i=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(l.x),this._checkWithEpsilon(l.y),this._checkWithEpsilon(l.z)));break;case t.PhysicsImpostor.PlaneImpostor:t.Tools.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),i=new this.BJSCANNON.Plane;break;case t.PhysicsImpostor.MeshImpostor:var c=r.getVerticesData?r.getVerticesData(t.VertexBuffer.PositionKind):[],u=r.getIndices?r.getIndices():[];if(!c)return;var h=r.position.clone(),d=r.rotation&&r.rotation.clone(),f=r.rotationQuaternion&&r.rotationQuaternion.clone();r.position.copyFromFloats(0,0,0),r.rotation&&r.rotation.copyFromFloats(0,0,0),r.rotationQuaternion&&r.rotationQuaternion.copyFrom(e.getParentsRotation()),r.rotationQuaternion&&r.parent&&r.rotationQuaternion.conjugateInPlace();var p,m=r.computeWorldMatrix(!0),g=new Array;for(p=0;p<c.length;p+=3)t.Vector3.TransformCoordinates(t.Vector3.FromArray(c,p),m).toArray(g,p);t.Tools.Warn("MeshImpostor only collides against spheres."),i=new this.BJSCANNON.Trimesh(g,u),r.position.copyFrom(h),d&&r.rotation&&r.rotation.copyFrom(d),f&&r.rotationQuaternion&&r.rotationQuaternion.copyFrom(f);break;case t.PhysicsImpostor.HeightmapImpostor:var _=r.position.clone(),v=r.rotation&&r.rotation.clone(),A=r.rotationQuaternion&&r.rotationQuaternion.clone();r.position.copyFromFloats(0,0,0),r.rotation&&r.rotation.copyFromFloats(0,0,0),r.rotationQuaternion&&r.rotationQuaternion.copyFrom(e.getParentsRotation()),r.rotationQuaternion&&r.parent&&r.rotationQuaternion.conjugateInPlace(),r.rotationQuaternion&&r.rotationQuaternion.multiplyInPlace(this._minus90X),i=this._createHeightmap(r),r.position.copyFrom(_),v&&r.rotation&&r.rotation.copyFrom(v),A&&r.rotationQuaternion&&r.rotationQuaternion.copyFrom(A),r.computeWorldMatrix(!0);break;case t.PhysicsImpostor.ParticleImpostor:i=new this.BJSCANNON.Particle}return i},i.prototype._createHeightmap=function(e,i){var r,n=e.getVerticesData(t.VertexBuffer.PositionKind),o=e.computeWorldMatrix(!0),s=new Array;for(r=0;r<n.length;r+=3)t.Vector3.TransformCoordinates(t.Vector3.FromArray(n,r),o).toArray(s,r);n=s;for(var a=new Array,l=i||~~(Math.sqrt(n.length/3)-1),c=e.getBoundingInfo(),u=Math.min(c.boundingBox.extendSizeWorld.x,c.boundingBox.extendSizeWorld.y),h=c.boundingBox.extendSizeWorld.z,d=2*u/l,f=0;f<n.length;f+=3){var p=Math.round(n[f+0]/d+l/2),m=Math.round(-1*(n[f+1]/d-l/2)),g=-n[f+2]+h;a[p]||(a[p]=[]),a[p][m]||(a[p][m]=g),a[p][m]=Math.max(g,a[p][m])}for(p=0;p<=l;++p){if(!a[p]){for(var _=1;!a[(p+_)%l];)_++;a[p]=a[(p+_)%l].slice()}for(m=0;m<=l;++m)if(!a[p][m]){var v;for(_=1;void 0===v;)v=a[p][(m+_++)%l];a[p][m]=v}}var A=new this.BJSCANNON.Heightfield(a,{elementSize:d});return A.minY=h,A},i.prototype._updatePhysicsBodyTransformation=function(e){var i=e.object;if(i.computeWorldMatrix&&i.computeWorldMatrix(!0),i.getBoundingInfo()){var r=e.getObjectCenter();this._tmpDeltaPosition.copyFrom(i.getAbsolutePivotPoint().subtract(r)),this._tmpDeltaPosition.divideInPlace(e.object.scaling),this._tmpPosition.copyFrom(r);var n=i.rotationQuaternion;if(n){if(e.type!==t.PhysicsImpostor.PlaneImpostor&&e.type!==t.PhysicsImpostor.HeightmapImpostor&&e.type!==t.PhysicsImpostor.CylinderImpostor||(n=n.multiply(this._minus90X),e.setDeltaRotation(this._plus90X)),e.type===t.PhysicsImpostor.HeightmapImpostor){var o=i,s=o.getBoundingInfo(),a=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var l=r.clone(),c=o.getPivotMatrix()||t.Matrix.Translation(0,0,0),u=t.Matrix.Translation(s.boundingBox.extendSizeWorld.x,0,-s.boundingBox.extendSizeWorld.z);o.setPreTransformMatrix(u),o.computeWorldMatrix(!0);var h=s.boundingBox.centerWorld.subtract(r).subtract(o.position).negate();this._tmpPosition.copyFromFloats(h.x,h.y-s.boundingBox.extendSizeWorld.y,h.z),this._tmpDeltaPosition.copyFrom(s.boundingBox.centerWorld.subtract(l)),this._tmpDeltaPosition.y+=s.boundingBox.extendSizeWorld.y,o.rotationQuaternion=a,o.setPreTransformMatrix(c),o.computeWorldMatrix(!0)}else e.type===t.PhysicsImpostor.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);e.setDeltaPosition(this._tmpDeltaPosition),e.physicsBody.position.copy(this._tmpPosition),e.physicsBody.quaternion.copy(n)}}},i.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},i.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},i.prototype.isSupported=function(){return void 0!==this.BJSCANNON},i.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},i.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},i.prototype.getLinearVelocity=function(e){var i=e.physicsBody.velocity;return i?new t.Vector3(i.x,i.y,i.z):null},i.prototype.getAngularVelocity=function(e){var i=e.physicsBody.angularVelocity;return i?new t.Vector3(i.x,i.y,i.z):null},i.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},i.prototype.getBodyMass=function(e){return e.physicsBody.mass},i.prototype.getBodyFriction=function(e){return e.physicsBody.material.friction},i.prototype.setBodyFriction=function(e,t){e.physicsBody.material.friction=t},i.prototype.getBodyRestitution=function(e){return e.physicsBody.material.restitution},i.prototype.setBodyRestitution=function(e,t){e.physicsBody.material.restitution=t},i.prototype.sleepBody=function(e){e.physicsBody.sleep()},i.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},i.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.distance=t},i.prototype.setMotor=function(e,t,i,r){r||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},i.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},i.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.quaternion.x,e.rotationQuaternion.y=i.quaternion.y,e.rotationQuaternion.z=i.quaternion.z,e.rotationQuaternion.w=i.quaternion.w)},i.prototype.getRadius=function(e){return e.physicsBody.shapes[0].boundingSphereRadius},i.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes[0];t.x=2*i.halfExtents.x,t.y=2*i.halfExtents.y,t.z=2*i.halfExtents.z},i.prototype.dispose=function(){},i.prototype._extendNamespace=function(){var e=new this.BJSCANNON.Vec3,t=this.BJSCANNON;this.BJSCANNON.World.prototype.step=function(i,r,n){if(n=n||10,0===(r=r||0))this.internalStep(i),this.time+=i;else{var o=Math.floor((this.time+r)/i)-Math.floor(this.time/i);o=Math.min(o,n)||1;for(var s=performance.now(),a=0;a!==o&&(this.internalStep(i),!(performance.now()-s>1e3*i));a++);this.time+=r;for(var l=this.time%i/i,c=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,c),c.scale(l,c),d.position.vadd(c,d.interpolatedPosition)):(d.interpolatedPosition.copy(d.position),d.interpolatedQuaternion.copy(d.quaternion))}}}},i}();t.CannonJSPlugin=i}(a||(a={})),function(e){var t=function(){function t(t){this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=e.Vector3.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear()}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this.world.timeStep=e},t.prototype.getTimeStep=function(){return this.world.timeStep},t.prototype.executeStep=function(e,t){var i=this;t.forEach(function(e){e.beforeStep()}),this.world.step(),t.forEach(function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e});for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o?(n.onCollide({body:o.physicsBody}),o.onCollide({body:n.physicsBody}),r=r.next):r=r.next}else r=r.next},t.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*r))},t.prototype.applyForce=function(t,i,r){e.Tools.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(t,i,r)},t.prototype.generatePhysicsBody=function(t){var i=this;if(t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else{if(t.isBodyInitRequired()){var r={name:t.uniqueId,config:[t.getParam("mass")||1,t.getParam("friction"),t.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==t.getParam("mass"),density:t.getParam("mass"),friction:t.getParam("friction"),restitution:t.getParam("restitution"),world:this.world},n=[t];!function(e){e.getChildMeshes&&e.getChildMeshes().forEach(function(e){e.physicsImpostor&&n.push(e.physicsImpostor)})}(t.object);var o=function(t){return Math.max(t,e.PhysicsEngine.Epsilon)},s=new e.Quaternion;n.forEach(function(n){if(n.object.rotationQuaternion){var a=n.object.rotationQuaternion;s=a.clone();var l=a.toEulerAngles(),c=n.getObjectExtendSize();if(n===t){var u=t.getObjectCenter();t.object.getAbsolutePivotPoint().subtractToRef(u,i._tmpPositionVector),i._tmpPositionVector.divideInPlace(t.object.scaling),r.pos.push(u.x),r.pos.push(u.y),r.pos.push(u.z),r.posShape.push(0,0,0),r.rot.push(0),r.rot.push(0),r.rot.push(0),r.rotShape.push(0,0,0)}else{var h=n.object.getAbsolutePosition().subtract(t.object.getAbsolutePosition());r.posShape.push(h.x),r.posShape.push(h.y),r.posShape.push(h.z),r.pos.push(0,0,0),r.rot.push(0),r.rot.push(0),r.rot.push(0),r.rotShape.push(57.29577951308232*l.x),r.rotShape.push(57.29577951308232*l.y),r.rotShape.push(57.29577951308232*l.z)}switch(n.type){case e.PhysicsImpostor.ParticleImpostor:e.Tools.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case e.PhysicsImpostor.SphereImpostor:var d=c.x,f=c.y,p=c.z,m=Math.max(o(d),o(f),o(p))/2;r.type.push("sphere"),r.size.push(m),r.size.push(m),r.size.push(m);break;case e.PhysicsImpostor.CylinderImpostor:var g=o(c.x)/2,_=o(c.y);r.type.push("cylinder"),r.size.push(g),r.size.push(_),r.size.push(_);break;case e.PhysicsImpostor.PlaneImpostor:case e.PhysicsImpostor.BoxImpostor:default:g=o(c.x),_=o(c.y);var v=o(c.z);r.type.push("box"),r.size.push(g),r.size.push(_),r.size.push(v)}n.object.rotationQuaternion=a}}),t.physicsBody=this.world.add(r),t.physicsBody.resetQuaternion(s),t.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpPositionVector)}},t.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,r=t.connectedImpostor.physicsBody;if(i&&r){var n,o=t.joint.jointData,s=o.nativeParams||{},a={body1:i,body2:r,axe1:s.axe1||(o.mainAxis?o.mainAxis.asArray():null),axe2:s.axe2||(o.connectedAxis?o.connectedAxis.asArray():null),pos1:s.pos1||(o.mainPivot?o.mainPivot.asArray():null),pos2:s.pos2||(o.connectedPivot?o.connectedPivot.asArray():null),min:s.min,max:s.max,collision:s.collision||o.collision,spring:s.spring,world:this.world};switch(t.joint.type){case e.PhysicsJoint.BallAndSocketJoint:n="jointBall";break;case e.PhysicsJoint.SpringJoint:e.Tools.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var l=o;a.min=l.length||a.min,a.max=Math.max(a.min,a.max);case e.PhysicsJoint.DistanceJoint:n="jointDistance",a.max=o.maxDistance;break;case e.PhysicsJoint.PrismaticJoint:n="jointPrisme";break;case e.PhysicsJoint.SliderJoint:n="jointSlide";break;case e.PhysicsJoint.WheelJoint:n="jointWheel";break;case e.PhysicsJoint.HingeJoint:default:n="jointHinge"}a.type=n,t.joint.physicsJoint=this.world.add(a)}},t.prototype.removeJoint=function(t){try{this.world.removeJoint(t.joint.physicsJoint)}catch(t){e.Tools.Warn(t)}},t.prototype.isSupported=function(){return void 0!==this.BJSOIMO},t.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.sleeping||(e.object.position.copyFrom(e.physicsBody.getPosition()),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion()))},t.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;r.position.copy(t),r.orientation.copy(i),r.syncShapes(),r.awake()},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.linearVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},t.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},t.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},t.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},t.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},t.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.awake()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},t.prototype.setMotor=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},t.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},t.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.s)},t.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},t.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},t.prototype.dispose=function(){this.world.clear()},t}();e.OimoJSPlugin=t}(a||(a={})),function(e){e.Scene.prototype.getPhysicsEngine=function(){return this._physicsEngine},e.Scene.prototype.enablePhysics=function(i,r){if(void 0===i&&(i=null),this._physicsEngine)return!0;var n=this._getComponent(e.SceneComponentConstants.NAME_PHYSICSENGINE);n||(n=new t(this),this._addComponent(n));try{return this._physicsEngine=new e.PhysicsEngine(i,r),!0}catch(t){return e.Tools.Error(t.message),!1}},e.Scene.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},e.Scene.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},e.Scene.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},e.Scene.prototype._advancePhysicsEngineStep=function(e){this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this))},Object.defineProperty(e.AbstractMesh.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add(function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)})))},enumerable:!0,configurable:!0}),e.AbstractMesh.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},e.AbstractMesh.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},e.AbstractMesh.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};var t=function(){function t(t){var i=this;this.name=e.SceneComponentConstants.NAME_PHYSICSENGINE,this.scene=t,this.scene.onBeforePhysicsObservable=new e.Observable,this.scene.onAfterPhysicsObservable=new e.Observable,this.scene.getDeterministicFrameTime=function(){return i.scene._physicsEngine?1e3*i.scene._physicsEngine.getTimeStep():1e3/60}}return t.prototype.register=function(){},t.prototype.rebuild=function(){},t.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},t}();e.PhysicsEngineSceneComponent=t}(a||(a={})),function(e){function t(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var i=t("DXT1"),r=t("DXT3"),n=t("DXT5"),o=t("DX10"),s=function(){function t(){}return t.GetDDSInfo=function(t){var s=new Int32Array(t,0,31),a=new Int32Array(t,0,35),l=1;131072&s[2]&&(l=Math.max(1,s[7]));var c=s[21],u=c===o?a[32]:0,h=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(c){case 113:h=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:h=e.Engine.TEXTURETYPE_FLOAT;break;case o:if(10===u){h=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:s[4],height:s[3],mipmapCount:l,isFourCC:4==(4&s[20]),isRGB:64==(64&s[20]),isLuminance:131072==(131072&s[20]),isCube:512==(512&s[28]),isCompressed:c===i||c===r||c===n,dxgiFormat:u,textureType:h}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var i=t._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?r|=((n|=2048)>>114-o)+(n>>113-o&1):(r|=o-112<<10|n>>1,r+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,i,r,n,o,s){for(var a=new Float32Array(n),l=new Uint16Array(o,r),c=0,u=0;u<i;u++)for(var h=0;h<e;h++){var d=4*(h+u*e);a[c]=t._FromHalfFloat(l[d]),a[c+1]=t._FromHalfFloat(l[d+1]),a[c+2]=t._FromHalfFloat(l[d+2]),t.StoreLODInAlphaChannel?a[c+3]=s:a[c+3]=t._FromHalfFloat(l[d+3]),c+=4}return a},t._GetHalfFloatRGBAArrayBuffer=function(e,i,r,n,o,s){if(t.StoreLODInAlphaChannel){for(var a=new Uint16Array(n),l=new Uint16Array(o,r),c=0,u=0;u<i;u++)for(var h=0;h<e;h++){var d=4*(h+u*e);a[c]=l[d],a[c+1]=l[d+1],a[c+2]=l[d+2],a[c+3]=t._ToHalfFloat(s),c+=4}return a}return new Uint16Array(o,r,n)},t._GetFloatRGBAArrayBuffer=function(e,i,r,n,o,s){if(t.StoreLODInAlphaChannel){for(var a=new Float32Array(n),l=new Float32Array(o,r),c=0,u=0;u<i;u++)for(var h=0;h<e;h++){var d=4*(h+u*e);a[c]=l[d],a[c+1]=l[d+1],a[c+2]=l[d+2],a[c+3]=s,c+=4}return a}return new Float32Array(o,r,n)},t._GetFloatAsUIntRGBAArrayBuffer=function(i,r,n,o,s,a){for(var l=new Uint8Array(o),c=new Float32Array(s,n),u=0,h=0;h<r;h++)for(var d=0;d<i;d++){var f=4*(d+h*i);l[u]=255*e.Scalar.Clamp(c[f]),l[u+1]=255*e.Scalar.Clamp(c[f+1]),l[u+2]=255*e.Scalar.Clamp(c[f+2]),t.StoreLODInAlphaChannel?l[u+3]=a:l[u+3]=255*e.Scalar.Clamp(c[f+3]),u+=4}return l},t._GetHalfFloatAsUIntRGBAArrayBuffer=function(i,r,n,o,s,a){for(var l=new Uint8Array(o),c=new Uint16Array(s,n),u=0,h=0;h<r;h++)for(var d=0;d<i;d++){var f=4*(d+h*i);l[u]=255*e.Scalar.Clamp(t._FromHalfFloat(c[f])),l[u+1]=255*e.Scalar.Clamp(t._FromHalfFloat(c[f+1])),l[u+2]=255*e.Scalar.Clamp(t._FromHalfFloat(c[f+2])),t.StoreLODInAlphaChannel?l[u+3]=a:l[u+3]=255*e.Scalar.Clamp(t._FromHalfFloat(c[f+3])),u+=4}return l},t._GetRGBAArrayBuffer=function(e,t,i,r,n,o,s,a,l){for(var c=new Uint8Array(r),u=new Uint8Array(n,i),h=0,d=0;d<t;d++)for(var f=0;f<e;f++){var p=4*(f+d*e);c[h]=u[p+o],c[h+1]=u[p+s],c[h+2]=u[p+a],c[h+3]=u[p+l],h+=4}return c},t._ExtractLongWordOrder=function(e){return 0===e||255===e||-16777216===e?0:1+t._ExtractLongWordOrder(e>>8)},t._GetRGBArrayBuffer=function(e,t,i,r,n,o,s,a){for(var l=new Uint8Array(r),c=new Uint8Array(n,i),u=0,h=0;h<t;h++)for(var d=0;d<e;d++){var f=3*(d+h*e);l[u]=c[f+o],l[u+1]=c[f+s],l[u+2]=c[f+a],u+=3}return l},t._GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n,i),a=0,l=0;l<t;l++)for(var c=0;c<e;c++){var u=c+l*e;o[a]=s[u],a++}return o},t.UploadDDSLevels=function(s,a,l,c,u,h,d,f){void 0===d&&(d=-1);var p=null;c.sphericalPolynomial&&(p=new Array);var m,g,_,v,A,y,b,T=s.getCaps().s3tc,E=new Int32Array(l,0,31),x=0,P=0,M=1;if(542327876===E[0])if(c.isFourCC||c.isRGB||c.isLuminance)if(!c.isCompressed||T){var S=E[22];v=E[1]+4;var C=!1;if(c.isFourCC)switch(m=E[21]){case i:M=8,P=T.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case r:M=16,P=T.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case n:M=16,P=T.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:C=!0;break;case o:v+=20;var R=!1;switch(c.dxgiFormat){case 10:C=!0,R=!0;break;case 88:c.isRGB=!0,c.isFourCC=!1,S=32,R=!0}if(R)break;default:return void console.error("Unsupported FourCC code:",function(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}(m))}var O=t._ExtractLongWordOrder(E[23]),D=t._ExtractLongWordOrder(E[24]),I=t._ExtractLongWordOrder(E[25]),w=t._ExtractLongWordOrder(E[26]);C&&(P=s._getRGBABufferInternalSizedFormat(c.textureType)),y=1,131072&E[2]&&!1!==u&&(y=Math.max(1,E[7]));for(var L=0;L<h;L++){for(g=E[4],_=E[3],b=0;b<y;++b){if(-1===d||d===b){var B=-1===d?b:0;if(!c.isCompressed&&c.isFourCC){a.format=e.Engine.TEXTUREFORMAT_RGBA,x=g*_*4;var F=null;s._badOS||s._badDesktopOS||!s.getCaps().textureHalfFloat&&!s.getCaps().textureFloat?(128===S?(F=t._GetFloatAsUIntRGBAArrayBuffer(g,_,v,x,l,B),p&&0==B&&p.push(t._GetFloatRGBAArrayBuffer(g,_,v,x,l,B))):64===S&&(F=t._GetHalfFloatAsUIntRGBAArrayBuffer(g,_,v,x,l,B),p&&0==B&&p.push(t._GetHalfFloatAsFloatRGBAArrayBuffer(g,_,v,x,l,B))),a.type=e.Engine.TEXTURETYPE_UNSIGNED_INT):128===S?(a.type=e.Engine.TEXTURETYPE_FLOAT,F=t._GetFloatRGBAArrayBuffer(g,_,v,x,l,B),p&&0==B&&p.push(F)):64!==S||s.getCaps().textureHalfFloat?(a.type=e.Engine.TEXTURETYPE_HALF_FLOAT,F=t._GetHalfFloatRGBAArrayBuffer(g,_,v,x,l,B),p&&0==B&&p.push(t._GetHalfFloatAsFloatRGBAArrayBuffer(g,_,v,x,l,B))):(a.type=e.Engine.TEXTURETYPE_FLOAT,F=t._GetHalfFloatAsFloatRGBAArrayBuffer(g,_,v,x,l,B),p&&0==B&&p.push(F)),F&&s._uploadDataToTextureDirectly(a,F,L,B)}else if(c.isRGB)a.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,24===S?(a.format=e.Engine.TEXTUREFORMAT_RGB,x=g*_*3,A=t._GetRGBArrayBuffer(g,_,v,x,l,O,D,I),s._uploadDataToTextureDirectly(a,A,L,B)):(a.format=e.Engine.TEXTUREFORMAT_RGBA,x=g*_*4,A=t._GetRGBAArrayBuffer(g,_,v,x,l,O,D,I,w),s._uploadDataToTextureDirectly(a,A,L,B));else if(c.isLuminance){var N=s._getUnpackAlignement(),V=g;x=Math.floor((g+N-1)/N)*N*(_-1)+V,A=t._GetLuminanceArrayBuffer(g,_,v,x,l),a.format=e.Engine.TEXTUREFORMAT_LUMINANCE,a.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,s._uploadDataToTextureDirectly(a,A,L,B)}else x=Math.max(4,g)/4*Math.max(4,_)/4*M,A=new Uint8Array(l,v,x),a.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,s._uploadCompressedDataToTextureDirectly(a,P,g,_,A,L,B)}v+=S?g*_*(S/8):x,g*=.5,_*=.5,g=Math.max(1,g),_=Math.max(1,_)}if(void 0!==f)break}p&&p.length>0?c.sphericalPolynomial=e.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({size:E[4],right:p[0],left:p[1],up:p[2],down:p[3],front:p[4],back:p[5],format:e.Engine.TEXTUREFORMAT_RGBA,type:e.Engine.TEXTURETYPE_FLOAT,gammaSpace:!1}):c.sphericalPolynomial=void 0}else e.Tools.Error("Compressed textures are not supported on this platform.");else e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else e.Tools.Error("Invalid magic number in DDS header")},t.StoreLODInAlphaChannel=!1,t}();e.DDSTools=s}(a||(a={})),function(e){var t=function(){function t(){this.supportCascades=!0}return t.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".dds")},t.prototype.transformUrl=function(e,t){return e},t.prototype.getFallbackTextureUrl=function(e,t){return null},t.prototype.loadCubeData=function(t,i,r,n,o){var s,a=i.getEngine(),l=!1;if(Array.isArray(t))for(var c=0;c<t.length;c++){var u=t[c];s=e.DDSTools.GetDDSInfo(u),i.width=s.width,i.height=s.height,l=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&i.generateMipMaps,a._unpackFlipY(s.isCompressed),e.DDSTools.UploadDDSLevels(a,i,u,s,l,6,-1,c),s.isFourCC||1!==s.mipmapCount||a.generateMipMapsForCubemap(i)}else{var h=t;s=e.DDSTools.GetDDSInfo(h),i.width=s.width,i.height=s.height,r&&(s.sphericalPolynomial=new e.SphericalPolynomial),l=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&i.generateMipMaps,a._unpackFlipY(s.isCompressed),e.DDSTools.UploadDDSLevels(a,i,h,s,l,6),s.isFourCC||1!==s.mipmapCount||a.generateMipMapsForCubemap(i)}a._setCubeMapTextureParams(l),i.isReady=!0,n&&n({isDDS:!0,width:i.width,info:s,data:t,texture:i})},t.prototype.loadData=function(t,i,r){var n=e.DDSTools.GetDDSInfo(t),o=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&i.generateMipMaps&&n.width>>n.mipmapCount-1==1;r(n.width,n.height,o,n.isFourCC,function(){e.DDSTools.UploadDDSLevels(i.getEngine(),i,t,n,o,1)})},t}();e.Engine._TextureLoaders.push(new t)}(a||(a={})),function(e){var t=function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},t.UploadContent=function(i,r){if(r.length<19)e.Tools.Error("Unable to load TGA file - Not enough data to contain header");else{var n=18,o=t.GetTGAHeader(r);if(o.id_length+n>r.length)e.Tools.Error("Unable to load TGA file - Not enough data");else{n+=o.id_length;var s,a=!1,l=!1,c=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:a=!0;case t._TYPE_INDEXED:l=!0;break;case t._TYPE_RLE_RGB:a=!0;case t._TYPE_RGB:break;case t._TYPE_RLE_GREY:a=!0;case t._TYPE_GREY:c=!0}var u,h,d,f,p,m,g,_=o.pixel_size>>3,v=o.width*o.height*_;if(l&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),a){var A,y,b;s=new Uint8Array(v);for(var T=0,E=new Uint8Array(_);n<v&&T<v;)if(y=1+(127&(A=r[n++])),128&A){for(b=0;b<_;++b)E[b]=r[n++];for(b=0;b<y;++b)s.set(E,T+b*_);T+=_*y}else{for(y*=_,b=0;b<y;++b)s[T+b]=r[n++];T+=y}}else s=r.subarray(n,n+=l?o.width*o.height:v);switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:h=0,f=1,g=o.width,d=0,p=1,m=o.height;break;case t._ORIGIN_BL:h=0,f=1,g=o.width,d=o.height-1,p=-1,m=-1;break;case t._ORIGIN_UR:h=o.width-1,f=-1,g=-1,d=0,p=1,m=o.height;break;case t._ORIGIN_BR:h=o.width-1,f=-1,g=-1,d=o.height-1,p=-1,m=-1}var x=t["_getImageData"+(c?"Grey":"")+o.pixel_size+"bits"](o,u,s,d,p,m,h,f,g);i.getEngine()._uploadDataToTextureDirectly(i,x)}}},t._getImageData8bits=function(e,t,i,r,n,o,s,a,l){var c,u,h,d=i,f=t,p=e.width,m=e.height,g=0,_=new Uint8Array(p*m*4);for(h=r;h!==o;h+=n)for(u=s;u!==l;u+=a,g++)c=d[g],_[4*(u+p*h)+3]=255,_[4*(u+p*h)+2]=f[3*c+0],_[4*(u+p*h)+1]=f[3*c+1],_[4*(u+p*h)+0]=f[3*c+2];return _},t._getImageData16bits=function(e,t,i,r,n,o,s,a,l){var c,u,h,d=i,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(h=r;h!==o;h+=n)for(u=s;u!==l;u+=a,m+=2){var _=255*((31744&(c=d[m+0]+(d[m+1]<<8)))>>10)/31|0,v=255*((992&c)>>5)/31|0,A=255*(31&c)/31|0;g[4*(u+f*h)+0]=_,g[4*(u+f*h)+1]=v,g[4*(u+f*h)+2]=A,g[4*(u+f*h)+3]=32768&c?0:255}return g},t._getImageData24bits=function(e,t,i,r,n,o,s,a,l){var c,u,h=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,p+=3)m[4*(c+d*u)+3]=255,m[4*(c+d*u)+2]=h[p+0],m[4*(c+d*u)+1]=h[p+1],m[4*(c+d*u)+0]=h[p+2];return m},t._getImageData32bits=function(e,t,i,r,n,o,s,a,l){var c,u,h=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,p+=4)m[4*(c+d*u)+2]=h[p+0],m[4*(c+d*u)+1]=h[p+1],m[4*(c+d*u)+0]=h[p+2],m[4*(c+d*u)+3]=h[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,l){var c,u,h,d=i,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(h=r;h!==o;h+=n)for(u=s;u!==l;u+=a,m++)c=d[m],g[4*(u+f*h)+0]=c,g[4*(u+f*h)+1]=c,g[4*(u+f*h)+2]=c,g[4*(u+f*h)+3]=255;return g},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,l){var c,u,h=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(c=s;c!==l;c+=a,p+=2)m[4*(c+d*u)+0]=h[p+0],m[4*(c+d*u)+1]=h[p+0],m[4*(c+d*u)+2]=h[p+0],m[4*(c+d*u)+3]=h[p+1];return m},t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t}();e.TGATools=t}(a||(a={})),function(e){var t=function(){function t(){this.supportCascades=!1}return t.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".tga")},t.prototype.transformUrl=function(e,t){return e},t.prototype.getFallbackTextureUrl=function(e,t){return null},t.prototype.loadCubeData=function(e,t,i,r,n){throw".env not supported in Cube."},t.prototype.loadData=function(t,i,r){var n=new Uint8Array(t),o=e.TGATools.GetTGAHeader(n);r(o.width,o.height,i.generateMipMaps,!1,function(){e.TGATools.UploadContent(i,n)})},t}();e.Engine._TextureLoaders.push(new t)}(a||(a={})),function(e){var t=function(){function t(i,r,n,o){this.arrayBuffer=i;var s=new Uint8Array(this.arrayBuffer,0,12);if(171===s[0]&&75===s[1]&&84===s[2]&&88===s[3]&&32===s[4]&&49===s[5]&&49===s[6]&&187===s[7]&&13===s[8]&&10===s[9]&&26===s[10]&&10===s[11]){var a=new Int32Array(this.arrayBuffer,12,13),l=16909060===a[0];this.glType=l?this.switchEndianness(a[1]):a[1],this.glTypeSize=l?this.switchEndianness(a[2]):a[2],this.glFormat=l?this.switchEndianness(a[3]):a[3],this.glInternalFormat=l?this.switchEndianness(a[4]):a[4],this.glBaseInternalFormat=l?this.switchEndianness(a[5]):a[5],this.pixelWidth=l?this.switchEndianness(a[6]):a[6],this.pixelHeight=l?this.switchEndianness(a[7]):a[7],this.pixelDepth=l?this.switchEndianness(a[8]):a[8],this.numberOfArrayElements=l?this.switchEndianness(a[9]):a[9],this.numberOfFaces=l?this.switchEndianness(a[10]):a[10],this.numberOfMipmapLevels=l?this.switchEndianness(a[11]):a[11],this.bytesOfKeyValueData=l?this.switchEndianness(a[12]):a[12],0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===r?this.loadType=t.COMPRESSED_2D:e.Tools.Error("number of faces expected"+r+", but found "+this.numberOfFaces):e.Tools.Error("texture arrays not currently supported"):e.Tools.Error("only 2D textures currently supported")):e.Tools.Error("only compressed formats currently supported")}else e.Tools.Error("texture missing KTX identifier")}return t.prototype.switchEndianness=function(e){return(255&e)<<24|(65280&e)<<8|e>>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a<s;a++){var l=new Int32Array(this.arrayBuffer,r,1)[0];r+=4;for(var c=0;c<this.numberOfFaces;c++){var u=new Uint8Array(this.arrayBuffer,r,l);e.getEngine()._uploadCompressedDataToTextureDirectly(e,this.glInternalFormat,n,o,u,c,a),r+=l,r+=3-(l+3)%4}n=Math.max(1,.5*n),o=Math.max(1,.5*o)}},t.HEADER_LEN=64,t.COMPRESSED_2D=0,t.COMPRESSED_3D=1,t.TEX_2D=2,t.TEX_3D=3,t}();e.KhronosTextureContainer=t}(a||(a={})),function(e){var t=function(){function t(){this.supportCascades=!1}return t.prototype.canLoad=function(e,t,i,r,n){return!(!t||r||i||n)},t.prototype.transformUrl=function(e,t){var i=e.lastIndexOf(".");return(i>-1?e.substring(0,i):e)+t},t.prototype.getFallbackTextureUrl=function(e,t){var i=new RegExp(t+"$");return e.replace(i,"")},t.prototype.loadCubeData=function(t,i,r,n,o){if(!Array.isArray(t)){var s=i.getEngine(),a=new e.KhronosTextureContainer(t,6),l=a.numberOfMipmapLevels>1&&i.generateMipMaps;s._unpackFlipY(!0),a.uploadLevels(i,i.generateMipMaps),i.width=a.pixelWidth,i.height=a.pixelHeight,s._setCubeMapTextureParams(l),i.isReady=!0}},t.prototype.loadData=function(t,i,r){var n=new e.KhronosTextureContainer(t,1);r(n.pixelWidth,n.pixelHeight,!1,!0,function(){n.uploadLevels(i,i.generateMipMaps)})},t}();e.Engine._TextureLoaders.unshift(new t)}(a||(a={})),function(e){var t=function(){function t(){}return t.GetEnvInfo=function(i){for(var r=new DataView(i),n=0,o=0;o<t._MagicBytes.length;o++)if(r.getUint8(n++)!==t._MagicBytes[o])return e.Tools.Error("Not a babylon environment map"),null;for(var s="",a=0;a=r.getUint8(n++);)s+=String.fromCharCode(a);var l=JSON.parse(s);return l.specular&&(l.specular.specularDataPosition=n,l.specular.lodGenerationScale=l.specular.lodGenerationScale||.8),l},t.CreateEnvTextureAsync=function(i){var r=this,n=i.getInternalTexture();if(!n)return Promise.reject("The cube texture is invalid.");if(!i._prefiltered)return Promise.reject("The cube texture is invalid (not prefiltered).");var o=n.getEngine();if(o&&o.premultipliedAlpha)return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");if(i.textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT)return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");var s=o.getRenderingCanvas();if(!s)return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");var a=e.Engine.TEXTURETYPE_FLOAT;if(!o.getCaps().textureFloatRender&&(a=e.Engine.TEXTURETYPE_HALF_FLOAT,!o.getCaps().textureHalfFloatRender))return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");var l=n.width,c=new e.Scene(o),u={},h=[],d=e.Scalar.Log2(n.width);d=Math.round(d);for(var f=function(t){for(var r=Math.pow(2,d-t),n=function(n){var l=i.readPixels(n,t),d=o.createRawTexture(l,r,r,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE,null,a),f=new Promise(function(i,a){var l=new e.PostProcess("rgbdEncode","rgbdEncode",null,null,1,null,e.Texture.NEAREST_SAMPLINGMODE,o,!1,void 0,e.Engine.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);l.getEffect().executeWhenCompiled(function(){l.onApply=function(e){e._bindTexture("textureSampler",d)};var a=o.getRenderWidth(),h=o.getRenderHeight();o.setSize(r,r),c.postProcessManager.directRender([l],null),e.Tools.ToBlob(s,function(e){var r=new FileReader;r.onload=function(e){var r=e.target.result;u[6*t+n]=r,i()},r.readAsArrayBuffer(e)}),o.setSize(a,h)})});h.push(f)},l=0;l<6;l++)n(l)},p=0;p<=d;p++)f(p);return Promise.all(h).then(function(){c.dispose();for(var e={version:1,width:l,irradiance:r._CreateEnvTextureIrradiance(i),specular:{mipmaps:[],lodGenerationScale:i.lodGenerationScale}},n=0,o=0;o<=d;o++)for(var s=0;s<6;s++){var a=u[6*o+s].byteLength;e.specular.mipmaps.push({length:a,position:n}),n+=a}for(var h=JSON.stringify(e),f=new ArrayBuffer(h.length+1),p=new Uint8Array(f),m=(o=0,h.length);o<m;o++)p[o]=h.charCodeAt(o);p[h.length]=0;var g=t._MagicBytes.length+n+f.byteLength,_=new ArrayBuffer(g),v=new Uint8Array(_),A=new DataView(_),y=0;for(o=0;o<t._MagicBytes.length;o++)A.setUint8(y++,t._MagicBytes[o]);v.set(new Uint8Array(f),y),y+=f.byteLength;for(o=0;o<=d;o++)for(s=0;s<6;s++){var b=u[6*o+s];v.set(new Uint8Array(b),y),y+=b.byteLength}return _})},t._CreateEnvTextureIrradiance=function(e){var t=e.sphericalPolynomial;return null==t?null:{x:[t.x.x,t.x.y,t.x.z],y:[t.y.x,t.y.y,t.y.z],z:[t.z.x,t.z.y,t.z.z],xx:[t.xx.x,t.xx.y,t.xx.z],yy:[t.yy.x,t.yy.y,t.yy.z],zz:[t.zz.x,t.zz.y,t.zz.z],yz:[t.yz.x,t.yz.y,t.yz.z],zx:[t.zx.x,t.zx.y,t.zx.z],xy:[t.xy.x,t.xy.y,t.xy.z]}},t.UploadEnvLevelsAsync=function(i,r,n){if(1!==n.version)throw new Error('Unsupported babylon environment map version "'+n.version+'"');var o=n.specular;if(!o)return Promise.resolve();var s=e.Scalar.Log2(n.width);if(s=Math.round(s)+1,o.mipmaps.length!==6*s)throw new Error('Unsupported specular mipmaps number "'+o.mipmaps.length+'"');i._lodGenerationScale=o.lodGenerationScale;for(var a=new Array(s),l=0;l<s;l++){a[l]=new Array(6);for(var c=0;c<6;c++){var u=o.mipmaps[6*l+c];a[l][c]=new Uint8Array(r,o.specularDataPosition+u.position,u.length)}}return t.UploadLevelsAsync(i,a)},t.UploadLevelsAsync=function(t,i){if(!e.Tools.IsExponentOfTwo(t.width))throw new Error("Texture size must be a power of two");var r=Math.round(e.Scalar.Log2(t.width))+1,n=t.getEngine(),o=!1,s=!1,a=null,l=null,c=null,u=n.getCaps();if(t.format=e.Engine.TEXTUREFORMAT_RGBA,t.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,t.generateMipMaps=!0,n.updateTextureSamplingMode(e.Texture.TRILINEAR_SAMPLINGMODE,t),u.textureLOD?n.webGLVersion<2?o=!1:u.textureHalfFloatRender&&u.textureHalfFloatLinearFiltering?(o=!0,t.type=e.Engine.TEXTURETYPE_HALF_FLOAT):u.textureFloatRender&&u.textureFloatLinearFiltering&&(o=!0,t.type=e.Engine.TEXTURETYPE_FLOAT):(o=!1,s=!0,c={}),o)a=new e.PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,e.Texture.TRILINEAR_SAMPLINGMODE,n,!1,void 0,t.type,void 0,null,!1),t._isRGBD=!1,t.invertY=!1,l=n.createRenderTargetCubeTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:e.Texture.TRILINEAR_SAMPLINGMODE,type:t.type,format:e.Engine.TEXTUREFORMAT_RGBA});else if(t._isRGBD=!0,t.invertY=!0,s)for(var h=t._lodGenerationScale,d=t._lodGenerationOffset,f=0;f<3;f++){var p=(r-1)*h+d,m=d+(p-d)*(1-f/2),g=Math.round(Math.min(Math.max(m,0),p)),_=new e.InternalTexture(n,e.InternalTexture.DATASOURCE_TEMP);_.isCube=!0,_.invertY=!0,_.generateMipMaps=!1,n.updateTextureSamplingMode(e.Texture.LINEAR_LINEAR,_);var v=new e.BaseTexture(null);switch(v.isCube=!0,v._texture=_,c[g]=v,f){case 0:t._lodTextureLow=v;break;case 1:t._lodTextureMid=v;break;case 2:t._lodTextureHigh=v}}var A=[],y=function(r){for(var u=function(u){var h=i[r][u],d=new Blob([h],{type:"image/png"}),f=URL.createObjectURL(d),p=new Image;p.src=f;var m=new Promise(function(i,h){p.onload=function(){if(o){var d=n.createTexture(null,!0,!0,null,e.Texture.NEAREST_SAMPLINGMODE,null,function(e){h(e)},p);a.getEffect().executeWhenCompiled(function(){a.onApply=function(e){e._bindTexture("textureSampler",d),e.setFloat2("scale",1,1)},n.scenes[0].postProcessManager.directRender([a],l,!0,u,r),n.restoreDefaultFramebuffer(),d.dispose(),window.URL.revokeObjectURL(f),i()})}else{if(n._uploadImageToTexture(t,p,u,r),s){var m=c[r];m&&n._uploadImageToTexture(m._texture,p,u,0)}i()}},p.onerror=function(e){h(e)}});A.push(m)},h=0;h<6;h++)u(h)};for(f=0;f<i.length;f++)y(f);if(i.length<r){var b=void 0,T=Math.pow(2,r-1-i.length),E=T*T*4;switch(t.type){case e.Engine.TEXTURETYPE_UNSIGNED_INT:b=new Uint8Array(E);break;case e.Engine.TEXTURETYPE_HALF_FLOAT:b=new Uint16Array(E);break;case e.Engine.TEXTURETYPE_FLOAT:b=new Float32Array(E)}for(f=i.length;f<r;f++)for(var x=0;x<6;x++)n._uploadArrayBufferViewToTexture(t,b,x,f)}return Promise.all(A).then(function(){l&&(n._releaseFramebufferObjects(l),l._swapAndDie(t)),a&&a.dispose(),s&&(t._lodTextureHigh&&t._lodTextureHigh._texture&&(t._lodTextureHigh._texture.isReady=!0),t._lodTextureMid&&t._lodTextureMid._texture&&(t._lodTextureMid._texture.isReady=!0),t._lodTextureLow&&t._lodTextureLow._texture&&(t._lodTextureLow._texture.isReady=!0))})},t.UploadEnvSpherical=function(t,i){1!==i.version&&e.Tools.Warn('Unsupported babylon environment map version "'+i.version+'"');var r=i.irradiance;if(r){var n=new e.SphericalPolynomial;e.Vector3.FromArrayToRef(r.x,0,n.x),e.Vector3.FromArrayToRef(r.y,0,n.y),e.Vector3.FromArrayToRef(r.z,0,n.z),e.Vector3.FromArrayToRef(r.xx,0,n.xx),e.Vector3.FromArrayToRef(r.yy,0,n.yy),e.Vector3.FromArrayToRef(r.zz,0,n.zz),e.Vector3.FromArrayToRef(r.yz,0,n.yz),e.Vector3.FromArrayToRef(r.zx,0,n.zx),e.Vector3.FromArrayToRef(r.xy,0,n.xy),t._sphericalPolynomial=n}},t._MagicBytes=[134,22,135,150,246,214,150,54],t}();e.EnvironmentTextureTools=t}(a||(a={})),function(e){var t=function(){function t(){this.supportCascades=!1}return t.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".env")},t.prototype.transformUrl=function(e,t){return e},t.prototype.getFallbackTextureUrl=function(e,t){return null},t.prototype.loadCubeData=function(t,i,r,n,o){if(!Array.isArray(t)){t=t;var s=e.EnvironmentTextureTools.GetEnvInfo(t);s?(i.width=s.width,i.height=s.width,e.EnvironmentTextureTools.UploadEnvSpherical(i,s),e.EnvironmentTextureTools.UploadEnvLevelsAsync(i,t,s).then(function(){i.isReady=!0,n&&n()})):o&&o("Can not parse the environment file",null)}},t.prototype.loadData=function(e,t,i){throw".env not supported in 2d."},t}();e.Engine._TextureLoaders.push(new t)}(a||(a={})),function(e){var t=function(){function t(t){var i=this;this.originalScene=t,this._pointerCaptures={},this._lastPointerEvents={},this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.onPointerOutObservable=new e.Observable,this.utilityLayerScene=new e.Scene(t.getEngine()),this.utilityLayerScene.useRightHandedSystem=t.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,t.getEngine().scenes.pop(),this.utilityLayerScene.detachControl(),this._originalPointerObserver=t.onPrePointerObservable.add(function(r,n){if(i.processAllEvents||r.type===e.PointerEventTypes.POINTERMOVE||r.type===e.PointerEventTypes.POINTERUP||r.type===e.PointerEventTypes.POINTERDOWN){var o=r.event;if(t.isPointerCaptured(o.pointerId))i._pointerCaptures[o.pointerId]=!1;else{var s=r.ray?i.utilityLayerScene.pickWithRay(r.ray):i.utilityLayerScene.pick(t.pointerX,t.pointerY);if(!r.ray&&s&&(r.ray=s.ray),i.utilityLayerScene.onPrePointerObservable.notifyObservers(r),i.onlyCheckPointerDownEvents&&r.type!=e.PointerEventTypes.POINTERDOWN)return r.skipOnPointerObservable||i.utilityLayerScene.onPointerObservable.notifyObservers(new e.PointerInfo(r.type,r.event,s)),void(r.type===e.PointerEventTypes.POINTERUP&&i._pointerCaptures[o.pointerId]&&(i._pointerCaptures[o.pointerId]=!1));if(i.utilityLayerScene.autoClearDepthAndStencil)s&&s.hit&&(r.skipOnPointerObservable||i.utilityLayerScene.onPointerObservable.notifyObservers(new e.PointerInfo(r.type,r.event,s)),r.skipOnPointerObservable=!0);else{var a=r.ray?t.pickWithRay(r.ray):t.pick(t.pointerX,t.pointerY),l=r.event;a&&s&&(0===s.distance&&a.pickedMesh?i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(a.pickedMesh)?(i._notifyObservers(r,a,l),r.skipOnPointerObservable=!0):r.type===e.PointerEventTypes.POINTERDOWN?i._pointerCaptures[l.pointerId]=!0:i._lastPointerEvents[l.pointerId]&&(i.onPointerOutObservable.notifyObservers(l.pointerId),delete i._lastPointerEvents[l.pointerId]):!i._pointerCaptures[l.pointerId]&&(s.distance<a.distance||0===a.distance)?(i._notifyObservers(r,s,l),r.skipOnPointerObservable||(r.skipOnPointerObservable=s.distance>0)):!i._pointerCaptures[l.pointerId]&&s.distance>a.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(a.pickedMesh)?(i._notifyObservers(r,a,l),r.skipOnPointerObservable=!0):i._lastPointerEvents[l.pointerId]&&(i.onPointerOutObservable.notifyObservers(l.pointerId),delete i._lastPointerEvents[l.pointerId])),r.type===e.PointerEventTypes.POINTERUP&&i._pointerCaptures[l.pointerId]&&(i._pointerCaptures[l.pointerId]=!1))}}}}),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderObservable.add(function(){i.shouldRender&&i.render()}),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(function(){i.dispose()}),this._updateCamera()}return Object.defineProperty(t,"DefaultUtilityLayer",{get:function(){return null==t._DefaultUtilityLayer&&(t._DefaultUtilityLayer=new t(e.Engine.LastCreatedScene),t._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){t._DefaultUtilityLayer=null})),t._DefaultUtilityLayer},enumerable:!0,configurable:!0}),Object.defineProperty(t,"DefaultKeepDepthUtilityLayer",{get:function(){return null==t._DefaultKeepDepthUtilityLayer&&(t._DefaultKeepDepthUtilityLayer=new t(e.Engine.LastCreatedScene),t._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,t._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){t._DefaultKeepDepthUtilityLayer=null})),t._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),t.prototype._notifyObservers=function(t,i,r){t.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new e.PointerInfo(t.type,t.event,i)),this._lastPointerEvents[r.pointerId]=!0)},t.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},t.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},t.prototype._updateCamera=function(){this.utilityLayerScene.activeCamera=this.originalScene.activeCamera},t._DefaultUtilityLayer=null,t._DefaultKeepDepthUtilityLayer=null,t}();e.UtilityLayerRenderer=t}(a||(a={})),function(e){var t=function(){function t(t){this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new e.Observable,this.onDragStartObservable=new e.Observable,this.onDragEndObservable=new e.Observable,this.moveAttached=!0,this.enabled=!0,this.detachCameraControls=!0,this.useObjectOrienationForDragging=!0,this._tmpVector=new e.Vector3(0,0,0),this._alternatePickedPoint=new e.Vector3(0,0,0),this._worldDragAxis=new e.Vector3(0,0,0),this._targetPosition=new e.Vector3(0,0,0),this._attachedElement=null,this._startDragRay=new e.Ray(new e.Vector3,new e.Vector3),this._lastPointerRay={},this._dragDelta=new e.Vector3,this._pointA=new e.Vector3(0,0,0),this._pointB=new e.Vector3(0,0,0),this._pointC=new e.Vector3(0,0,0),this._lineA=new e.Vector3(0,0,0),this._lineB=new e.Vector3(0,0,0),this._localAxis=new e.Vector3(0,0,0),this._lookAt=new e.Vector3(0,0,0),this._options=t||{};var i=0;if(this._options.dragAxis&&i++,this._options.dragPlaneNormal&&i++,i>1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(t.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(i){var r=this;this._scene=i.getScene(),this._attachedNode=i,t._planeScene||(this._debugMode?t._planeScene=this._scene:(t._planeScene=new e.Scene(this._scene.getEngine()),t._planeScene.detachControl(),this._scene.getEngine().scenes.pop(),this._scene.onDisposeObservable.addOnce(function(){t._planeScene.dispose(),t._planeScene=null}))),this._dragPlane=e.Mesh.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,t._planeScene,!1,e.Mesh.DOUBLESIDE),this.lastDragPosition=new e.Vector3(0,0,0);this._pointerObserver=this._scene.onPointerObservable.add(function(i,n){if(r.enabled)if(i.type==e.PointerEventTypes.POINTERDOWN)!r.dragging&&i.pickInfo&&i.pickInfo.hit&&i.pickInfo.pickedMesh&&i.pickInfo.pickedPoint&&i.pickInfo.ray&&function(e){return r._attachedNode==e||e.isDescendantOf(r._attachedNode)}(i.pickInfo.pickedMesh)&&r._startDrag(i.event.pointerId,i.pickInfo.ray,i.pickInfo.pickedPoint);else if(i.type==e.PointerEventTypes.POINTERUP)r.currentDraggingPointerID==i.event.pointerId&&r.releaseDrag();else if(i.type==e.PointerEventTypes.POINTERMOVE){var o=i.event.pointerId;r.currentDraggingPointerID===t._AnyMouseID&&o!==t._AnyMouseID&&"mouse"==i.event.pointerType&&(r._lastPointerRay[r.currentDraggingPointerID]&&(r._lastPointerRay[o]=r._lastPointerRay[r.currentDraggingPointerID],delete r._lastPointerRay[r.currentDraggingPointerID]),r.currentDraggingPointerID=o),r._lastPointerRay[o]||(r._lastPointerRay[o]=new e.Ray(new e.Vector3,new e.Vector3)),i.pickInfo&&i.pickInfo.ray&&(r._lastPointerRay[o].origin.copyFrom(i.pickInfo.ray.origin),r._lastPointerRay[o].direction.copyFrom(i.pickInfo.ray.direction),r.currentDraggingPointerID==o&&r.dragging&&r._moveDrag(i.pickInfo.ray))}}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(){r._moving&&r.moveAttached&&(e.BoundingBoxGizmo._RemoveAndStorePivotPoint(r._attachedNode),r._targetPosition.subtractToRef(r._attachedNode.absolutePosition,r._tmpVector),r._tmpVector.scaleInPlace(r.dragDeltaRatio),r._attachedNode.getAbsolutePosition().addToRef(r._tmpVector,r._tmpVector),r._attachedNode.setAbsolutePosition(r._tmpVector),e.BoundingBoxGizmo._RestorePivotPoint(r._attachedNode))})},t.prototype.releaseDrag=function(){this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID}),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&this._scene.activeCamera.attachControl(this._attachedElement,!0)},t.prototype.startDrag=function(e,i,r){void 0===e&&(e=t._AnyMouseID),this._startDrag(e,i,r);var n=this._lastPointerRay[e];e===t._AnyMouseID&&(n=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),n&&this._moveDrag(n)},t.prototype._startDrag=function(t,i,r){if(this._scene.activeCamera&&!this.dragging&&this._attachedNode){e.BoundingBoxGizmo._RemoveAndStorePivotPoint(this._attachedNode),i?(this._startDragRay.direction.copyFrom(i.direction),this._startDragRay.origin.copyFrom(i.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,r||this._tmpVector);var n=this._pickWithRayOnDragPlane(this._startDragRay);n&&(this.dragging=!0,this.currentDraggingPointerID=t,this.lastDragPosition.copyFrom(n),this.onDragStartObservable.notifyObservers({dragPlanePoint:n,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this._attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),e.BoundingBoxGizmo._RestorePivotPoint(this._attachedNode)}},t.prototype._moveDrag=function(t){this._moving=!0;var i=this._pickWithRayOnDragPlane(t);if(i){this.updateDragPlane&&this._updateDragPlanePosition(t,i);var r=0;this._options.dragAxis?(e.Vector3.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis),i.subtractToRef(this.lastDragPosition,this._tmpVector),r=e.Vector3.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(r,this._dragDelta)):(r=this._dragDelta.length(),i.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:r,delta:this._dragDelta,dragPlanePoint:i,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(i)}},t.prototype._pickWithRayOnDragPlane=function(i){var r=this;if(!i)return null;var n=Math.acos(e.Vector3.Dot(this._dragPlane.forward,i.direction));if(n>Math.PI/2&&(n=Math.PI-n),this.maxDragAngle>0&&n>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(i.direction),this._attachedNode.absolutePosition.subtractToRef(i.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(-2*e.Vector3.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var o=e.Vector3.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-o,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this._attachedNode.absolutePosition),this._alternatePickedPoint}return null}var s=t._planeScene.pickWithRay(i,function(e){return e==r._dragPlane});return s&&s.hit&&s.pickedMesh&&s.pickedPoint?s.pickedPoint:null},t.prototype._updateDragPlanePosition=function(t,i){this._pointA.copyFrom(i),this._options.dragAxis?(this.useObjectOrienationForDragging?e.Vector3.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),this._pointA.addToRef(this._localAxis,this._pointB),t.origin.subtractToRef(this._pointA,this._pointC),this._pointA.addToRef(this._pointC.normalize(),this._pointC),this._pointB.subtractToRef(this._pointA,this._lineA),this._pointC.subtractToRef(this._pointA,this._lineB),e.Vector3.CrossToRef(this._lineA,this._lineB,this._lookAt),e.Vector3.CrossToRef(this._lineA,this._lookAt,this._lookAt),this._lookAt.normalize(),this._dragPlane.position.copyFrom(this._pointA),this._pointA.subtractToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrienationForDragging?e.Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.subtractToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(t.origin)),this._dragPlane.computeWorldMatrix(!0)},t.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},t._AnyMouseID=-2,t}();e.PointerDragBehavior=t}(a||(a={})),function(e){var t=function(){function t(){this._startDistance=0,this._initialScale=new e.Vector3(0,0,0),this._targetScale=new e.Vector3(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new e.PointerDragBehavior({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new e.PointerDragBehavior({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(t.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},t.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add(function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))}),this._dragBehaviorB.onDragStartObservable.add(function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))}),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(e){e.onDragObservable.add(function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}})}),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add(function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}})},t.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)})},t}();e.MultiPointerScaleBehavior=t}(a||(a={})),function(e){var t=function(){function t(){this._sceneRenderObserver=null,this._targetPosition=new e.Vector3(0,0,0),this._moving=!1,this._startingOrientation=new e.Quaternion,this.zDragFactor=3,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new e.Observable,this.onDragEndObservable=new e.Observable}return Object.defineProperty(t.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(i){var r=this;this._ownerNode=i,this._scene=this._ownerNode.getScene(),t._virtualScene||(t._virtualScene=new e.Scene(this._scene.getEngine()),t._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var n=null,o=new e.Vector3(0,0,0);this._virtualOriginMesh=new e.AbstractMesh("",t._virtualScene),this._virtualOriginMesh.rotationQuaternion=new e.Quaternion,this._virtualDragMesh=new e.AbstractMesh("",t._virtualScene),this._virtualDragMesh.rotationQuaternion=new e.Quaternion;var s=null;this._pointerObserver=this._scene.onPointerObservable.add(function(t,i){if(t.type==e.PointerEventTypes.POINTERDOWN){if(!r.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.ray&&function(e){return r._ownerNode==e||e.isDescendantOf(r._ownerNode)}(t.pickInfo.pickedMesh)){r._scene.activeCamera&&r._scene.activeCamera.cameraRigMode==e.Camera.RIG_MODE_NONE&&t.pickInfo.ray.origin.copyFrom(r._scene.activeCamera.position),n=r._ownerNode,e.BoundingBoxGizmo._RemoveAndStorePivotPoint(n),o.copyFrom(t.pickInfo.ray.origin),r._virtualOriginMesh.position.copyFrom(t.pickInfo.ray.origin),r._virtualOriginMesh.lookAt(t.pickInfo.ray.origin.subtract(t.pickInfo.ray.direction)),r._virtualOriginMesh.removeChild(r._virtualDragMesh),n.computeWorldMatrix(),r._virtualDragMesh.position.copyFrom(n.absolutePosition),n.rotationQuaternion||(n.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z));var a=n.parent;n.setParent(null),r._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion),n.setParent(a),r._virtualOriginMesh.addChild(r._virtualDragMesh),r._targetPosition.copyFrom(r._virtualDragMesh.absolutePosition),r.dragging=!0,r.currentDraggingPointerID=t.event.pointerId,r.detachCameraControls&&r._scene.activeCamera&&!r._scene.activeCamera.leftCamera&&(r._scene.activeCamera.inputs.attachedElement?(s=r._scene.activeCamera.inputs.attachedElement,r._scene.activeCamera.detachControl(r._scene.activeCamera.inputs.attachedElement)):s=null),e.BoundingBoxGizmo._RestorePivotPoint(n),r.onDragStartObservable.notifyObservers({})}}else if(t.type==e.PointerEventTypes.POINTERUP)r.currentDraggingPointerID==t.event.pointerId&&(r.dragging=!1,r._moving=!1,r.currentDraggingPointerID=-1,n=null,r._virtualOriginMesh.removeChild(r._virtualDragMesh),r.detachCameraControls&&s&&r._scene.activeCamera&&!r._scene.activeCamera.leftCamera&&r._scene.activeCamera.attachControl(s,!0),r.onDragEndObservable.notifyObservers({}));else if(t.type==e.PointerEventTypes.POINTERMOVE&&r.currentDraggingPointerID==t.event.pointerId&&r.dragging&&t.pickInfo&&t.pickInfo.ray&&n){var l=r.zDragFactor;r._scene.activeCamera&&r._scene.activeCamera.cameraRigMode==e.Camera.RIG_MODE_NONE&&(t.pickInfo.ray.origin.copyFrom(r._scene.activeCamera.position),l=0);var c=t.pickInfo.ray.origin.subtract(o);o.copyFrom(t.pickInfo.ray.origin);var u=-e.Vector3.Dot(c,t.pickInfo.ray.direction);r._virtualOriginMesh.addChild(r._virtualDragMesh),r._virtualDragMesh.position.z-=r._virtualDragMesh.position.z<1?u*r.zDragFactor:u*l*r._virtualDragMesh.position.z,r._virtualDragMesh.position.z<0&&(r._virtualDragMesh.position.z=0),r._virtualOriginMesh.position.copyFrom(t.pickInfo.ray.origin),r._virtualOriginMesh.lookAt(t.pickInfo.ray.origin.subtract(t.pickInfo.ray.direction)),r._virtualOriginMesh.removeChild(r._virtualDragMesh),r._targetPosition.copyFrom(r._virtualDragMesh.absolutePosition),n.parent&&e.Vector3.TransformCoordinatesToRef(r._targetPosition,e.Matrix.Invert(n.parent.getWorldMatrix()),r._targetPosition),r._moving||r._startingOrientation.copyFrom(r._virtualDragMesh.rotationQuaternion),r._moving=!0}});var a=new e.Quaternion;this._sceneRenderObserver=i.getScene().onBeforeRenderObservable.add(function(){if(r.dragging&&r._moving&&n){e.BoundingBoxGizmo._RemoveAndStorePivotPoint(n),n.position.addInPlace(r._targetPosition.subtract(n.position).scale(r.dragDeltaRatio)),a.copyFrom(r._startingOrientation),a.x=-a.x,a.y=-a.y,a.z=-a.z,r._virtualDragMesh.rotationQuaternion.multiplyToRef(a,a),e.Quaternion.RotationYawPitchRollToRef(a.toEulerAngles("xyz").y,0,0,a),a.multiplyToRef(r._startingOrientation,a);var t=n.parent;n.setParent(null),e.Quaternion.SlerpToRef(n.rotationQuaternion,a,r.dragDeltaRatio,n.rotationQuaternion),n.setParent(t),e.BoundingBoxGizmo._RestorePivotPoint(n)}})},t.prototype.detach=function(){this._scene&&this._scene.onPointerObservable.remove(this._pointerObserver),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragStartObservable.clear()},t}();e.SixDofDragBehavior=t}(a||(a={})),function(e){var t=function(){return function(t,i,r,n){void 0===i&&(i=new e.Vector3),void 0===r&&(r=0),void 0===n&&(n=!1),this.direction=t,this.rotatedDirection=i,this.diff=r,this.ignore=n}}(),i=function(){function i(i){this.ui=i,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new t(e.Vector3.Up()),new t(e.Vector3.Down()),new t(e.Vector3.Left()),new t(e.Vector3.Right()),new t(e.Vector3.Forward()),new t(e.Vector3.Forward().scaleInPlace(-1))],this._tmpMatrix=new e.Matrix,this._tmpVector=new e.Vector3,this._zeroVector=e.Vector3.Zero(),this._lookAtTmpMatrix=new e.Matrix}return i.prototype.init=function(){},i.prototype._closestFace=function(t){var i=this;return this._faceVectors.forEach(function(r){i._target.rotationQuaternion||(i._target.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(i._target.rotation.y,i._target.rotation.x,i._target.rotation.z)),i._target.rotationQuaternion.toRotationMatrix(i._tmpMatrix),e.Vector3.TransformCoordinatesToRef(r.direction,i._tmpMatrix,r.rotatedDirection),r.diff=e.Vector3.GetAngleBetweenVectors(r.rotatedDirection,t,e.Vector3.Cross(r.rotatedDirection,t))}),this._faceVectors.reduce(function(e,t){return e.ignore?t:t.ignore?e:e.diff<t.diff?e:t},this._faceVectors[0])},i.prototype._lookAtToRef=function(t,i,r){void 0===i&&(i=new e.Vector3(0,1,0)),e.Matrix.LookAtLHToRef(this._zeroVector,t,i,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),e.Quaternion.FromRotationMatrixToRef(this._lookAtTmpMatrix,r)},i.prototype.attach=function(t){var i=this;this._target=t,this._scene=this._target.getScene(),this._onRenderObserver=this._scene.onBeforeRenderObservable.add(function(){if(i._scene.activeCamera){var r=i._scene.activeCamera.position;i._scene.activeCamera.devicePosition&&(r=i._scene.activeCamera.devicePosition);var n=i._closestFace(r.subtract(t.position));i._scene.activeCamera.leftCamera?i._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(i._tmpMatrix):i._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(i._tmpMatrix),e.Vector3.TransformCoordinatesToRef(e.Vector3.Up(),i._tmpMatrix,i._tmpVector),i._faceVectors.forEach(function(e){n.direction.x&&e.direction.x&&(e.ignore=!0),n.direction.y&&e.direction.y&&(e.ignore=!0),n.direction.z&&e.direction.z&&(e.ignore=!0)});var o=i._closestFace(i._tmpVector);i._faceVectors.forEach(function(e){e.ignore=!1}),i.ui.position.copyFrom(t.position),n.direction.x&&(n.rotatedDirection.scaleToRef(t.scaling.x/2+i.distanceAwayFromFace,i._tmpVector),i.ui.position.addInPlace(i._tmpVector)),n.direction.y&&(n.rotatedDirection.scaleToRef(t.scaling.y/2+i.distanceAwayFromFace,i._tmpVector),i.ui.position.addInPlace(i._tmpVector)),n.direction.z&&(n.rotatedDirection.scaleToRef(t.scaling.z/2+i.distanceAwayFromFace,i._tmpVector),i.ui.position.addInPlace(i._tmpVector)),i.ui.rotationQuaternion||(i.ui.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(i.ui.rotation.y,i.ui.rotation.x,i.ui.rotation.z)),n.rotatedDirection.scaleToRef(-1,i._tmpVector),i._lookAtToRef(i._tmpVector,o.rotatedDirection,i.ui.rotationQuaternion),o.direction.x&&i.ui.up.scaleToRef(i.distanceAwayFromBottomOfFace-t.scaling.x/2,i._tmpVector),o.direction.y&&i.ui.up.scaleToRef(i.distanceAwayFromBottomOfFace-t.scaling.y/2,i._tmpVector),o.direction.z&&i.ui.up.scaleToRef(i.distanceAwayFromBottomOfFace-t.scaling.z/2,i._tmpVector),i.ui.position.addInPlace(i._tmpVector)}})},i.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)},i}();e.AttachToBoxBehavior=i}(a||(a={})),function(e){var t=function(){function e(){var e=this;this.delay=0,this.fadeInTime=300,this._millisecondsPerFrame=1e3/60,this._hovered=!1,this._hoverValue=0,this._ownerNode=null,this._update=function(){if(e._ownerNode){if(e._hoverValue+=e._hovered?e._millisecondsPerFrame:-e._millisecondsPerFrame,e._setAllVisibility(e._ownerNode,(e._hoverValue-e.delay)/e.fadeInTime),e._ownerNode.visibility>1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach(function(e){i._setAllVisibility(e,t)})},e}();e.FadeInOutBehavior=t}(a||(a={})),function(e){var t=function(){function t(t){void 0===t&&(t=e.UtilityLayerRenderer.DefaultUtilityLayer);var i=this;this.gizmoLayer=t,this.scaleRatio=1,this._tmpMatrix=new e.Matrix,this._customMeshSet=!1,this.updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this._updateScale=!0,this._interactionsEnabled=!0,this._tempVector=new e.Vector3,this._rootMesh=new e.Mesh("gizmoRootNode",t.utilityLayerScene),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function(){i._update()}),this.attachedMesh=null}return Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,this._rootMesh.setEnabled(!!e),this._attachedMeshChanged(e)},enumerable:!0,configurable:!0}),t.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._rootMesh.getChildMeshes().forEach(function(e){e.dispose()}),e.parent=this._rootMesh,this._customMeshSet=!0},t.prototype._attachedMeshChanged=function(e){},t.prototype._update=function(){if(this.attachedMesh&&(this.updateGizmoRotationToMatchAttachedMesh?(this._rootMesh.rotationQuaternion||(this._rootMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this._rootMesh.rotation.y,this._rootMesh.rotation.x,this._rootMesh.rotation.z)),this._tempVector.copyFrom(this.attachedMesh.scaling),this.attachedMesh.scaling.x<0&&(this.attachedMesh.scaling.x*=-1),this.attachedMesh.scaling.y<0&&(this.attachedMesh.scaling.y*=-1),this.attachedMesh.scaling.z<0&&(this.attachedMesh.scaling.z*=-1),this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix),this.attachedMesh.scaling.copyFrom(this._tempVector),this.attachedMesh.computeWorldMatrix(),e.Quaternion.FromRotationMatrixToRef(this._tmpMatrix,this._rootMesh.rotationQuaternion)):this._rootMesh.rotationQuaternion&&this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateGizmoPositionToMatchAttachedMesh&&this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition),this._updateScale&&this.gizmoLayer.utilityLayerScene.activeCamera&&this.attachedMesh)){var t=this.gizmoLayer.utilityLayerScene.activeCamera.position;this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition&&(t=this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition),this._rootMesh.position.subtractToRef(t,this._tempVector);var i=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(i,i,i)}},t.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},t}();e.Gizmo=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n){void 0===r&&(r=e.Color3.Gray()),void 0===n&&(n=e.UtilityLayerRenderer.DefaultUtilityLayer);var o=t.call(this,n)||this;o._pointerObserver=null,o.snapDistance=0,o.onSnapObservable=new e.Observable;var s=new e.StandardMaterial("",n.utilityLayerScene);s.disableLighting=!0,s.emissiveColor=r;var a=new e.StandardMaterial("",n.utilityLayerScene);a.disableLighting=!0,a.emissiveColor=r.add(new e.Color3(.3,.3,.3));var l=new e.AbstractMesh("",n.utilityLayerScene),c=e.MeshBuilder.CreateCylinder("yPosMesh",{diameterTop:0,height:1.5,diameterBottom:.75,tessellation:96},n.utilityLayerScene),u=e.MeshBuilder.CreateLines("yPosMesh",{points:[new e.Vector3(0,0,0),new e.Vector3(0,1.1,0)]},n.utilityLayerScene);u.color=s.emissiveColor,l.addChild(c),l.addChild(u),c.scaling.scaleInPlace(.05),c.material=s,c.rotation.x=Math.PI/2,c.position.z+=.3,u.scaling.scaleInPlace(.26),u.rotation.x=Math.PI/2,u.material=s,l.lookAt(o._rootMesh.position.subtract(i)),l.scaling.scaleInPlace(1/3),o._rootMesh.addChild(l);var h=0,d=new e.Vector3,f={snapDistance:0};o.dragBehavior=new e.PointerDragBehavior({dragAxis:i}),o.dragBehavior.moveAttached=!1,o._rootMesh.addBehavior(o.dragBehavior);var p=new e.Vector3,m=new e.Matrix;return o.dragBehavior.onDragObservable.add(function(t){if(o.attachedMesh)if(o.attachedMesh.parent?(o.attachedMesh.parent.computeWorldMatrix().invertToRef(m),m.setTranslationFromFloats(0,0,0),e.Vector3.TransformCoordinatesToRef(t.delta,m,p)):p.copyFrom(t.delta),0==o.snapDistance)o.attachedMesh.position.addInPlace(p);else if(h+=t.dragDistance,Math.abs(h)>o.snapDistance){var i=Math.floor(Math.abs(h)/o.snapDistance);h%=o.snapDistance,p.normalizeToRef(d),d.scaleInPlace(o.snapDistance*i),o.attachedMesh.position.addInPlace(d),f.snapDistance=o.snapDistance*i,o.onSnapObservable.notifyObservers(f)}}),o._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(e,t){if(!o._customMeshSet){var i=e.pickInfo&&-1!=o._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a:s;o._rootMesh.getChildMeshes().forEach(function(e){e.material=i,e.color&&(e.color=i.emissiveColor)})}}),o}return o(i,t),i.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},i.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),t.prototype.dispose.call(this)},i}(e.Gizmo);e.AxisDragGizmo=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n){void 0===r&&(r=e.Color3.Gray()),void 0===n&&(n=e.UtilityLayerRenderer.DefaultUtilityLayer);var o=t.call(this,n)||this;o._pointerObserver=null,o.snapDistance=0,o.onSnapObservable=new e.Observable,o.uniformScaling=!1,o._coloredMaterial=new e.StandardMaterial("",n.utilityLayerScene),o._coloredMaterial.disableLighting=!0,o._coloredMaterial.emissiveColor=r;var s=new e.StandardMaterial("",n.utilityLayerScene);s.disableLighting=!0,s.emissiveColor=r.add(new e.Color3(.3,.3,.3));var a=new e.AbstractMesh("",n.utilityLayerScene),l=e.MeshBuilder.CreateBox("yPosMesh",{size:.4},n.utilityLayerScene),c=e.MeshBuilder.CreateLines("yPosMesh",{points:[new e.Vector3(0,0,0),new e.Vector3(0,1.1,0)]},n.utilityLayerScene);c.color=o._coloredMaterial.emissiveColor,a.addChild(l),a.addChild(c),l.scaling.scaleInPlace(.1),l.material=o._coloredMaterial,l.rotation.x=Math.PI/2,l.position.z+=.3,c.scaling.scaleInPlace(.26),c.rotation.x=Math.PI/2,c.material=o._coloredMaterial,a.lookAt(o._rootMesh.position.subtract(i)),o._rootMesh.addChild(a),a.scaling.scaleInPlace(1/3),o.dragBehavior=new e.PointerDragBehavior({dragAxis:i}),o.dragBehavior.moveAttached=!1,o._rootMesh.addBehavior(o.dragBehavior);var u=0,h=new e.Vector3,d={snapDistance:0};return o.dragBehavior.onDragObservable.add(function(e){if(o.attachedMesh){var t=!1,r=0;o.uniformScaling?(o.attachedMesh.scaling.normalizeToRef(h),h.y<0&&h.scaleInPlace(-1)):h.copyFrom(i),0==o.snapDistance?h.scaleToRef(e.dragDistance,h):(u+=e.dragDistance,Math.abs(u)>o.snapDistance?(r=Math.floor(u/o.snapDistance),u%=o.snapDistance,h.scaleToRef(o.snapDistance*r,h),t=!0):h.scaleInPlace(0)),o.attachedMesh.scaling.addInPlace(h),t&&(d.snapDistance=o.snapDistance*r,o.onSnapObservable.notifyObservers(d))}}),o._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(e,t){if(!o._customMeshSet){var i=e.pickInfo&&-1!=o._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?s:o._coloredMaterial;o._rootMesh.getChildMeshes().forEach(function(e){e.material=i,e.color&&(e.color=i.emissiveColor)})}}),o}return o(i,t),i.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},i.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),t.prototype.dispose.call(this)},i.prototype.setCustomMesh=function(e,i){var r=this;void 0===i&&(i=!1),t.prototype.setCustomMesh.call(this,e),i&&(this._rootMesh.getChildMeshes().forEach(function(e){e.material=r._coloredMaterial,e.color&&(e.color=r._coloredMaterial.emissiveColor)}),this._customMeshSet=!1)},i}(e.Gizmo);e.AxisScaleGizmo=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){void 0===r&&(r=e.Color3.Gray()),void 0===n&&(n=e.UtilityLayerRenderer.DefaultUtilityLayer),void 0===o&&(o=32);var s=t.call(this,n)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new e.Observable;var a=new e.StandardMaterial("",n.utilityLayerScene);a.disableLighting=!0,a.emissiveColor=r;var l=new e.StandardMaterial("",n.utilityLayerScene);l.disableLighting=!0,l.emissiveColor=r.add(new e.Color3(.3,.3,.3));for(var c=new e.AbstractMesh("",n.utilityLayerScene),u=new Array,h=0;h<o;h++){var d=2*Math.PI*(h/(o-1));u.push(new e.Vector3(.8*Math.sin(d),0,.8*Math.cos(d)))}var f=e.Mesh.CreateLines("",u,n.utilityLayerScene);f.color=a.emissiveColor,f.scaling.scaleInPlace(.26),f.material=a,f.rotation.x=Math.PI/2,c.addChild(f),c.lookAt(s._rootMesh.position.subtract(i)),s._rootMesh.addChild(c),c.scaling.scaleInPlace(1/3),s.dragBehavior=new e.PointerDragBehavior({dragPlaneNormal:i}),s.dragBehavior.moveAttached=!1,s.dragBehavior.maxDragAngle=9*Math.PI/20,s.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,s._rootMesh.addBehavior(s.dragBehavior);var p=new e.Vector3;s.dragBehavior.onDragStartObservable.add(function(e){s.attachedMesh&&p.copyFrom(e.dragPlanePoint)});var m=new e.Matrix,g=new e.Vector3,_=new e.Vector3,v={snapDistance:0},A=0,y=new e.Matrix,b=new e.Vector3,T=new e.Quaternion;return s.dragBehavior.onDragObservable.add(function(t){if(s.attachedMesh){s.attachedMesh.rotationQuaternion||(s.attachedMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(s.attachedMesh.rotation.y,s.attachedMesh.rotation.x,s.attachedMesh.rotation.z));var r=t.dragPlanePoint.subtract(s.attachedMesh.absolutePosition).normalize(),o=p.subtract(s.attachedMesh.absolutePosition).normalize(),a=e.Vector3.Cross(r,o),l=e.Vector3.Dot(r,o),c=Math.atan2(a.length(),l);if(g.copyFrom(i),_.copyFrom(i),s.updateGizmoRotationToMatchAttachedMesh&&(s.attachedMesh.rotationQuaternion.toRotationMatrix(m),_=e.Vector3.TransformCoordinates(g,m)),n.utilityLayerScene.activeCamera){var u=n.utilityLayerScene.activeCamera.position.subtract(s.attachedMesh.position);e.Vector3.Dot(u,_)>0&&(g.scaleInPlace(-1),_.scaleInPlace(-1))}e.Vector3.Dot(_,a)>0&&(c=-c);var h=!1;if(0!=s.snapDistance)if(A+=c,Math.abs(A)>s.snapDistance){var d=Math.floor(A/s.snapDistance);A%=s.snapDistance,c=s.snapDistance*d,h=!0}else c=0;y.reset(),s.attachedMesh.parent&&(s.attachedMesh.parent.computeWorldMatrix().invertToRef(y),y.getRotationMatrixToRef(y),e.Vector3.TransformCoordinatesToRef(g,y,g));var f=Math.sin(c/2);T.set(g.x*f,g.y*f,g.z*f,Math.cos(c/2)),y.determinant()>0&&(T.toEulerAnglesToRef(b),e.Quaternion.RotationYawPitchRollToRef(b.y,-b.x,-b.z,T)),s.updateGizmoRotationToMatchAttachedMesh?s.attachedMesh.rotationQuaternion.multiplyToRef(T,s.attachedMesh.rotationQuaternion):T.multiplyToRef(s.attachedMesh.rotationQuaternion,s.attachedMesh.rotationQuaternion),p.copyFrom(t.dragPlanePoint),h&&(v.snapDistance=c,s.onSnapObservable.notifyObservers(v))}}),s._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(e,t){if(!s._customMeshSet){var i=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?l:a;s._rootMesh.getChildMeshes().forEach(function(e){e.material=i,e.color&&(e.color=i.emissiveColor)})}}),s}return o(i,t),i.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},i.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),t.prototype.dispose.call(this)},i}(e.Gizmo);e.PlaneRotationGizmo=t}(a||(a={})),function(e){var t=function(t){function i(i){void 0===i&&(i=e.UtilityLayerRenderer.DefaultUtilityLayer);var r=t.call(this,i)||this;return r.onDragStartObservable=new e.Observable,r.onDragEndObservable=new e.Observable,r.xGizmo=new e.AxisDragGizmo(new e.Vector3(1,0,0),e.Color3.Red().scale(.5),i),r.yGizmo=new e.AxisDragGizmo(new e.Vector3(0,1,0),e.Color3.Green().scale(.5),i),r.zGizmo=new e.AxisDragGizmo(new e.Vector3(0,0,1),e.Color3.Blue().scale(.5),i),[r.xGizmo,r.yGizmo,r.zGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){r.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){r.onDragEndObservable.notifyObservers({})})}),r.attachedMesh=null,r}return o(i,t),Object.defineProperty(i.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),i.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},i.prototype.setCustomMesh=function(t){e.Tools.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},i}(e.Gizmo);e.PositionGizmo=t}(a||(a={})),function(e){var t=function(t){function i(i,r){void 0===i&&(i=e.UtilityLayerRenderer.DefaultUtilityLayer),void 0===r&&(r=32);var n=t.call(this,i)||this;return n.onDragStartObservable=new e.Observable,n.onDragEndObservable=new e.Observable,n.xGizmo=new e.PlaneRotationGizmo(new e.Vector3(1,0,0),e.Color3.Red().scale(.5),i,r),n.yGizmo=new e.PlaneRotationGizmo(new e.Vector3(0,1,0),e.Color3.Green().scale(.5),i,r),n.zGizmo=new e.PlaneRotationGizmo(new e.Vector3(0,0,1),e.Color3.Blue().scale(.5),i,r),[n.xGizmo,n.yGizmo,n.zGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){n.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){n.onDragEndObservable.notifyObservers({})})}),n.attachedMesh=null,n}return o(i,t),Object.defineProperty(i.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),i.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},i.prototype.setCustomMesh=function(t){e.Tools.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},i}(e.Gizmo);e.RotationGizmo=t}(a||(a={})),function(e){var t=function(t){function i(i){void 0===i&&(i=e.UtilityLayerRenderer.DefaultUtilityLayer);var r=t.call(this,i)||this;r.onDragStartObservable=new e.Observable,r.onDragEndObservable=new e.Observable,r.xGizmo=new e.AxisScaleGizmo(new e.Vector3(1,0,0),e.Color3.Red().scale(.5),i),r.yGizmo=new e.AxisScaleGizmo(new e.Vector3(0,1,0),e.Color3.Green().scale(.5),i),r.zGizmo=new e.AxisScaleGizmo(new e.Vector3(0,0,1),e.Color3.Blue().scale(.5),i),r.uniformScaleGizmo=new e.AxisScaleGizmo(new e.Vector3(0,1,0),e.Color3.Yellow().scale(.5),i),r.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh=!1,r.uniformScaleGizmo.uniformScaling=!0;var n=e.Mesh.CreatePolyhedron("",{type:1},r.uniformScaleGizmo.gizmoLayer.utilityLayerScene);n.scaling.scaleInPlace(.02),n.visibility=0;var o=e.Mesh.CreatePolyhedron("",{type:1},r.uniformScaleGizmo.gizmoLayer.utilityLayerScene);return o.scaling.scaleInPlace(.007),n.addChild(o),r.uniformScaleGizmo.setCustomMesh(n,!0),[r.xGizmo,r.yGizmo,r.zGizmo,r.uniformScaleGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){r.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){r.onDragEndObservable.notifyObservers({})})}),r.attachedMesh=null,r}return o(i,t),Object.defineProperty(i.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e,this.uniformScaleGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(t){t||e.Tools.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported."),this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=t,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=t,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e,this.uniformScaleGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e,this.uniformScaleGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),i.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.uniformScaleGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},i}(e.Gizmo);e.ScaleGizmo=t}(a||(a={})),function(e){var t=function(t){function i(r,n){void 0===r&&(r=e.Color3.Gray()),void 0===n&&(n=e.UtilityLayerRenderer.DefaultKeepDepthUtilityLayer);var o=t.call(this,n)||this;o._boundingDimensions=new e.Vector3(1,1,1),o._renderObserver=null,o._pointerObserver=null,o._scaleDragSpeed=.2,o._tmpQuaternion=new e.Quaternion,o._tmpVector=new e.Vector3(0,0,0),o._tmpRotationMatrix=new e.Matrix,o.ignoreChildren=!1,o.includeChildPredicate=null,o.rotationSphereSize=.1,o.scaleBoxSize=.1,o.fixedDragMeshScreenSize=!1,o.fixedDragMeshScreenSizeDistanceFactor=10,o.onDragStartObservable=new e.Observable,o.onScaleBoxDragObservable=new e.Observable,o.onScaleBoxDragEndObservable=new e.Observable,o.onRotationSphereDragObservable=new e.Observable,o.onRotationSphereDragEndObservable=new e.Observable,o.scalePivot=null,o._existingMeshScale=new e.Vector3,o._updateScale=!1,o._anchorMesh=new e.AbstractMesh("anchor",n.utilityLayerScene);var s=new e.StandardMaterial("",n.utilityLayerScene);s.disableLighting=!0,s.emissiveColor=r;var a=new e.StandardMaterial("",n.utilityLayerScene);a.disableLighting=!0,a.emissiveColor=r.clone().add(new e.Color3(.3,.3,.3)),o._lineBoundingBox=new e.AbstractMesh("",n.utilityLayerScene),o._lineBoundingBox.rotationQuaternion=new e.Quaternion;var l=[];l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,0,0),new e.Vector3(o._boundingDimensions.x,0,0)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,0,0),new e.Vector3(0,o._boundingDimensions.y,0)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,0,0),new e.Vector3(0,0,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(o._boundingDimensions.x,0,0),new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,0)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(o._boundingDimensions.x,0,0),new e.Vector3(o._boundingDimensions.x,0,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,o._boundingDimensions.y,0),new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,0)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,o._boundingDimensions.y,0),new e.Vector3(0,o._boundingDimensions.y,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,0,o._boundingDimensions.z),new e.Vector3(o._boundingDimensions.x,0,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(0,0,o._boundingDimensions.z),new e.Vector3(0,o._boundingDimensions.y,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,o._boundingDimensions.z),new e.Vector3(0,o._boundingDimensions.y,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,o._boundingDimensions.z),new e.Vector3(o._boundingDimensions.x,0,o._boundingDimensions.z)]},n.utilityLayerScene)),l.push(e.MeshBuilder.CreateLines("lines",{points:[new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,o._boundingDimensions.z),new e.Vector3(o._boundingDimensions.x,o._boundingDimensions.y,0)]},n.utilityLayerScene)),l.forEach(function(t){t.color=r,t.position.addInPlace(new e.Vector3(-o._boundingDimensions.x/2,-o._boundingDimensions.y/2,-o._boundingDimensions.z/2)),t.isPickable=!1,o._lineBoundingBox.addChild(t)}),o._rootMesh.addChild(o._lineBoundingBox),o._rotateSpheresParent=new e.AbstractMesh("",n.utilityLayerScene),o._rotateSpheresParent.rotationQuaternion=new e.Quaternion;for(var c=function(t){var r=e.MeshBuilder.CreateSphere("",{diameter:1},n.utilityLayerScene);r.rotationQuaternion=new e.Quaternion,r.material=s,(p=new e.PointerDragBehavior({})).moveAttached=!1,p.updateDragPlane=!1,r.addBehavior(p);var a=new e.Vector3(1,0,0),l=0;p.onDragStartObservable.add(function(e){a.copyFrom(r.forward),l=0}),p.onDragObservable.add(function(r){if(o.onRotationSphereDragObservable.notifyObservers({}),o.attachedMesh){i._RemoveAndStorePivotPoint(o.attachedMesh);var n=a,s=r.dragPlaneNormal.scale(e.Vector3.Dot(r.dragPlaneNormal,n)),c=n.subtract(s).normalizeToNew(),u=-e.Vector3.Dot(c,r.delta);u=u/o._boundingDimensions.length()*o._anchorMesh.scaling.length(),o.attachedMesh.rotationQuaternion||(o.attachedMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(o.attachedMesh.rotation.y,o.attachedMesh.rotation.x,o.attachedMesh.rotation.z)),o._anchorMesh.rotationQuaternion||(o._anchorMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(o._anchorMesh.rotation.y,o._anchorMesh.rotation.x,o._anchorMesh.rotation.z)),l+=u,Math.abs(l)<=2*Math.PI&&(t>=8?e.Quaternion.RotationYawPitchRollToRef(0,0,u,o._tmpQuaternion):t>=4?e.Quaternion.RotationYawPitchRollToRef(u,0,0,o._tmpQuaternion):e.Quaternion.RotationYawPitchRollToRef(0,u,0,o._tmpQuaternion),o._anchorMesh.addChild(o.attachedMesh),o._anchorMesh.rotationQuaternion.multiplyToRef(o._tmpQuaternion,o._anchorMesh.rotationQuaternion),o._anchorMesh.removeChild(o.attachedMesh)),o.updateBoundingBox(),i._RestorePivotPoint(o.attachedMesh)}}),p.onDragStartObservable.add(function(){o.onDragStartObservable.notifyObservers({}),o._selectNode(r)}),p.onDragEndObservable.add(function(){o.onRotationSphereDragEndObservable.notifyObservers({}),o._selectNode(null)}),u._rotateSpheresParent.addChild(r)},u=this,h=0;h<12;h++)c(h);o._rootMesh.addChild(o._rotateSpheresParent),o._scaleBoxesParent=new e.AbstractMesh("",n.utilityLayerScene),o._scaleBoxesParent.rotationQuaternion=new e.Quaternion;for(var d=0;d<2;d++)for(var f=0;f<2;f++)for(var p,m=function(){var t=e.MeshBuilder.CreateBox("",{size:1},n.utilityLayerScene);t.material=s;var r=new e.Vector3(0==d?-1:1,0==f?-1:1,0==_?-1:1);(p=new e.PointerDragBehavior({dragAxis:r})).moveAttached=!1,t.addBehavior(p),p.onDragObservable.add(function(r){if(o.onScaleBoxDragObservable.notifyObservers({}),o.attachedMesh){i._RemoveAndStorePivotPoint(o.attachedMesh);var n=r.dragDistance/o._boundingDimensions.length()*o._anchorMesh.scaling.length(),s=new e.Vector3(n,n,n);s.scaleInPlace(o._scaleDragSpeed),o.updateBoundingBox(),o.scalePivot?(o.attachedMesh.getWorldMatrix().getRotationMatrixToRef(o._tmpRotationMatrix),o._boundingDimensions.scaleToRef(.5,o._tmpVector),e.Vector3.TransformCoordinatesToRef(o._tmpVector,o._tmpRotationMatrix,o._tmpVector),o._anchorMesh.position.subtractInPlace(o._tmpVector),o._boundingDimensions.multiplyToRef(o.scalePivot,o._tmpVector),e.Vector3.TransformCoordinatesToRef(o._tmpVector,o._tmpRotationMatrix,o._tmpVector),o._anchorMesh.position.addInPlace(o._tmpVector)):(t.absolutePosition.subtractToRef(o._anchorMesh.position,o._tmpVector),o._anchorMesh.position.subtractInPlace(o._tmpVector)),o._anchorMesh.addChild(o.attachedMesh),o._anchorMesh.scaling.addInPlace(s),(o._anchorMesh.scaling.x<0||o._anchorMesh.scaling.y<0||o._anchorMesh.scaling.z<0)&&o._anchorMesh.scaling.subtractInPlace(s),o._anchorMesh.removeChild(o.attachedMesh),i._RestorePivotPoint(o.attachedMesh)}}),p.onDragStartObservable.add(function(){o.onDragStartObservable.notifyObservers({}),o._selectNode(t)}),p.onDragEndObservable.add(function(){o.onScaleBoxDragEndObservable.notifyObservers({}),o._selectNode(null)}),g._scaleBoxesParent.addChild(t)},g=this,_=0;_<2;_++)m();o._rootMesh.addChild(o._scaleBoxesParent);var v=new Array;return o._pointerObserver=n.utilityLayerScene.onPointerObservable.add(function(e,t){v[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=v[e.event.pointerId]&&(v[e.event.pointerId].material=s,delete v[e.event.pointerId]):o._rotateSpheresParent.getChildMeshes().concat(o._scaleBoxesParent.getChildMeshes()).forEach(function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(v[e.event.pointerId]=t,t.material=a)})}),o._renderObserver=o.gizmoLayer.originalScene.onBeforeRenderObservable.add(function(){o.attachedMesh&&!o._existingMeshScale.equals(o.attachedMesh.scaling)&&o.updateBoundingBox()}),o.updateBoundingBox(),o}return o(i,t),i._RemoveAndStorePivotPoint=function(t){t&&0===i._PivotCached&&(t.getPivotPointToRef(i._OldPivotPoint),i._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(e.Matrix.IdentityReadOnly),i._OldPivotPoint.subtractToRef(t.getPivotPoint(),i._PivotTranslation),i._PivotTmpVector.copyFromFloats(1,1,1),i._PivotTmpVector.subtractInPlace(t.scaling),i._PivotTmpVector.multiplyInPlace(i._PivotTranslation),t.position.addInPlace(i._PivotTmpVector))),i._PivotCached++},i._RestorePivotPoint=function(e){e&&!i._OldPivotPoint.equalsToFloats(0,0,0)&&1===i._PivotCached&&(e.setPivotPoint(i._OldPivotPoint),i._PivotTmpVector.copyFromFloats(1,1,1),i._PivotTmpVector.subtractInPlace(e.scaling),i._PivotTmpVector.multiplyInPlace(i._PivotTranslation),e.position.subtractInPlace(i._PivotTmpVector)),this._PivotCached--},i.prototype._attachedMeshChanged=function(e){e&&(i._RemoveAndStorePivotPoint(e),this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),i._RestorePivotPoint(e),this.updateBoundingBox())},i.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(t,i){t.isVisible=!e||t==e})},i.prototype.updateBoundingBox=function(){if(this.attachedMesh){i._RemoveAndStorePivotPoint(this.attachedMesh),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var t=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);t.max.subtractToRef(t.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((t.max.x+t.min.x)/2,(t.max.y+t.min.y)/2,(t.max.z+t.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector)}for(var r=this._rotateSpheresParent.getChildMeshes(),n=0;n<3;n++)for(var o=0;o<2;o++)for(var s=0;s<2;s++){var a=4*n+2*o+s;if(0==n&&(r[a].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*o,this._boundingDimensions.z*s),r[a].position.addInPlace(new e.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),r[a].lookAt(e.Vector3.Cross(e.Vector3.Right(),r[a].position.normalizeToNew()).normalizeToNew().add(r[a].position))),1==n&&(r[a].position.set(this._boundingDimensions.x*o,this._boundingDimensions.y/2,this._boundingDimensions.z*s),r[a].position.addInPlace(new e.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),r[a].lookAt(e.Vector3.Cross(e.Vector3.Up(),r[a].position.normalizeToNew()).normalizeToNew().add(r[a].position))),2==n&&(r[a].position.set(this._boundingDimensions.x*o,this._boundingDimensions.y*s,this._boundingDimensions.z/2),r[a].position.addInPlace(new e.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),r[a].lookAt(e.Vector3.Cross(e.Vector3.Forward(),r[a].position.normalizeToNew()).normalizeToNew().add(r[a].position))),this.fixedDragMeshScreenSize){this._rootMesh.computeWorldMatrix(),this._rotateSpheresParent.computeWorldMatrix(),r[a].computeWorldMatrix(),r[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var l=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;r[a].scaling.set(l,l,l)}else r[a].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}var c=this._scaleBoxesParent.getChildMeshes();for(n=0;n<2;n++)for(o=0;o<2;o++)for(s=0;s<2;s++){if(c[a=4*n+2*o+s])if(c[a].position.set(this._boundingDimensions.x*n,this._boundingDimensions.y*o,this._boundingDimensions.z*s),c[a].position.addInPlace(new e.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize){this._rootMesh.computeWorldMatrix(),this._scaleBoxesParent.computeWorldMatrix(),c[a].computeWorldMatrix(),c[a].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);l=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;c[a].scaling.set(l,l,l)}else c[a].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),i._RestorePivotPoint(this.attachedMesh))},i.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach(function(t,i){i<4?t.setEnabled(-1!=e.indexOf("x")):i<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))})},i.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),t.prototype.dispose.call(this)},i.MakeNotPickableAndWrapInBoundingBox=function(t){var i=function(e){e.isPickable=!1,e.getChildMeshes().forEach(function(e){i(e)})};i(t),t.rotationQuaternion||(t.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z));var r=t.position.clone(),n=t.rotationQuaternion.clone();t.rotationQuaternion.set(0,0,0,1),t.position.set(0,0,0);var o=e.MeshBuilder.CreateBox("box",{size:1},t.getScene()),s=t.getHierarchyBoundingVectors();return s.max.subtractToRef(s.min,o.scaling),o.position.set((s.max.x+s.min.x)/2,(s.max.y+s.min.y)/2,(s.max.z+s.min.z)/2),t.addChild(o),t.rotationQuaternion.copyFrom(n),t.position.copyFrom(r),t.removeChild(o),o.addChild(t),o.visibility=0,o},i.prototype.setCustomMesh=function(t){e.Tools.Error("Custom meshes are not supported on this gizmo")},i._PivotCached=0,i._OldPivotPoint=new e.Vector3,i._PivotTranslation=new e.Vector3,i._PivotTmpVector=new e.Vector3,i}(e.Gizmo);e.BoundingBoxGizmo=t}(a||(a={})),function(e){var t=function(){function t(t){var i=this;this.scene=t,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObserver=null,this._attachedMesh=null,this._boundingBoxColor=e.Color3.FromHexString("#0984e3"),this.boundingBoxDragBehavior=new e.SixDofDragBehavior,this.attachableMeshes=null,this.usePointerToAttachGizmos=!0,this._defaultKeepDepthUtilityLayer=new e.UtilityLayerRenderer(t),this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._defaultUtilityLayer=new e.UtilityLayerRenderer(t),this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null},this._pointerObserver=t.onPointerObservable.add(function(t,r){if(i.usePointerToAttachGizmos&&t.type==e.PointerEventTypes.POINTERDOWN)if(t.pickInfo&&t.pickInfo.pickedMesh){var n=t.pickInfo.pickedMesh;if(null==i.attachableMeshes)for(;n&&null!=n.parent;)n=n.parent;else{var o=!1;i.attachableMeshes.forEach(function(e){n&&(n==e||n.isDescendantOf(e))&&(n=e,o=!0)}),o||(n=null)}n instanceof e.AbstractMesh?i._attachedMesh!=n&&i.attachToMesh(n):i.attachToMesh(null)}else i.attachToMesh(null)})}return t.prototype.attachToMesh=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=e,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedMesh=e)}this.boundingBoxGizmoEnabled&&this._attachedMesh&&this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)},Object.defineProperty(t.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(t){t?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new e.PositionGizmo(this._defaultUtilityLayer)),this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedMesh=null),this._gizmosEnabled.positionGizmo=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(t){t?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new e.RotationGizmo(this._defaultUtilityLayer)),this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedMesh=null),this._gizmosEnabled.rotationGizmo=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(t){t?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new e.ScaleGizmo(this._defaultUtilityLayer),this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedMesh=null),this._gizmosEnabled.scaleGizmo=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(t){t?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new e.BoundingBoxGizmo(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh,this._attachedMesh&&(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this.gizmos.boundingBoxGizmo.attachedMesh=null),this._gizmosEnabled.boundingBoxGizmo=t},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){for(var e in this.scene.onPointerObservable.remove(this._pointerObserver),this.gizmos){var t=this.gizmos[e];t&&t.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach()},t}();e.GizmoManager=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){void 0===i&&(i=0),void 0===r&&(r=null),this.name=t,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this.onInfluenceChanged=new e.Observable,this._onDataLayoutChanged=new e.Observable,this._animationPropertiesOverride=null,this._scene=r||e.Engine.LastCreatedScene,this.influence=i}return Object.defineProperty(t.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!0,configurable:!0}),t.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},t.prototype.getPositions=function(){return this._positions},t.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},t.prototype.getNormals=function(){return this._normals},t.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},t.prototype.getTangents=function(){return this._tangents},t.prototype.serialize=function(){var t={};return t.name=this.name,t.influence=this.influence,t.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(t.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(t.tangents=Array.prototype.slice.call(this.getTangents())),e.Animation.AppendSerializedAnimations(this,t),t},t.Parse=function(i){var r=new t(i.name,i.influence);if(r.setPositions(i.positions),i.normals&&r.setNormals(i.normals),i.tangents&&r.setTangents(i.tangents),i.animations)for(var n=0;n<i.animations.length;n++){var o=i.animations[n];r.animations.push(e.Animation.Parse(o))}return r},t.FromMesh=function(i,r,n){r||(r=i.name);var o=new t(r,n,i.getScene());return o.setPositions(i.getVerticesData(e.VertexBuffer.PositionKind)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&o.setNormals(i.getVerticesData(e.VertexBuffer.NormalKind)),i.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&o.setTangents(i.getVerticesData(e.VertexBuffer.TangentKind)),o},t}();e.MorphTarget=t}(a||(a={})),function(e){var t=function(){function t(t){void 0===t&&(t=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new e.SmartArray(16),this._supportsNormals=!1,this._supportsTangents=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,t||(t=e.Engine.LastCreatedScene),this._scene=t,this._scene&&(this._scene.morphTargetManagers.push(this),this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(t.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"supportsNormals",{get:function(){return this._supportsNormals},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"supportsTangents",{get:function(){return this._supportsTangents},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"influences",{get:function(){return this._influences},enumerable:!0,configurable:!0}),t.prototype.getActiveTarget=function(e){return this._activeTargets.data[e]},t.prototype.getTarget=function(e){return this._targets[e]},t.prototype.addTarget=function(e){var t=this;this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(function(e){t._syncActiveTargets(e)})),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(function(){t._syncActiveTargets(!0)})),this._syncActiveTargets(!0)},t.prototype.removeTarget=function(e){var t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t<i.length;t++){var r=i[t];e.targets.push(r.serialize())}return e},t.prototype._syncActiveTargets=function(t){var i=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._vertexCount=0;for(var r=0,n=this._targets;r<n.length;r++){var o=n[r];if(0!==o.influence){this._activeTargets.push(o),this._tempInfluences[i++]=o.influence,this._supportsNormals=this._supportsNormals&&o.hasNormals,this._supportsTangents=this._supportsTangents&&o.hasTangents;var s=o.getPositions();if(s){var a=s.length/3;if(0===this._vertexCount)this._vertexCount=a;else if(this._vertexCount!==a)return void e.Tools.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._influences&&this._influences.length===i||(this._influences=new Float32Array(i));for(var l=0;l<i;l++)this._influences[l]=this._tempInfluences[l];t&&this.synchronize()},t.prototype.synchronize=function(){if(this._scene)for(var e=0,t=this._scene.meshes;e<t.length;e++){var i=t[e];i.morphTargetManager===this&&i._syncGeometryWithMorphTargetManager()}},t.Parse=function(i,r){var n=new t(r);n._uniqueId=i.id;for(var o=0,s=i.targets;o<s.length;o++){var a=s[o];n.addTarget(e.MorphTarget.Parse(a))}return n},t}();e.MorphTargetManager=t}(a||(a={})),function(e){var t=function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArrayNoDuplicate(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}},t.prototype.select=function(e,t){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++){this.blocks[i].select(e,this._selectionContent,t)}return t?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersects=function(e,t,i){this._selectionContent.reset();for(var r=0;r<this.blocks.length;r++){this.blocks[r].intersects(e,t,this._selectionContent,i)}return i?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersectsRay=function(e){this._selectionContent.reset();for(var t=0;t<this.blocks.length;t++){this.blocks[t].intersectsRay(e,this._selectionContent)}return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t._CreateBlocks=function(t,i,r,n,o,s,a,l){a.blocks=new Array;for(var c=new e.Vector3((i.x-t.x)/2,(i.y-t.y)/2,(i.z-t.z)/2),u=0;u<2;u++)for(var h=0;h<2;h++)for(var d=0;d<2;d++){var f=t.add(c.multiplyByFloats(u,h,d)),p=t.add(c.multiplyByFloats(u+1,h+1,d+1)),m=new e.OctreeBlock(f,p,n,o+1,s,l);m.addEntries(r),a.blocks.push(m)}},t.CreationFuncForMeshes=function(e,t){var i=e.getBoundingInfo();!e.isBlocked&&i.boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t}();e.Octree=t}(a||(a={})),function(e){var t=function(){function t(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(t.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}else this._creationFunc(e,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},t.prototype.addEntries=function(e){for(var t=0;t<e.length;t++){var i=e[t];this.addEntry(i)}},t.prototype.select=function(t,i,r){if(e.BoundingBox.IsInFrustum(this._boundingVectors,t)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){this.blocks[n].select(t,i,r)}return}r?i.concat(this.entries):i.concatWithNoDuplicate(this.entries)}},t.prototype.intersects=function(t,i,r,n){if(e.BoundingBox.IntersectsSphere(this._minPoint,this._maxPoint,t,i)){if(this.blocks){for(var o=0;o<this.blocks.length;o++){this.blocks[o].intersects(t,i,r,n)}return}n?r.concat(this.entries):r.concatWithNoDuplicate(this.entries)}},t.prototype.intersectsRay=function(e,t){if(e.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var i=0;i<this.blocks.length;i++){this.blocks[i].intersectsRay(e,t)}return}t.concatWithNoDuplicate(this.entries)}},t.prototype.createInnerBlocks=function(){e.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},t}();e.OctreeBlock=t}(a||(a={})),function(e){e.Scene.prototype.createOrUpdateSelectionOctree=function(i,r){void 0===i&&(i=64),void 0===r&&(r=2);var n=this._getComponent(e.SceneComponentConstants.NAME_OCTREE);n||(n=new t(this),this._addComponent(n)),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,i,r));var o=this.getWorldExtends();return this._selectionOctree.update(o.min,o.max,this.meshes),this._selectionOctree},Object.defineProperty(e.Scene.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),e.AbstractMesh.prototype.createOrUpdateSubmeshesOctree=function(i,r){void 0===i&&(i=64),void 0===r&&(r=2);var n=this.getScene(),o=n._getComponent(e.SceneComponentConstants.NAME_OCTREE);o||(o=new t(n),n._addComponent(o)),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,i,r)),this.computeWorldMatrix(!0);var s=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(s.minimumWorld,s.maximumWorld,this.subMeshes),this._submeshesOctree};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new e.Ray(e.Vector3.Zero(),new e.Vector3(1,1,1)),this.scene=t,this.scene.getActiveMeshCandidates=this.getActiveMeshCandidates.bind(this),this.scene.getActiveSubMeshCandidates=this.getActiveSubMeshCandidates.bind(this),this.scene.getCollidingSubMeshCandidates=this.getCollidingSubMeshCandidates.bind(this),this.scene.getIntersectingSubMeshCandidates=this.getIntersectingSubMeshCandidates.bind(this)}return t.prototype.register=function(){var e=this;this.scene.onMeshRemovedObservable.add(function(t){var i=e.scene.selectionOctree;if(void 0!==i&&null!==i){var r=i.dynamicContent.indexOf(t);-1!==r&&i.dynamicContent.splice(r,1)}}),this.scene.onMeshImportedObservable.add(function(t){var i=e.scene.selectionOctree;void 0!==i&&null!==i&&i.addMesh(t)})},t.prototype.getActiveMeshCandidates=function(){return this.scene._selectionOctree?this.scene._selectionOctree.select(this.scene.frustumPlanes):this.scene._getDefaultMeshCandidates()},t.prototype.getActiveSubMeshCandidates=function(e){return e._submeshesOctree&&e.useOctreeForRenderingSelection?e._submeshesOctree.select(this.scene.frustumPlanes):this.scene._getDefaultSubMeshCandidates(e)},t.prototype.getIntersectingSubMeshCandidates=function(t,i){return t._submeshesOctree&&t.useOctreeForPicking?(e.Ray.TransformToRef(i,t.getWorldMatrix(),this._tempRay),t._submeshesOctree.intersectsRay(this._tempRay)):this.scene._getDefaultSubMeshCandidates(t)},t.prototype.getCollidingSubMeshCandidates=function(e,t){if(e._submeshesOctree&&e.useOctreeForCollisions){var i=t._velocityWorldLength+Math.max(t._radius.x,t._radius.y,t._radius.z);return e._submeshesOctree.intersects(t._basePointWorld,i)}return this.scene._getDefaultSubMeshCandidates(e)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){},t}();e.OctreeSceneComponent=t}(a||(a={})),function(e){var t=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add(function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)}),a}return o(t,e),t}(e.PostProcess);e.AnaglyphPostProcess=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("AnaglyphArcRotateCamera",function(i,r,n){return function(){return new t(i,0,0,1,e.Vector3.Zero(),n.interaxial_distance,r)}});var t=function(t){function i(i,r,n,o,s,a,l){var c=t.call(this,i,r,n,o,s,l)||this;return c.interaxialDistance=a,c.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),c}return o(i,t),i.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},i}(e.ArcRotateCamera);e.AnaglyphArcRotateCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("AnaglyphFreeCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,r)}});var t=function(t){function i(i,r,n,o){var s=t.call(this,i,r,o)||this;return s.interaxialDistance=n,s.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),s}return o(i,t),i.prototype.getClassName=function(){return"AnaglyphFreeCamera"},i}(e.FreeCamera);e.AnaglyphFreeCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("AnaglyphGamepadCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,r)}});var t=function(t){function i(i,r,n,o){var s=t.call(this,i,r,o)||this;return s.interaxialDistance=n,s.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),s}return o(i,t),i.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},i}(e.GamepadCamera);e.AnaglyphGamepadCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("AnaglyphUniversalCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,r)}});var t=function(t){function i(i,r,n,o){var s=t.call(this,i,r,o)||this;return s.interaxialDistance=n,s.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),s}return o(i,t),i.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},i}(e.UniversalCamera);e.AnaglyphUniversalCamera=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=r[0]._rigPostProcess,l._stepSize=new e.Vector2(1/l.width,1/l.height),l.onSizeChangedObservable.add(function(){l._stepSize=new e.Vector2(1/l.width,1/l.height)}),l.onApplyObservable.add(function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)}),l}return o(i,t),i}(e.PostProcess);e.StereoscopicInterlacePostProcess=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("StereoscopicArcRotateCamera",function(i,r,n){return function(){return new t(i,0,0,1,e.Vector3.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,r)}});var t=function(t){function i(i,r,n,o,s,a,l,c){var u=t.call(this,i,r,n,o,s,c)||this;return u.interaxialDistance=a,u.isStereoscopicSideBySide=l,u.setCameraRigMode(l?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),u}return o(i,t),i.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},i}(e.ArcRotateCamera);e.StereoscopicArcRotateCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("StereoscopicFreeCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,r)}});var t=function(t){function i(i,r,n,o,s){var a=t.call(this,i,r,s)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=o,a.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return o(i,t),i.prototype.getClassName=function(){return"StereoscopicFreeCamera"},i}(e.FreeCamera);e.StereoscopicFreeCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("StereoscopicGamepadCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,r)}});var t=function(t){function i(i,r,n,o,s){var a=t.call(this,i,r,s)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=o,a.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return o(i,t),i.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},i}(e.GamepadCamera);e.StereoscopicGamepadCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("StereoscopicFreeCamera",function(i,r,n){return function(){return new t(i,e.Vector3.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,r)}});var t=function(t){function i(i,r,n,o,s){var a=t.call(this,i,r,s)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=o,a.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return o(i,t),i.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},i}(e.UniversalCamera);e.StereoscopicUniversalCamera=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){var s=t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE)||this;return s._isRightEye=n,s._distortionFactors=o.distortionK,s._postProcessScaleFactor=o.postProcessScaleFactor,s._lensCenterOffset=o.lensCenterOffset,s.adaptScaleToCurrentViewport=!0,s.onSizeChangedObservable.add(function(){s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)}),s.onApplyObservable.add(function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])}),s}return o(i,t),i}(e.PostProcess);e.VRDistortionCorrectionPostProcess=t}(a||(a={})),function(e){var t=function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=null!==e.alpha?e.alpha:0,t._beta=null!==e.beta?e.beta:0,t._gamma=null!==e.gamma?e.gamma:0},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},t.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t}();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t}(a||(a={})),function(e){var t=function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=0|+e.alpha),null!==e.gamma&&(this._gamma=0|+e.gamma),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t}(a||(a={})),function(e){var t=function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return e.Matrix.Translation(t,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return e.Matrix.Translation(-t,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t}();e.VRCameraMetrics=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("WebVRFreeCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}}),e.Node.AddNodeConstructor("WebVRGamepadCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n,o){void 0===o&&(o={});var s=t.call(this,i,r,n)||this;s.webVROptions=o,s._vrDevice=null,s.rawPose=null,s._specsVersion="1.1",s._attached=!1,s._descendants=[],s._deviceRoomPosition=e.Vector3.Zero(),s._deviceRoomRotationQuaternion=e.Quaternion.Identity(),s._standingMatrix=null,s.devicePosition=e.Vector3.Zero(),s.deviceRotationQuaternion=e.Quaternion.Identity(),s.deviceScaleFactor=1,s._deviceToWorld=e.Matrix.Identity(),s._worldToDevice=e.Matrix.Identity(),s.controllers=[],s.onControllersAttachedObservable=new e.Observable,s.onControllerMeshLoadedObservable=new e.Observable,s.onPoseUpdatedFromDeviceObservable=new e.Observable,s._poseSet=!1,s.rigParenting=!0,s._defaultHeight=void 0,s._htmlElementAttached=null,s._detachIfAttached=function(){var e=s.getEngine().getVRDevice();e&&!e.isPresenting&&s._htmlElementAttached&&s.detachControl(s._htmlElementAttached)},s._workingVector=e.Vector3.Zero(),s._oneVector=e.Vector3.One(),s._workingMatrix=e.Matrix.Identity(),s._tmpMatrix=new e.Matrix,s._cache.position=e.Vector3.Zero(),o.defaultHeight&&(s._defaultHeight=o.defaultHeight,s.position.y=s._defaultHeight),s.minZ=.1,5===arguments.length&&(s.webVROptions=arguments[4]),void 0==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),void 0==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),void 0==s.webVROptions.defaultLightingOnControllers&&(s.webVROptions.defaultLightingOnControllers=!0),s.rotationQuaternion=new e.Quaternion,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale);var a=s.getEngine();return s._onVREnabled=function(e){e&&s.initControllers()},a.onVRRequestPresentComplete.add(s._onVREnabled),a.initWebVR().add(function(t){t.vrDisplay&&s._vrDevice!==t.vrDisplay&&(s._vrDevice=t.vrDisplay,s.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR())}),"undefined"!=typeof VRFrameData&&(s._frameData=new VRFrameData),n.onBeforeCameraRenderObservable.add(function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,function(e){var t=s.controllers.some(function(t){return t._mesh===e}),i=-1!==s._rigCameras.indexOf(e);return!t&&!i}),s._descendants.forEach(function(t){t.parent=e}))}),n.onAfterCameraRenderObservable.add(function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach(function(e){e.parent=s})}),s}return o(i,t),i.prototype.deviceDistanceToRoomGround=function(){return this._standingMatrix?(this._standingMatrix.getTranslationToRef(this._workingVector),this._deviceRoomPosition.y+this._workingVector.y):this._defaultHeight||0},i.prototype.useStandingMatrix=function(t){var i=this;void 0===t&&(t=function(e){}),this.getEngine().initWebVRAsync().then(function(r){r.vrDisplay&&r.vrDisplay.stageParameters&&r.vrDisplay.stageParameters.sittingToStandingTransform&&i.webVROptions.trackPosition?(i._standingMatrix=new e.Matrix,e.Matrix.FromFloat32ArrayToRefScaled(r.vrDisplay.stageParameters.sittingToStandingTransform,0,1,i._standingMatrix),i.getScene().useRightHandedSystem||[2,6,8,9,14].forEach(function(e){i._standingMatrix&&(i._standingMatrix.m[e]*=-1)}),t(!0)):t(!1)})},i.prototype.useStandingMatrixAsync=function(){var e=this;return new Promise(function(t,i){e.useStandingMatrix(function(e){t(e)})})},i.prototype.dispose=function(){this._detachIfAttached(),this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),this._updateCacheWhenTrackingDisabledObserver&&this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),t.prototype.dispose.call(this)},i.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t<i.length;t++){var r=i[t];if(r.hand===e)return r}return null},Object.defineProperty(i.prototype,"leftController",{get:function(){return this._leftController||(this._leftController=this.getControllerByName("left")),this._leftController},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rightController",{get:function(){return this._rightController||(this._rightController=this.getControllerByName("right")),this._rightController},enumerable:!0,configurable:!0}),i.prototype.getForwardRay=function(e){return void 0===e&&(e=100),this.leftCamera?t.prototype.getForwardRay.call(this,e,this.leftCamera.getWorldMatrix(),this.leftCamera.globalPosition):t.prototype.getForwardRay.call(this,e)},i.prototype._checkInputs=function(){this._vrDevice&&this._vrDevice.isPresenting&&(this._vrDevice.getFrameData(this._frameData),this.updateFromDevice(this._frameData.pose)),t.prototype._checkInputs.call(this)},i.prototype.updateFromDevice=function(e){e&&e.orientation&&(this.rawPose=e,this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0],e.orientation[1],-e.orientation[2],-e.orientation[3]),this.getScene().useRightHandedSystem&&(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1),this.webVROptions.trackPosition&&this.rawPose.position&&(this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2]),this.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1)),this._poseSet=!0)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r),this._attached=!0,this._htmlElementAttached=i,r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this._vrDevice&&this.getEngine().enableVR(),window.addEventListener("vrdisplaypresentchange",this._detachIfAttached)},i.prototype.detachControl=function(e){this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),t.prototype.detachControl.call(this,e),this._attached=!1,this.getEngine().disableVR(),window.removeEventListener("vrdisplaypresentchange",this._detachIfAttached)},i.prototype.getClassName=function(){return"WebVRFreeCamera"},i.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},i.prototype._updateRigCameras=function(){var e=this._rigCameras[0],t=this._rigCameras[1];e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),e.position.copyFrom(this._deviceRoomPosition),t.position.copyFrom(this._deviceRoomPosition)},i.prototype._correctPositionIfNotTrackPosition=function(t,i){void 0===i&&(i=!1),this.rawPose&&this.rawPose.position&&!this.webVROptions.trackPosition&&(e.Matrix.TranslationToRef(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2],this._tmpMatrix),i||this._tmpMatrix.invert(),this._tmpMatrix.multiplyToRef(t,t))},i.prototype._updateCache=function(i){var r=this;this.rotationQuaternion.equals(this._cache.rotationQuaternion)&&this.position.equals(this._cache.position)||(this.updateCacheCalled||(this.updateCacheCalled=!0,this.update()),this.rotationQuaternion.toRotationMatrix(this._workingMatrix),e.Vector3.TransformCoordinatesToRef(this._deviceRoomPosition,this._workingMatrix,this._workingVector),this.devicePosition.subtractToRef(this._workingVector,this._workingVector),e.Matrix.ComposeToRef(this._oneVector,this.rotationQuaternion,this._workingVector,this._deviceToWorld),this._deviceToWorld.getTranslationToRef(this._workingVector),this._workingVector.addInPlace(this.position),this._workingVector.subtractInPlace(this._cache.position),this._deviceToWorld.setTranslation(this._workingVector),this._deviceToWorld.invertToRef(this._worldToDevice),this.controllers.forEach(function(e){e._deviceToWorld.copyFrom(r._deviceToWorld),r._correctPositionIfNotTrackPosition(e._deviceToWorld),e.update()})),i||t.prototype._updateCache.call(this),this.updateCacheCalled=!1},i.prototype._computeDevicePosition=function(){e.Vector3.TransformCoordinatesToRef(this._deviceRoomPosition,this._deviceToWorld,this.devicePosition)},i.prototype.update=function(){this._computeDevicePosition(),e.Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion,this._workingMatrix),this._workingMatrix.multiplyToRef(this._deviceToWorld,this._workingMatrix),e.Quaternion.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this._poseSet&&this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),t.prototype.update.call(this)},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype._getWebVRViewMatrix=function(){var t=this,i=this._cameraRigParams.parentCamera;i._updateCache();var r=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return e.Matrix.FromArrayToRef(r,0,this._webvrViewMatrix),this.getScene().useRightHandedSystem||[2,6,8,9,14].forEach(function(e){t._webvrViewMatrix.m[e]*=-1}),this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),1!==i.deviceScaleFactor&&(this._webvrViewMatrix.invert(),i.deviceScaleFactor&&(this._webvrViewMatrix.m[12]*=i.deviceScaleFactor,this._webvrViewMatrix.m[13]*=i.deviceScaleFactor,this._webvrViewMatrix.m[14]*=i.deviceScaleFactor),this._webvrViewMatrix.invert()),i._correctPositionIfNotTrackPosition(this._webvrViewMatrix,!0),i._worldToDevice.multiplyToRef(this._webvrViewMatrix,this._webvrViewMatrix),this._workingMatrix=this._workingMatrix||e.Matrix.Identity(),this._webvrViewMatrix.invertToRef(this._workingMatrix),this._workingMatrix.multiplyToRef(i.getWorldMatrix(),this._workingMatrix),this._workingMatrix.getTranslationToRef(this._globalPosition),this._markSyncedWithParent(),this._webvrViewMatrix},i.prototype._getWebVRProjectionMatrix=function(){var t=this,i=this.parent;i._vrDevice.depthNear=i.minZ,i._vrDevice.depthFar=i.maxZ;var r=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return e.Matrix.FromArrayToRef(r,0,this._projectionMatrix),this.getScene().useRightHandedSystem||[8,9,10,11].forEach(function(e){t._projectionMatrix.m[e]*=-1}),this._projectionMatrix},i.prototype.initControllers=function(){var t=this;this.controllers=[];var i=this.getScene().gamepadManager;this._onGamepadDisconnectedObserver=i.onGamepadDisconnectedObservable.add(function(i){if(i.type===e.Gamepad.POSE_ENABLED){var r=i;r.defaultModel&&r.defaultModel.setEnabled(!1),"right"===r.hand&&(t._rightController=null),"left"===r.hand&&(t._leftController=null);var n=t.controllers.indexOf(r);-1!==n&&t.controllers.splice(n,1)}}),this._onGamepadConnectedObserver=i.onGamepadConnectedObservable.add(function(i){if(i.type===e.Gamepad.POSE_ENABLED){var r=i;if(t.webVROptions.trackPosition||(r._disableTrackPosition(new e.Vector3("left"==r.hand?-.15:.15,-.5,.25)),t._updateCacheWhenTrackingDisabledObserver||(t._updateCacheWhenTrackingDisabledObserver=t._scene.onBeforeRenderObservable.add(function(){t._updateCache()}))),r.deviceScaleFactor=t.deviceScaleFactor,r._deviceToWorld.copyFrom(t._deviceToWorld),t._correctPositionIfNotTrackPosition(r._deviceToWorld),t.webVROptions.controllerMeshes&&(r.defaultModel?r.defaultModel.setEnabled(!0):r.initControllerMesh(t.getScene(),function(i){if(i.scaling.scaleInPlace(t.deviceScaleFactor),t.onControllerMeshLoadedObservable.notifyObservers(r),t.webVROptions.defaultLightingOnControllers){t._lightOnControllers||(t._lightOnControllers=new e.HemisphericLight("vrControllersLight",new e.Vector3(0,1,0),t.getScene()));var n=function(e,t){var i=e.getChildren();i&&0!==i.length&&i.forEach(function(e){t.includedOnlyMeshes.push(e),n(e,t)})};t._lightOnControllers.includedOnlyMeshes.push(i),n(i,t._lightOnControllers)}})),r.attachToPoseControlledCamera(t),-1===t.controllers.indexOf(r)){t.controllers.push(r);for(var n=!1,o=0;o<t.controllers.length;o++)t.controllers[o].controllerType===e.PoseEnabledControllerType.VIVE&&(n?t.controllers[o].hand="right":(n=!0,t.controllers[o].hand="left"));t.controllers.length>=2&&t.onControllersAttachedObservable.notifyObservers(t.controllers)}}})},i}(e.FreeCamera);e.WebVRFreeCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("DeviceOrientationCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n){var o=t.call(this,i,r,n)||this;return o._quaternionCache=new e.Quaternion,o.inputs.addDeviceOrientation(),o}return o(i,t),i.prototype.getClassName=function(){return"DeviceOrientationCamera"},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},i.prototype.resetToCurrentRotation=function(t){var i=this;void 0===t&&(t=e.Axis.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new e.Quaternion),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach(function(e){t[e]?i._initialQuaternion[e]*=-1:i._initialQuaternion[e]=0}),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},i}(e.FreeCamera);e.DeviceOrientationCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n,o,s){void 0===o&&(o=!0),void 0===s&&(s=e.VRCameraMetrics.GetDefault());var a=t.call(this,i,r,n)||this;return s.compensateDistortion=o,a.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:s}),a}return o(i,t),i.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},i}(e.DeviceOrientationCamera);e.VRDeviceOrientationFreeCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(i,r){return function(){return new t(i,0,0,1,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===l&&(l=!0),void 0===c&&(c=e.VRCameraMetrics.GetDefault());var u=t.call(this,i,r,n,o,s,a)||this;return c.compensateDistortion=l,u.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:c}),u.inputs.addVRDeviceOrientation(),u}return o(i,t),i.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},i}(e.ArcRotateCamera);e.VRDeviceOrientationArcRotateCamera=t}(a||(a={})),function(e){e.Node.AddNodeConstructor("VRDeviceOrientationGamepadCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(t){function i(i,r,n,o,s){void 0===o&&(o=!0),void 0===s&&(s=e.VRCameraMetrics.GetDefault());var a=t.call(this,i,r,n,o,s)||this;return a.inputs.addGamepad(),a}return o(i,t),i.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},i}(e.VRDeviceOrientationFreeCamera);e.VRDeviceOrientationGamepadCamera=t}(a||(a={})),function(e){var t=function(){function t(i,r){if(void 0===r&&(r=null),this.scene=i,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=t._idCounter++,r)this._gazeTracker=r.clone("gazeTracker");else{this._gazeTracker=e.Mesh.CreateTorus("gazeTracker",.0035,.0025,20,i,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new e.StandardMaterial("targetMat",i);n.specularColor=e.Color3.Black(),n.emissiveColor=new e.Color3(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return t.prototype._getForwardRay=function(t){return new e.Ray(e.Vector3.Zero(),new e.Vector3(0,0,t))},t.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},t.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},t.prototype._activatePointer=function(){this._activePointer=!0},t.prototype._deactivatePointer=function(){this._activePointer=!1},t.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},t.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},t._idCounter=0,t}(),i=function(t){function i(i,r,n){var o=t.call(this,r,n)||this;o.webVRController=i,o._laserPointer=e.Mesh.CreateCylinder("laserPointer",1,.004,2e-4,20,1,r,!1);var s=new e.StandardMaterial("laserPointerMat",r);if(s.emissiveColor=new e.Color3(.7,.7,.7),s.alpha=.6,o._laserPointer.material=s,o._laserPointer.rotation.x=Math.PI/2,o._laserPointer.position.z=-.5,o._laserPointer.isVisible=!1,o._laserPointer.isPickable=!1,!i.mesh){var a=new e.Mesh("preloadControllerMesh",r),l=new e.Mesh(e.PoseEnabledController.POINTING_POSE,r);l.rotation.x=-.7,a.addChild(l),i.attachToMesh(a)}return o._setLaserPointerParent(i.mesh),o._meshAttachedObserver=i._meshAttachedObservable.add(function(e){o._setLaserPointerParent(e)}),o}return o(i,t),i.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},i.prototype._activatePointer=function(){t.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},i.prototype._deactivatePointer=function(){t.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},i.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},i.prototype._setLaserPointerParent=function(t){var i=function(e){e.isPickable=!1,e.getChildMeshes().forEach(function(e){i(e)})};i(t);var r=t.getChildMeshes();this.webVRController._pointingPoseNode=null;for(var n=0;n<r.length;n++)if(r[n].name&&r[n].name.indexOf(e.PoseEnabledController.POINTING_POSE)>=0){t=r[n],this.webVRController._pointingPoseNode=t;break}this._laserPointer.parent=t},i.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},i.prototype.dispose=function(){t.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},i}(t),r=function(t){function i(e,i){var r=t.call(this,i)||this;return r.getCamera=e,r}return o(i,t),i.prototype._getForwardRay=function(t){var i=this.getCamera();return i?i.getForwardRay(t):new e.Ray(e.Vector3.Zero(),e.Vector3.Forward())},i}(t),n=function(){function t(t,n){void 0===n&&(n={});var o=this;if(this.webVROptions=n,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.onEnteringVRObservable=new e.Observable,this.onExitingVRObservable=new e.Observable,this.onControllerMeshLoadedObservable=new e.Observable,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._rotationAllowed=!0,this._teleportBackwardsVector=new e.Vector3(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new e.Vector3(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this.onNewMeshSelected=new e.Observable,this.onNewMeshPicked=new e.Observable,this.onBeforeCameraTeleport=new e.Observable,this.onAfterCameraTeleport=new e.Observable,this.onSelectedMeshUnselected=new e.Observable,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this._onResize=function(){o.moveButtonToBottomRight(),o._fullscreenVRpresenting&&o._webVRready&&o.exitVR()},this._onFullscreenChange=function(){void 0!==document.fullscreen?o._fullscreenVRpresenting=document.fullscreen:void 0!==document.mozFullScreen?o._fullscreenVRpresenting=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o._fullscreenVRpresenting=document.webkitIsFullScreen:void 0!==document.msIsFullScreen?o._fullscreenVRpresenting=document.msIsFullScreen:void 0!==document.msFullscreenElement&&(o._fullscreenVRpresenting=document.msFullscreenElement),!o._fullscreenVRpresenting&&o._canvas&&(o.exitVR(),o._useCustomVRButton||(o._btnVR.style.top=o._canvas.offsetTop+o._canvas.offsetHeight-70+"px",o._btnVR.style.left=o._canvas.offsetLeft+o._canvas.offsetWidth-100+"px"))},this.beforeRender=function(){o._leftController&&o._leftController._activePointer&&o._castRayAndSelectObject(o._leftController),o._rightController&&o._rightController._activePointer&&o._castRayAndSelectObject(o._rightController),o._noControllerIsActive?o._castRayAndSelectObject(o._cameraGazer):o._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(t){if(t.type!==e.Gamepad.POSE_ENABLED)t.leftStick&&t.onleftstickchanged(function(e){o._teleportationInitialized&&o.teleportationEnabled&&(!o._leftController&&!o._rightController||o._leftController&&!o._leftController._activePointer&&o._rightController&&!o._rightController._activePointer)&&(o._checkTeleportWithRay(e,o._cameraGazer),o._checkTeleportBackwards(e,o._cameraGazer))}),t.rightStick&&t.onrightstickchanged(function(e){o._teleportationInitialized&&o._checkRotate(e,o._cameraGazer)}),t.type===e.Gamepad.XBOX&&(t.onbuttondown(function(t){o._interactionsEnabled&&t===e.Xbox360Button.A&&o._cameraGazer._selectionPointerDown()}),t.onbuttonup(function(t){o._interactionsEnabled&&t===e.Xbox360Button.A&&o._cameraGazer._selectionPointerUp()}));else{var r=t,n=new i(r,o._scene,o._cameraGazer._gazeTracker);"right"===r.hand||o._leftController&&o._leftController.webVRController!=r?o._rightController=n:o._leftController=n,o._tryEnableInteractionOnController(n)}},this._tryEnableInteractionOnController=function(e){o._interactionsRequested&&!e._interactionsEnabled&&o._enableInteractionOnController(e),o._teleportationRequested&&!e._teleportationEnabled&&o._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(t){t instanceof e.WebVRController&&("left"===t.hand&&null!=o._leftController&&(o._leftController.dispose(),o._leftController=null),"right"===t.hand&&null!=o._rightController&&(o._rightController.dispose(),o._rightController=null))},this._workingVector=e.Vector3.Zero(),this._workingQuaternion=e.Quaternion.Identity(),this._workingMatrix=e.Matrix.Identity(),this._scene=t,this._canvas=t.getEngine().getRenderingCanvas(),void 0===n.createFallbackVRDeviceOrientationFreeCamera&&(n.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===n.createDeviceOrientationCamera&&(n.createDeviceOrientationCamera=!0),void 0===n.laserToggle&&(n.laserToggle=!0),void 0===n.defaultHeight&&(n.defaultHeight=1.7),n.useCustomVRButton&&(this._useCustomVRButton=!0,n.customVRButton&&(this._btnVR=n.customVRButton)),n.rayLength&&(this._rayLength=n.rayLength),this._defaultHeight=n.defaultHeight,n.positionScale&&(this._rayLength*=n.positionScale,this._defaultHeight*=n.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new e.Vector3(0,this._defaultHeight,0),n.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new e.DeviceOrientationCamera("deviceOrientationVRHelper",this._position.clone(),t),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof e.TargetCamera&&this._scene.activeCamera.rotation)){var s=this._scene.activeCamera;s.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(s.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(e.Quaternion.RotationYawPitchRoll(s.rotation.y,s.rotation.x,s.rotation.z)),this._deviceOrientationCamera.rotation=s.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas)}else this._existingCamera=this._scene.activeCamera;if(n.createFallbackVRDeviceOrientationFreeCamera&&(this._vrDeviceOrientationCamera=new e.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper",this._position,this._scene)),this._webVRCamera=new e.WebVRFreeCamera("WebVRHelper",this._position,this._scene,n),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new r(function(){return o.currentVRCamera},t),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";var a=".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }";a+=".babylonVRicon.vrdisplaypresenting { display: none; }";var l=document.createElement("style");l.appendChild(document.createTextNode(a)),document.getElementsByTagName("head")[0].appendChild(l),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",function(){o.isInVRMode?o.exitVR():o.enterVR()}),window.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),document.onmsfullscreenchange=this._onFullscreenChange,n.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add(function(e){e.vrDisplay&&o.displayVRButton()}),this._onKeyDown=function(e){27===e.keyCode&&o.isInVRMode&&o.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add(function(e,t){o.isInVRMode&&(o.exitVR(),o._fullscreenVRpresenting&&o._scene.getEngine().switchFullscreen(!0))},e.PointerEventTypes.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return o.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return o.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){o._webVRrequesting=!0,o.updateButtonVisibility()},this._onVRRequestPresentComplete=function(e){o._webVRrequesting=!1,o.updateButtonVisibility()},t.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),t.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),t.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),window.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),t.onDisposeObservable.add(function(){o.dispose()}),this._webVRCamera.onControllerMeshLoadedObservable.add(function(e){return o._onDefaultMeshLoaded(e)}),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new e.CircleEase,this._circleEase.setEasingMode(e.EasingFunction.EASINGMODE_EASEINOUT),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes})}return Object.defineProperty(t.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._leftController&&this._leftController._gazeTracker&&this._leftController._gazeTracker.dispose(),this._rightController&&this._rightController._gazeTracker&&this._rightController._gazeTracker.dispose(),this._cameraGazer._gazeTracker=e,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name="gazeTracker",this._leftController&&(this._leftController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")),this._rightController&&(this._rightController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(this._rightController&&this._rightController._activatePointer(),this._leftController&&this._leftController._activatePointer()):(this._rightController&&(this._rightController._deactivatePointer(),this._rightController._gazeTracker.isVisible=!1),this._leftController&&(this._leftController._deactivatePointer(),this._leftController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!0,configurable:!0}),t.prototype._onDefaultMeshLoaded=function(t){this._leftController&&this._leftController.webVRController==t&&t.mesh&&this._leftController._setLaserPointerParent(t.mesh),this._rightController&&this._rightController.webVRController==t&&t.mesh&&this._rightController._setLaserPointerParent(t.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(t)}catch(t){e.Tools.Warn("Error in your custom logic onControllerMeshLoaded: "+t)}},Object.defineProperty(t.prototype,"isInVRMode",{get:function(){return this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!0,configurable:!0}),t.prototype.onVrDisplayPresentChange=function(){var t=this._scene.getEngine().getVRDevice();if(t){var i=this._webVRpresenting;this._webVRpresenting=t.isPresenting,i&&!this._webVRpresenting&&this.exitVR()}else e.Tools.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},t.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},t.prototype.moveButtonToBottomRight=function(){this._canvas&&!this._useCustomVRButton&&(this._btnVR.style.top=this._canvas.offsetTop+this._canvas.offsetHeight-70+"px",this._btnVR.style.left=this._canvas.offsetLeft+this._canvas.offsetWidth-100+"px")},t.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},t.prototype.updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode?this._btnVR.className+=" vrdisplaypresenting":(this._webVRready&&(this._btnVR.className+=" vrdisplayready"),this._webVRsupported&&(this._btnVR.className+=" vrdisplaysupported"),this._webVRrequesting&&(this._btnVR.className+=" vrdisplayrequesting")))},t.prototype.enterVR=function(){if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(t){e.Tools.Warn("Error in your custom logic onEnteringVR: "+t)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone(),this._existingCamera=this._scene.activeCamera),this._webVRrequesting||(this._webVRready?this._webVRpresenting||(this._webVRCamera.position=this._position,this._scene.activeCamera=this._webVRCamera):this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().switchFullscreen(!0),this.updateButtonVisibility()),this._scene.activeCamera&&this._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._hasEnteredVR=!0)},t.prototype.exitVR=function(){if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(t){e.Tools.Warn("Error in your custom logic onExitingVR: "+t)}this._webVRpresenting&&this._scene.getEngine().disableVR(),this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera),this.updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this.beforeRender),this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),this._hasEnteredVR=!1}},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!0,configurable:!0}),t.prototype.enableInteractions=function(){var e=this;this._interactionsEnabled||(this._interactionsRequested=!0,this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(e){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0)},Object.defineProperty(t.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),t.prototype._isTeleportationFloor=function(e){for(var t=0;t<this._floorMeshesCollection.length;t++)if(this._floorMeshesCollection[t].id===e.id)return!0;return!(!this._floorMeshName||e.name!==this._floorMeshName)},t.prototype.addFloorMesh=function(e){this._floorMeshesCollection&&(this._floorMeshesCollection.indexOf(e)>-1||this._floorMeshesCollection.push(e))},t.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},t.prototype.enableTeleportation=function(t){if(void 0===t&&(t={}),!this._teleportationInitialized){this._teleportationRequested=!0,this.enableInteractions(),t.floorMeshName&&(this._floorMeshName=t.floorMeshName),t.floorMeshes&&(this._floorMeshesCollection=t.floorMeshes),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var i=new e.ImageProcessingConfiguration;i.vignetteColor=new e.Color4(0,0,0,0),i.vignetteEnabled=!0,this._postProcessMove=new e.ImageProcessingPostProcess("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,i),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},t.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add(function(i){t._displayLaserPointer&&1===i.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))}),e.webVRController.onTriggerStateChangedObservable.add(function(i){var r=e;t._noControllerIsActive&&(r=t._cameraGazer),r._pointerDownOnMeshAsked?i.value<t._padSensibilityDown&&r._selectionPointerUp():i.value>t._padSensibilityUp&&r._selectionPointerDown()}))},t.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)<this._padSensibilityDown&&(this._teleportActive&&this.teleportCamera(this._haloCenter),t._teleportationRequestInitiated=!1):e.y<-this._padSensibilityUp&&t._dpadPressed&&(t._activatePointer(),t._teleportationRequestInitiated=!0))},t.prototype._checkRotate=function(e,t){t._teleportationRequestInitiated||(t._rotationLeftAsked?e.x>-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.x<this._padSensibilityDown&&(t._rotationRightAsked=!1):e.x>this._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},t.prototype._checkTeleportBackwards=function(t,i){if(!i._teleportationRequestInitiated)if(t.y>this._padSensibilityUp&&i._dpadPressed){if(!i._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var r=e.Quaternion.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),n=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(r=this.currentVRCamera.deviceRotationQuaternion,n=this.currentVRCamera.devicePosition),r.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,e.Quaternion.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),e.Vector3.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var o=new e.Ray(n,this._workingVector),s=this._scene.pickWithRay(o,this._raySelectionPredicate);s&&s.pickedPoint&&s.pickedMesh&&this._isTeleportationFloor(s.pickedMesh)&&s.distance<5&&this.teleportCamera(s.pickedPoint),i._teleportationBackRequestInitiated=!0}}else i._teleportationBackRequestInitiated=!1},t.prototype._enableTeleportationOnController=function(t){var i=this;t.webVRController.mesh&&(t._interactionsEnabled||this._enableInteractionOnController(t),t._interactionsEnabled=!0,t._teleportationEnabled=!0,t.webVRController.controllerType===e.PoseEnabledControllerType.VIVE&&(t._dpadPressed=!1,t.webVRController.onPadStateChangedObservable.add(function(e){t._dpadPressed=e.pressed,t._dpadPressed||(t._rotationLeftAsked=!1,t._rotationRightAsked=!1,t._teleportationBackRequestInitiated=!1)})),t.webVRController.onPadValuesChangedObservable.add(function(e){i.teleportationEnabled&&(i._checkTeleportBackwards(e,t),i._checkTeleportWithRay(e,t)),i._checkRotate(e,t)}))},t.prototype._createTeleportationCircles=function(){this._teleportationTarget=e.Mesh.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var t=new e.DynamicTexture("DynamicTexture",512,this._scene,!0);t.hasAlpha=!0;var i=t.getContext();i.beginPath(),i.arc(256,256,200,0,2*Math.PI,!1),i.fillStyle=this._teleportationFillColor,i.fill(),i.lineWidth=10,i.strokeStyle=this._teleportationBorderColor,i.stroke(),i.closePath(),t.update();var r=new e.StandardMaterial("TextPlaneMaterial",this._scene);r.diffuseTexture=t,this._teleportationTarget.material=r;var n=e.Mesh.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);n.isPickable=!1,n.parent=this._teleportationTarget;var o=new e.Animation("animationInnerCircle","position.y",30,e.Animation.ANIMATIONTYPE_FLOAT,e.Animation.ANIMATIONLOOPMODE_CYCLE),s=[];s.push({frame:0,value:0}),s.push({frame:30,value:.4}),s.push({frame:60,value:0}),o.setKeys(s);var a=new e.SineEase;a.setEasingMode(e.EasingFunction.EASINGMODE_EASEINOUT),o.setEasingFunction(a),n.animations=[],n.animations.push(o),this._scene.beginAnimation(n,0,60,!0),this._hideTeleportationTarget()},t.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},t.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},t.prototype._rotateCamera=function(t){var i=this;if(this.currentVRCamera instanceof e.FreeCamera){t?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var r=e.Quaternion.FromRotationMatrix(e.Matrix.RotationY(Math.PI/4*this._rotationAngle)),n=new e.Animation("animationRotation","rotationQuaternion",90,e.Animation.ANIMATIONTYPE_QUATERNION,e.Animation.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),o.push({frame:6,value:r}),n.setKeys(o),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var s=new e.Animation("animationPP","vignetteWeight",90,e.Animation.ANIMATIONTYPE_FLOAT,e.Animation.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:3,value:4}),a.push({frame:6,value:0}),s.setKeys(a),s.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(s);var l=new e.Animation("animationPP2","vignetteStretch",90,e.Animation.ANIMATIONTYPE_FLOAT,e.Animation.ANIMATIONLOOPMODE_CONSTANT),c=[];c.push({frame:0,value:0}),c.push({frame:3,value:10}),c.push({frame:6,value:0}),l.setKeys(c),l.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(l),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,function(){i._webVRCamera.detachPostProcess(i._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},t.prototype._moveTeleportationSelectorTo=function(t,i,r){if(t.pickedPoint){i._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(t.pickedPoint),this._teleportationTarget.position.copyFrom(t.pickedPoint));var n=this._convertNormalToDirectionOfRay(t.getNormal(!0,!1),r);if(n){var o=e.Vector3.Cross(e.Axis.Y,n),s=e.Vector3.Cross(n,o);e.Vector3.RotationFromAxisToRef(s,n,o,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},t.prototype.teleportCamera=function(t){var i=this;if(this.currentVRCamera instanceof e.FreeCamera){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),t.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(t),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this.currentVRCamera.animations=[];var r=new e.Animation("animationCameraTeleportation","position",90,e.Animation.ANIMATIONTYPE_VECTOR3,e.Animation.ANIMATIONLOOPMODE_CONSTANT),n=[{frame:0,value:this.currentVRCamera.position},{frame:11,value:this._workingVector}];r.setKeys(n),r.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(r),this._postProcessMove.animations=[];var o=new e.Animation("animationPP","vignetteWeight",90,e.Animation.ANIMATIONTYPE_FLOAT,e.Animation.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:5,value:8}),s.push({frame:11,value:0}),o.setKeys(s),this._postProcessMove.animations.push(o);var a=new e.Animation("animationPP2","vignetteStretch",90,e.Animation.ANIMATIONTYPE_FLOAT,e.Animation.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:5,value:10}),l.push({frame:11,value:0}),a.setKeys(l),this._postProcessMove.animations.push(a),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,11,!1,1,function(){i._webVRCamera.detachPostProcess(i._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,11,!1,1,function(){i.onAfterCameraTeleport.notifyObservers(i._workingVector)}),this._hideTeleportationTarget()}},t.prototype._convertNormalToDirectionOfRay=function(t,i){t&&(Math.acos(e.Vector3.Dot(t,i.direction))<Math.PI/2&&t.scaleInPlace(-1));return t},t.prototype._castRayAndSelectObject=function(t){if(this.currentVRCamera instanceof e.FreeCamera){var i=t._getForwardRay(this._rayLength),r=this._scene.pickWithRay(i,this._raySelectionPredicate);if(r&&(t._laserPointer&&(r.originMesh=t._laserPointer.parent),this._scene.simulatePointerMove(r,{pointerId:t._id})),t._currentHit=r,r&&r.pickedPoint){if(this._displayGaze){var n=1;t._gazeTracker.isVisible=!0,t._isActionableMesh&&(n=3),this.updateGazeTrackerScale&&(t._gazeTracker.scaling.x=r.distance*n,t._gazeTracker.scaling.y=r.distance*n,t._gazeTracker.scaling.z=r.distance*n);var o=this._convertNormalToDirectionOfRay(r.getNormal(),i);if(o){var s=e.Vector3.Cross(e.Axis.Y,o),a=e.Vector3.Cross(o,s);e.Vector3.RotationFromAxisToRef(a,o,s,t._gazeTracker.rotation)}t._gazeTracker.position.copyFrom(r.pickedPoint),t._gazeTracker.position.x<0?t._gazeTracker.position.x+=.002:t._gazeTracker.position.x-=.002,t._gazeTracker.position.y<0?t._gazeTracker.position.y+=.002:t._gazeTracker.position.y-=.002,t._gazeTracker.position.z<0?t._gazeTracker.position.z+=.002:t._gazeTracker.position.z-=.002}t._updatePointerDistance(r.distance)}else t._updatePointerDistance(),t._gazeTracker.isVisible=!1;if(r&&r.pickedMesh){if(this._teleportationInitialized&&this._isTeleportationFloor(r.pickedMesh)&&r.pickedPoint)return t._currentMeshSelected&&!this._isTeleportationFloor(t._currentMeshSelected)&&this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,void(t._teleportationRequestInitiated&&this._moveTeleportationSelectorTo(r,t,i));if(r.pickedMesh!==t._currentMeshSelected)if(this.meshSelectionPredicate(r.pickedMesh)){this.onNewMeshPicked.notifyObservers(r),t._currentMeshSelected=r.pickedMesh,r.pickedMesh.isPickable&&r.pickedMesh.actionManager?(this.changeGazeColor(new e.Color3(0,0,1)),this.changeLaserColor(new e.Color3(.2,.2,1)),t._isActionableMesh=!0):(this.changeGazeColor(new e.Color3(.7,.7,.7)),this.changeLaserColor(new e.Color3(.7,.7,.7)),t._isActionableMesh=!1);try{this.onNewMeshSelected.notifyObservers(r.pickedMesh)}catch(t){e.Tools.Warn("Error in your custom logic onNewMeshSelected: "+t)}}else this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,this.changeGazeColor(new e.Color3(.7,.7,.7)),this.changeLaserColor(new e.Color3(.7,.7,.7))}else this._notifySelectedMeshUnselected(t._currentMeshSelected),t._currentMeshSelected=null,this.changeGazeColor(new e.Color3(.7,.7,.7)),this.changeLaserColor(new e.Color3(.7,.7,.7))}},t.prototype._notifySelectedMeshUnselected=function(e){e&&this.onSelectedMeshUnselected.notifyObservers(e)},t.prototype.changeLaserColor=function(e){this._leftController&&this._leftController._setLaserPointerColor(e),this._rightController&&this._rightController._setLaserPointerColor(e)},t.prototype.changeGazeColor=function(e){this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=e,this._leftController&&(this._leftController._gazeTracker.material.emissiveColor=e),this._rightController&&(this._rightController._gazeTracker.material.emissiveColor=e))},t.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._webVRCamera&&this._webVRCamera.dispose(),this._vrDeviceOrientationCamera&&this._vrDeviceOrientationCamera.dispose(),!this._useCustomVRButton&&this._btnVR.parentNode&&document.body.removeChild(this._btnVR),this._deviceOrientationCamera&&this._scene.activeCamera!=this._deviceOrientationCamera&&this._deviceOrientationCamera.dispose(),this._cameraGazer&&this._cameraGazer.dispose(),this._leftController&&this._leftController.dispose(),this._rightController&&this._rightController.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this._floorMeshesCollection=[],document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.onmsfullscreenchange=null,this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),this._scene.unregisterBeforeRender(this.beforeRender)},t.prototype.getClassName=function(){return"VRExperienceHelper"},t}();e.VRExperienceHelper=n}(a||(a={})),function(e){var t;!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(t=e.JoystickAxis||(e.JoystickAxis={}));var i=function(){function i(r){var n=this;if(this._leftJoystick=!!r,i._globalJoystickIndex++,this._axisTargetedByLeftAndRight=t.X,this._axisTargetedByUpAndDown=t.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new e.StringDictionary,this.deltaPosition=e.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(e){i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas&&(i.vjCanvas.width=i.vjCanvasWidth,i.vjCanvas.height=i.vjCanvasHeight),i.halfWidth=i.vjCanvasWidth/2},!i.vjCanvas){window.addEventListener("resize",this._onResize,!1),i.vjCanvas=document.createElement("canvas"),i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=window.innerWidth,i.vjCanvas.height=window.innerHeight,i.vjCanvas.style.width="100%",i.vjCanvas.style.height="100%",i.vjCanvas.style.position="absolute",i.vjCanvas.style.backgroundColor="transparent",i.vjCanvas.style.top="0px",i.vjCanvas.style.left="0px",i.vjCanvas.style.zIndex="5",i.vjCanvas.style.msTouchAction="none",i.vjCanvas.setAttribute("touch-action","none");var o=i.vjCanvas.getContext("2d");if(!o)throw new Error("Unable to create canvas for virtual joystick");i.vjCanvasContext=o,i.vjCanvasContext.strokeStyle="#ffffff",i.vjCanvasContext.lineWidth=2,document.body.appendChild(i.vjCanvas)}i.halfWidth=i.vjCanvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new e.Vector2(0,0),this._joystickPreviousPointerPos=new e.Vector2(0,0),this._joystickPointerStartPos=new e.Vector2(0,0),this._deltaJoystickVector=new e.Vector2(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},i.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),i.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),i.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return i.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},i.prototype._onPointerDown=function(e){e.preventDefault(),(!0===this._leftJoystick?e.clientX<i.halfWidth:e.clientX>i.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}var r=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}}else{var n=this._touches.get(e.pointerId.toString());n&&(n.x=e.clientX,n.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach(function(t,r){r.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-64,e._joystickPointerStartPos.y-64,128,128),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-42,e._joystickPreviousPointerPos.y-42,84,84),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)}),requestAnimationFrame(function(){e._drawVirtualJoystick()})},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i._globalJoystickIndex=0,i}();e.VirtualJoystick=i}(a||(a={})),function(e){e.Node.AddNodeConstructor("VirtualJoysticksCamera",function(i,r){return function(){return new t(i,e.Vector3.Zero(),r)}});var t=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return o(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(e.FreeCamera);e.VirtualJoysticksCamera=t}(a||(a={})),function(e){var t=function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t}();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t}(a||(a={})),function(e){var t=function(){return function(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}}();e.SimplificationSettings=t;var i,r=function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach(function(e){i.getSimplifier(t).simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()})});else{var r=this.getSimplifier(t);e.AsyncLoop.Run(t.settings.length,function(e){!function(e,i){r.simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()})}(t.settings[e.index],function(){e.executeNext()})},function(){t.successCallback&&t.successCallback(),i.executeNext()})}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case i.QUADRATIC:default:return new l(e.mesh)}},t}();e.SimplificationQueue=r,function(e){e[e.QUADRATIC=0]="QUADRATIC"}(i=e.SimplificationType||(e.SimplificationType={}));var n=function(){return function(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}}(),o=function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e}(),s=function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,l){return this.data[e]*this.data[n]*this.data[l]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[l]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e}(),a=function(){return function(e,t){this.vertexId=e,this.triangleId=t}}(),l=function(){function t(t){this._mesh=t,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,function(e){r.initWithMesh(e.index,function(){r.runDecimation(t,e.index,function(){e.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){i(r._reconstructedMesh)},0)})},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length;e.AsyncLoop.Run(this.decimationIterations,function(t){a-s<=o?t.breakLoop():function(t,i){setTimeout(function(){t%5==0&&n.updateMesh(0===t);for(var r=0;r<n.triangles.length;++r)n.triangles[r].isDirty=!1;var l=1e-9*Math.pow(t+3,n.aggressiveness);e.AsyncLoop.SyncAsyncForLoop(n.triangles.length,n.syncIterations,function(t){var i=~~((n.triangles.length/2+t)%n.triangles.length),r=n.triangles[i];if(r&&!(r.error[3]>l||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]<l){var a=[],c=[],u=r.vertices[o],h=r.vertices[(o+1)%3];if(u.isBorder||h.isBorder)continue;var d=e.Vector3.Zero(),f=e.Vector3.Zero(),p=e.Vector2.Zero(),m=new e.Color4(0,0,0,1);n.calculateError(u,h,d,f,p,m);var g=new Array;if(n.isFlipped(u,h,d,a,r.borderFactor,g))continue;if(n.isFlipped(h,u,d,c,r.borderFactor,g))continue;if(a.indexOf(!0)<0||c.indexOf(!0)<0)continue;var _=new Array;if(g.forEach(function(e){-1===_.indexOf(e)&&(e.deletePending=!0,_.push(e))}),_.length%2!=0)continue;u.q=h.q.add(u.q),u.updatePosition(d);var v=n.references.length;s=n.updateTriangles(u,u,a,s),s=n.updateTriangles(u,h,c,s);var A=n.references.length-v;if(A<=u.triangleCount){if(A)for(var y=0;y<A;y++)n.references[u.triangleStart+y]=n.references[v+y]}else u.triangleStart=v;u.triangleCount=A;break}},i,function(){return a-s<=o})},0)}(t.index,function(){t.executeNext()})},function(){setTimeout(function(){n.reconstructMesh(i),r()},0)})},t.prototype.initWithMesh=function(t,i,r){var s=this;this.vertices=[],this.triangles=[];var a=this._mesh.getVerticesData(e.VertexBuffer.PositionKind),l=this._mesh.getIndices(),c=this._mesh.subMeshes[t],u=[],h=c.verticesCount;e.AsyncLoop.SyncAsyncForLoop(h,this.syncIterations/4>>0,function(t){if(a){var i=t+c.verticesStart,n=e.Vector3.FromArray(a,3*i),l=function(e){if(r)for(var t=0;t<s.vertices.length;++t)if(s.vertices[t].position.equals(e))return s.vertices[t];return null}(n)||new o(n,s.vertices.length);l.originalOffsets.push(i),l.id===s.vertices.length&&s.vertices.push(l),u.push(l.id)}},function(){e.AsyncLoop.SyncAsyncForLoop(c.indexCount/3,s.syncIterations,function(e){if(l){var t=3*(c.indexStart/3+e),i=l[t+0],r=l[t+1],o=l[t+2],a=s.vertices[u[i-c.verticesStart]],h=s.vertices[u[r-c.verticesStart]],d=s.vertices[u[o-c.verticesStart]],f=new n([a,h,d]);f.originalOffset=t,s.triangles.push(f)}},function(){s.init(i)})})},t.prototype.init=function(t){var i=this;e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();for(var n=0;n<3;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))},function(){e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,function(e){for(var t=i.triangles[e],r=0;r<3;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])},function(){t()})})},t.prototype.reconstructMesh=function(t){var i,r,n,o=[];for(i=0;i<this.vertices.length;++i)this.vertices[i].triangleCount=0;for(i=0;i<this.triangles.length;++i)if(!this.triangles[i].deleted){for(r=this.triangles[i],n=0;n<3;++n)r.vertices[n].triangleCount=1;o.push(r)}var s=this._reconstructedMesh.getVerticesData(e.VertexBuffer.PositionKind)||[],a=this._reconstructedMesh.getVerticesData(e.VertexBuffer.NormalKind)||[],l=this._reconstructedMesh.getVerticesData(e.VertexBuffer.UVKind)||[],c=this._reconstructedMesh.getVerticesData(e.VertexBuffer.ColorKind)||[],u=this._mesh.getVerticesData(e.VertexBuffer.NormalKind),h=this._mesh.getVerticesData(e.VertexBuffer.UVKind),d=this._mesh.getVerticesData(e.VertexBuffer.ColorKind),f=0;for(i=0;i<this.vertices.length;++i){var p=this.vertices[i];p.id=f,p.triangleCount&&p.originalOffsets.forEach(function(e){u&&(s.push(p.position.x),s.push(p.position.y),s.push(p.position.z),a.push(u[3*e]),a.push(u[3*e+1]),a.push(u[3*e+2]),h&&h.length?(l.push(h[2*e]),l.push(h[2*e+1])):d&&d.length&&(c.push(d[4*e]),c.push(d[4*e+1]),c.push(d[4*e+2]),c.push(d[4*e+3])),++f)})}var m=this._reconstructedMesh.getTotalIndices(),g=this._reconstructedMesh.getTotalVertices(),_=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var v=this._reconstructedMesh.getIndices(),A=this._mesh.getIndices();for(i=0;i<o.length;++i)r=o[i],[0,1,2].forEach(function(e){var t=A[r.originalOffset+e],i=r.vertices[e].originalOffsets.indexOf(t);i<0&&(i=0),v.push(r.vertices[e].id+i+g)});this._reconstructedMesh.setIndices(v),this._reconstructedMesh.setVerticesData(e.VertexBuffer.PositionKind,s),this._reconstructedMesh.setVerticesData(e.VertexBuffer.NormalKind,a),l.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,l),c.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,c);var y=this._mesh.subMeshes[t];t>0&&(this._reconstructedMesh.subMeshes=[],_.forEach(function(t){e.SubMesh.AddToMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())}),e.SubMesh.AddToMesh(y.materialIndex,g,f,m,3*o.length,this._reconstructedMesh))},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a<t.triangleCount;++a){var l=this.triangles[this.references[t.triangleStart+a].triangleId];if(!l.deleted){var c=this.references[t.triangleStart+a].vertexId,u=l.vertices[(c+1)%3],h=l.vertices[(c+2)%3];if(u!==i&&h!==i){var d=u.position.subtract(r);d=d.normalize();var f=h.position.subtract(r);if(f=f.normalize(),Math.abs(e.Vector3.Dot(d,f))>.999)return!0;var p=e.Vector3.Cross(d,f).normalize();if(n[a]=!1,e.Vector3.Dot(p,l.normal)<.2)return!0}else n[a]=!0,s.push(l)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o<t.triangleCount;++o){var s=this.references[t.triangleStart+o],a=this.triangles[s.triangleId];a.deleted||(i[o]&&a.deletePending?(a.deleted=!0,n++):(a.vertices[s.vertexId]=e,a.isDirty=!0,a.error[0]=this.calculateError(a.vertices[0],a.vertices[1])+a.borderFactor/2,a.error[1]=this.calculateError(a.vertices[1],a.vertices[2])+a.borderFactor/2,a.error[2]=this.calculateError(a.vertices[2],a.vertices[0])+a.borderFactor/2,a.error[3]=Math.min(a.error[0],a.error[1],a.error[2]),this.references.push(s)))}return n},t.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],r=[],n=this.vertices[e];for(t=0;t<n.triangleCount;++t)for(var o=this.triangles[this.references[n.triangleStart+t].triangleId],s=0;s<3;s++){for(var a=0,l=o.vertices[s];a<i.length&&r[a]!==l.id;)++a;a===i.length?(i.push(1),r.push(l.id)):i[a]++}for(t=0;t<i.length;++t)1===i[t]?this.vertices[r[t]].isBorder=!0:this.vertices[r[t]].isBorder=!1}},t.prototype.updateMesh=function(e){var t,i,r,n;if(void 0===e&&(e=!1),!e){var o=[];for(t=0;t<this.triangles.length;++t)this.triangles[t].deleted||o.push(this.triangles[t]);this.triangles=o}for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0,this.vertices[t].triangleStart=0;for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)(n=i.vertices[r]).triangleCount++;var s=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=s,s+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var l=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)l[(n=i.vertices[r]).triangleStart+n.triangleCount]=new a(r,t),n.triangleCount++;this.references=l,e&&this.identifyBorder()},t.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},t.prototype.calculateError=function(t,i,r,n,o,s){var a=t.q.add(i.q),l=t.isBorder&&i.isBorder,c=0,u=a.det(0,1,2,1,4,5,2,5,7);if(0===u||l){var h=t.position.add(i.position).divide(new e.Vector3(2,2,2)),d=this.vertexError(a,t.position),f=this.vertexError(a,i.position),p=this.vertexError(a,h);(c=Math.min(d,f,p))===d?r&&r.copyFrom(t.position):c===f?r&&r.copyFrom(i.position):r&&r.copyFrom(h)}else r||(r=e.Vector3.Zero()),r.x=-1/u*a.det(1,2,3,4,5,6,5,7,8),r.y=1/u*a.det(0,2,3,1,5,6,2,7,8),r.z=-1/u*a.det(0,1,3,1,4,6,2,5,8),c=this.vertexError(a,r);return c},t}()}(a||(a={})),function(e){Object.defineProperty(e.Scene.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new e.SimplificationQueue;var i=this._getComponent(e.SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE);i||(i=new t(this),this._addComponent(i))}return this._simplificationQueue},set:function(e){this._simplificationQueue=e},enumerable:!0,configurable:!0}),e.Mesh.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};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE,this.scene=t}return t.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(e.SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE,this,this._beforeCameraUpdate)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){},t.prototype._beforeCameraUpdate=function(){this.scene._simplificationQueue&&!this.scene._simplificationQueue.running&&this.scene._simplificationQueue.executeNext()},t}();e.SimplicationQueueSceneComponent=t}(a||(a={})),function(e){var t=function(){return function(e,t){this.distance=e,this.mesh=t}}();e.MeshLODLevel=t}(a||(a={})),function(e){var t=function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return""},e.prototype.apply=function(e,t){return!0},e}();e.SceneOptimization=t;var i=function(e){function t(t,i,r){void 0===t&&(t=0),void 0===i&&(i=1024),void 0===r&&(r=.5);var n=e.call(this,t)||this;return n.priority=t,n.maximumSize=i,n.step=r,n}return o(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var i=!0,r=0;r<e.textures.length;r++){var n=e.textures[r];if(n.canRescale&&!n.getContext){var o=n.getSize();Math.max(o.width,o.height)>this.maximumSize&&(n.scale(this.step),i=!1)}}return i},t}(t);e.TextureOptimization=i;var r=function(e){function t(t,i,r){void 0===t&&(t=0),void 0===i&&(i=2),void 0===r&&(r=.25);var n=e.call(this,t)||this;return n.priority=t,n.maximumScale=i,n.step=r,n._currentScale=-1,n._directionOffset=1,n}return o(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(t);e.HardwareScalingOptimization=r;var n=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(t);e.ShadowsOptimization=n;var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(t);e.PostProcessesOptimization=s;var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(t);e.LensFlaresOptimization=a;var l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(t);e.CustomOptimization=l;var c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(t);e.ParticlesOptimization=c;var u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(t);e.RenderTargetsOptimization=u;var h=function(t){function i(){var i=null!==t&&t.apply(this,arguments)||this;return i._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!i.isDisposed()&&(!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels)))},i}return o(i,t),Object.defineProperty(i,"UpdateSelectionTree",{get:function(){return i._UpdateSelectionTree},set:function(e){i._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),i.prototype.getDescription=function(){return"Merging similar meshes together"},i.prototype.apply=function(t,r,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a<s;a++){var l=new Array,c=o[a];if(this._canBeMerged(c)){l.push(c);for(var u=a+1;u<s;u++){var h=o[u];this._canBeMerged(h)&&(h.material===c.material&&h.checkCollisions===c.checkCollisions&&(l.push(h),s--,o.splice(u,1),u--))}l.length<2||e.Mesh.MergeMeshes(l,void 0,!0)}}var d=t;return d.createOrUpdateSelectionOctree&&(void 0!=n?n&&d.createOrUpdateSelectionOctree():i.UpdateSelectionTree&&d.createOrUpdateSelectionOctree()),!0},i._UpdateSelectionTree=!1,i}(t);e.MergeMeshesOptimization=h;var d=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.prototype.addOptimization=function(e){return this.optimizations.push(e),this},e.prototype.addCustomOptimization=function(e,t,i){void 0===i&&(i=0);var r=new l(i);return r.onApply=e,r.onGetDescription=t,this.optimizations.push(r),this},e.LowDegradationAllowed=function(t){var r=new e(t),o=0;return r.addOptimization(new h(o)),r.addOptimization(new n(o)),r.addOptimization(new a(o)),o++,r.addOptimization(new s(o)),r.addOptimization(new c(o)),o++,r.addOptimization(new i(o,1024)),r},e.ModerateDegradationAllowed=function(t){var o=new e(t),l=0;return o.addOptimization(new h(l)),o.addOptimization(new n(l)),o.addOptimization(new a(l)),l++,o.addOptimization(new s(l)),o.addOptimization(new c(l)),l++,o.addOptimization(new i(l,512)),l++,o.addOptimization(new u(l)),l++,o.addOptimization(new r(l,2)),o},e.HighDegradationAllowed=function(t){var o=new e(t),l=0;return o.addOptimization(new h(l)),o.addOptimization(new n(l)),o.addOptimization(new a(l)),l++,o.addOptimization(new s(l)),o.addOptimization(new c(l)),l++,o.addOptimization(new i(l,256)),l++,o.addOptimization(new u(l)),l++,o.addOptimization(new r(l,4)),o},e}();e.SceneOptimizerOptions=d;var f=function(){function t(t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=!1);var o=this;if(this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new e.Observable,this.onNewOptimizationAppliedObservable=new e.Observable,this.onFailureObservable=new e.Observable,this._options=i||new d,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),r)for(var s=0,a=0,l=this._options.optimizations;a<l.length;a++){l[a].priority=s++}this._improvementMode=n,this._scene=t||e.Engine.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(t.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(e){this._targetFrameRate=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(e){this._trackerDuration=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!0,configurable:!0}),t.prototype.stop=function(){this._isRunning=!1},t.prototype.reset=function(){this._currentPriorityLevel=0},t.prototype.start=function(){var e=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){e._checkCurrentState()},e._trackerDuration)}))},t.prototype._checkCurrentState=function(){var e=this;if(this._isRunning){var t=this._scene,i=this._options;if(this._currentFrameRate=Math.round(t.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,n=!0,o=0;o<i.optimizations.length;o++){var s=i.optimizations[o];s.priority===this._currentPriorityLevel&&(n=!1,r=r&&s.apply(t,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(n)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);r&&this._currentPriorityLevel++,t.executeWhenReady(function(){setTimeout(function(){e._checkCurrentState()},e._trackerDuration)})}},t.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},t.OptimizeAsync=function(e,i,r,n){var o=new t(e,i||d.ModerateDegradationAllowed(),!1);return r&&o.onSuccessObservable.add(function(){r()}),n&&o.onFailureObservable.add(function(){n()}),o.start(),o},t}();e.SceneOptimizer=f}(a||(a={})),function(e){e.Scene.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new t(this)),this._outlineRenderer},Object.defineProperty(e.AbstractMesh.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=t,this._engine=t.getEngine(),this.scene._addComponent(this)}return t.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(e.SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(e.SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},t.prototype.rebuild=function(){},t.prototype.dispose=function(){},t.prototype.render=function(t,i,r){var n=this;void 0===r&&(r=!1);var o=this.scene,s=o.getEngine(),a=s.getCaps().instancedArrays&&null!==i.visibleInstances[t._id]&&void 0!==i.visibleInstances[t._id];if(this.isReady(t,a)){var l=t.getRenderingMesh(),c=t.getMaterial();if(c&&o.activeCamera){if(s.enableEffect(this._effect),c.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(o.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",r?0:l.outlineWidth),this._effect.setColor4("color",r?l.overlayColor:l.outlineColor,r?l.overlayAlpha:c.alpha),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),l.useBones&&l.computeBonesUsingShaders&&l.skeleton&&this._effect.setMatrices("mBones",l.skeleton.getTransformMatrices(l)),l._bind(t,this._effect,e.Material.TriangleFillMode),c&&c.needAlphaTesting()){var u=c.getAlphaTestTexture();u&&(this._effect.setTexture("diffuseSampler",u),this._effect.setMatrix("diffuseMatrix",u.getTextureMatrix()))}s.setZOffset(-this.zOffset),l._processRendering(t,this._effect,e.Material.TriangleFillMode,i,a,function(e,t){n._effect.setMatrix("world",t)}),s.setZOffset(0)}}},t.prototype.isReady=function(t,i){var r=[],n=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],o=t.getMesh(),s=t.getMaterial();s&&(s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),s.useLogarithmicDepth&&r.push("#define LOGARITHMICDEPTH")),o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this.scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype._beforeRenderingMesh=function(e,t,i){this._savedDepthWrite=this._engine.getDepthWrite(),e.renderOutline&&(this._engine.setDepthWrite(!1),this.render(t,i),this._engine.setDepthWrite(this._savedDepthWrite))},t.prototype._afterRenderingMesh=function(t,i,r){if(t.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(i,r),this._engine.setColorWrite(!0)),t.renderOverlay){var n=this._engine.getAlphaMode();this._engine.setAlphaMode(e.Engine.ALPHA_COMBINE),this.render(i,r,!0),this._engine.setAlphaMode(n)}},t}();e.OutlineRenderer=t}(a||(a={})),function(e){e.AbstractMesh.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},e.AbstractMesh.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new i(this,e,t),this},Object.defineProperty(e.AbstractMesh.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),e.LinesMesh.prototype.enableEdgesRendering=function(t,i){return void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.LineEdgesRenderer(this,t,i),this};var t=function(){return function(){this.edges=new Array,this.edgesConnectedCount=0}}(),i=function(){function i(e,t,i,r){void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===r&&(r=!0);var n=this;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),r&&this._generateEdgesLines(),this._meshRebuildObserver=this._source.onRebuildObservable.add(function(){n._rebuild()}),this._meshDisposeObserver=this._source.onDisposeObservable.add(function(){n.dispose()})}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype._rebuild=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),(t=this._buffers[e.VertexBuffer.NormalKind])&&t._rebuild();var i=this._source.getScene().getEngine();this._ib=i.createIndexBuffer(this._linesIndices)},i.prototype.dispose=function(){this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),(t=this._buffers[e.VertexBuffer.NormalKind])&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;void 0===i?s=!0:s=e.Vector3.Dot(r[t],r[i])<this._epsilon;if(s){var a=this._linesPositions.length/3;n.subtract(o).normalize(),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(-1),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesIndices.push(a),this._linesIndices.push(a+1),this._linesIndices.push(a+2),this._linesIndices.push(a),this._linesIndices.push(a+2),this._linesIndices.push(a+3)}},i.prototype._generateEdgesLines=function(){var i=this._source.getVerticesData(e.VertexBuffer.PositionKind),r=this._source.getIndices();if(r&&i){var n,o,s=new Array,a=new Array;for(n=0;n<r.length;n+=3){o=new t;var l=r[n],c=r[n+1],u=r[n+2];o.p0=new e.Vector3(i[3*l],i[3*l+1],i[3*l+2]),o.p1=new e.Vector3(i[3*c],i[3*c+1],i[3*c+2]),o.p2=new e.Vector3(i[3*u],i[3*u+1],i[3*u+2]);var h=e.Vector3.Cross(o.p1.subtract(o.p0),o.p2.subtract(o.p1));h.normalize(),a.push(h),s.push(o)}for(n=0;n<s.length;n++){o=s[n];for(var d=n+1;d<s.length;d++){var f=s[d];if(3===o.edgesConnectedCount)break;if(3!==f.edgesConnectedCount)for(var p=r[3*d],m=r[3*d+1],g=r[3*d+2],_=0;_<3;_++){var v=0;if(void 0===o.edges[_]){switch(_){case 0:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(o.p0,o.p1,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(r[3*n],r[3*n+1],p,m,g);break;case 1:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(o.p1,o.p2,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(r[3*n+1],r[3*n+2],p,m,g);break;case 2:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(o.p2,o.p0,f.p0,f.p1,f.p2):this._processEdgeForAdjacencies(r[3*n+2],r[3*n],p,m,g)}if(-1!==v&&(o.edges[_]=d,f.edges[v]=n,o.edgesConnectedCount++,f.edgesConnectedCount++,3===o.edgesConnectedCount))break}}}}for(n=0;n<s.length;n++){var A=s[n];this._checkEdge(n,A.edges[0],a,A.p0,A.p1),this._checkEdge(n,A.edges[1],a,A.p1,A.p2),this._checkEdge(n,A.edges[2],a,A.p2,A.p0)}var y=this._source.getScene().getEngine();this._buffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(y,this._linesPositions,e.VertexBuffer.PositionKind,!1),this._buffers[e.VertexBuffer.NormalKind]=new e.VertexBuffer(y,this._linesNormals,e.VertexBuffer.NormalKind,!1,!1,4),this._ib=y.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},i.prototype.isReady=function(){return this._lineShader.isReady()},i.prototype.render=function(){var t=this._source.getScene();if(this.isReady()&&t.activeCamera){var i=t.getEngine();this._lineShader._preBind(),1!==this._source.edgesColor.a?i.setAlphaMode(e.Engine.ALPHA_COMBINE):i.setAlphaMode(e.Engine.ALPHA_DISABLE),i.bindBuffers(this._buffers,this._ib,this._lineShader.getEffect()),t.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),t.activeCamera.mode===e.Camera.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",i.getAspectRatio(t.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),i.drawElementsType(e.Material.TriangleFillMode,0,this._indicesCount),this._lineShader.unbind()}},i}();e.EdgesRenderer=i}(a||(a={})),function(e){var t=function(){return function(){this.edges=new Array,this.edgesConnectedCount=0}}(),i=function(i){function r(e,t,r){void 0===t&&(t=.95),void 0===r&&(r=!1);var n=i.call(this,e,t,r,!1)||this;return n._generateEdgesLines(),n}return o(r,i),r.prototype._checkEdge=function(e,t,i,r,n){var o=this._linesPositions.length/3;r.subtract(n).normalize(),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(-1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(1),this._linesIndices.push(o),this._linesIndices.push(o+1),this._linesIndices.push(o+2),this._linesIndices.push(o),this._linesIndices.push(o+2),this._linesIndices.push(o+3)},r.prototype._generateEdgesLines=function(){var i=this._source.getVerticesData(e.VertexBuffer.PositionKind);if(this._source.getIndices()&&i){for(var r,n=new Array,o=new Array,s=0;s<i.length/3-1;s++){var a=new t;a.p0=new e.Vector3(i[3*s],i[3*s+1],i[3*s+2]),a.p1=new e.Vector3(i[3*(s+1)],i[3*(s+1)+1],i[3*(s+1)+2]),n.push(a)}for(r=0;r<n.length;r++){var l=n[r];this._checkEdge(r,l.edges[0],o,l.p0,l.p1)}var c=this._source.getScene().getEngine();this._buffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,this._linesPositions,e.VertexBuffer.PositionKind,!1),this._buffers[e.VertexBuffer.NormalKind]=new e.VertexBuffer(c,this._linesNormals,e.VertexBuffer.NormalKind,!1,!1,4),this._ib=c.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},r}(e.EdgesRenderer);e.LineEdgesRenderer=i}(a||(a={})),function(e){e.AbstractScene.AddParser(e.SceneComponentConstants.NAME_EFFECTLAYER,function(t,i,r,n){if(t.effectLayers){r.effectLayers||(r.effectLayers=new Array);for(var o=0;o<t.effectLayers.length;o++){var s=e.EffectLayer.Parse(t.effectLayers[o],i,n);r.effectLayers.push(s)}}}),e.AbstractScene.prototype.removeEffectLayer=function(e){var t=this.effectLayers.indexOf(e);return-1!==t&&this.effectLayers.splice(t,1),t},e.AbstractScene.prototype.addEffectLayer=function(e){this.effectLayers.push(e)};var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_EFFECTLAYER,this._renderEffects=!1,this._needStencil=!1,this._previousStencilState=!1,this.scene=t,this._engine=t.getEngine(),t.effectLayers=new Array}return t.prototype.register=function(){this.scene._isReadyForMeshStage.registerStep(e.SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(e.SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW,this,this._drawCamera)},t.prototype.rebuild=function(){for(var e=0,t=this.scene.effectLayers;e<t.length;e++){t[e]._rebuild()}},t.prototype.serialize=function(e){e.effectLayers=[];for(var t=0,i=this.scene.effectLayers;t<i.length;t++){var r=i[t];r.serialize&&e.effectLayers.push(r.serialize())}},t.prototype.addFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach(function(e){t.scene.addEffectLayer(e)})},t.prototype.removeFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach(function(e){t.scene.removeEffectLayer(e)})},t.prototype.dispose=function(){for(var e=this.scene.effectLayers;e.length;)e[0].dispose()},t.prototype._isReadyForMesh=function(e,t){for(var i=0,r=this.scene.effectLayers;i<r.length;i++){var n=r[i];if(n.hasMesh(e))for(var o=0,s=e.subMeshes;o<s.length;o++){var a=s[o];if(!n.isReady(a,t))return!1}}return!0},t.prototype._renderMainTexture=function(t){this._renderEffects=!1,this._needStencil=!1;var i=this.scene.effectLayers;if(i&&i.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(var r=0,n=i;r<n.length;r++){var o=n[r];if(o.shouldRender()&&(!o.camera||o.camera.cameraRigMode===e.Camera.RIG_MODE_NONE&&t===o.camera||o.camera.cameraRigMode!==e.Camera.RIG_MODE_NONE&&o.camera._rigCameras.indexOf(t)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var s=o._mainTexture;s._shouldRender()&&(this.scene.incrementRenderId(),s.render(!1,!1))}}this.scene.incrementRenderId()}},t.prototype._setStencil=function(e){this._needStencil&&this._engine.setStencilBuffer(!0)},t.prototype._setStencilBack=function(e){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},t.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,i=0;i<t.length;i++){var r=t[i];r.renderingGroupId===e&&r.shouldRender()&&r.render()}this._engine.setDepthBuffer(!0)}},t.prototype._drawCamera=function(e){this._renderEffects&&this._draw(-1)},t.prototype._drawRenderingGroup=function(e){!this.scene._isInIntermediateRendering()&&this._renderEffects&&this._draw(e)},t}();e.EffectLayerSceneComponent=t}(a||(a={}));s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(e){var t=function(){function t(t,i){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new e.Color4},this.neutralColor=new e.Color4,this.isEnabled=!0,this.onDisposeObservable=new e.Observable,this.onBeforeRenderMainTextureObservable=new e.Observable,this.onBeforeComposeObservable=new e.Observable,this.onAfterComposeObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.name=t,this._scene=i||e.Engine.LastCreatedScene;var r=this._scene._getComponent(e.SceneComponentConstants.NAME_EFFECTLAYER);r||(r=new e.EffectLayerSceneComponent(this._scene),this._scene._addComponent(r)),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._generateIndexBuffer(),this._genrateVertexBuffer()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},enumerable:!0,configurable:!0}),t.prototype._init=function(t){this._effectLayerOptions=s({mainTextureRatio:.5,alphaBlendingMode:e.Engine.ALPHA_COMBINE,camera:null,renderingGroupId:-1},t),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mergeEffect=this._createMergeEffect()},t.prototype._generateIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._engine.createIndexBuffer(e)},t.prototype._genrateVertexBuffer=function(){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1);var i=new e.VertexBuffer(this._engine,t,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=i},t.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},t.prototype._createMainTexture=function(){var t=this;this._mainTexture=new e.RenderTargetTexture("HighlightLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(e,i,r,n){var o;t.onBeforeRenderMainTextureObservable.notifyObservers(t);var s=t._scene.getEngine();if(n.length){for(s.setColorWrite(!1),o=0;o<n.length;o++)t._renderSubMesh(n.data[o]);s.setColorWrite(!0)}for(o=0;o<e.length;o++)t._renderSubMesh(e.data[o]);for(o=0;o<i.length;o++)t._renderSubMesh(i.data[o]);for(o=0;o<r.length;o++)t._renderSubMesh(r.data[o])},this._mainTexture.onClearObservable.add(function(e){e.clear(t.neutralColor,!0,!0,!0)})},t.prototype._isReady=function(t,i,r){var n=t.getMaterial();if(!n)return!1;if(!n.isReady(t.getMesh(),i))return!1;var o=[],s=[e.VertexBuffer.PositionKind],a=t.getMesh(),l=!1,c=!1;if(n&&n.needAlphaTesting()){var u=n.getAlphaTestTexture();u&&(o.push("#define ALPHATEST"),a.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===u.coordinatesIndex?(o.push("#define DIFFUSEUV2"),c=!0):a.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push("#define DIFFUSEUV1"),l=!0))}r&&(o.push("#define EMISSIVE"),a.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===r.coordinatesIndex?(o.push("#define EMISSIVEUV2"),c=!0):a.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push("#define EMISSIVEUV1"),l=!0)),l&&(s.push(e.VertexBuffer.UVKind),o.push("#define UV1")),c&&(s.push(e.VertexBuffer.UV2Kind),o.push("#define UV2")),a.useBones&&a.computeBonesUsingShaders?(s.push(e.VertexBuffer.MatricesIndicesKind),s.push(e.VertexBuffer.MatricesWeightsKind),a.numBoneInfluencers>4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),o.push("#define BonesPerMesh "+(a.skeleton?a.skeleton.bones.length+1:0))):o.push("#define NUM_BONE_INFLUENCERS 0");var h=a.morphTargetManager,d=0;h&&h.numInfluencers>0&&(o.push("#define MORPHTARGETS"),d=h.numInfluencers,o.push("#define NUM_MORPH_INFLUENCERS "+d),e.MaterialHelper.PrepareAttributesForMorphTargets(s,a,{NUM_MORPH_INFLUENCERS:d})),i&&(o.push("#define INSTANCES"),s.push("world0"),s.push("world1"),s.push("world2"),s.push("world3"));var f=o.join("\n");return this._cachedDefines!==f&&(this._cachedDefines=f,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",s,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix","morphTargetInfluences"],["diffuseSampler","emissiveSampler"],f,void 0,void 0,void 0,{maxSimultaneousMorphTargets:d})),this._effectLayerMapGenerationEffect.isReady()},t.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t<this._postProcesses.length;t++)if(!this._postProcesses[t].isReady())return;var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(e),i.setState(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,e);var r=i.getAlphaMode();i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(e),i.setAlphaMode(r),this.onAfterComposeObservable.notifyObservers(this);var n=this._mainTexture.getSize();this._setMainTextureSize(),n.width===this._mainTextureDesiredSize.width&&n.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}},t.prototype.hasMesh=function(e){return-1===this.renderingGroupId||e.renderingGroupId===this.renderingGroupId},t.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},t.prototype._shouldRenderMesh=function(e){return!0},t.prototype._shouldRenderEmissiveTextureForMesh=function(e){return!0},t.prototype._renderSubMesh=function(t){var i=this;if(this.shouldRender()){var r=t.getMaterial(),n=t.getRenderingMesh(),o=this._scene,s=o.getEngine();if(r&&!r.needAlphaBlendingForMesh(n)){s.setState(r.backFaceCulling);var a=n._getInstancesRenderList(t._id);if(!a.mustReturn&&this._shouldRenderMesh(n)){var l=s.getCaps().instancedArrays&&null!==a.visibleInstances[t._id]&&void 0!==a.visibleInstances[t._id];if(this._setEmissiveTextureAndColor(n,t,r),this._isReady(t,l,this._emissiveTextureAndColor.texture)){if(s.enableEffect(this._effectLayerMapGenerationEffect),n._bind(t,this._effectLayerMapGenerationEffect,e.Material.TriangleFillMode),this._effectLayerMapGenerationEffect.setMatrix("viewProjection",o.getTransformMatrix()),this._effectLayerMapGenerationEffect.setFloat4("color",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a),r&&r.needAlphaTesting()){var c=r.getAlphaTestTexture();if(c){this._effectLayerMapGenerationEffect.setTexture("diffuseSampler",c);var u=c.getTextureMatrix();u&&this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix",u)}}this._emissiveTextureAndColor.texture&&(this._effectLayerMapGenerationEffect.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),n.useBones&&n.computeBonesUsingShaders&&n.skeleton&&this._effectLayerMapGenerationEffect.setMatrices("mBones",n.skeleton.getTransformMatrices(n)),e.MaterialHelper.BindMorphTargetParameters(n,this._effectLayerMapGenerationEffect),n._processRendering(t,this._effectLayerMapGenerationEffect,e.Material.TriangleFillMode,a,l,function(e,t){return i._effectLayerMapGenerationEffect.setMatrix("world",t)})}else this._mainTexture.resetRefreshCounter()}}}},t.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),this._generateIndexBuffer()},t.prototype._disposeTextureAndPostProcesses=function(){this._mainTexture.dispose();for(var e=0;e<this._postProcesses.length;e++)this._postProcesses[e]&&this._postProcesses[e].dispose();this._postProcesses=[];for(e=0;e<this._textures.length;e++)this._textures[e]&&this._textures[e].dispose();this._textures=[]},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),this._disposeTextureAndPostProcesses();var i=this._scene.effectLayers.indexOf(this,0);i>-1&&this._scene.effectLayers.splice(i,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},t.prototype.getClassName=function(){return"EffectLayer"},t.Parse=function(t,i,r){return e.Tools.Instantiate(t.customType).Parse(t,i,r)},n([e.serialize()],t.prototype,"name",void 0),n([e.serializeAsColor4()],t.prototype,"neutralColor",void 0),n([e.serialize()],t.prototype,"isEnabled",void 0),n([e.serializeAsCameraReference()],t.prototype,"camera",null),n([e.serialize()],t.prototype,"renderingGroupId",null),t}();e.EffectLayer=t}(a||(a={})),function(e){e.AbstractScene.prototype.getHighlightLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===i.EffectName)return this.effectLayers[t];return null};var t=function(t){function i(i,r,n,o,s,a,l,c){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE);var u=t.call(this,i,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,o,s,a,l,c)||this;return u.direction=r,u.kernel=n,u.onApplyObservable.add(function(e){e.setFloat2("screenSize",u.width,u.height),e.setVector2("direction",u.direction),e.setFloat("blurWidth",u.kernel)}),u}return o(i,t),i}(e.PostProcess),i=function(i){function r(t,n,o){var a=i.call(this,t,n)||this;return a.name=t,a.innerGlow=!0,a.outerGlow=!0,a.onBeforeBlurObservable=new e.Observable,a.onAfterBlurObservable=new e.Observable,a._instanceGlowingMeshStencilReference=r.GlowingMeshStencilReference++,a._meshes={},a._excludedMeshes={},a.neutralColor=r.NeutralColor,a._engine.isStencilEnable||e.Tools.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new BABYLON.Engine(canvas, antialias, { stencil: true }"),a._options=s({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:e.Engine.ALPHA_COMBINE,camera:null,renderingGroupId:-1},o),a._init({alphaBlendingMode:a._options.alphaBlendingMode,camera:a._options.camera,mainTextureFixedSize:a._options.mainTextureFixedSize,mainTextureRatio:a._options.mainTextureRatio,renderingGroupId:a._options.renderingGroupId}),a._shouldRender=!1,a}return o(r,i),Object.defineProperty(r.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),r.prototype.getEffectName=function(){return r.EffectName},r.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[e.VertexBuffer.PositionKind],["offset"],["textureSampler"],this._options.isStroke?"#define STROKE \n":void 0)},r.prototype._createTextureAndPostProcesses=function(){var i=this,r=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,n=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;r=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(r,this._maxSize):r,n=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(n,this._maxSize):n;var o=0;o=this._engine.getCaps().textureHalfFloatRender?e.Engine.TEXTURETYPE_HALF_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new e.RenderTargetTexture("HighlightLayerBlurRTT",{width:r,height:n},this._scene,!1,!0,o),this._blurTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(e.Texture.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===e.Engine.ALPHA_COMBINE?(this._downSamplePostprocess=new e.PassPostProcess("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.onApplyObservable.add(function(e){e.setTexture("textureSampler",i._mainTexture)}),this._horizontalBlurPostprocess=new t("HighlightLayerHBP",new e.Vector2(1,0),this._options.blurHorizontalSize,1,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",r,n)}),this._verticalBlurPostprocess=new t("HighlightLayerVBP",new e.Vector2(0,1),this._options.blurVerticalSize,1,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",r,n)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new e.BlurPostProcess("HighlightLayerHBP",new e.Vector2(1,0),this._options.blurHorizontalSize/2,{width:r,height:n},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._horizontalBlurPostprocess.width=r,this._horizontalBlurPostprocess.height=n,this._horizontalBlurPostprocess.onApplyObservable.add(function(e){e.setTexture("textureSampler",i._mainTexture)}),this._verticalBlurPostprocess=new e.BlurPostProcess("HighlightLayerVBP",new e.Vector2(0,1),this._options.blurVerticalSize/2,{width:r,height:n},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,o),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add(function(){i.onBeforeBlurObservable.notifyObservers(i);var e=i._blurTexture.getInternalTexture();e&&i._scene.postProcessManager.directRender(i._postProcesses,e,!0),i.onAfterBlurObservable.notifyObservers(i)}),this._postProcesses.map(function(e){e.autoClear=!1})},r.prototype.needStencil=function(){return!0},r.prototype.isReady=function(e,t){var r=e.getMaterial(),n=e.getRenderingMesh();if(!r||!n||!this._meshes)return!1;var o=null,s=this._meshes[n.uniqueId];return s&&s.glowEmissiveOnly&&r&&(o=r.emissiveTexture),i.prototype._isReady.call(this,e,t,o)},r.prototype._internalRender=function(t){t.setTexture("textureSampler",this._blurTexture);var i=this._engine,r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getStencilOperationPass(),a=i.getStencilOperationFail(),l=i.getStencilOperationDepthFail(),c=i.getStencilFunctionReference();i.setStencilOperationPass(e.Engine.REPLACE),i.setStencilOperationFail(e.Engine.KEEP),i.setStencilOperationDepthFail(e.Engine.KEEP),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.drawElementsType(e.Material.TriangleFillMode,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.drawElementsType(e.Material.TriangleFillMode,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setStencilBuffer(r),i.setStencilOperationPass(s),i.setStencilOperationFail(a),i.setStencilOperationDepthFail(l),i.setStencilFunctionReference(c)},r.prototype.shouldRender=function(){return!!i.prototype.shouldRender.call(this)&&!!this._meshes},r.prototype._shouldRenderMesh=function(e){return(!this._excludedMeshes||!this._excludedMeshes[e.uniqueId])&&!!i.prototype.hasMesh.call(this,e)},r.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=this._meshes[e.uniqueId];r?this._emissiveTextureAndColor.color.set(r.color.r,r.color.g,r.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),r&&r.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null},r.prototype.addExcludedMesh=function(e){this._excludedMeshes&&(this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add(function(e){e.getEngine().setStencilBuffer(!1)}),afterRender:e.onAfterRenderObservable.add(function(e){e.getEngine().setStencilBuffer(!0)})}))},r.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var t=this._excludedMeshes[e.uniqueId];t&&(t.beforeRender&&e.onBeforeRenderObservable.remove(t.beforeRender),t.afterRender&&e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=null}},r.prototype.hasMesh=function(e){return!!this._meshes&&(!!i.prototype.hasMesh.call(this,e)&&(void 0!==this._meshes[e.uniqueId]&&null!==this._meshes[e.uniqueId]))},r.prototype.addMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),this._meshes){var n=this._meshes[e.uniqueId];n?n.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add(function(e){r._excludedMeshes&&r._excludedMeshes[e.uniqueId]?r._defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)}),observerDefault:e.onAfterRenderObservable.add(this._defaultStencilReference),glowEmissiveOnly:i},e.onDisposeObservable.add(function(){r._disposeMesh(e)})),this._shouldRender=!0}},r.prototype.removeMesh=function(e){if(this._meshes){var t=this._meshes[e.uniqueId];for(var i in t&&(t.observerHighlight&&e.onBeforeRenderObservable.remove(t.observerHighlight),t.observerDefault&&e.onAfterRenderObservable.remove(t.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1,this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}},r.prototype._defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(r.NormalMeshStencilReference)},r.prototype._disposeMesh=function(e){this.removeMesh(e),this.removeExcludedMesh(e)},r.prototype.dispose=function(){if(this._meshes){for(var e in this._meshes){(t=this._meshes[e])&&t.mesh&&(t.observerHighlight&&t.mesh.onBeforeRenderObservable.remove(t.observerHighlight),t.observerDefault&&t.mesh.onAfterRenderObservable.remove(t.observerDefault))}this._meshes=null}if(this._excludedMeshes){for(var e in this._excludedMeshes){var t;(t=this._excludedMeshes[e])&&(t.beforeRender&&t.mesh.onBeforeRenderObservable.remove(t.beforeRender),t.afterRender&&t.mesh.onAfterRenderObservable.remove(t.afterRender))}this._excludedMeshes=null}i.prototype.dispose.call(this)},r.prototype.getClassName=function(){return"HighlightLayer"},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);if(t.customType="BABYLON.HighlightLayer",t.meshes=[],this._meshes)for(var i in this._meshes){var r=this._meshes[i];r&&t.meshes.push({glowEmissiveOnly:r.glowEmissiveOnly,color:r.color.asArray(),meshId:r.mesh.id})}if(t.excludedMeshes=[],this._excludedMeshes)for(var n in this._excludedMeshes){var o=this._excludedMeshes[n];o&&t.excludedMeshes.push(o.mesh.id)}return t},r.Parse=function(t,i,n){var o,s=e.SerializationHelper.Parse(function(){return new r(t.name,i,t.options)},t,i,n);for(o=0;o<t.excludedMeshes.length;o++){(a=i.getMeshByID(t.excludedMeshes[o]))&&s.addExcludedMesh(a)}for(o=0;o<t.meshes.length;o++){var a,l=t.meshes[o];(a=i.getMeshByID(l.meshId))&&s.addMesh(a,e.Color3.FromArray(l.color),l.glowEmissiveOnly)}return s},r.EffectName="HighlightLayer",r.NeutralColor=new e.Color4(0,0,0,0),r.GlowingMeshStencilReference=2,r.NormalMeshStencilReference=1,n([e.serialize()],r.prototype,"innerGlow",void 0),n([e.serialize()],r.prototype,"outerGlow",void 0),n([e.serialize()],r.prototype,"blurHorizontalSize",null),n([e.serialize()],r.prototype,"blurVerticalSize",null),n([e.serialize("options")],r.prototype,"_options",void 0),r}(e.EffectLayer);e.HighlightLayer=i}(a||(a={})),function(e){e.AbstractScene.prototype.getGlowLayerByName=function(e){for(var i=0;i<this.effectLayers.length;i++)if(this.effectLayers[i].name===e&&this.effectLayers[i].getEffectName()===t.EffectName)return this.effectLayers[i];return null};var t=function(t){function i(r,n,o){var a=t.call(this,r,n)||this;return a._intensity=1,a._includedOnlyMeshes=[],a._excludedMeshes=[],a.neutralColor=new e.Color4(0,0,0,1),a._options=s({mainTextureRatio:i.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1},o),a._init({alphaBlendingMode:e.Engine.ALPHA_ADD,camera:a._options.camera,mainTextureFixedSize:a._options.mainTextureFixedSize,mainTextureRatio:a._options.mainTextureRatio,renderingGroupId:a._options.renderingGroupId}),a}return o(i,t),Object.defineProperty(i.prototype,"blurKernelSize",{get:function(){return this._horizontalBlurPostprocess1.kernel},set:function(e){this._horizontalBlurPostprocess1.kernel=e,this._verticalBlurPostprocess1.kernel=e,this._horizontalBlurPostprocess2.kernel=e,this._verticalBlurPostprocess2.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!0,configurable:!0}),i.prototype.getEffectName=function(){return i.EffectName},i.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[e.VertexBuffer.PositionKind],["offset"],["textureSampler","textureSampler2"],"#define EMISSIVE \n")},i.prototype._createTextureAndPostProcesses=function(){var t=this,i=this._mainTextureDesiredSize.width,r=this._mainTextureDesiredSize.height;i=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(i,this._maxSize):i,r=this._engine.needPOTTextures?e.Tools.GetExponentOfTwo(r,this._maxSize):r;var n=0;n=this._engine.getCaps().textureHalfFloatRender?e.Engine.TEXTURETYPE_HALF_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new e.RenderTargetTexture("GlowLayerBlurRTT",{width:i,height:r},this._scene,!1,!0,n),this._blurTexture1.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var o=Math.floor(i/2),s=Math.floor(r/2);this._blurTexture2=new e.RenderTargetTexture("GlowLayerBlurRTT2",{width:o,height:s},this._scene,!1,!0,n),this._blurTexture2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2],this._horizontalBlurPostprocess1=new e.BlurPostProcess("GlowLayerHBP1",new e.Vector2(1,0),this._options.blurKernelSize/2,{width:i,height:r},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess1.width=i,this._horizontalBlurPostprocess1.height=r,this._horizontalBlurPostprocess1.onApplyObservable.add(function(e){e.setTexture("textureSampler",t._mainTexture)}),this._verticalBlurPostprocess1=new e.BlurPostProcess("GlowLayerVBP1",new e.Vector2(0,1),this._options.blurKernelSize/2,{width:i,height:r},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess2=new e.BlurPostProcess("GlowLayerHBP2",new e.Vector2(1,0),this._options.blurKernelSize/2,{width:o,height:s},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess2.width=o,this._horizontalBlurPostprocess2.height=s,this._horizontalBlurPostprocess2.onApplyObservable.add(function(e){e.setTexture("textureSampler",t._blurTexture1)}),this._verticalBlurPostprocess2=new e.BlurPostProcess("GlowLayerVBP2",new e.Vector2(0,1),this._options.blurKernelSize/2,{width:o,height:s},null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(function(){var e=t._blurTexture1.getInternalTexture();e&&(t._scene.postProcessManager.directRender(t._postProcesses1,e,!0),(e=t._blurTexture2.getInternalTexture())&&t._scene.postProcessManager.directRender(t._postProcesses2,e,!0))}),this._postProcesses.map(function(e){e.autoClear=!1})},i.prototype.isReady=function(e,i){var r=e.getMaterial(),n=e.getRenderingMesh();if(!r||!n)return!1;var o=r.emissiveTexture;return t.prototype._isReady.call(this,e,i,o)},i.prototype.needStencil=function(){return!1},i.prototype._internalRender=function(t){t.setTexture("textureSampler",this._blurTexture1),t.setTexture("textureSampler2",this._blurTexture2),t.setFloat("offset",this._intensity);var i=this._engine,r=i.getStencilBuffer();i.setStencilBuffer(!1),i.drawElementsType(e.Material.TriangleFillMode,0,6),i.setStencilBuffer(r)},i.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(r=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,t,i,this._emissiveTextureAndColor.color):i.emissiveColor?this._emissiveTextureAndColor.color.set(i.emissiveColor.r*r,i.emissiveColor.g*r,i.emissiveColor.b*r,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)},i.prototype._shouldRenderMesh=function(e){return this.hasMesh(e)},i.prototype.addExcludedMesh=function(e){-1===this._excludedMeshes.indexOf(e.uniqueId)&&this._excludedMeshes.push(e.uniqueId)},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes.indexOf(e.uniqueId);-1!==t&&this._excludedMeshes.splice(t,1)},i.prototype.addIncludedOnlyMesh=function(e){-1===this._includedOnlyMeshes.indexOf(e.uniqueId)&&this._includedOnlyMeshes.push(e.uniqueId)},i.prototype.removeIncludedOnlyMesh=function(e){var t=this._includedOnlyMeshes.indexOf(e.uniqueId);-1!==t&&this._includedOnlyMeshes.splice(t,1)},i.prototype.hasMesh=function(e){return!!t.prototype.hasMesh.call(this,e)&&(this._includedOnlyMeshes.length?-1!==this._includedOnlyMeshes.indexOf(e.uniqueId):!this._excludedMeshes.length||-1===this._excludedMeshes.indexOf(e.uniqueId))},i.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},i.prototype.getClassName=function(){return"GlowLayer"},i.prototype.serialize=function(){var t,i=e.SerializationHelper.Serialize(this);if(i.customType="BABYLON.GlowLayer",i.includedMeshes=[],this._includedOnlyMeshes.length)for(t=0;t<this._includedOnlyMeshes.length;t++){(r=this._scene.getMeshByUniqueID(this._includedOnlyMeshes[t]))&&i.includedMeshes.push(r.id)}if(i.excludedMeshes=[],this._excludedMeshes.length)for(t=0;t<this._excludedMeshes.length;t++){var r;(r=this._scene.getMeshByUniqueID(this._excludedMeshes[t]))&&i.excludedMeshes.push(r.id)}return i},i.Parse=function(t,r,n){var o,s=e.SerializationHelper.Parse(function(){return new i(t.name,r,t.options)},t,r,n);for(o=0;o<t.excludedMeshes.length;o++){(a=r.getMeshByID(t.excludedMeshes[o]))&&s.addExcludedMesh(a)}for(o=0;o<t.includedMeshes.length;o++){var a;(a=r.getMeshByID(t.includedMeshes[o]))&&s.addIncludedOnlyMesh(a)}return s},i.EffectName="GlowLayer",i.DefaultBlurKernelSize=32,i.DefaultTextureRatio=.5,n([e.serialize()],i.prototype,"blurKernelSize",null),n([e.serialize()],i.prototype,"intensity",null),n([e.serialize("options")],i.prototype,"_options",void 0),i}(e.EffectLayer);e.GlowLayer=t}(a||(a={})),function(e){var t;!function(e){e[e.INIT=0]="INIT",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE",e[e.ERROR=3]="ERROR"}(t=e.AssetTaskState||(e.AssetTaskState={}));var i=function(){function e(e){this.name=e,this._isCompleted=!1,this._taskState=t.INIT}return Object.defineProperty(e.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"taskState",{get:function(){return this._taskState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!0,configurable:!0}),e.prototype._setErrorObject=function(e,t){this._errorObject||(this._errorObject={message:e,exception:t})},e.prototype.run=function(e,i,r){var n=this;this._taskState=t.RUNNING,this.runTask(e,function(){n.onDoneCallback(i,r)},function(e,t){n.onErrorCallback(r,e,t)})},e.prototype.runTask=function(e,t,i){throw new Error("runTask is not implemented")},e.prototype.reset=function(){this._taskState=t.INIT},e.prototype.onErrorCallback=function(e,i,r){this._taskState=t.ERROR,this._errorObject={message:i,exception:r},this.onError&&this.onError(this,i,r),e()},e.prototype.onDoneCallback=function(e,i){try{this._taskState=t.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(e){this.onErrorCallback(i,"Task is done, error executing success callback(s)",e)}},e}();e.AbstractAssetTask=i;var r=function(){return function(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i}}();e.AssetsProgressEvent=r;var n=function(t){function i(e,i,r,n){var o=t.call(this,e)||this;return o.name=e,o.meshesNames=i,o.rootUrl=r,o.sceneFilename=n,o}return o(i,t),i.prototype.runTask=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,i()},null,function(e,t,i){r(t,i)})},i}(i);e.MeshAssetTask=n;var s=function(e){function t(t,i){var r=e.call(this,t)||this;return r.name=t,r.url=i,r}return o(t,e),t.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,function(e){r.text=e,t()},void 0,!1,!1,function(e,t){e&&i(e.status+" "+e.statusText,t)})},t}(i);e.TextFileAssetTask=s;var a=function(e){function t(t,i){var r=e.call(this,t)||this;return r.name=t,r.url=i,r}return o(t,e),t.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,function(e){r.data=e,t()},void 0,!0,!0,function(e,t){e&&i(e.status+" "+e.statusText,t)})},t}(i);e.BinaryFileAssetTask=a;var l=function(t){function i(e,i){var r=t.call(this,e)||this;return r.name=e,r.url=i,r}return o(i,t),i.prototype.runTask=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,i()},o.onerror=function(e){r("Error loading image",e)},o.src=this.url},i}(i);e.ImageAssetTask=l;var c=function(t){function i(i,r,n,o,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=t.call(this,i)||this;return a.name=i,a.url=r,a.noMipmap=n,a.invertY=o,a.samplingMode=s,a}return o(i,t),i.prototype.runTask=function(t,i,r){this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,function(){i()},function(e,t){r(e,t)})},i}(i);e.TextureAssetTask=c;var u=function(t){function i(e,i,r,n,o){var s=t.call(this,e)||this;return s.name=e,s.url=i,s.extensions=r,s.noMipmap=n,s.files=o,s}return o(i,t),i.prototype.runTask=function(t,i,r){this.texture=new e.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,function(){i()},function(e,t){r(e,t)})},i}(i);e.CubeTextureAssetTask=u;var h=function(t){function i(e,i,r,n,o,s,a){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=!1);var l=t.call(this,e)||this;return l.name=e,l.url=i,l.size=r,l.noMipmap=n,l.generateHarmonics=o,l.gammaSpace=s,l.reserved=a,l}return o(i,t),i.prototype.run=function(t,i,r){this.texture=new e.HDRCubeTexture(this.url,t,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,function(){i()},function(e,t){r(e,t)})},i}(i);e.HDRCubeTextureAssetTask=h;var d=function(){function i(t){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new e.Observable,this.onTaskErrorObservable=new e.Observable,this.onTasksDoneObservable=new e.Observable,this.onProgressObservable=new e.Observable,this.useDefaultLoadingScreen=!0,this._scene=t}return i.prototype.addMeshTask=function(e,t,i,r){var o=new n(e,t,i,r);return this._tasks.push(o),o},i.prototype.addTextFileTask=function(e,t){var i=new s(e,t);return this._tasks.push(i),i},i.prototype.addBinaryFileTask=function(e,t){var i=new a(e,t);return this._tasks.push(i),i},i.prototype.addImageTask=function(e,t){var i=new l(e,t);return this._tasks.push(i),i},i.prototype.addTextureTask=function(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE);var s=new c(t,i,r,n,o);return this._tasks.push(s),s},i.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new u(e,t,i,r,n);return this._tasks.push(o),o},i.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var a=new h(e,t,i,r,n,o,s);return this._tasks.push(a),a},i.prototype.removeTask=function(e){var t=this._tasks.indexOf(e);t>-1&&this._tasks.splice(t,1)},i.prototype._decreaseWaitingTasksCount=function(i){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,i),this.onProgressObservable.notifyObservers(new r(this._waitingTasksCount,this._totalTasksCount,i))}catch(t){e.Tools.Error("Error running progress callbacks."),console.log(t)}if(0===this._waitingTasksCount){try{this.onFinish&&this.onFinish(this._tasks);for(var n=this._tasks.slice(),o=0,s=n;o<s.length;o++){if((i=s[o]).taskState===t.DONE){var a=this._tasks.indexOf(i);a>-1&&this._tasks.splice(a,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(t){e.Tools.Error("Error running tasks-done callbacks."),console.log(t)}this._isLoading=!1,this._scene.getEngine().hideLoadingUI()}},i.prototype._runTask=function(e){var t=this,i=function(i,r){e._setErrorObject(i,r),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){i("Error executing task success callbacks",e)}},i)},i.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},i.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e<this._tasks.length;e++){var i=this._tasks[e];i.taskState===t.INIT&&this._runTask(i)}return this},i}();e.AssetsManager=d}(a||(a={})),function(e){var t=[],i=function(i,r){if(!t[i.id]&&!i.doNotSerialize){if(i instanceof e.BoxGeometry)r.boxes.push(i.serialize());else if(i instanceof e.SphereGeometry)r.spheres.push(i.serialize());else if(i instanceof e.CylinderGeometry)r.cylinders.push(i.serialize());else if(i instanceof e.TorusGeometry)r.toruses.push(i.serialize());else if(i instanceof e.GroundGeometry)r.grounds.push(i.serialize());else if(i instanceof e.Plane)r.planes.push(i.serialize());else if(i instanceof e.TorusKnotGeometry)r.torusKnots.push(i.serialize());else{if(i instanceof e._PrimitiveGeometry)throw new Error("Unknown primitive type");r.vertexData.push(i.serializeVerticeData())}t[i.id]=!0}},r=function(e,t){var r={},n=e._geometry;return n&&(e.getScene().getGeometryByID(n.id)||i(n,t.geometries)),e.serialize&&e.serialize(r),r},n=function(){function n(){}return n.ClearCache=function(){t=[]},n.Serialize=function(o){var s,a,l,c={};if(n.ClearCache(),c.useDelayedTextureLoading=o.useDelayedTextureLoading,c.autoClear=o.autoClear,c.clearColor=o.clearColor.asArray(),c.ambientColor=o.ambientColor.asArray(),c.gravity=o.gravity.asArray(),c.collisionsEnabled=o.collisionsEnabled,c.workerCollisions=o.workerCollisions,o.fogMode&&0!==o.fogMode&&(c.fogMode=o.fogMode,c.fogColor=o.fogColor.asArray(),c.fogStart=o.fogStart,c.fogEnd=o.fogEnd,c.fogDensity=o.fogDensity),o.isPhysicsEnabled()){var u=o.getPhysicsEngine();u&&(c.physicsEnabled=!0,c.physicsGravity=u.gravity.asArray(),c.physicsEngine=u.getPhysicsPluginName())}o.metadata&&(c.metadata=o.metadata),c.morphTargetManagers=[];for(var h=0,d=o.meshes;h<d.length;h++){var f=(A=d[h]).morphTargetManager;f&&c.morphTargetManagers.push(f.serialize())}for(c.lights=[],s=0;s<o.lights.length;s++)(a=o.lights[s]).doNotSerialize||c.lights.push(a.serialize());for(c.cameras=[],s=0;s<o.cameras.length;s++){var p=o.cameras[s];p.doNotSerialize||c.cameras.push(p.serialize())}for(o.activeCamera&&(c.activeCameraID=o.activeCamera.id),e.Animation.AppendSerializedAnimations(o,c),c.materials=[],c.multiMaterials=[],s=0;s<o.materials.length;s++)(l=o.materials[s]).doNotSerialize||c.materials.push(l.serialize());for(c.multiMaterials=[],s=0;s<o.multiMaterials.length;s++){var m=o.multiMaterials[s];c.multiMaterials.push(m.serialize())}for(o.environmentTexture&&(c.environmentTexture=o.environmentTexture.name),c.skeletons=[],s=0;s<o.skeletons.length;s++){var g=o.skeletons[s];g.doNotSerialize||c.skeletons.push(g.serialize())}for(c.transformNodes=[],s=0;s<o.transformNodes.length;s++)c.transformNodes.push(o.transformNodes[s].serialize());c.geometries={},c.geometries.boxes=[],c.geometries.spheres=[],c.geometries.cylinders=[],c.geometries.toruses=[],c.geometries.grounds=[],c.geometries.planes=[],c.geometries.torusKnots=[],c.geometries.vertexData=[],t=[];var _=o.getGeometries();for(s=0;s<_.length;s++){var v=_[s];v.isReady()&&i(v,c.geometries)}for(c.meshes=[],s=0;s<o.meshes.length;s++){var A;if((A=o.meshes[s])instanceof e.Mesh){var y=A;y.doNotSerialize||y.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADED&&y.delayLoadState!==e.Engine.DELAYLOADSTATE_NONE||c.meshes.push(r(y,c))}}for(c.particleSystems=[],s=0;s<o.particleSystems.length;s++)c.particleSystems.push(o.particleSystems[s].serialize());o.actionManager&&(c.actions=o.actionManager.serialize("scene"));for(var b=0,T=o._serializableComponents;b<T.length;b++){T[b].serialize(c)}return c},n.SerializeMesh=function(t,o,s){void 0===o&&(o=!1),void 0===s&&(s=!1);var a={};if(n.ClearCache(),t=t instanceof Array?t:[t],o||s)for(var l=0;l<t.length;++l)s&&t[l].getDescendants().forEach(function(i){i instanceof e.Mesh&&t.indexOf(i)<0&&t.push(i)}),o&&t[l].parent&&t.indexOf(t[l].parent)<0&&t.push(t[l].parent);return t.forEach(function(t){!function(t,n){if(t.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||t.delayLoadState===e.Engine.DELAYLOADSTATE_NONE){if(t.material)if(t.material instanceof e.MultiMaterial){if(n.multiMaterials=n.multiMaterials||[],n.materials=n.materials||[],!n.multiMaterials.some(function(e){return e.id===t.material.id})){n.multiMaterials.push(t.material.serialize());for(var o=function(e){e&&(n.materials.some(function(t){return t.id===e.id})||n.materials.push(e.serialize()))},s=0,a=t.material.subMaterials;s<a.length;s++)o(a[s])}}else n.materials=n.materials||[],n.materials.some(function(e){return e.id===t.material.id})||n.materials.push(t.material.serialize());var l=t._geometry;l&&(n.geometries||(n.geometries={},n.geometries.boxes=[],n.geometries.spheres=[],n.geometries.cylinders=[],n.geometries.toruses=[],n.geometries.grounds=[],n.geometries.planes=[],n.geometries.torusKnots=[],n.geometries.vertexData=[]),i(l,n.geometries)),t.skeleton&&(n.skeletons=n.skeletons||[],n.skeletons.push(t.skeleton.serialize())),n.meshes=n.meshes||[],n.meshes.push(r(t,n))}}(t,a)}),a},n}();e.SceneSerializer=n}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=!1);var s=this;this.name=t,this._viewMatrix=e.Matrix.Identity(),this._target=e.Vector3.Zero(),this._add=e.Vector3.Zero(),this._invertYAxis=!1,this.position=e.Vector3.Zero(),this._scene=r,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new e.RenderTargetTexture(t,i,r,n,!0,o?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRenderObservable.add(function(t){switch(t){case 0:s._add.copyFromFloats(1,0,0);break;case 1:s._add.copyFromFloats(-1,0,0);break;case 2:s._add.copyFromFloats(0,s._invertYAxis?1:-1,0);break;case 3:s._add.copyFromFloats(0,s._invertYAxis?-1:1,0);break;case 4:s._add.copyFromFloats(0,0,1);break;case 5:s._add.copyFromFloats(0,0,-1)}s._attachedMesh&&s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),s.position.addToRef(s._add,s._target),e.Matrix.LookAtLHToRef(s.position,s._target,e.Vector3.Up(),s._viewMatrix),r.setTransformMatrix(s._viewMatrix,s._projectionMatrix),r._forcedViewPosition=s.position}),this._renderTargetTexture.onAfterUnbindObservable.add(function(){r._forcedViewPosition=null,r.updateTransformMatrix(!0)}),r.activeCamera&&(this._projectionMatrix=e.Matrix.PerspectiveFovLH(Math.PI/2,1,r.activeCamera.minZ,r.activeCamera.maxZ))}return Object.defineProperty(t.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},Object.defineProperty(t.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),t.prototype.attachToMesh=function(e){this._attachedMesh=e},t.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},t.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},t}();e.ReflectionProbe=t}(a||(a={})),function(e){var t=function(){function t(t){this.name=e.SceneComponentConstants.NAME_LAYER,this.scene=t,this._engine=t.getEngine(),t.layers=new Array}return t.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER,this,this._drawBackground),this.scene._afterCameraDrawStage.registerStep(e.SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER,this,this._drawForeground)},t.prototype.rebuild=function(){for(var e=0,t=this.scene.layers;e<t.length;e++){t[e]._rebuild()}},t.prototype.dispose=function(){for(var e=this.scene.layers;e.length;)e[0].dispose()},t.prototype._draw=function(e,t){var i=this.scene.layers;if(i.length){this._engine.setDepthBuffer(!1);for(var r=e.layerMask,n=0,o=i;n<o.length;n++){var s=o[n];s.isBackground===t&&0!=(s.layerMask&r)&&s.render()}this._engine.setDepthBuffer(!0)}},t.prototype._drawBackground=function(e){this._draw(e,!0)},t.prototype._drawForeground=function(e){this._draw(e,!1)},t}();e.LayerSceneComponent=t}(a||(a={})),function(e){var t=function(){function t(t,i,r,n,o){this.name=t,this.scale=new e.Vector2(1,1),this.offset=new e.Vector2(0,0),this.alphaBlendingMode=e.Engine.ALPHA_COMBINE,this.layerMask=268435455,this._vertexBuffers={},this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.texture=i?new e.Texture(i,r,!0):null,this.isBackground=void 0===n||n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=r||e.Engine.LastCreatedScene;var s=this._scene._getComponent(e.SceneComponentConstants.NAME_LAYER);s||(s=new e.LayerSceneComponent(this._scene),this._scene._addComponent(s)),this._scene.layers.push(this);var a=this._scene.getEngine(),l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1);var c=new e.VertexBuffer(a,l,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=c,this._createIndexBuffer(),this._effect=a.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=a.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}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,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&t._rebuild(),this._createIndexBuffer()},t.prototype.render=function(){var t=this.alphaTest?this._alphaTestEffect:this._effect;if(t.isReady()&&this.texture&&this.texture.isReady()){var i=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.alphaTest?i.drawElementsType(e.Material.TriangleFillMode,0,6):(i.setAlphaMode(this.alphaBlendingMode),i.drawElementsType(e.Material.TriangleFillMode,0,6),i.setAlphaMode(e.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},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),this.texture&&(this.texture.dispose(),this.texture=null);var i=this._scene.layers.indexOf(this);this._scene.layers.splice(i,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},t}();e.Layer=t}(a||(a={})),function(e){var t=function(){function t(){}return t.CreateResizedCopy=function(t,i,r,n){void 0===n&&(n=!0);var o=t.getScene(),s=o.getEngine(),a=new e.RenderTargetTexture("resized"+t.name,{width:i,height:r},o,!t.noMipmap,!0,t._texture.type,!1,t._samplingMode,!1);a.wrapU=t.wrapU,a.wrapV=t.wrapV,a.uOffset=t.uOffset,a.vOffset=t.vOffset,a.uScale=t.uScale,a.vScale=t.vScale,a.uAng=t.uAng,a.vAng=t.vAng,a.wAng=t.wAng,a.coordinatesIndex=t.coordinatesIndex,a.level=t.level,a.anisotropicFilteringLevel=t.anisotropicFilteringLevel,a._texture.isReady=!1,t.wrapU=e.Texture.CLAMP_ADDRESSMODE,t.wrapV=e.Texture.CLAMP_ADDRESSMODE;var l=new e.PassPostProcess("pass",1,null,n?e.Texture.BILINEAR_SAMPLINGMODE:e.Texture.NEAREST_SAMPLINGMODE,s,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT);return l.getEffect().executeWhenCompiled(function(){l.onApply=function(e){e.setTexture("textureSampler",t)};var e=a.getInternalTexture();e&&(o.postProcessManager.directRender([l],e),s.unBindFramebuffer(e),a.disposeFramebufferObjects(),l.dispose(),e.isReady=!0)}),a},t.GetEnvironmentBRDFTexture=function(t){if(!t._environmentBRDFTexture){var i=e.Texture.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture",t,!0,!1,e.Texture.BILINEAR_SAMPLINGMODE);i.wrapU=e.Texture.CLAMP_ADDRESSMODE,i.wrapV=e.Texture.CLAMP_ADDRESSMODE,t._environmentBRDFTexture=i}return t._environmentBRDFTexture},t._environmentBRDFBase64Texture="data:image/png;base64,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",t}();e.TextureTools=t}(a||(a={})),function(e){var t=function(){function t(){this._mode=t.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(t.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(i){var r=this;this._attachedCamera=i;var n=this._attachedCamera.getScene();t.EasingFunction.setEasingMode(t.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add(function(t){t.type!==e.PointerEventTypes.POINTERDOWN?t.type===e.PointerEventTypes.POINTERUP&&(r._isPointerDown=!1):r._isPointerDown=!0}),this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add(function(e){e&&r.zoomOnMesh(e)}),this._onAfterCheckInputsObserver=i.onAfterCheckInputsObservable.add(function(){r._applyUserInteraction(),r._maintainCameraAboveGround()})},t.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},t.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)},t.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)},t.prototype.zoomOnMeshesHierarchy=function(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=null);for(var n=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),o=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s=0;s<t.length;s++){var a=t[s].getHierarchyBoundingVectors(!0);e.Tools.CheckExtends(a.min,n,o),e.Tools.CheckExtends(a.max,n,o)}this.zoomOnBoundingInfo(n,o,i,r)},t.prototype.zoomOnBoundingInfo=function(i,r,n,o){var s,a=this;if(void 0===n&&(n=!1),void 0===o&&(o=null),this._attachedCamera){var l=i.y,c=l+(r.y-l)*this._positionScale,u=r.subtract(i).scale(.5);if(n)s=new e.Vector3(0,c,0);else{var h=i.add(u);s=new e.Vector3(h.x,c,h.z)}this._vectorTransition||(this._vectorTransition=e.Animation.CreateAnimation("target",e.Animation.ANIMATIONTYPE_VECTOR3,60,t.EasingFunction)),this._betaIsAnimating=!0;var d=e.Animation.TransitionTo("target",s,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);d&&this._animatables.push(d);var f=0;if(this._mode===t.FitFrustumSidesMode){var p=this._calculateLowerRadiusFromModelBoundingSphere(i,r);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=u.length()+this._attachedCamera.minZ),f=p}else this._mode===t.IgnoreBoundsSizeMode&&(f=this._calculateLowerRadiusFromModelBoundingSphere(i,r),this.autoCorrectCameraLimitsAndSensibility&&null===this._attachedCamera.lowerRadiusLimit&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var m=r.subtract(i).length();this._attachedCamera.panningSensibility=5e3/m,this._attachedCamera.wheelPrecision=100/f}this._radiusTransition||(this._radiusTransition=e.Animation.CreateAnimation("radius",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction)),(d=e.Animation.TransitionTo("radius",f,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,function(){a.stopAllAnimations(),o&&o(),a._attachedCamera&&a._attachedCamera.useInputToRestoreState&&a._attachedCamera.storeState()}))&&this._animatables.push(d)}},t.prototype._calculateLowerRadiusFromModelBoundingSphere=function(e,i){var r=i.subtract(e).length(),n=this._getFrustumSlope(),o=.5*r*this._radiusScale,s=o*Math.sqrt(1+1/(n.x*n.x)),a=o*Math.sqrt(1+1/(n.y*n.y)),l=Math.max(s,a),c=this._attachedCamera;return c?(c.lowerRadiusLimit&&this._mode===t.IgnoreBoundsSizeMode&&(l=l<c.lowerRadiusLimit?c.lowerRadiusLimit:l),c.upperRadiusLimit&&(l=l>c.upperRadiusLimit?c.upperRadiusLimit:l),l):0},t.prototype._maintainCameraAboveGround=function(){var i=this;if(!(this._elevationReturnTime<0)){var r=e.Tools.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,o=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>o&&r>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=e.Animation.CreateAnimation("beta",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction));var s=e.Animation.TransitionTo("beta",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,function(){i._clearAnimationLocks(),i.stopAllAnimations()});s&&this._animatables.push(s)}}},t.prototype._getFrustumSlope=function(){var t=this._attachedCamera;if(!t)return e.Vector2.Zero();var i=t.getScene().getEngine().getAspectRatio(t),r=Math.tan(t.fov/2),n=r*i;return new e.Vector2(n,r)},t.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},t.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=e.Tools.Now,this.stopAllAnimations(),this._clearAnimationLocks())},t.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(t.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),t.EasingFunction=new e.ExponentialEase,t.EasingMode=e.EasingFunction.EASINGMODE_EASEINOUT,t.IgnoreBoundsSizeMode=0,t.FitFrustumSidesMode=1,t}();e.FramingBehavior=t}(a||(a={})),function(e){var t=function(){function t(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(t.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add(function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}}):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))})},t.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},t.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},t.prototype._applyBoundRadiusAnimation=function(i){var r=this;if(this._attachedCamera){this._radiusBounceTransition||(t.EasingFunction.setEasingMode(t.EasingMode),this._radiusBounceTransition=e.Animation.CreateAnimation("radius",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var n=e.Animation.TransitionTo("radius",this._attachedCamera.radius+i,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,function(){return r._clearAnimationLocks()});n&&this._animatables.push(n)}},t.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},t.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},t.EasingFunction=new e.BackEase(.3),t.EasingMode=e.EasingFunction.EASINGMODE_EASEOUT,t}();e.BouncingBehavior=t}(a||(a={})),function(e){var t=function(){function t(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(t.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!0,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(t){var i=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();this._onPrePointerObservableObserver=r.onPrePointerObservable.add(function(t){t.type!==e.PointerEventTypes.POINTERDOWN?t.type===e.PointerEventTypes.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){var t=e.Tools.Now,r=0;null!=i._lastFrameTime&&(r=t-i._lastFrameTime),i._lastFrameTime=t,i._applyUserInteraction();var n=t-i._lastInteractionTime-i._idleRotationWaitTime,o=Math.max(Math.min(n/i._idleRotationSpinupTime,1),0);i._cameraRotationSpeed=i._idleRotationSpeed*o,i._attachedCamera&&(i._attachedCamera.alpha-=i._cameraRotationSpeed*(r/1e3))})},t.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},t.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},t.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},t.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=e.Tools.Now)},t.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},t}();e.AutoRotationBehavior=t}(a||(a={})),function(e){var t=function(){return function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4}}();e.NullEngineOptions=t;var i=function(i){function r(r){void 0===r&&(r=new t);var n=i.call(this,null)||this;return void 0===r.deterministicLockstep&&(r.deterministicLockstep=!1),void 0===r.lockstepMaxSteps&&(r.lockstepMaxSteps=4),n._options=r,n._caps=new e.EngineCapabilities,n._caps.maxTexturesImageUnits=16,n._caps.maxVertexTextureImageUnits=16,n._caps.maxTextureSize=512,n._caps.maxCubemapTextureSize=512,n._caps.maxRenderTextureSize=512,n._caps.maxVertexAttribs=16,n._caps.maxVaryingVectors=16,n._caps.maxFragmentUniformVectors=16,n._caps.maxVertexUniformVectors=16,n._caps.standardDerivatives=!1,n._caps.astc=null,n._caps.s3tc=null,n._caps.pvrtc=null,n._caps.etc1=null,n._caps.etc2=null,n._caps.textureAnisotropicFilterExtension=null,n._caps.maxAnisotropy=0,n._caps.uintIndices=!1,n._caps.fragmentDepthSupported=!1,n._caps.highPrecisionShaderSupported=!0,n._caps.colorBufferFloat=!1,n._caps.textureFloat=!1,n._caps.textureFloatLinearFiltering=!1,n._caps.textureFloatRender=!1,n._caps.textureHalfFloat=!1,n._caps.textureHalfFloatLinearFiltering=!1,n._caps.textureHalfFloatRender=!1,n._caps.textureLOD=!1,n._caps.drawBuffersExtension=!1,n._caps.depthTextureExtension=!1,n._caps.vertexArrayObject=!1,n._caps.instancedArrays=!1,e.Tools.Log("Babylon.js null engine (v"+e.Engine.Version+") launched"),"undefined"==typeof URL&&(URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(Blob=function(){}),n}return o(r,i),r.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},r.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},r.prototype.getHardwareScalingLevel=function(){return 1},r.prototype.createVertexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},r.prototype.createIndexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},r.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1)},r.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},r.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},r.prototype.setViewport=function(e,t,i){this._cachedViewport=e},r.prototype.createShaderProgram=function(e,t,i,r){return{transformFeedback:null,__SPECTOR_rebuildProgram:null}},r.prototype.getUniforms=function(e,t){return[]},r.prototype.getAttributes=function(e,t){return[]},r.prototype.bindSamplers=function(e){this._currentEffect=null},r.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},r.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1)},r.prototype.setIntArray=function(e,t){},r.prototype.setIntArray2=function(e,t){},r.prototype.setIntArray3=function(e,t){},r.prototype.setIntArray4=function(e,t){},r.prototype.setFloatArray=function(e,t){},r.prototype.setFloatArray2=function(e,t){},r.prototype.setFloatArray3=function(e,t){},r.prototype.setFloatArray4=function(e,t){},r.prototype.setArray=function(e,t){},r.prototype.setArray2=function(e,t){},r.prototype.setArray3=function(e,t){},r.prototype.setArray4=function(e,t){},r.prototype.setMatrices=function(e,t){},r.prototype.setMatrix=function(e,t){},r.prototype.setMatrix3x3=function(e,t){},r.prototype.setMatrix2x2=function(e,t){},r.prototype.setFloat=function(e,t){},r.prototype.setFloat2=function(e,t,i){},r.prototype.setFloat3=function(e,t,i,r){},r.prototype.setBool=function(e,t){},r.prototype.setFloat4=function(e,t,i,r,n){},r.prototype.setColor3=function(e,t){},r.prototype.setColor4=function(e,t,i){},r.prototype.setAlphaMode=function(t,i){void 0===i&&(i=!1),this._alphaMode!==t&&(this._alphaState.alphaBlend=t!==e.Engine.ALPHA_DISABLE,i||this.setDepthWrite(t===e.Engine.ALPHA_DISABLE),this._alphaMode=t)},r.prototype.bindBuffers=function(e,t,i){},r.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},r.prototype.draw=function(e,t,i,r){},r.prototype.drawElementsType=function(e,t,i,r){},r.prototype.drawArraysType=function(e,t,i,r){},r.prototype._createTexture=function(){return{}},r.prototype._releaseTexture=function(e){},r.prototype.createTexture=function(t,i,r,n,o,s,a,l,c,u){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var h=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_URL),d=String(t);return h.url=d,h.generateMipMaps=!i,h.samplingMode=o,h.invertY=r,h.baseWidth=this._options.textureSize,h.baseHeight=this._options.textureSize,h.width=this._options.textureSize,h.height=this._options.textureSize,u&&(h.format=u),h.isReady=!0,s&&s(),this._internalTexturesCache.push(h),h},r.prototype.createRenderTargetTexture=function(t,i){var r=new e.RenderTargetCreationOptions;void 0!==i&&"object"==typeof i?(r.generateMipMaps=i.generateMipMaps,r.generateDepthBuffer=void 0===i.generateDepthBuffer||i.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&i.generateStencilBuffer,r.type=void 0===i.type?e.Engine.TEXTURETYPE_UNSIGNED_INT:i.type,r.samplingMode=void 0===i.samplingMode?e.Texture.TRILINEAR_SAMPLINGMODE:i.samplingMode):(r.generateMipMaps=i,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=e.Engine.TEXTURETYPE_UNSIGNED_INT,r.samplingMode=e.Texture.TRILINEAR_SAMPLINGMODE);var n=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET),o=t.width||t,s=t.height||t;return n._depthStencilBuffer={},n._framebuffer={},n.baseWidth=o,n.baseHeight=s,n.width=o,n.height=s,n.isReady=!0,n.samples=1,n.generateMipMaps=!!r.generateMipMaps,n.samplingMode=r.samplingMode,n.type=r.type,n._generateDepthBuffer=r.generateDepthBuffer,n._generateStencilBuffer=!!r.generateStencilBuffer,this._internalTexturesCache.push(n),n},r.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},r.prototype.bindFramebuffer=function(e,t,i,r,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!n&&this.setViewport(this._cachedViewport,i,r)},r.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},r.prototype.createDynamicVertexBuffer=function(e){return{capacity:1,references:1,is32Bits:!1}},r.prototype.updateDynamicTexture=function(e,t,i,r,n){void 0===r&&(r=!1)},r.prototype.getError=function(){return 0},r.prototype._getUnpackAlignement=function(){return 1},r.prototype._unpackFlipY=function(e){},r.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},r.prototype.updateDynamicVertexBuffer=function(e,t,i,r){},r.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},r.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},r.prototype._releaseBuffer=function(e){return e.references--,0===e.references},r.prototype.releaseEffects=function(){},r.prototype.displayLoadingUI=function(){},r.prototype.hideLoadingUI=function(){},r.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0)},r.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},r.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},r.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},r}(e.Engine);e.NullEngine=i}(a||(a={})),function(e){var t=function(){function t(t){this.engine=t,this._captureGPUFrameTime=!1,this._gpuFrameTime=new e.PerfCounter,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new e.PerfCounter,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(t.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add(function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())}),this._onEndFrameObserver=this.engine.onEndFrameObservable.add(function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}})):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add(function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()}),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add(function(){t._shaderCompilationTime.endMonitoring()})):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},t}();e.EngineInstrumentation=t}(a||(a={})),function(e){var t=function(){function t(t){var i=this;this.scene=t,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new e.PerfCounter,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new e.PerfCounter,this._captureFrameTime=!1,this._frameTime=new e.PerfCounter,this._captureRenderTime=!1,this._renderTime=new e.PerfCounter,this._captureInterFrameTime=!1,this._interFrameTime=new e.PerfCounter,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new e.PerfCounter,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new e.PerfCounter,this._capturePhysicsTime=!1,this._physicsTime=new e.PerfCounter,this._captureAnimationsTime=!1,this._animationsTime=new e.PerfCounter,this._captureCameraRenderTime=!1,this._cameraRenderTime=new e.PerfCounter,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=t.onBeforeAnimationsObservable.add(function(){i._captureActiveMeshesEvaluationTime&&i._activeMeshesEvaluationTime.fetchNewFrame(),i._captureRenderTargetsRenderTime&&i._renderTargetsRenderTime.fetchNewFrame(),i._captureFrameTime&&(e.Tools.StartPerformanceCounter("Scene rendering"),i._frameTime.beginMonitoring()),i._captureInterFrameTime&&i._interFrameTime.endMonitoring(),i._captureParticlesRenderTime&&i._particlesRenderTime.fetchNewFrame(),i._captureSpritesRenderTime&&i._spritesRenderTime.fetchNewFrame(),i._captureAnimationsTime&&i._animationsTime.beginMonitoring(),i.scene.getEngine()._drawCalls.fetchNewFrame(),i.scene.getEngine()._textureCollisions.fetchNewFrame()}),this._onAfterRenderObserver=t.onAfterRenderObservable.add(function(){i._captureFrameTime&&(e.Tools.EndPerformanceCounter("Scene rendering"),i._frameTime.endMonitoring()),i._captureRenderTime&&i._renderTime.endMonitoring(!1),i._captureInterFrameTime&&i._interFrameTime.beginMonitoring()})}return Object.defineProperty(t.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(t){var i=this;t!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=t,t?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add(function(){e.Tools.StartPerformanceCounter("Active meshes evaluation"),i._activeMeshesEvaluationTime.beginMonitoring()}),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add(function(){e.Tools.EndPerformanceCounter("Active meshes evaluation"),i._activeMeshesEvaluationTime.endMonitoring()})):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(t){var i=this;t!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=t,t?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add(function(){e.Tools.StartPerformanceCounter("Render targets rendering"),i._renderTargetsRenderTime.beginMonitoring()}),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add(function(){e.Tools.EndPerformanceCounter("Render targets rendering"),i._renderTargetsRenderTime.endMonitoring(!1)})):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(t){var i=this;t!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=t,t?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add(function(){e.Tools.StartPerformanceCounter("Particles"),i._particlesRenderTime.beginMonitoring()}),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add(function(){e.Tools.EndPerformanceCounter("Particles"),i._particlesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(t){var i=this;t!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=t,this.scene.spriteManagers&&(t?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add(function(){e.Tools.StartPerformanceCounter("Sprites"),i._spritesRenderTime.beginMonitoring()}),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add(function(){e.Tools.EndPerformanceCounter("Sprites"),i._spritesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(t){var i=this;t!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=t,t?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add(function(){e.Tools.StartPerformanceCounter("Physics"),i._physicsTime.beginMonitoring()}),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add(function(){e.Tools.EndPerformanceCounter("Physics"),i._physicsTime.endMonitoring()})):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add(function(){t._animationsTime.endMonitoring()}):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var i=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add(function(){i._renderTime.beginMonitoring(),e.Tools.StartPerformanceCounter("Main render")}),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add(function(){i._renderTime.endMonitoring(!1),e.Tools.EndPerformanceCounter("Main render")})):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(t){var i=this;t!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=t,t?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add(function(t){i._cameraRenderTime.beginMonitoring(),e.Tools.StartPerformanceCounter("Rendering camera "+t.name)}),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add(function(t){i._cameraRenderTime.endMonitoring(!1),e.Tools.EndPerformanceCounter("Rendering camera "+t.name)})):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureCollisionsCounter",{get:function(){return this.scene.getEngine()._textureCollisions},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},t}();e.SceneInstrumentation=t}(a||(a={})),function(e){var t=function(){return function(){this._timeElapsedQueryEnded=!1}}();e._TimeToken=t}(a||(a={})),function(e){var t=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.GAMMADIFFUSE=!1,t.DIFFUSEHASALPHA=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONBLUR=!1,t.REFLECTIONFRESNEL=!1,t.REFLECTIONFALLOFF=!1,t.TEXTURELODSUPPORT=!1,t.PREMULTIPLYALPHA=!1,t.USERGBCOLOR=!1,t.USEHIGHLIGHTANDSHADOWCOLORS=!1,t.NOISE=!1,t.REFLECTIONBGR=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.EQUIRECTANGULAR_RELFECTION_FOV=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SHADOWFLOAT=!1,t.rebuild(),t}return o(t,e),t}(e.MaterialDefines),i=function(i){function r(t,r){var n=i.call(this,t,r)||this;return n.primaryColor=e.Color3.White(),n._primaryColorShadowLevel=0,n._primaryColorHighlightLevel=0,n.reflectionTexture=null,n.reflectionBlur=0,n.diffuseTexture=null,n._shadowLights=null,n.shadowLights=null,n.shadowLevel=0,n.sceneCenter=e.Vector3.Zero(),n.opacityFresnel=!0,n.reflectionFresnel=!1,n.reflectionFalloffDistance=0,n.reflectionAmount=1,n.reflectionReflectance0=.05,n.reflectionReflectance90=.5,n.useRGBColor=!0,n.enableNoise=!1,n._fovMultiplier=1,n.useEquirectangularFOV=!1,n._maxSimultaneousLights=4,n.maxSimultaneousLights=4,n._imageProcessingObserver=null,n.switchToBGR=!1,n._renderTargets=new e.SmartArray(16),n._reflectionControls=e.Vector4.Zero(),n._white=e.Color3.White(),n._primaryShadowColor=e.Color3.Black(),n._primaryHighlightColor=e.Color3.Black(),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),n._diffuseTexture&&n._diffuseTexture.isRenderTarget&&n._renderTargets.push(n._diffuseTexture),n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._renderTargets},n}return o(r,i),Object.defineProperty(r.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"reflectionStandardFresnelWeight",{set:function(e){var t=e;t<.5?(t*=2,this.reflectionReflectance0=r.StandardReflectance0*t,this.reflectionReflectance90=r.StandardReflectance90*t):(t=2*t-1,this.reflectionReflectance0=r.StandardReflectance0+(1-r.StandardReflectance0)*t,this.reflectionReflectance90=r.StandardReflectance90+(1-r.StandardReflectance90)*t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fovMultiplier",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!0,configurable:!0}),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._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(e){t._computePrimaryColorFromPerceptualColor(),t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),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}),Object.defineProperty(r.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),r.prototype.needAlphaTesting=function(){return!0},r.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},r.prototype.isReadyForSubMesh=function(i,r,n){var o=this;if(void 0===n&&(n=!1),r.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var s=this.getScene(),a=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&a._renderId===s.getRenderId())return!0;var l=s.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(s,i,a,!1,this._maxSimultaneousLights),a._needNormals=!0,a._areTexturesDirty){if(a._needUVs=!1,s.texturesEnabled){if(s.getEngine().getCaps().textureLOD&&(a.TEXTURELODSUPPORT=!0),this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,a,"DIFFUSE"),a.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,a.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,a.OPACITYFRESNEL=this._opacityFresnel}else a.DIFFUSE=!1,a.DIFFUSEHASALPHA=!1,a.GAMMADIFFUSE=!1,a.OPACITYFRESNEL=!1;var c=this._reflectionTexture;if(c&&e.StandardMaterial.ReflectionTextureEnabled){if(!c.isReadyOrNotBlocking())return!1;switch(a.REFLECTION=!0,a.GAMMAREFLECTION=c.gammaSpace,a.RGBDREFLECTION=c.isRGBD,a.REFLECTIONBLUR=this._reflectionBlur>0,a.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!c.invertZ:c.invertZ,a.LODINREFLECTIONALPHA=c.lodLevelInAlpha,a.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,a.REFLECTIONBGR=this.switchToBGR,c.coordinatesMode===e.Texture.INVCUBIC_MODE&&(a.INVERTCUBICMAP=!0),a.REFLECTIONMAP_3D=c.isCube,c.coordinatesMode){case e.Texture.EXPLICIT_MODE:a.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:a.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:a.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:a.REFLECTIONMAP_SKYBOX=!0,a.REFLECTIONMAP_SKYBOX_TRANSFORMED=!c.getReflectionTextureMatrix().isIdentity();break;case e.Texture.SPHERICAL_MODE:a.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:default:a.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(a.REFLECTIONFRESNEL=!0,a.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(a.REFLECTIONFRESNEL=!1,a.REFLECTIONFALLOFF=!1)}else a.REFLECTION=!1,a.REFLECTIONFRESNEL=!1,a.REFLECTIONFALLOFF=!1,a.REFLECTIONBLUR=!1,a.REFLECTIONMAP_3D=!1,a.REFLECTIONMAP_SPHERICAL=!1,a.REFLECTIONMAP_PLANAR=!1,a.REFLECTIONMAP_CUBIC=!1,a.REFLECTIONMAP_PROJECTION=!1,a.REFLECTIONMAP_SKYBOX=!1,a.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,a.REFLECTIONMAP_EXPLICIT=!1,a.REFLECTIONMAP_EQUIRECTANGULAR=!1,a.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,a.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,a.INVERTCUBICMAP=!1,a.REFLECTIONMAP_OPPOSITEZ=!1,a.LODINREFLECTIONALPHA=!1,a.GAMMAREFLECTION=!1,a.RGBDREFLECTION=!1}a.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,a.USERGBCOLOR=this._useRGBColor,a.NOISE=this._enableNoise}if(a._areLightsDirty&&(a.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel)),a._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(e.MaterialHelper.PrepareDefinesForMisc(i,s,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(i),a),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,n),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!1,!0,!1)&&i&&(s.getEngine().getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("BackgroundMaterial: Normals have been created for the mesh: "+i.name))),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var u=new e.EffectFallbacks;a.FOG&&u.addFallback(0,"FOG"),a.POINTSIZE&&u.addFallback(1,"POINTSIZE"),e.MaterialHelper.HandleFallbacksForShadows(a,u,this._maxSimultaneousLights),a.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,i);var h=[e.VertexBuffer.PositionKind];a.NORMAL&&h.push(e.VertexBuffer.NormalKind),a.UV1&&h.push(e.VertexBuffer.UVKind),a.UV2&&h.push(e.VertexBuffer.UV2Kind),e.MaterialHelper.PrepareAttributesForBones(h,i,a,u),e.MaterialHelper.PrepareAttributesForInstances(h,a);var d=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],f=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],p=["Material","Scene"];e.ImageProcessingConfiguration&&(e.ImageProcessingConfiguration.PrepareUniforms(d,a),e.ImageProcessingConfiguration.PrepareSamplers(f,a)),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:a,maxSimultaneousLights:this._maxSimultaneousLights});var m=a.toString();r.setEffect(s.getEngine().createEffect("background",{attributes:h,uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:m,fallbacks:u,onCompiled:function(e){o.onCompiled&&o.onCompiled(e),o.bindSceneUniformBuffer(e,s.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},l),a),this.buildUniformLayout()}return!(!r.effect||!r.effect.isReady())&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},r.prototype._computePrimaryColors=function(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.create()},r.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},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),e.MaterialHelper.BindBonesParameters(i,this._activeEffect);var a=this._mustRebind(n,s,i.visibility);if(a){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s);var l=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(n.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),l&&e.StandardMaterial.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),n.texturesEnabled&&(this._diffuseTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),l&&e.StandardMaterial.ReflectionTextureEnabled&&(o.REFLECTIONBLUR&&o.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",l):o.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l)):this._uniformBuffer.setTexture("reflectionSampler",l),o.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),e.MaterialHelper.BindClipPlane(this._activeEffect,n),e.MaterialHelper.BindEyePosition(s,n)}!a&&this.isFrozen||(n.lightsEnabled&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,!1),this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},r.prototype.dispose=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),i.prototype.dispose.call(this,e)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone(function(){return new r(t,i.getScene())},this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.BackgroundMaterial",t},r.prototype.getClassName=function(){return"BackgroundMaterial"},r.Parse=function(t,i,n){return e.SerializationHelper.Parse(function(){return new r(t.name,i)},t,i,n)},r.StandardReflectance0=.05,r.StandardReflectance90=.5,n([e.serializeAsColor3()],r.prototype,"_primaryColor",void 0),n([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"primaryColor",void 0),n([e.serializeAsColor3()],r.prototype,"__perceptualColor",void 0),n([e.serialize()],r.prototype,"_primaryColorShadowLevel",void 0),n([e.serialize()],r.prototype,"_primaryColorHighlightLevel",void 0),n([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"primaryColorHighlightLevel",null),n([e.serializeAsTexture()],r.prototype,"_reflectionTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),n([e.serialize()],r.prototype,"_reflectionBlur",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionBlur",void 0),n([e.serializeAsTexture()],r.prototype,"_diffuseTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"shadowLights",void 0),n([e.serialize()],r.prototype,"_shadowLevel",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"shadowLevel",void 0),n([e.serializeAsVector3()],r.prototype,"_sceneCenter",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"sceneCenter",void 0),n([e.serialize()],r.prototype,"_opacityFresnel",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityFresnel",void 0),n([e.serialize()],r.prototype,"_reflectionFresnel",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionFresnel",void 0),n([e.serialize()],r.prototype,"_reflectionFalloffDistance",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionFalloffDistance",void 0),n([e.serialize()],r.prototype,"_reflectionAmount",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionAmount",void 0),n([e.serialize()],r.prototype,"_reflectionReflectance0",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionReflectance0",void 0),n([e.serialize()],r.prototype,"_reflectionReflectance90",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionReflectance90",void 0),n([e.serialize()],r.prototype,"_useRGBColor",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRGBColor",void 0),n([e.serialize()],r.prototype,"_enableNoise",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"enableNoise",void 0),n([e.serialize()],r.prototype,"_maxSimultaneousLights",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"maxSimultaneousLights",void 0),n([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),r}(e.PushMaterial);e.BackgroundMaterial=i}(a||(a={}));s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(e){var t=function(){function t(i,r){var n=this;this._errorHandler=function(e,t){n.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=s({},t._getDefaultOptions(),i),this._scene=r,this.onErrorObservable=new e.Observable,this._setupBackground(),this._setupImageProcessing()}return t._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new e.Color3(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:e.Engine.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new e.Color3(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:e.Vector3.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(t.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),t.prototype.updateOptions=function(e){var t=s({},this._options,e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},t.prototype.setMainColor=function(t){this.groundMaterial&&(this.groundMaterial.primaryColor=t),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=t),this.groundMirror&&(this.groundMirror.clearColor=new e.Color4(t.r,t.g,t.b,1))},t.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},t.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof e.BaseTexture)this._scene.environmentTexture=this._options.environmentTexture;else{var t=e.CubeTexture.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=t}},t.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new e.Mesh("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var t=this._getSceneSize();this._options.createGround&&(this._setupGround(t),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(t),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(t),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=t.rootPosition.x,this._rootMesh.position.z=t.rootPosition.z,this._rootMesh.position.y=t.rootPosition.y},t.prototype._getSceneSize=function(){var t=this,i=this._options.groundSize,r=this._options.skyboxSize,n=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:i,skyboxSize:r,rootPosition:n};var o=this._scene.getWorldExtends(function(e){return e!==t._ground&&e!==t._rootMesh&&e!==t._skybox}),s=o.max.subtract(o.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof e.ArcRotateCamera&&this._scene.activeCamera.upperRadiusLimit&&(r=i=2*this._scene.activeCamera.upperRadiusLimit);var a=s.length();a>i&&(r=i=2*a),i*=1.1,r*=1.5,(n=o.min.add(s.scale(.5))).y=o.min.y-this._options.groundYBias}return{groundSize:i,skyboxSize:r,rootPosition:n}},t.prototype._setupGround=function(t){var i=this;this._ground&&!this._ground.isDisposed()||(this._ground=e.Mesh.CreatePlane("BackgroundPlane",t.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add(function(){i._ground=null})),this._ground.receiveShadows=this._options.enableGroundShadow},t.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new e.BackgroundMaterial("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},t.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof e.BaseTexture)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var t=new e.Texture(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler);t.gammaSpace=!1,t.hasAlpha=!0,this._groundMaterial.diffuseTexture=t}},t.prototype._setupGroundMirrorTexture=function(t){var i=e.Texture.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new e.MirrorTexture("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,e.Texture.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new e.Plane(0,-1,0,t.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=i,this._groundMirror.wrapV=i,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var r=0;r<this._scene.meshes.length;r++){var n=this._scene.meshes[r];n!==this._ground&&n!==this._skybox&&n!==this._rootMesh&&this._groundMirror.renderList.push(n)}this._groundMirror.clearColor=new e.Color4(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),this._groundMirror.adaptiveBlurKernel=this._options.groundMirrorBlurKernel},t.prototype._setupMirrorInGroundMaterial=function(){this._groundMaterial&&(this._groundMaterial.reflectionTexture=this._groundMirror,this._groundMaterial.reflectionFresnel=!0,this._groundMaterial.reflectionAmount=this._options.groundMirrorAmount,this._groundMaterial.reflectionStandardFresnelWeight=this._options.groundMirrorFresnelWeight,this._groundMaterial.reflectionFalloffDistance=this._options.groundMirrorFallOffDistance)},t.prototype._setupSkybox=function(t){var i=this;this._skybox&&!this._skybox.isDisposed()||(this._skybox=e.Mesh.CreateBox("BackgroundSkybox",t.skyboxSize,this._scene,void 0,e.Mesh.BACKSIDE),this._skybox.onDisposeObservable.add(function(){i._skybox=null})),this._skybox.parent=this._rootMesh},t.prototype._setupSkyboxMaterial=function(){this._skybox&&(this._skyboxMaterial||(this._skyboxMaterial=new e.BackgroundMaterial("BackgroundSkyboxMaterial",this._scene)),this._skyboxMaterial.useRGBColor=!1,this._skyboxMaterial.primaryColor=this._options.skyboxColor,this._skyboxMaterial.enableNoise=!0,this._skybox.material=this._skyboxMaterial)},t.prototype._setupSkyboxReflectionTexture=function(){this._skyboxMaterial&&(this._skyboxTexture||(this._options.skyboxTexture instanceof e.BaseTexture?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new e.CubeTexture(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=e.Texture.SKYBOX_MODE,this._skyboxTexture.gammaSpace=!1,this._skyboxMaterial.reflectionTexture=this._skyboxTexture)))},t.prototype.dispose=function(){this._groundMaterial&&this._groundMaterial.dispose(!0,!0),this._skyboxMaterial&&this._skyboxMaterial.dispose(!0,!0),this._rootMesh.dispose(!1)},t._groundTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundGround.png",t._skyboxTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundSkybox.dds",t._environmentTextureCDNUrl="https://assets.babylonjs.com/environments/environmentSpecular.env",t}();e.EnvironmentHelper=t}(a||(a={})),function(e){var t=function(){function t(){this.systems=new Array}return Object.defineProperty(t.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),t.prototype.setEmitterAsSphere=function(t,i,r){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:t,renderingGroupId:i};var n=e.MeshBuilder.CreateSphere("emitterSphere",{diameter:t.diameter,segments:t.segments},r);n.renderingGroupId=i;var o=new e.StandardMaterial("emitterSphereMaterial",r);o.emissiveColor=t.color,n.material=o;for(var s=0,a=this.systems;s<a.length;s++){a[s].emitter=n}this._emitterNode=n},t.prototype.start=function(e){for(var t=0,i=this.systems;t<i.length;t++){var r=i[t];e&&(r.emitter=e),r.start()}},t.prototype.dispose=function(){for(var e=0,t=this.systems;e<t.length;e++){t[e].dispose()}this.systems=[],this._emitterNode&&(this._emitterNode.dispose(),this._emitterNode=null)},t.prototype.serialize=function(){for(var e={systems:[]},t=0,i=this.systems;t<i.length;t++){var r=i[t];e.systems.push(r.serialize())}return this._emitterNode&&(e.emitter=this._emitterCreationOptions),e},t.Parse=function(i,r,n){void 0===n&&(n=!1);var o=new t,s=e.ParticleHelper.BaseAssetsUrl+"/textures/";r=r||e.Engine.LastCreatedScene;for(var a=0,l=i.systems;a<l.length;a++){var c=l[a];o.systems.push(n?e.GPUParticleSystem.Parse(c,r,s,!0):e.ParticleSystem.Parse(c,r,s,!0))}if(i.emitter){var u=i.emitter.options;switch(i.emitter.kind){case"Sphere":o.setEmitterAsSphere({diameter:u.diameter,segments:u.segments,color:e.Color3.FromArray(u.color)},i.emitter.renderingGroupId,r)}}return o},t}();e.ParticleSystemSet=t}(a||(a={})),function(e){var t=function(){function t(){}return t.CreateDefault=function(t,i,r,n){var o;return void 0===i&&(i=500),void 0===n&&(n=!1),(o=n?new e.GPUParticleSystem("default system",{capacity:i},r):new e.ParticleSystem("default system",i,r)).emitter=t,o.particleTexture=new e.Texture("https://www.babylonjs.com/assets/Flare.png",o.getScene()),o.createConeEmitter(.1,Math.PI/4),o.color1=new e.Color4(1,1,1,1),o.color2=new e.Color4(1,1,1,1),o.colorDead=new e.Color4(1,1,1,0),o.minSize=.1,o.maxSize=.1,o.minEmitPower=2,o.maxEmitPower=2,o.updateSpeed=1/60,o.emitRate=30,o},t.CreateAsync=function(i,r,n){void 0===n&&(n=!1),r||(r=e.Engine.LastCreatedScene);var o={};return r._addPendingData(o),new Promise(function(s,a){if(n&&!e.GPUParticleSystem.IsSupported)return r._removePendingData(o),a("Particle system with GPU is not supported.");e.Tools.LoadFile(t.BaseAssetsUrl+"/systems/"+i+".json",function(t,i){r._removePendingData(o);var a=JSON.parse(t.toString());return s(e.ParticleSystemSet.Parse(a,r,n))},void 0,void 0,void 0,function(e,t){return r._removePendingData(o),a("An error occured while the creation of your particle system. Check if your type '"+i+"' exists.")})})},t.ExportSet=function(t){for(var i=new e.ParticleSystemSet,r=0,n=t;r<n.length;r++){var o=n[r];i.systems.push(o)}return i},t.BaseAssetsUrl="https://assets.babylonjs.com/particles",t}();e.ParticleHelper=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o){var s=t.call(this,i,o)||this;s._useDirectMapping=!1,i=i||"videoDome",n.resolution=0|Math.abs(n.resolution)||32,n.clickToPlay=Boolean(n.clickToPlay),n.autoPlay=void 0===n.autoPlay||Boolean(n.autoPlay),n.loop=void 0===n.loop||Boolean(n.loop),n.size=Math.abs(n.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),void 0===n.useDirectMapping?s._useDirectMapping=!0:s._useDirectMapping=n.useDirectMapping,s._setReady(!1);var a={loop:n.loop,autoPlay:n.autoPlay,autoUpdateTexture:!0,poster:n.poster},l=s._material=new e.BackgroundMaterial(i+"_material",o),c=s._videoTexture=new e.VideoTexture(i+"_texture",r,o,!1,s._useDirectMapping,e.Texture.TRILINEAR_SAMPLINGMODE,a);return s._mesh=e.Mesh.CreateSphere(i+"_mesh",n.resolution,n.size,o,!1,e.Mesh.BACKSIDE),c.onLoadObservable.addOnce(function(){s._setReady(!0)}),l.useEquirectangularFOV=!0,l.fovMultiplier=1,l.opacityFresnel=!1,s._useDirectMapping?(c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,l.diffuseTexture=c):(c.coordinatesMode=e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,l.reflectionTexture=c),s._mesh.material=l,s._mesh.parent=s,n.clickToPlay&&(o.onPointerUp=function(){s._videoTexture.video.play()}),s}return o(i,t),Object.defineProperty(i.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e,i){void 0===i&&(i=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),t.prototype.dispose.call(this,e,i)},i}(e.TransformNode);e.VideoDome=t}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===s&&(s=null);var a=t.call(this,i,o)||this;a._useDirectMapping=!1,a.onLoadErrorObservable=new e.Observable,i=i||"photoDome",n.resolution=0|Math.abs(n.resolution)||32,n.size=Math.abs(n.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),void 0===n.useDirectMapping?a._useDirectMapping=!0:a._useDirectMapping=n.useDirectMapping,a._setReady(!1);var l=a._material=new e.BackgroundMaterial(i+"_material",o);return a._mesh=e.Mesh.CreateSphere(i+"_mesh",n.resolution,n.size,o,!1,e.Mesh.BACKSIDE),l.opacityFresnel=!1,l.useEquirectangularFOV=!0,l.fovMultiplier=1,a.photoTexture=new e.Texture(r,o,!0,!a._useDirectMapping,void 0,void 0,function(e,t){a.onLoadErrorObservable.notifyObservers(e||"Unknown error occured"),s&&s(e,t)}),a.photoTexture.onLoadObservable.addOnce(function(){a._setReady(!0)}),a._mesh.material=l,a._mesh.parent=a,a}return o(i,t),Object.defineProperty(i.prototype,"photoTexture",{get:function(){return this._photoTexture},set:function(t){this._photoTexture!==t&&(this._photoTexture=t,this._useDirectMapping?(this._photoTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._photoTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._photoTexture):(this._photoTexture.coordinatesMode=e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._photoTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._photoTexture))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),i.prototype.dispose=function(e,i){void 0===i&&(i=!1),this._photoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this.onLoadErrorObservable.clear(),t.prototype.dispose.call(this,e,i)},i}(e.TransformNode);e.PhotoDome=t}(a||(a={})),function(e){var t=function(){return function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=e.AbstractMesh.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=e.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE}}();e.Engine.prototype.createQuery=function(){return this._gl.createQuery()},e.Engine.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},e.Engine.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},e.Engine.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},e.Engine.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},e.Engine.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},e.Engine.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},e.Engine.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},e.Engine.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},e.Engine.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},e.Engine.prototype.startTimeQuery=function(){var t=this.getCaps(),i=t.timerQuery;if(!i)return null;var r=new e._TimeToken;if(this._gl.getParameter(i.GPU_DISJOINT_EXT),t.canUseTimestampForTimerQuery)r._startTimeQuery=this._createTimeQuery(),i.queryCounterEXT(r._startTimeQuery,i.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;r._timeElapsedQuery=this._createTimeQuery(),i.beginQueryEXT?i.beginQueryEXT(i.TIME_ELAPSED_EXT,r._timeElapsedQuery):this._gl.beginQuery(i.TIME_ELAPSED_EXT,r._timeElapsedQuery),this._currentNonTimestampToken=r}return r},e.Engine.prototype.endTimeQuery=function(e){var t=this.getCaps(),i=t.timerQuery;if(!i||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),i.queryCounterEXT(e._endTimeQuery,i.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;i.endQueryEXT?i.endQueryEXT(i.TIME_ELAPSED_EXT):this._gl.endQuery(i.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(i.GPU_DISJOINT_EXT),n=!1;if(e._endTimeQuery?n=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(n=this._getTimeQueryAvailability(e._timeElapsedQuery)),n&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var s=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-s,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},e.Engine.prototype._getGlAlgorithmType=function(t){return t===e.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(e.AbstractMesh.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},enumerable:!1,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new t),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.AbstractMesh.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),e.AbstractMesh.prototype._checkOcclusionQuery=function(){var t=this._occlusionDataStorage;if(t.occlusionType===e.AbstractMesh.OCCLUSION_TYPE_NONE)return t.isOccluded=!1,!1;var i=this.getEngine();if(i.webGLVersion<2)return t.isOccluded=!1,!1;if(!i.isQueryResultAvailable)return t.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(i.isQueryResultAvailable(this._occlusionQuery)){var r=i.getQueryResult(this._occlusionQuery);t.isOcclusionQueryInProgress=!1,t.occlusionInternalRetryCounter=0,t.isOccluded=1!==r}else{if(t.occlusionInternalRetryCounter++,!(-1!==t.occlusionRetryCount&&t.occlusionInternalRetryCounter>t.occlusionRetryCount))return!1;t.isOcclusionQueryInProgress=!1,t.occlusionInternalRetryCounter=0,t.isOccluded=t.occlusionType!==e.AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC&&t.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var o=n.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=i.createQuery()),i.beginOcclusionQuery(t.occlusionQueryAlgorithmType,this._occlusionQuery),o.renderOcclusionBoundingBox(this),i.endOcclusionQuery(t.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return t.isOccluded}}(a||(a={})),function(e){var t=function(t){function i(i,r,n,o,s){void 0===r&&(r=256),void 0===n&&(n=e.Engine.LastCreatedScene);var a=t.call(this,i,r,"noise",n,o,s)||this;return a._time=0,a.brightness=.2,a.octaves=3,a.persistence=.8,a.animationSpeedFactor=1,a.autoClear=!1,a._updateShaderUniforms(),a}return o(i,t),i.prototype._updateShaderUniforms=function(){var e=this.getScene();e&&(this._time+=e.getAnimationRatio()*this.animationSpeedFactor*.01,this.setFloat("brightness",this.brightness),this.setFloat("persistence",this.persistence),this.setFloat("timeScale",this._time))},i.prototype._getDefines=function(){return"#define OCTAVES "+(0|this.octaves)},i.prototype.render=function(e){this._updateShaderUniforms(),t.prototype.render.call(this,e)},i.prototype.serialize=function(){var e={customType:"BABYLON.NoiseProceduralTexture"};return e.brightness=this.brightness,e.octaves=this.octaves,e.persistence=this.persistence,e.animationSpeedFactor=this.animationSpeedFactor,e.size=this.getSize().width,e.generateMipMaps=this._generateMipMaps,e},i.Parse=function(e,t,r){var n=new i(e.name,e.size,t,void 0,e.generateMipMaps);return n.brightness=e.brightness,n.octaves=e.octaves,n.persistence=e.persistence,n.animationSpeedFactor=e.animationSpeedFactor,n},i}(e.ProceduralTexture);e.NoiseProceduralTexture=t}(a||(a={}));var a;s=this&&this.__assign||function(){return(s=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!function(e){var t=function(){function t(e,i){if(void 0===i&&(i=null),!t.IsSupported(e))throw"Your browser does not support recording so far.";var r=e.getRenderingCanvas();if(!r)throw"The babylon engine must have a canvas to be recorded";this._canvas=r,this._canvas.isRecording=!1,this._options=s({},t._defaultOptions,i);var n=this._canvas.captureStream(this._options.fps);this._mediaRecorder=new MediaRecorder(n,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return t.IsSupported=function(e){var t=e.getRenderingCanvas();return!!t&&"function"==typeof t.captureStream},Object.defineProperty(t.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!0,configurable:!0}),t.prototype.stopRecording=function(){this._canvas&&this._mediaRecorder&&this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},t.prototype.startRecording=function(e,t){var i=this;if(void 0===e&&(e="babylonjs.webm"),void 0===t&&(t=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return t>0&&setTimeout(function(){i.stopRecording()},1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(e,t){i._resolve=e,i._reject=t})},t.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},t.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},t.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},t.prototype._handleStop=function(){this.stopRecording();var t=new Blob(this._recordedChunks);this._resolve&&this._resolve(t),window.URL.createObjectURL(t),this._fileName&&e.Tools.Download(t,this._fileName)},t._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},t}();e.VideoRecorder=t}(a||(a={})),function(e){e.Scene.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)},e.Scene.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 c=new e.ArcRotateCamera("default camera",-Math.PI/2,Math.PI/2,l,a,this);c.lowerRadiusLimit=.01*l,c.wheelPrecision=100/l,n=c}else{var u=new e.FreeCamera("default camera",new e.Vector3(a.x,a.y,-l),this);u.setTarget(a),n=u}n.minZ=.01*l,n.maxZ=1e3*l,n.speed=.2*l,this.activeCamera=n;var h=this.getEngine().getRenderingCanvas();r&&h&&n.attachControl(h)}},e.Scene.prototype.createDefaultCameraOrLight=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this.createDefaultLight(t),this.createDefaultCamera(e,t,i)},e.Scene.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},e.Scene.prototype.createDefaultEnvironment=function(t){return e.EnvironmentHelper?new e.EnvironmentHelper(t,this):null},e.Scene.prototype.createDefaultVRExperience=function(t){return void 0===t&&(t={}),new e.VRExperienceHelper(this,t)}}(a||(a={})),a.Effect.ShadersStore={defaultVertexShader:"#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif \n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}",pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2;\n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",rgbdEncodePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void) \n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}",rgbdDecodePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void) \n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET \nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD \nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction; \n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET \nuniform vec3 particlesInfos; \n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition; \n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#endif\nvoid main(void) { \nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD \n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY \nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz; \n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition; \nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz; \n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner; \n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0); \n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0); \n#endif \nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include<clipPlaneVertex>\n}",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include<clipPlaneFragmentDeclaration>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\n\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n}",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",gpuRenderParticlesVertexShader:"#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition; \n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else \nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY \nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0)); \n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition; \nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0)); \n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0); \n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif \n#include<clipPlaneVertex>\n}",gpuRenderParticlesPixelShader:"#version 300 es\nuniform sampler2D textureSampler;\nin vec2 vUV;\nin vec4 vColor;\nout vec4 outFragColor;\n#include<clipPlaneFragmentDeclaration2> \n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment> \nvec4 textureColor=texture(textureSampler,vUV);\noutFragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\noutFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha); \n#endif \n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\noutFragColor=applyImageProcessing(outFragColor);\n#endif\n#endif\n}\n",gpuUpdateParticlesVertexShader:"#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\nuniform mat4 emitterWM;\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\n\nin vec3 position;\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\n\nout vec3 outPosition;\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta; \n\nif (newAge>=life && stopFactor != 0.) {\nvec3 position;\nvec3 direction;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=mod(newAge,outLife);\n\noutSeed=seed;\n\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\n\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n\n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=vec3(0,0,0);\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\ndirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\ndirection=position+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\ndirection=position+directionRandomizer*randoms3;\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nposition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\ndirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\ndirection=normalize(direction);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.00001;\n#else\nfloat h=randoms2.y*height.y;\n\nh=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h*height.x;\nposition=vec3(randX,randY,randZ); \n\nif (abs(cos(coneAngle)) == 1.0) {\ndirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\ndirection=position+directionRandomizer*randoms3;\n}\n#else \n\nposition=vec3(0.,0.,0.);\n\ndirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\noutPosition=(emitterWM*vec4(position,1.)).xyz;\nvec3 initial=(emitterWM*vec4(direction,0.)).xyz;\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\noutPosition=position+direction*directionScale;\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nvec3 localPosition=outPosition-emitterWM[3].xyz;\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#endif \nfloat ratio=clamp(mod(offsetAge*cellInfos.z,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}",gpuUpdateParticlesPixelShader:"#version 300 es\nvoid main() {\ndiscard;\n}\n",postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}",geometryVertexShader:"precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nvarying vec2 uv;\n#endif\n#ifdef UV2\nvarying vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",geometryPixelShader:"#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef POSITION\n#include<mrtFragmentDeclaration>[3]\n#else\n#include<mrtFragmentDeclaration>[2]\n#endif\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[2]=vec4(vPosition,1.0);\n#endif\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n",ssao2PixelShader:"\nprecision highp float;\nuniform sampler2D textureSampler;\nuniform float near;\nuniform float far;\nuniform float radius;\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);\nvarying vec2 vUV;\nfloat perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform sampler2D normalSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float base;\nuniform float xViewport;\nuniform float yViewport;\nuniform float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(textureSampler,vUV).r;\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\nvec3 normal=texture2D(normalSampler,vUV).rgb; \nfloat occlusion=0.0;\nfloat correctedRadius=min(radius,minZAspect*depth/near);\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\nvec3 origin=vViewRay*depth;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\n\nfloat dotProduct=dot(rvec,normal);\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i<SAMPLES; ++i) {\n\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\n\nvec4 offset=vec4(samplePosition,1.0);\noffset=projection*offset;\noffset.xyz/=offset.w;\noffset.xy=offset.xy*0.5+0.5;\nif (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {\ncontinue;\n}\n\nfloat sampleDepth=abs(texture2D(textureSampler,offset.xy).r);\n\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 direction=vec2(0.0,1.0);\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=abs(texture2D(depthSampler,samplePos).r);\nfloat weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n#else\nvec4 color;\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#else\nvec2 direction=vec2(0.0,1.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#endif\ngl_FragColor.rgb=vec3(color.r);\ngl_FragColor.a=1.0;\n#endif\n}\n#endif\n",ssaoCombinePixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\nvoid main(void) {\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n}\n",lensHighlightsPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\nif (gain == -1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\n\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n\n}",depthOfFieldPixelShader:"\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\n\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion == 0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\n\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\n\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n",standardPixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n",fxaaVertexShader:"\nattribute vec2 position;\nuniform vec2 texelSize;\n\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n}",fxaaPixelShader:"uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\nreturn;\n}\n#endif\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\n#ifdef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\n}\nelse\n{\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}\n#else\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n#endif\n}",chromaticAberrationPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);\nvec2 directionOfEffect=direction;\nif(directionOfEffect.x == 0. && directionOfEffect.y == 0.){\ndirectionOfEffect=normalize(centered_screen_pos);\n}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\n\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;\nfloat ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;\n\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\noriginal.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);\ngl_FragColor=original;\n}",grainPixelShader:"#include<helperFunctions>\n\nuniform sampler2D textureSampler; \n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}",sharpenPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 color=texture2D(textureSampler,vUV);\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\n}",kernelBlurVertexShader:"\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}",kernelBlurPixelShader:"\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g; \nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; \n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r; \nreturn coc; \n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}",depthOfFieldMergePixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\nuniform sampler2D circleOfConfusionSampler;\nuniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\nvoid main(void)\n{\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\n#if BLUR_LEVEL == 0\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred0=texture2D(blurStep0,vUV);\ngl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL == 1\nif(coc<0.5){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(original,blurred1,coc/0.5);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV); \nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\n}\n#endif\n#if BLUR_LEVEL == 2\nif(coc<0.33){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(original,blurred2,coc/0.33);\n}else if(coc<0.66){\nvec4 blurred1=texture2D(blurStep1,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\n}\n#endif\n}\n",circleOfConfusionPixelShader:"\nuniform sampler2D depthSampler;\n\nvarying vec2 vUV;\n\nuniform vec2 cameraMinMaxZ;\n\nuniform float focusDistance;\nuniform float cocPrecalculation;\nvoid main(void)\n{\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0; \nfloat coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));\ncoc=clamp(coc,0.0,1.0);\ngl_FragColor=vec4(coc,depth,coc,1.0);\n}\n",bloomMergePixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); \n}\n",extractHighlightsPixelShader:"#include<helperFunctions>\n\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\n}",refractionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}",blackAndWhitePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void) \n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11)); \nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}",convolutionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}",filterPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}",volumetricLightScatteringPixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;\ndataSample*=illuminationDecay*weight;\ncolor+=dataSample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n}\n",volumetricLightScatteringPassPixelShader:"#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n",colorCorrectionPixelShader:"\nuniform sampler2D textureSampler; \nuniform sampler2D colorTable; \n\nvarying vec2 vUV;\n\nconst float SLICE_COUNT=16.0; \n\nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {\nfloat sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}",tonemapPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\nvoid main(void) \n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}",displayPassPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}",highlightsPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void) \n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); \n}",imageProcessingPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}",lensFlareVertexShader:"\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}",lensFlarePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}",anaglyphPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}",stereoscopicInterlacePixelShader:"const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}",vrDistortionCorrectionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*color;\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",lineVertexShader:"\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n}",linePixelShader:"uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}",outlineVertexShader:"\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<logDepthVertex>\n}\n",outlinePixelShader:"#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n}",layerVertexShader:"\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}",layerPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}",backgroundVertexShader:"precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 \nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",backgroundPixelShader:"#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n",noisePixelShader:"\n\nuniform float brightness;\nuniform float persistence;\nuniform float timeScale;\n\nvarying vec2 vUV;\n\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y); \nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i<OCTAVES; i++)\n{\nfrequency=pow(2.0,float(i));\namplitude=pow(persistence,float(i));\nsum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;\n}\nreturn sum;\n}\n\nvoid main(void)\n{\nfloat x=abs(vUV.x);\nfloat y=abs(vUV.y);\nfloat noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);\ngl_FragColor=vec4(noise,noise,noise,1.0);\n}\n"},a.Effect.IncludesShadersStore={depthPrePass:"#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif",bonesDeclaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif",instancesDeclaration:"#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\n#endif",bumpVertexDeclaration:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",clipPlaneVertexDeclaration:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nvarying float fClipDistance4;\n#endif",fogVertexDeclaration:"#ifdef FOG\nvarying vec3 vFogDistance;\n#endif",morphTargetsVertexGlobalDeclaration:"#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif",morphTargetsVertexDeclaration:"#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif",logDepthDeclaration:"#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif",morphTargetsVertex:"#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif",instancesVertex:"#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif",bonesVertex:"#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif",bumpVertex:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif",clipPlaneVertex:"#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif",fogVertex:"#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif",shadowsVertex:"#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",helperFunctions:"const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D); \n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}",lightFragmentDeclaration:"#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}",lightUboDeclaration:"#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X}; \n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif",defaultVertexDeclaration:"\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",defaultFragmentDeclaration:"uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif",defaultUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",shadowsFragmentFunctions:"#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n",fresnelFunction:"#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif",reflectionFunction:"#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y; \n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y; \nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}",imageProcessingDeclaration:"#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif",imageProcessingFunctions:"#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}",bumpFragmentFunctions:"#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",clipPlaneFragmentDeclaration:"#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif",fogFragmentDeclaration:"#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif",clipPlaneFragment:"#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif",bumpFragment:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW); \n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif",lightFragment:"#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif",logDepthFragment:"#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif",fogFragment:"#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif",pbrVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n",pbrFragmentDeclaration:"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif",pbrUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif",pbrLightFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}",clipPlaneVertexDeclaration2:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nout float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nout float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nout float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nout float fClipDistance4;\n#endif",clipPlaneFragmentDeclaration2:"#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif",mrtFragmentDeclaration:"#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n",bones300Declaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nin vec4 matricesIndices;\nin vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nin vec4 matricesIndicesExtra;\nin vec4 matricesWeightsExtra;\n#endif\n#endif",instances300Declaration:"#ifdef INSTANCES\nin vec4 world0;\nin vec4 world1;\nin vec4 world2;\nin vec4 world3;\n#else\nuniform mat4 world;\n#endif",kernelBlurFragment:"#ifdef DOF\nfactor=sampleCoC(sampleCoord{X}); \ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif",kernelBlurFragment2:"#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif",kernelBlurVaryingDeclaration:"varying vec2 sampleCoord{X};",kernelBlurVertex:"sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};",backgroundVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif",backgroundFragmentDeclaration:" uniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif",backgroundUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};"};var l=void 0!==t?t:"undefined"!=typeof window?window:this;return l.BABYLON=a,void 0!==r&&(l.Earcut={earcut:r}),a})}).call(this,i(21))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(25).default;t.deepmerge=r,t.isUrl=function(e){return 0===e.indexOf("http")||0===e.indexOf("/")||0===e.indexOf("./")||0===e.indexOf("../")},t.kebabToCamel=function(e){return e.replace(/(\-\w)/g,function(e){return e[1].toUpperCase()})},t.camelToKebab=function(e){return e?e.replace(/([A-Z])/g,function(e){return"-"+e[0].toLowerCase()}):null},t.extendClassWithConfig=function e(t,i){i&&"object"==typeof i&&Object.keys(i).forEach(function(r){r in t&&"function"!=typeof t[r]&&("object"==typeof t[r]?e(t[r],i[r]):void 0!==i[r]&&(t[r]=i[r]))})}},function(e,t,i){"use strict";function r(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}Object.defineProperty(t,"__esModule",{value:!0}),r(i(30)),r(i(32)),r(i(38))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(1),o=function(){function e(){}return e.prototype.map=function(e){for(var t={},i=function(i){var r=e.attributes.item(i);if(!r)return"continue";var o=r.nodeName.split(".");o.reduce(function(e,t,i){var s=n.kebabToCamel(t);if(i===o.length-1){var a=r.nodeValue;if("true"===a)a=!0;else if("false"===a)a=!1;else if("undefined"===a)a=void 0;else if("null"===a)a=null;else{if(!isNaN(parseFloat(a))&&isFinite(a)){var l=parseFloat(a);isNaN(l)||(a=l)}}e[s]=a}else e[s]=e[s]||{};return e[s]},t)},r=0;r<e.attributes.length;++r)i(r);return t},e}(),s=function(){function e(){}return e.prototype.map=function(e){return JSON.parse(e)},e}(),a=function(){function e(){}return e.prototype.map=function(e){var t=new o,i=t.map(e),r=function(e,i){var o=e.children;if(o.length)for(var s=0;s<o.length;++s){var a=o.item(s),l=t.map(a),c=n.kebabToCamel(a.nodeName.toLowerCase());if(a.attributes.getNamedItem("array")&&"true"===a.attributes.getNamedItem("array").nodeValue)i[c]=[];else if(e.attributes.getNamedItem("array")&&"true"===e.attributes.getNamedItem("array").nodeValue)i.push(l);else if(i[c]){e.setAttribute("array","true"),i=[i[c],l]}else i[c]=l;r(a,i[c]||l)}return i};return r(e,i),i},e}(),l=function(){function e(){this._mappers={html:new o,json:new s,dom:new a}}return e.prototype.getMapper=function(e){return this._mappers[e]||r.Tools.Error("No mapper defined for "+e),this._mappers[e]},e.prototype.registerMapper=function(e,t){this._mappers[e]=t},e.prototype.dispose=function(){this._mappers={}},e.DefaultMapper="json",e}();t.MapperManager=l,t.mapperManager=new l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(){this.disableInit=!1,this.disableWebGL2Support=!1}return Object.defineProperty(e.prototype,"version",{get:function(){return r.Engine.Version},enumerable:!0,configurable:!0}),e}();t.ViewerGlobals=n,t.viewerGlobals=new n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,n=i(0),o=i(52),s=i(1);!function(e){e[e.INIT=0]="INIT",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e[e.ENTRY=3]="ENTRY",e[e.ENTRYDONE=4]="ENTRYDONE",e[e.COMPLETE=5]="COMPLETE",e[e.CANCELED=6]="CANCELED",e[e.ERROR=7]="ERROR"}(r=t.ModelState||(t.ModelState={}));var a=function(){function e(e,t,i){var o=this;this._observablesManager=e,this._configurationContainer=i,this._meshes=[],this.particleSystems=[],this.skeletons=[],this._loaderDone=!1,this._animatables=[],this._frameRate=60,this._shadowsRenderedAfterLoad=!1,this.onLoadedObservable=new n.Observable,this.onLoadErrorObservable=new n.Observable,this.onLoadProgressObservable=new n.Observable,this.onCompleteObservable=new n.Observable,this.onAfterConfigure=new n.Observable,this.state=r.INIT;var a=this._configurationContainer&&this._configurationContainer.scene;this.rootMesh=new n.AbstractMesh("modelRootMesh",a),this._pivotMesh=new n.AbstractMesh("pivotMesh",a),this._pivotMesh.parent=this.rootMesh,this._pivotMesh.rotation.y+=Math.PI,this._scaleTransition=new n.Animation("scaleAnimation","scaling",this._frameRate,n.Animation.ANIMATIONTYPE_VECTOR3,n.Animation.ANIMATIONLOOPMODE_CONSTANT),this._animations=[],this._modelConfiguration=s.deepmerge(this._configurationContainer&&this._configurationContainer.configuration.model||{},t),this._observablesManager&&this._observablesManager.onModelAddedObservable.notifyObservers(this),this._modelConfiguration.entryAnimation&&this.rootMesh.setEnabled(!1),this.onLoadedObservable.add(function(){o.updateConfiguration(o._modelConfiguration),o._observablesManager&&o._observablesManager.onModelLoadedObservable.notifyObservers(o),o._initAnimations()}),this.onCompleteObservable.add(function(){o.state=r.COMPLETE})}return Object.defineProperty(e.prototype,"shadowsRenderedAfterLoad",{get:function(){return this._shadowsRenderedAfterLoad},set:function(e){if(!e)throw new Error("can only be enabled");this._shadowsRenderedAfterLoad=e},enumerable:!0,configurable:!0}),e.prototype.getViewerId=function(){return this._configurationContainer&&this._configurationContainer.viewerId},Object.defineProperty(e.prototype,"enabled",{get:function(){return this.rootMesh.isEnabled()},set:function(e){this.rootMesh.setEnabled(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loaderDone",{set:function(e){this._loaderDone=e,this._checkCompleteState()},enumerable:!0,configurable:!0}),e.prototype._checkCompleteState=function(){this._loaderDone&&this.state===r.ENTRYDONE&&this._modelComplete()},e.prototype.addMesh=function(e,t){if(e.parent||(e.parent=this._pivotMesh),e.receiveShadows=!!this.configuration.receiveShadows,this._meshes.push(e),t)return this.onLoadedObservable.notifyObserversWithPromise(this)},Object.defineProperty(e.prototype,"meshes",{get:function(){return this._meshes},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"configuration",{get:function(){return this._modelConfiguration},set:function(e){this._modelConfiguration=e,this._configureModel()},enumerable:!0,configurable:!0}),e.prototype.updateConfiguration=function(e){this._modelConfiguration=s.deepmerge(this._modelConfiguration,e),this._configureModel()},e.prototype._initAnimations=function(){var e=this;this.skeletons.length&&this.skeletons.forEach(function(t,i){var r=new n.AnimationGroup("animation-"+i,e._configurationContainer&&e._configurationContainer.scene),o=!1;t.getAnimatables().forEach(function(e){e.animations[0]&&(r.addTargetedAnimation(e.animations[0],e),o=!0)}),o&&e.addAnimationGroup(r)});var t=function(){};if(this._modelConfiguration.animation&&(this._modelConfiguration.animation.playOnce&&this._animations.forEach(function(e){e.playMode=0}),this._modelConfiguration.animation.autoStart&&this._animations.length)){var i=!0===this._modelConfiguration.animation.autoStart?this._animations[0].name:this._modelConfiguration.animation.autoStart;t=function(){e.playAnimation(i)}}this._enterScene(t)},e.prototype._enterScene=function(e){var t=this,i=this.rootMesh.getScene(),n=i.animationPropertiesOverride.enableBlending,o=function(){t.state=r.ENTRYDONE,i.animationPropertiesOverride.enableBlending=n,t._checkCompleteState(),e&&e()};this._entryAnimation?(this.rootMesh.setEnabled(!0),i.animationPropertiesOverride.enableBlending=!1,this._applyAnimation(this._entryAnimation,!0,o)):o()},e.prototype._exitScene=function(e){this._exitAnimation?this._applyAnimation(this._exitAnimation,!1,e):e()},e.prototype._modelComplete=function(){var e=this;this._pivotMesh.getChildMeshes(!1).filter(function(e){return e.material}).forEach(function(t){e._applyModelMaterialConfiguration(t.material)}),this.state=r.COMPLETE,this.onCompleteObservable.notifyObservers(this)},e.prototype.addAnimationGroup=function(e){this._animations.push(new o.GroupModelAnimation(e))},e.prototype.getAnimations=function(){return this._animations},e.prototype.getAnimationNames=function(){return this._animations.map(function(e){return e.name})},e.prototype._getAnimationByName=function(e){var t=this._animations.filter(function(t){return t.name===e.trim()});return 1===t.length?t[0]:null},e.prototype.playAnimation=function(e){var t=this.setCurrentAnimationByName(e);return t&&t.start(),t},e.prototype.setCurrentAnimationByName=function(e){var t=this._getAnimationByName(e.trim());if(t)return this.currentAnimation&&3!==this.currentAnimation.state&&this.currentAnimation.stop(),this.currentAnimation=t,t;throw new Error("animation not found - "+e)},e.prototype._configureModel=function(){var e=this,t=[this.rootMesh],i=function(e,i,r){t.forEach(function(t){r?t[e][r]=i:t[e]=i})},r=function(e,t){void 0!==t.x&&i(e,t.x,"x"),void 0!==t.y&&i(e,t.y,"y"),void 0!==t.z&&i(e,t.z,"z"),void 0!==t.w&&i(e,t.w,"w")};if(this._modelConfiguration.normalize){var o=!1,s=!1,a=void 0;!0===this._modelConfiguration.normalize?(o=!0,s=!0):(o=!!this._modelConfiguration.normalize.center,s=!!this._modelConfiguration.normalize.unitSize,a=this._modelConfiguration.normalize.parentIndex);var l=[];void 0!==a?l.push(this._meshes[a]):l=1===this._pivotMesh.getChildMeshes(!0).length?[this._pivotMesh]:t,s&&l.forEach(function(e){e.normalizeToUnitCube(!0),e.computeWorldMatrix(!0)}),o&&l.forEach(function(e){var t=e.getHierarchyBoundingVectors(!0),i=t.max.subtract(t.min).scale(.5),r=t.min.add(i);e.position=r.scale(-1),e.position.y+=i.y,e.computeWorldMatrix(!0)})}if(this._modelConfiguration.position&&r("position",this._modelConfiguration.position),this._modelConfiguration.rotation&&(this._modelConfiguration.rotation.w?(t.forEach(function(e){e.rotationQuaternion||(e.rotationQuaternion=new n.Quaternion)}),r("rotationQuaternion",this._modelConfiguration.rotation)):r("rotation",this._modelConfiguration.rotation)),this._modelConfiguration.rotationOffsetAxis){var c=new n.Vector3(0,0,0).copyFrom(this._modelConfiguration.rotationOffsetAxis);t.forEach(function(t){e._modelConfiguration.rotationOffsetAngle&&t.rotate(c,e._modelConfiguration.rotationOffsetAngle)})}this._modelConfiguration.scaling&&r("scaling",this._modelConfiguration.scaling),this._modelConfiguration.castShadow&&this._meshes.forEach(function(e){n.Tags.AddTagsTo(e,"castShadow")}),this._pivotMesh.getChildMeshes(!1).filter(function(e){return e.material}).forEach(function(t){e._applyModelMaterialConfiguration(t.material)}),this._modelConfiguration.entryAnimation&&(this._entryAnimation=this._modelAnimationConfigurationToObject(this._modelConfiguration.entryAnimation)),this._modelConfiguration.exitAnimation&&(this._exitAnimation=this._modelAnimationConfigurationToObject(this._modelConfiguration.exitAnimation)),this.onAfterConfigure.notifyObservers(this)},e.prototype._modelAnimationConfigurationToObject=function(e){var t={time:.5};return e.scaling&&(t.scaling=n.Vector3.Zero()),void 0!==e.easingFunction&&(t.easingFunction=e.easingFunction),void 0!==e.easingMode&&(t.easingMode=e.easingMode),s.extendClassWithConfig(t,e),t},e.prototype._applyModelMaterialConfiguration=function(e){if(this._modelConfiguration.material)if(s.extendClassWithConfig(e,this._modelConfiguration.material),e instanceof n.PBRMaterial)void 0!==this._modelConfiguration.material.directIntensity&&(e.directIntensity=this._modelConfiguration.material.directIntensity),void 0!==this._modelConfiguration.material.emissiveIntensity&&(e.emissiveIntensity=this._modelConfiguration.material.emissiveIntensity),void 0!==this._modelConfiguration.material.environmentIntensity&&(e.environmentIntensity=this._modelConfiguration.material.environmentIntensity),void 0!==this._modelConfiguration.material.directEnabled&&(e.disableLighting=!this._modelConfiguration.material.directEnabled),this._configurationContainer&&this._configurationContainer.reflectionColor&&(e.reflectionColor=this._configurationContainer.reflectionColor);else if(e instanceof n.MultiMaterial)for(var t=0;t<e.subMaterials.length;t++){var i=e.subMaterials[t];i&&this._applyModelMaterialConfiguration(i)}},e.prototype._applyAnimation=function(e,t,i){var r=[];if(e.scaling){var o=t?e.scaling:new n.Vector3(1,1,1),s=t?new n.Vector3(1,1,1):e.scaling;o.equals(s)||(this.rootMesh.scaling=o,this._setLinearKeys(this._scaleTransition,this.rootMesh.scaling,s,e.time),r.push(this._scaleTransition))}this.transitionTo(r,e.time,this._createEasingFunction(e.easingFunction),e.easingMode,function(){i&&i()})},e.prototype.transitionTo=function(e,t,i,r,n){if(void 0===r&&(r=BABYLON.EasingFunction.EASINGMODE_EASEINOUT),i)for(var o=0,s=e;o<s.length;o++){var a=s[o];i.setEasingMode(r),a.setEasingFunction(i)}if(this.stopAllAnimations(),this.rootMesh.animations=e,this.rootMesh.getScene().beginAnimation){var l=this.rootMesh.getScene().beginAnimation(this.rootMesh,0,this._frameRate*t,!1,1,function(){n&&n()});this._animatables.push(l)}},e.prototype._setLinearKeys=function(e,t,i,r){e.setKeys([{frame:0,value:t},{frame:this._frameRate*r,value:i}])},e.prototype._createEasingFunction=function(e){var t;switch(e){case 1:t=new n.CircleEase;break;case 2:t=new n.BackEase(.3);break;case 3:t=new n.BounceEase;break;case 4:t=new n.CubicEase;break;case 5:t=new n.ElasticEase;break;case 6:t=new n.ExponentialEase;break;case 7:t=new n.PowerEase;break;case 8:t=new n.QuadraticEase;break;case 9:t=new n.QuarticEase;break;case 10:t=new n.QuinticEase;break;case 11:t=new n.SineEase;break;default:n.Tools.Log("No ease function found")}return t},e.prototype.stopAllAnimations=function(){for(this.rootMesh&&(this.rootMesh.animations=[]),this.currentAnimation&&this.currentAnimation.stop();this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.prototype.remove=function(){this.stopAllAnimations(),this.rootMesh.isVisible=!1,this._observablesManager&&this._observablesManager.onModelRemovedObservable.notifyObservers(this)},e.prototype.dispose=function(){this.remove(),this.onAfterConfigure.clear(),this.onLoadedObservable.clear(),this.onLoadErrorObservable.clear(),this.onLoadProgressObservable.clear(),this.loader&&"gltf"===this.loader.name&&this.loader.dispose(),this.particleSystems.forEach(function(e){return e.dispose()}),this.particleSystems.length=0,this.skeletons.forEach(function(e){return e.dispose()}),this.skeletons.length=0,this._animations.forEach(function(e){return e.dispose()}),this._animations.length=0,this.rootMesh.dispose(!1,!0)},e}();t.ViewerModel=a},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(){this.onEventBroadcastedObservable=new r.Observable,this._event=this._eventEnabled}return Object.defineProperty(e.prototype,"broadcast",{get:function(){return this._event},enumerable:!0,configurable:!0}),e.prototype.flushWebGLErrors=function(e,t){if(e)for(var i=!0;i;){var r=e.getError();0===r?i=!1:this.broadcast("WebGL Error",t,{error:r})}},Object.defineProperty(e.prototype,"enable",{set:function(e){this._event=e?this._eventEnabled:this._eventDisabled},enumerable:!0,configurable:!0}),e.prototype._eventDisabled=function(){},e.prototype._eventEnabled=function(e,t,i){var r={viewerId:t,event:e,session:this.session,date:new Date,now:window.performance?window.performance.now():Date.now(),detail:null};if("object"==typeof i)for(var n in i)i.hasOwnProperty(n)&&(r[n]=i[n]);else i&&(r.detail=i);this.onEventBroadcastedObservable.notifyObservers(r)},Object.defineProperty(e.prototype,"session",{get:function(){return this._currentSessionId||(this._currentSessionId="SESSION_"+Date.now()+Math.floor(65536*Math.random())),this._currentSessionId},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.onEventBroadcastedObservable.clear(),delete this.onEventBroadcastedObservable},e}();t.TelemetryManager=n,t.telemetryManager=new n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(18),n=function(){function e(e,t,i){this.templateName="navBar",this.eventsToAttach=["pointerdown"],this._prepend=!0,this._buttonName=e,this._buttonClass=t||e+"-button",this._htmlTemplate=i||'\n<button class="'+this._buttonClass+'">\n <span class="icon '+this._buttonName+'-icon"></span>\n</button>\n'}return e.prototype.interactionPredicate=function(e){if(0!==e.event.button)return!1;var t=e.event.target;if(!t)return!1;for(var i=t.classList,r=0;r<i.length;++r){if(-1!==i[r].indexOf(this._buttonClass))return!0}return!1},e.prototype.addHTMLTemplate=function(e){var t=this._generateHTMLElement(e),i=e.parent.querySelector("div.default-control");i&&(this._prepend?i.insertBefore(t,i.firstChild):i.appendChild(t))},e.prototype._generateHTMLElement=function(e){var t,i=r.compile(this._htmlTemplate,{noEscape:e.configuration.params&&!!e.configuration.params.noEscape})(e.configuration.params||{});try{t=document.createRange().createContextualFragment(i)}catch(e){var n=document.createElement(this._buttonClass);n.innerHTML=i,t=n}return t},e}();t.AbstractViewerNavbarButton=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(){this._viewers={},this.onViewerAddedObservable=new r.Observable,this.onViewerRemovedObservable=new r.Observable}return e.prototype.addViewer=function(e){this._viewers[e.getBaseId()]=e,this._onViewerAdded(e)},e.prototype.removeViewer=function(e){var t=e.getBaseId();delete this._viewers[t],this.onViewerRemovedObservable.notifyObservers(t)},e.prototype.getViewerById=function(e){return this._viewers[e]},e.prototype.getViewerByHTMLElement=function(e){for(var t in this._viewers)if(this._viewers[t].containerElement===e)return this.getViewerById(t)},e.prototype.getViewerPromiseById=function(e){var t=this;return new Promise(function(i,r){var n=t.getViewerById(e);if(n)return i(n);var o=function(r){r.getBaseId()===e&&(i(r),t.onViewerAddedObservable.removeCallback(o))};t.onViewerAddedObservable.add(o)})},e.prototype._onViewerAdded=function(e){this.onViewerAdded&&this.onViewerAdded(e),this.onViewerAddedObservable.notifyObservers(e)},e.prototype.dispose=function(){for(var e in delete this._onViewerAdded,this._viewers)this._viewers[e].dispose();this.onViewerAddedObservable.clear(),this.onViewerRemovedObservable.clear()},e}();t.ViewerManager=n,t.viewerManager=new n},function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=function(t,i){return(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])})(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)}}();Object.defineProperty(t,"__esModule",{value:!0});var n=i(10),o=i(0),s=i(65),a=i(66),l=function(e){function t(t,i){void 0===i&&(i={extends:"default"});var r=e.call(this,t,i)||this;return r.containerElement=t,r._registeredPlugins=[],r._handlePointerClick=function(e){if(0===e.event.button){var t=e.event.target;if(t){for(var i=t.parentElement.classList,n=t.classList,o="",s=0;s<n.length;++s){var a=n[s];if(-1!==a.indexOf("-button")||-1!==a.indexOf("-wrapper")){o=a;break}}switch(o){case"speed-button":case"types-button":i.contains("open")?i.remove("open"):i.add("open");break;case"play-pause-button":r._togglePlayPause();break;case"label-option-button":var l=t.dataset.value,c=t.querySelector("span.animation-label");c&&l&&r._updateAnimationType({value:l.trim(),label:c.innerHTML});break;case"speed-option-button":if(!r._currentAnimation)return;var u=t.dataset.value;u&&r._updateAnimationSpeed(u);break;case"progress-wrapper":r._resumePlay=!r._isAnimationPaused,r._resumePlay&&r._togglePlayPause(!0);break;case"fullscreen-button":r.toggleFullscreen();break;case"vr-button":r.toggleVR();break;default:return}}}},r._togglePlayPause=function(e){if(r._currentAnimation&&(r._isAnimationPaused?r._currentAnimation.restart():r._currentAnimation.pause(),r._isAnimationPaused=!r._isAnimationPaused,!e)){var t=r.templateManager.getTemplate("navBar");t&&t.updateParams({paused:r._isAnimationPaused})}},r._updateProgressBar=function(){var e=r.templateManager.getTemplate("navBar");if(e){var t=e.parent.querySelector("input.progress-wrapper");if(t&&r._currentAnimation){var i=r._currentAnimation.currentFrame/r._currentAnimation.frames*100,n=t.valueAsNumber;Math.abs(n-i)>.5&&(t.value=""+i),1===r._currentAnimation.state?r.sceneManager.camera.autoRotationBehavior&&!r._oldIdleRotationValue&&(r._oldIdleRotationValue=r.sceneManager.camera.autoRotationBehavior.idleRotationSpeed,r.sceneManager.camera.autoRotationBehavior.idleRotationSpeed=0):r.sceneManager.camera.autoRotationBehavior&&r._oldIdleRotationValue&&(r.sceneManager.camera.autoRotationBehavior.idleRotationSpeed=r._oldIdleRotationValue,r._oldIdleRotationValue=0)}}},r._updateAnimationSpeed=function(e,t){var i=r.templateManager.getTemplate("navBar");i&&e&&r._currentAnimation&&(r._currentAnimation.speedRatio=parseFloat(e),r._isAnimationPaused||r._currentAnimation.restart(),t?t.selectedSpeed=e+"x":i.updateParams({selectedSpeed:e+"x"}))},r._updateAnimationType=function(e,t){var i=r.templateManager.getTemplate("navBar");i&&(e&&(r._currentAnimation=r.sceneManager.models[0].setCurrentAnimationByName(e.value)),t?(t.selectedAnimation=r._animationList.indexOf(e.value)+1,t.selectedAnimationName=e.label):i.updateParams({selectedAnimation:r._animationList.indexOf(e.value)+1,selectedAnimationName:e.label}),r._updateAnimationSpeed("1.0",t))},r.toggleFullscreen=function(){var e=r.templateManager.getTemplate("viewer"),t=e&&e.parent,i=r.fullscreenElement||t;i&&(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?((document.exitFullscreen||document.webkitExitFullscreen||document.msExitFullscreen||document.mozCancelFullScreen).call(document),t&&t.classList.remove("in-fullscreen")):((i.requestFullscreen||i.webkitRequestFullscreen||i.msRequestFullscreen||i.mozRequestFullScreen).call(i),t&&t.classList.add("in-fullscreen")))},r._onModelLoaded=function(e){r._configureTemplate(e);var t=20;r.configuration.lab&&void 0!==r.configuration.lab.hideLoadingDelay&&(t=r.configuration.lab.hideLoadingDelay),setTimeout(function(){r.sceneManager.scene.executeWhenReady(function(){r.hideLoadingScreen()})},t)},r.onModelLoadedObservable.add(r._onModelLoaded),r.onModelRemovedObservable.add(function(){r._configureTemplate()}),r.onEngineInitObservable.add(function(){r.sceneManager.onLightsConfiguredObservable.add(function(e){r._configureLights()})}),r.onInitDoneObservable.add(function(){r.sceneManager.models.length||r.hideLoadingScreen()}),r}return r(t,e),t.prototype.registerTemplatePlugin=function(e){var t=this;if(!e.templateName)throw new Error("No template name provided");this._registeredPlugins.push(e);var i=this.templateManager.getTemplate(e.templateName);if(!i)throw new Error("Template "+e.templateName+" not found");e.addHTMLTemplate&&(i.onHTMLRendered.add(function(t){e.addHTMLTemplate(t)}),i.redraw()),e.eventsToAttach&&e.eventsToAttach.forEach(function(i){e.onEvent&&t.templateManager.eventManager.registerCallback(e.templateName,function(t){e.onEvent&&e.interactionPredicate(t)&&e.onEvent(t)},i)})},t.prototype._onTemplatesLoaded=function(){var t=this;this.showLoadingScreen(),this._initNavbar();var i=this.templateManager.getTemplate("overlay");if(i){var r=i.parent.querySelector(".close-button");r&&r.addEventListener("pointerdown",function(){t.hideOverlayScreen()})}return this.configuration.templates&&this.configuration.templates.viewer&&this.configuration.templates.viewer.params&&this.configuration.templates.viewer.params.enableDragAndDrop&&this.onSceneInitObservable.addOnce(function(){new o.FilesInput(t.engine,t.sceneManager.scene,function(){},function(){},function(){},function(){},function(){},function(e){t.loadModel(e)},function(){}).monitorElementForDragNDrop(t.templateManager.getCanvas())}),e.prototype._onTemplatesLoaded.call(this)},t.prototype._initNavbar=function(){var e=this,t=this.templateManager.getTemplate("navBar");t&&(this.onFrameRenderedObservable.add(this._updateProgressBar),this.templateManager.eventManager.registerCallback("navBar",this._handlePointerClick,"click"),this.templateManager.eventManager.registerCallback("navBar",function(){},"pointerdown",".help-button"),this.templateManager.eventManager.registerCallback("navBar",function(t){var i=t.event.target;if(e._currentAnimation){var r=+i.value/100*e._currentAnimation.frames;isNaN(r)||e._currentAnimation.goToFrame(r)}},"input"),this.templateManager.eventManager.registerCallback("navBar",function(){e._resumePlay&&e._togglePlayPause(!0),e._resumePlay=!1},"pointerup",".progress-wrapper"),1===window.devicePixelRatio&&t.configuration.params&&!t.configuration.params.hideHdButton&&t.updateParams({hideHdButton:!0}),this.registerTemplatePlugin(new s.HDButtonPlugin(this)),this.registerTemplatePlugin(new a.PrintButtonPlugin(this)))},t.prototype._initVR=function(){var t=this;this.engine.onVRDisplayChangedObservable.add(function(){var e=t.templateManager.getTemplate("viewer"),i=e&&e.parent;i&&(t.sceneManager.vrHelper.isInVRMode?i.classList.add("in-vr"):i.classList.remove("in-vr"))}),this.sceneManager.vrHelper&&this.sceneManager.vrHelper.onExitingVR.add(function(){var e=t.templateManager.getTemplate("viewer"),i=e&&e.parent;i&&i.classList.remove("in-vr")}),e.prototype._initVR.call(this)},t.prototype._prepareContainerElement=function(){var e=this.containerElement;e.style&&(e.style.position="relative",e.style.height="100%",e.style.display="flex")},t.prototype._configureTemplate=function(e){var t=this.templateManager.getTemplate("navBar");if(t){var i=t.configuration.params||{};if(e){var r=e.getAnimationNames();if(i.animations=r.map(function(e){return{label:e,value:e}}),r.length){this._isAnimationPaused=e.configuration.animation&&!e.configuration.animation.autoStart||!e.configuration.animation,this._animationList=r,i.paused=this._isAnimationPaused;var n=0;e.configuration.animation&&"string"==typeof e.configuration.animation.autoStart&&-1===(n=r.indexOf(e.configuration.animation.autoStart))&&(n=0),this._updateAnimationType(i.animations[n],i)}else i.animations=null;e.configuration.thumbnail&&(i.logoImage=e.configuration.thumbnail)}else i.animations=null;t.updateParams(i,!1)}},t.prototype.loadModel=function(t){var i=this;return t||(t=this.configuration.model),this.showLoadingScreen(),e.prototype.loadModel.call(this,t,!0).catch(function(e){return console.log(e),i.hideLoadingScreen(),i.showOverlayScreen("error"),Promise.reject(e)})},t.prototype.showOverlayScreen=function(e){var t=this,i=this.templateManager.getTemplate("overlay");return i?i.show(function(i){var r=t.containerElement.getBoundingClientRect();i.parent.style.display="flex",i.parent.style.width=r.width+"px",i.parent.style.height=r.height+"px",i.parent.style.opacity="1";var n=t.templateManager.getTemplate(e);return n?n.show(function(e){return e.parent.style.display="flex",Promise.resolve(e)}):Promise.reject(e+" template not found")}):Promise.resolve("Overlay template not found")},t.prototype.hideOverlayScreen=function(){var e=this.templateManager.getTemplate("overlay");return e?e.hide(function(e){e.parent.style.opacity="0";var t=function(){e.parent.removeEventListener("transitionend",t),e.parent.style.display="none"};e.parent.addEventListener("transitionend",t);var i=e.parent.querySelectorAll(".overlay");if(i)for(var r=0;r<i.length;++r){i.item(r).style.display="none"}return Promise.resolve(e)}):Promise.resolve("Overlay template not found")},t.prototype.show=function(e){var t=this.templateManager.getTemplate("main");return t?t.show(e):Promise.reject("Main template not found")},t.prototype.hide=function(e){var t=this.templateManager.getTemplate("main");return t?t.hide(e):Promise.reject("Main template not found")},t.prototype.showLoadingScreen=function(){var e=this,t=this.templateManager.getTemplate("loadingScreen");return t?t.show(function(t){var i=e.containerElement.getBoundingClientRect();t.parent.style.display="flex",t.parent.style.width=i.width+"px",t.parent.style.height=i.height+"px",t.parent.style.opacity="1";var r="black";return e.configuration.templates&&e.configuration.templates.loadingScreen&&(r=e.configuration.templates.loadingScreen.params&&e.configuration.templates.loadingScreen.params.backgroundColor||r),t.parent.style.backgroundColor=r,Promise.resolve(t)}):Promise.resolve("Loading Screen template not found")},t.prototype.hideLoadingScreen=function(){var e=this.templateManager.getTemplate("loadingScreen");return e?e.hide(function(e){e.parent.style.opacity="0";var t=function(){e.parent.removeEventListener("transitionend",t),e.parent.style.display="none"};return e.parent.addEventListener("transitionend",t),Promise.resolve(e)}):Promise.resolve("Loading Screen template not found")},t.prototype.dispose=function(){this.templateManager.dispose(),e.prototype.dispose.call(this)},t.prototype._onConfigurationLoaded=function(t){var i=this;e.prototype._onConfigurationLoaded.call(this,t);var r=this.configuration.templates||{};this.templateManager.initTemplate(r),this.templateManager.onAllLoaded.add(function(){var e=i.templateManager.getCanvas();e&&(i._canvas=e),i._onTemplateLoaded()})},t.prototype._configureLights=function(){var e=this;if(this.configuration.lab&&this.configuration.lab.flashlight){var t,i=.5,r=Math.PI/2;"object"==typeof this.configuration.lab.flashlight&&(r=this.configuration.lab.flashlight.exponent||r,i=this.configuration.lab.flashlight.angle||i);var n=new o.SpotLight("flashlight",o.Vector3.Zero(),o.Vector3.Zero(),r,i,this.sceneManager.scene);"object"==typeof this.configuration.lab.flashlight&&(n.intensity=this.configuration.lab.flashlight.intensity||n.intensity,this.configuration.lab.flashlight.diffuse&&(n.diffuse.r=this.configuration.lab.flashlight.diffuse.r,n.diffuse.g=this.configuration.lab.flashlight.diffuse.g,n.diffuse.b=this.configuration.lab.flashlight.diffuse.b),this.configuration.lab.flashlight.specular&&(n.specular.r=this.configuration.lab.flashlight.specular.r,n.specular.g=this.configuration.lab.flashlight.specular.g,n.specular.b=this.configuration.lab.flashlight.specular.b)),this.sceneManager.scene.constantlyUpdateMeshUnderPointer=!0,this.sceneManager.scene.onPointerObservable.add(function(e){t=4===e.type&&e.pickInfo?e.pickInfo.pickedPoint:void 0});var s=function(){e.sceneManager.camera&&n&&(n.position.copyFrom(e.sceneManager.camera.position),t&&t.subtractToRef(n.position,n.direction))};this.sceneManager.scene.registerBeforeRender(s),this._registeredOnBeforeRenderFunctions.push(s)}},t}(n.AbstractViewer);t.DefaultViewer=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(11),o=i(26),s=i(4),a=i(27),l=i(1),c=i(13),u=i(58),h=i(59),d=i(6),f=i(63),p=i(8),m=function(){function e(e,t){void 0===t&&(t={});var i=this;this.containerElement=e,this.runRenderLoop=!0,this._isDisposed=!1,this._hdToggled=!1,this._vrToggled=!1,this._vrModelRepositioning=0,this._vrScale=1,this._vrInit=!1,this._resize=function(){i.isCanvasInDOM()&&(i.canvas.clientWidth<=0||i.canvas.clientHeight<=0||i.configuration.engine&&i.configuration.engine.disableResize||i.engine.resize())},this._render=function(e){void 0===e&&(e=!1),(e||i.sceneManager.scene&&i.sceneManager.scene.activeCamera)&&(i.runRenderLoop||e?(i.engine.performanceMonitor.enable(),i.sceneManager.scene.render(),i.onFrameRenderedObservable.notifyObservers(i)):(i.engine.performanceMonitor.disable(),i.sceneManager.scene.activeCamera&&i.sceneManager.scene.activeCamera.update()))},e.id?this.baseId=e.id:this.baseId=e.id="bjs"+Math.random().toString(32).substr(2,8),this._registeredOnBeforeRenderFunctions=[],this._configurationContainer=new o.ConfigurationContainer,this.observablesManager=new u.ObservablesManager,this.modelLoader=new c.ModelLoader(this.observablesManager,this._configurationContainer),r.RenderingManager.AUTOCLEAR=!1,this._configurationLoader=new a.ConfigurationLoader,this._configurationLoader.loadConfiguration(t,function(e){i._onConfigurationLoaded(e)}),this.onSceneInitObservable.add(function(){i.updateConfiguration()}),this.onInitDoneObservable.add(function(){i._isInit=!0,i.engine.runRenderLoop(i._render)}),this._prepareContainerElement(),p.viewerManager.addViewer(this)}return Object.defineProperty(e.prototype,"onSceneInitObservable",{get:function(){return this.observablesManager.onSceneInitObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onEngineInitObservable",{get:function(){return this.observablesManager.onEngineInitObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onModelAddedObservable",{get:function(){return this.observablesManager.onModelAddedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onModelLoadedObservable",{get:function(){return this.observablesManager.onModelLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onModelLoadProgressObservable",{get:function(){return this.observablesManager.onModelLoadProgressObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onModelLoadErrorObservable",{get:function(){return this.observablesManager.onModelLoadErrorObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onModelRemovedObservable",{get:function(){return this.observablesManager.onModelRemovedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onLoaderInitObservable",{get:function(){return this.observablesManager.onLoaderInitObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onInitDoneObservable",{get:function(){return this.observablesManager.onViewerInitDoneObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onFrameRenderedObservable",{get:function(){return this.observablesManager.onFrameRenderedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onEnteringVRObservable",{get:function(){return this.observablesManager.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVRObservable",{get:function(){return this.observablesManager.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this._canvas},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"configurationContainer",{get:function(){return this._configurationContainer},enumerable:!0,configurable:!0}),e.prototype.getBaseId=function(){return this.baseId},e.prototype.isCanvasInDOM=function(){return!!this._canvas&&!!this._canvas.parentElement},Object.defineProperty(e.prototype,"renderInBackground",{get:function(){return this.engine&&this.engine.renderEvenInBackground},set:function(e){this.engine&&(this.engine.renderEvenInBackground=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"configuration",{get:function(){return this._configurationContainer.configuration},enumerable:!0,configurable:!0}),e.prototype.forceResize=function(){this._resize()},e.prototype.toggleHD=function(){this._hdToggled=!this._hdToggled;var e=this._hdToggled?Math.max(.5,1/(window.devicePixelRatio||2)):1;this.engine.setHardwareScalingLevel(e)},e.prototype.toggleVR=function(){if(this._vrInit||this._initVR(),this.sceneManager.vrHelper&&!this.sceneManager.vrHelper.isInVRMode)if(this.sceneManager.environmentHelper&&this.sceneManager.environmentHelper.ground&&this.sceneManager.vrHelper.addFloorMesh(this.sceneManager.environmentHelper.ground),this._vrToggled=!0,this.sceneManager.vrHelper.enterVR(),this.sceneManager.vrHelper.currentVRCamera&&this.sceneManager.vrHelper.currentVRCamera!==this.sceneManager.camera){if(this.configuration.vr&&void 0!==this.configuration.vr.cameraPosition?this.sceneManager.vrHelper.currentVRCamera.position.copyFrom(this.configuration.vr.cameraPosition):this.sceneManager.vrHelper.currentVRCamera.position.copyFromFloats(0,this.sceneManager.vrHelper.currentVRCamera.position.y,-1),this.sceneManager.vrHelper.currentVRCamera.rotationQuaternion&&this.sceneManager.vrHelper.currentVRCamera.rotationQuaternion.copyFromFloats(0,0,0,1),this.configuration.vr&&void 0!==this.configuration.vr.modelHeightCorrection&&("number"==typeof this.configuration.vr.modelHeightCorrection?this._vrModelRepositioning=this.configuration.vr.modelHeightCorrection:this.configuration.vr.modelHeightCorrection?this._vrModelRepositioning=this.sceneManager.vrHelper.currentVRCamera.position.y/2:this._vrModelRepositioning=0),this.sceneManager.models.length){var e=this.sceneManager.models[0].rootMesh.getHierarchyBoundingVectors(),t=e.max.subtract(e.min),i=Math.max(t.x,t.y,t.z);this._vrScale=1/i,this.configuration.vr&&this.configuration.vr.objectScaleFactor&&(this._vrScale*=this.configuration.vr.objectScaleFactor),this.sceneManager.models[0].rootMesh.scaling.scaleInPlace(this._vrScale),this.sceneManager.models[0].rootMesh.position.y+=this._vrModelRepositioning,this.sceneManager.models[0].rootMesh.rotationQuaternion=null}this.sceneManager.environmentHelper&&(this.sceneManager.environmentHelper.ground&&this.sceneManager.environmentHelper.ground.scaling.scaleInPlace(this._vrScale),this.sceneManager.environmentHelper.skybox&&this.sceneManager.environmentHelper.skybox.scaling.scaleInPlace(this._vrScale)),this.sceneManager.defaultRenderingPipelineEnabled&&this.sceneManager.defaultRenderingPipeline&&(this.sceneManager.defaultRenderingPipeline.imageProcessingEnabled=!1,this.sceneManager.defaultRenderingPipeline.prepare())}else this._vrModelRepositioning=0;else this.sceneManager.vrHelper&&this.sceneManager.vrHelper.exitVR()},e.prototype._initVR=function(){var e=this;this.sceneManager.vrHelper&&this.observablesManager.onExitingVRObservable.add(function(){e._vrToggled&&(e._vrToggled=!1,e.sceneManager.models.length&&(e.sceneManager.models[0].rootMesh.scaling.scaleInPlace(1/e._vrScale),e.sceneManager.models[0].rootMesh.position.y-=e._vrModelRepositioning),e.sceneManager.environmentHelper&&(e.sceneManager.environmentHelper.ground&&e.sceneManager.environmentHelper.ground.scaling.scaleInPlace(1/e._vrScale),e.sceneManager.environmentHelper.skybox&&e.sceneManager.environmentHelper.skybox.scaling.scaleInPlace(1/e._vrScale)),e.sceneManager.defaultRenderingPipelineEnabled&&e.sceneManager.defaultRenderingPipeline&&(e.sceneManager.defaultRenderingPipeline.imageProcessingEnabled=!0,e.sceneManager.defaultRenderingPipeline.prepare()),e.canvas.removeAttribute("height"),e.canvas.removeAttribute("width"),e.engine.resize())}),this._vrInit=!0},e.prototype._onConfigurationLoaded=function(e){var t=this;this._configurationContainer.configuration=l.deepmerge(this.configuration||{},e),this.configuration.observers&&this._configureObservers(this.configuration.observers),this.configuration.loaderPlugins&&Object.keys(this.configuration.loaderPlugins).forEach(function(e){t.configuration.loaderPlugins&&t.configuration.loaderPlugins[e]&&t.modelLoader.addPlugin(e)}),this.templateManager=new f.TemplateManager(this.containerElement),this.observablesManager.onViewerInitStartedObservable.notifyObservers(this)},e.prototype.forceRender=function(){this._render(!0)},e.prototype.takeScreenshot=function(e,t,i){var r=this;return void 0===t&&(t=0),void 0===i&&(i=0),t=t||this.canvas.clientWidth,i=i||this.canvas.clientHeight,new Promise(function(n,o){try{BABYLON.Tools.CreateScreenshot(r.engine,r.sceneManager.camera,{width:t,height:i},function(t){e&&e(t),n(t)})}catch(e){o(e)}})},e.prototype.updateConfiguration=function(e){var t=this;void 0===e&&(e=this.configuration),"string"==typeof e?r.Tools.LoadFile(e,function(i){try{var r=JSON.parse(i.toString());return t.updateConfiguration(r)}catch(t){console.log("Error parsing file "+e)}},void 0,void 0,void 0,function(t){console.log("Error parsing file "+e,t)}):(n.processConfigurationCompatibility(e),this._configurationContainer.configuration=l.deepmerge(this.configuration||{},e),this.sceneManager.updateConfiguration(e),e.observers&&this._configureObservers(e.observers),e.loaderPlugins&&Object.keys(e.loaderPlugins).forEach(function(i){e.loaderPlugins&&e.loaderPlugins[i]&&t.modelLoader.addPlugin(i)}))},e.prototype._configureObservers=function(e){e.onEngineInit?this.onEngineInitObservable.add(window[e.onEngineInit]):""===e.onEngineInit&&this.configuration.observers&&this.configuration.observers.onEngineInit&&this.onEngineInitObservable.removeCallback(window[this.configuration.observers.onEngineInit]),e.onSceneInit?this.onSceneInitObservable.add(window[e.onSceneInit]):""===e.onSceneInit&&this.configuration.observers&&this.configuration.observers.onSceneInit&&this.onSceneInitObservable.removeCallback(window[this.configuration.observers.onSceneInit]),e.onModelLoaded?this.onModelLoadedObservable.add(window[e.onModelLoaded]):""===e.onModelLoaded&&this.configuration.observers&&this.configuration.observers.onModelLoaded&&this.onModelLoadedObservable.removeCallback(window[this.configuration.observers.onModelLoaded])},e.prototype.dispose=function(){this._isDisposed||(window.removeEventListener("resize",this._resize),this.sceneManager&&(this.sceneManager.scene&&this.sceneManager.scene.activeCamera&&this.sceneManager.scene.activeCamera.detachControl(this.canvas),this.sceneManager.dispose()),this._fpsTimeoutInterval&&clearInterval(this._fpsTimeoutInterval),this.observablesManager.dispose(),this.modelLoader.dispose(),this.engine&&this.engine.dispose(),p.viewerManager.removeViewer(this),this._isDisposed=!0)},e.prototype._onTemplatesLoaded=function(){return Promise.resolve(this)},e.prototype._onTemplateLoaded=function(){var e=this;return this._isDisposed?Promise.reject("viewer was disposed"):this._onTemplatesLoaded().then(function(){var t="string"==typeof e.configuration.model||e.configuration.model&&e.configuration.model.url;return e._initEngine().then(function(t){return e.onEngineInitObservable.notifyObserversWithPromise(t)}).then(function(){return e._initTelemetryEvents(),t?e.loadModel(e.configuration.model).catch(function(){}).then(function(){return e.sceneManager.scene}):e.sceneManager.scene||e.sceneManager.initScene(e.configuration.scene)}).then(function(){return e.onInitDoneObservable.notifyObserversWithPromise(e)}).catch(function(t){return r.Tools.Warn(t.toString()),e})})},e.prototype._initEngine=function(){if(this._injectCustomShaders(),!this.canvas)return Promise.reject("Canvas element not found!");var e=this.configuration.engine||{};if(s.viewerGlobals.disableWebGL2Support&&(e.engineOptions=e.engineOptions||{},e.engineOptions.disableWebGL2Support=!0),this.engine=new r.Engine(this.canvas,!!e.antialiasing,e.engineOptions),r.Database.IDBStorageEnabled=!1,e.disableResize||window.addEventListener("resize",this._resize),this.configuration.engine){if(this.configuration.engine.adaptiveQuality){var t=Math.max(.5,1/(window.devicePixelRatio||2));this.engine.setHardwareScalingLevel(t)}this.configuration.engine.hdEnabled&&this.toggleHD()}return this.sceneManager=new h.SceneManager(this.engine,this._configurationContainer,this.observablesManager),Promise.resolve(this.engine)},e.prototype.initModel=function(e,t){var i,r=this;if(void 0===t&&(t=!0),!(i="string"==typeof e?{url:e}:e instanceof File?{file:e,root:"file:"}:e).url&&!i.file)throw new Error("no model provided");if(t&&this.sceneManager.clearScene(!0,!1),this.configuration.model&&"object"==typeof this.configuration.model){var n=l.deepmerge({},this.configuration.model);i=l.deepmerge(n,i),e instanceof File&&(i.file=e)}else this.configuration.model=i;this._isLoading=!0;var o=this.modelLoader.load(i);return this.lastUsedLoader=o.loader,o.onLoadErrorObservable.add(function(e){r.onModelLoadErrorObservable.notifyObserversWithPromise(e)}),o.onLoadProgressObservable.add(function(e){r.onModelLoadProgressObservable.notifyObserversWithPromise(e)}),this.onLoaderInitObservable.notifyObserversWithPromise(this.lastUsedLoader),o.onLoadedObservable.add(function(){r._isLoading=!1}),o},e.prototype.loadModel=function(e,t){var i=this;return void 0===t&&(t=!0),this._isLoading?Promise.reject("another model is curently being loaded."):Promise.resolve(this.sceneManager.scene).then(function(e){return e||i.sceneManager.initScene(i.configuration.scene,i.configuration.optimizer)}).then(function(){var r=i.initModel(e,t);return new Promise(function(e,t){r.onLoadedObservable.add(function(){e(r)}),r.onLoadErrorObservable.add(function(e){t(e)})})})},e.prototype._initTelemetryEvents=function(){var e=this;d.telemetryManager.broadcast("Engine Capabilities",this.baseId,this.engine.getCaps()),d.telemetryManager.broadcast("Platform Details",this.baseId,{userAgent:navigator.userAgent,platform:navigator.platform}),d.telemetryManager.flushWebGLErrors(this.engine,this.baseId);var t=function(){d.telemetryManager.broadcast("Current FPS",e.baseId,{fps:e.engine.getFps()})};t(),this._fpsTimeoutInterval=window.setInterval(t,6e4)},e.prototype._injectCustomShaders=function(){var e=this.configuration.customShaders;e&&(e.shaders&&Object.keys(e.shaders).forEach(function(t){r.Effect.ShadersStore[t]=e.shaders[t]}),e.includes&&Object.keys(e.includes).forEach(function(t){r.Effect.IncludesShadersStore[t]=e.includes[t]}))},e}();t.AbstractViewer=m},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(12);function n(e,t,i,r){var n=t.split(".");if(0!==n.length){var o=n.pop();if(o){var s=e;n.forEach(function(e){s[e]=s[e]||{},s=s[e]}),(void 0===s[o]||r)&&(s[o]=i)}}}t.processConfigurationCompatibility=function(e){e.camera&&(void 0!==e.camera.contrast&&n(e,"scene.imageProcessingConfiguration.contrast",e.camera.contrast),void 0!==e.camera.exposure&&n(e,"scene.imageProcessingConfiguration.exposure",e.camera.exposure)),e.scene&&(e.scene.glow&&(n(e,"lab.defaultRenderingPipelines.glowLayerEnabled",!0),!1!==r.getConfigurationKey("scene.imageProcessingConfiguration.isEnabled",e)&&n(e,"scene.imageProcessingConfiguration.isEnabled",!0)),e.scene.mainColor&&n(e,"environmentMap.mainColor",e.scene.mainColor,!0));e.model&&"object"==typeof e.model&&void 0!==e.model.castShadows&&void 0===e.model.castShadow&&(e.model.castShadow=e.model.castShadows),e.lab&&(e.lab.assetsRootURL&&n(e,"scene.assetsRootURL",e.lab.assetsRootURL,!0),e.lab.environmentMap&&n(e,"environmentMap",e.lab.environmentMap,!0))}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getConfigurationKey=function e(t,i){var r=t.split(".");if(0!==r.length&&i){if(1!==r.length){var n=r.shift();return e(r.join("."),i[n])}return void 0!==i[t]?i[t]:void 0}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(14),o=i(5),s=i(53),a=function(){function e(e,t){this._observablesManager=e,this._configurationContainer=t,this._disposed=!1,this._loaders=[],this._loadId=0,this._plugins=[]}return Object.defineProperty(e.prototype,"baseUrl",{get:function(){return this._baseUrl},enumerable:!0,configurable:!0}),e.prototype.addPlugin=function(e){var t={};if("string"==typeof e){var i=s.getLoaderPluginByName(e);i&&(t=i)}else t=e;t&&-1===this._plugins.indexOf(t)&&this._plugins.push(t)},e.prototype.load=function(e){var t,i=this,s=new o.ViewerModel(this._observablesManager,e,this._configurationContainer);if(s.loadId=this._loadId++,e.file?(this._baseUrl="file:",t=e.file):e.url&&(t=r.Tools.GetFilename(e.url)||e.url,this._baseUrl=e.root||r.Tools.GetFolderPath(e.url)),!t||!this._baseUrl)return s.state=o.ModelState.ERROR,r.Tools.Error("No URL provided"),s;var a=e.loader,l=s.rootMesh.getScene();if(s.loader=r.SceneLoader.ImportMesh(void 0,this._baseUrl,t,l,function(e,t,n,o){e.forEach(function(e){r.Tags.AddTagsTo(e,"viewerMesh"),s.addMesh(e)}),s.particleSystems=t,s.skeletons=n;for(var a=0,c=o;a<c.length;a++){var u=c[a];s.addAnimationGroup(u)}i._checkAndRun("onLoaded",s),l.executeWhenReady(function(){s.onLoadedObservable.notifyObservers(s)})},function(e){i._checkAndRun("onProgress",e),s.onLoadProgressObservable.notifyObserversWithPromise(e)},function(e,t,n){s.state=o.ModelState.ERROR,r.Tools.Error("Load Error: There was an error loading the model. "+t),i._checkAndRun("onError",t,n),s.onLoadErrorObservable.notifyObserversWithPromise({message:t,exception:n})},a),"gltf"===s.loader.name){var c=s.loader;c.animationStartMode=n.GLTFLoaderAnimationStartMode.NONE,c.compileMaterials=!0,e.file||(c.rewriteRootURL=function(t,i){return e.root||r.Tools.GetFolderPath(i||e.url||"")}),this._configurationContainer&&this._configurationContainer.configuration&&this._configurationContainer.configuration.ground&&"object"==typeof this._configurationContainer.configuration.ground&&this._configurationContainer.configuration.ground.mirror&&(c.useClipPlane=!0),Object.keys(c).filter(function(e){return 0===e.indexOf("on")&&-1!==e.indexOf("Observable")}).forEach(function(e){c[e].add(function(t){i._checkAndRun(e.replace("Observable",""),t)})}),c.onParsedObservable.add(function(e){e&&e.json&&e.json.asset&&(s.loadInfo=e.json.asset)}),c.onCompleteObservable.add(function(){s.loaderDone=!0})}else s.loaderDone=!0;return this._checkAndRun("onInit",s.loader,s),this._loaders.push(s.loader),s},e.prototype.cancelLoad=function(e){var t=e.loader||this._loaders[e.loadId];t&&"gltf"===t.name?(t.dispose(),e.state=o.ModelState.CANCELED):r.Tools.Warn("This type of loader cannot cancel the request")},e.prototype.dispose=function(){this._loaders.forEach(function(e){"gltf"===e.name&&e.dispose()}),this._loaders.length=0,this._disposed=!0},e.prototype._checkAndRun=function(e){for(var t=this,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];this._disposed||this._plugins.filter(function(t){return t[e]}).forEach(function(r){try{r[e].apply(t,i)}catch(e){}})},e}();t.ModelLoader=a},function(e,t,i){!function(t,r){var n=t.BABYLON||this.BABYLON;n=n||i(0),e.exports=r(n)}(this,function(e){e=e||this.BABYLON;this&&this.__decorate;var t=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)}}();return function(e){var t=function(){function t(){this.solidPattern=/solid (\S*)([\S\s]*)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.name="stl",this.extensions={".stl":{isBinary:!0}}}return t.prototype.importMesh=function(t,i,r,n,o,s,a){var l;if("string"!=typeof r){if(this.isBinary(r)){var c=new e.Mesh("stlmesh",i);return this.parseBinary(c,r),o&&o.push(c),!0}for(var u=new Uint8Array(r),h="",d=0;d<r.byteLength;d++)h+=String.fromCharCode(u[d]);r=h}for(;l=this.solidPattern.exec(r);){var f=l[1];if(f!=l[3])return e.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(t&&f)if(t instanceof Array){if(!t.indexOf(f))continue}else if(f!==t)continue;f=f||"stlmesh";c=new e.Mesh(f,i);this.parseASCII(c,l[2]),o&&o.push(c)}return!0},t.prototype.load=function(e,t,i){var r=this.importMesh(null,e,t,i,null,null,null);return r&&e.createDefaultCameraOrLight(),r},t.prototype.loadAssetContainer=function(t,i,r,n){var o=new e.AssetContainer(t);return this.importMesh(null,t,i,r,o.meshes,null,null),o.removeAllFromScene(),o},t.prototype.isBinary=function(e){var t;if(50,84+50*(t=new DataView(e)).getUint32(80,!0)===t.byteLength)return!0;for(var i=t.byteLength,r=0;r<i;r++)if(t.getUint8(r)>127)return!0;return!1},t.prototype.parseBinary=function(t,i){for(var r=new DataView(i),n=r.getUint32(80,!0),o=0,s=new Float32Array(3*n*3),a=new Float32Array(3*n*3),l=new Uint32Array(3*n),c=0,u=0;u<n;u++){for(var h=84+50*u,d=r.getFloat32(h,!0),f=r.getFloat32(h+4,!0),p=r.getFloat32(h+8,!0),m=1;m<=3;m++){var g=h+12*m;s[o]=r.getFloat32(g,!0),s[o+2]=r.getFloat32(g+4,!0),s[o+1]=r.getFloat32(g+8,!0),a[o]=d,a[o+2]=f,a[o+1]=p,o+=3}l[c]=c++,l[c]=c++,l[c]=c++}t.setVerticesData(e.VertexBuffer.PositionKind,s),t.setVerticesData(e.VertexBuffer.NormalKind,a),t.setIndices(l),t.computeWorldMatrix(!0)},t.prototype.parseASCII=function(t,i){for(var r,n=[],o=[],s=[],a=0;r=this.facetsPattern.exec(i);){var l=r[1],c=this.normalPattern.exec(l);if(this.normalPattern.lastIndex=0,c){for(var u,h=[Number(c[1]),Number(c[5]),Number(c[3])];u=this.vertexPattern.exec(l);)n.push(Number(u[1]),Number(u[5]),Number(u[3])),o.push(h[0],h[1],h[2]);s.push(a++,a++,a++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,t.setVerticesData(e.VertexBuffer.PositionKind,n),t.setVerticesData(e.VertexBuffer.NormalKind,o),t.setIndices(s),t.computeWorldMatrix(!0)},t}();e.STLFileLoader=t,e.SceneLoader&&e.SceneLoader.RegisterPlugin(new t)}(e||(e={})),function(e){var t=function(){function t(){this.materials=[]}return t.prototype.parseMTL=function(i,r,n){if(!(r instanceof ArrayBuffer)){for(var o,s=r.split("\n"),a=/\s+/,l=null,c=0;c<s.length;c++){var u=s[c].trim();if(0!==u.length&&"#"!==u.charAt(0)){var h=u.indexOf(" "),d=h>=0?u.substring(0,h):u;d=d.toLowerCase();var f=h>=0?u.substring(h+1).trim():"";"newmtl"===d?(l&&this.materials.push(l),l=new e.StandardMaterial(f,i)):"kd"===d&&l?(o=f.split(a,3).map(parseFloat),l.diffuseColor=e.Color3.FromArray(o)):"ka"===d&&l?(o=f.split(a,3).map(parseFloat),l.ambientColor=e.Color3.FromArray(o)):"ks"===d&&l?(o=f.split(a,3).map(parseFloat),l.specularColor=e.Color3.FromArray(o)):"ke"===d&&l?(o=f.split(a,3).map(parseFloat),l.emissiveColor=e.Color3.FromArray(o)):"ns"===d&&l?l.specularPower=parseFloat(f):"d"===d&&l?l.alpha=parseFloat(f):"map_ka"===d&&l?l.ambientTexture=t._getTexture(n,f,i):"map_kd"===d&&l?l.diffuseTexture=t._getTexture(n,f,i):"map_ks"===d&&l?l.specularTexture=t._getTexture(n,f,i):"map_ns"===d||("map_bump"===d&&l?l.bumpTexture=t._getTexture(n,f,i):"map_d"===d&&l&&(l.opacityTexture=t._getTexture(n,f,i)))}}l&&this.materials.push(l)}},t._getTexture=function(t,i,r){if(!i)return null;var n=t;if("file:"===t){var o=i.lastIndexOf("\\");-1===o&&(o=i.lastIndexOf("/")),n+=o>-1?i.substr(o+1):i}else n+=i;return new e.Texture(n,r)},t}();e.MTLFileLoader=t;var i=function(){function i(){this.name="obj",this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.normalPattern=/vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.facePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,this.facePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,this.facePattern5=/f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/}return i.prototype._loadMTL=function(t,i,r){var n=e.Tools.BaseUrl+i+t;e.Tools.LoadFile(n,r,void 0,void 0,!1,function(){console.warn("Error - Unable to load "+n)})},i.prototype.importMeshAsync=function(e,t,i,r,n,o){return this._parseSolid(e,t,i,r).then(function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[]}})},i.prototype.loadAsync=function(e,t,i,r,n){return this.importMeshAsync(null,e,t,i,r).then(function(){})},i.prototype.loadAssetContainerAsync=function(t,i,r,n,o){return this.importMeshAsync(null,t,i,r).then(function(i){var r=new e.AssetContainer(t);return i.meshes.forEach(function(e){return r.meshes.push(e)}),r.removeAllFromScene(),r})},i.prototype._parseSolid=function(r,n,o,s){for(var a,l=this,c=[],u=[],h=[],d=[],f=[],p=[],m=[],g=[],_=[],v=0,A=!1,y=[],b=[],T=[],E=[],x="",P="",M=new t,S=1,C=!0,R=function(e,t,r,n,o,s){var a;-1==(a=i.OPTIMIZE_WITH_UV?function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var i=e[t[0]].normals.indexOf(t[1]);return 1!=i&&t[2]==e[t[0]].uv[i]?e[t[0]].idx[i]:-1}(_,[e,r,t]):function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var i=e[t[0]].normals.indexOf(t[1]);return-1===i?-1:e[t[0]].idx[i]}(_,[e,r]))?(f.push(p.length),p.push(n),m.push(o),g.push(s),_[e].normals.push(r),_[e].idx.push(v++),i.OPTIMIZE_WITH_UV&&_[e].uv.push(t)):f.push(a)},O=function(){for(var e=0;e<p.length;e++)y.push(p[e].x,p[e].y,p[e].z),b.push(g[e].x,g[e].y,g[e].z),T.push(m[e].x,m[e].y);p=[],g=[],m=[],_=[],v=0},D=function(e,t){t+1<e.length&&(E.push(e[0],e[t],e[t+1]),D(e,t+=1))},I=function(t,i){D(t,i);for(var r=0;r<E.length;r++){var n=parseInt(E[r])-1;R(n,0,0,c[n],e.Vector2.Zero(),e.Vector3.Up())}E=[]},w=function(t,i){D(t,i);for(var r=0;r<E.length;r++){var n=E[r].split("/"),o=parseInt(n[0])-1,s=parseInt(n[1])-1;R(o,s,0,c[o],h[s],e.Vector3.Up())}E=[]},L=function(e,t){D(e,t);for(var i=0;i<E.length;i++){var r=E[i].split("/"),n=parseInt(r[0])-1,o=parseInt(r[1])-1,s=parseInt(r[2])-1;R(n,o,s,c[n],h[o],u[s])}E=[]},B=function(t,i){D(t,i);for(var r=0;r<E.length;r++){var n=E[r].split("//"),o=parseInt(n[0])-1,s=parseInt(n[1])-1;R(o,1,s,c[o],e.Vector2.Zero(),u[s])}E=[]},F=function(e,t){D(e,t);for(var i=0;i<E.length;i++){var r=E[i].split("/"),n=c.length+parseInt(r[0]),o=h.length+parseInt(r[1]),s=u.length+parseInt(r[2]);R(n,o,s,c[n],h[o],u[s])}E=[]},N=function(){d.length>0&&(a=d[d.length-1],O(),f.reverse(),a.indices=f.slice(),a.positions=y.slice(),a.normals=b.slice(),a.uvs=T.slice(),f=[],y=[],b=[],T=[])},V=o.split("\n"),U=0;U<V.length;U++){var G,k=V[U].trim();if(0!==k.length&&"#"!==k.charAt(0))if(null!==(G=this.vertexPattern.exec(k)))c.push(new e.Vector3(parseFloat(G[1]),parseFloat(G[2]),parseFloat(G[3])));else if(null!==(G=this.normalPattern.exec(k)))u.push(new e.Vector3(parseFloat(G[1]),parseFloat(G[2]),parseFloat(G[3])));else if(null!==(G=this.uvPattern.exec(k)))h.push(new e.Vector2(parseFloat(G[1]),parseFloat(G[2])));else if(null!==(G=this.facePattern3.exec(k)))L(G[1].trim().split(" "),1);else if(null!==(G=this.facePattern4.exec(k)))B(G[1].trim().split(" "),1);else if(null!==(G=this.facePattern5.exec(k)))F(G[1].trim().split(" "),1);else if(null!==(G=this.facePattern2.exec(k)))w(G[1].trim().split(" "),1);else if(null!==(G=this.facePattern1.exec(k)))I(G[1].trim().split(" "),1);else if(this.group.test(k)||this.obj.test(k)){var z={name:k.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,materialName:""};N(),d.push(z),A=!0,C=!0,S=1}else if(this.usemtl.test(k)){if(x=k.substring(7).trim(),!C){N();z={name:"_mm"+S.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,materialName:x};S++,d.push(z)}A&&C&&(d[d.length-1].materialName=x,C=!1)}else this.mtllib.test(k)?P=k.substring(7).trim():this.smooth.test(k)||console.log("Unhandled expression at line : "+k)}A&&(a=d[d.length-1],f.reverse(),O(),a.indices=f,a.positions=y,a.normals=b,a.uvs=T),A||(f.reverse(),O(),d.push({name:e.Geometry.RandomId(),indices:f,positions:y,normals:b,uvs:T,materialName:x}));for(var H=[],j=new Array,W=0;W<d.length;W++){if(r&&d[W].name)if(r instanceof Array){if(-1==r.indexOf(d[W].name))continue}else if(d[W].name!==r)continue;a=d[W];var X=new e.Mesh(d[W].name,n);j.push(d[W].materialName);var Y=new e.VertexData;Y.positions=a.positions,Y.normals=a.normals,Y.uvs=a.uvs,Y.indices=a.indices,Y.applyToMesh(X),i.INVERT_Y&&(X.scaling.y*=-1),H.push(X)}var Q=[];return""!==P&&Q.push(new Promise(function(e,t){l._loadMTL(P,s,function(i){try{M.parseMTL(n,i,s);for(var r=0;r<M.materials.length;r++){for(var o,a=0,l=[];(o=j.indexOf(M.materials[r].name,a))>-1;)l.push(o),a=o+1;if(-1==o&&0==l.length)M.materials[r].dispose();else for(var c=0;c<l.length;c++)H[l[c]].material=M.materials[r]}e()}catch(e){t(e)}})})),Promise.all(Q).then(function(){return H})},i.OPTIMIZE_WITH_UV=!1,i.INVERT_Y=!1,i}();e.OBJFileLoader=i,e.SceneLoader&&e.SceneLoader.RegisterPlugin(new i)}(e||(e={})),function(e){var t,i;!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(t=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(i=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(e.GLTFLoaderState||(e.GLTFLoaderState={}));var r=function(){function r(){this.onParsedObservable=new e.Observable,this.coordinateSystemMode=t.AUTO,this.animationStartMode=i.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCameraLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onErrorObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this.onExtensionLoadedObservable=new e.Observable,this.validate=!1,this.onValidatedObservable=new e.Observable,this._loader=null,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(r.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this._clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},r.prototype._clear=function(){this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear()},r.prototype.importMeshAsync=function(e,t,i,r,n,o){var s=this;return this._parseAsync(t,i,r,o).then(function(i){return s._log("Loading "+(o||"")),s._loader=s._getLoader(i),s._loader.importMeshAsync(e,t,i,r,n,o)})},r.prototype.loadAsync=function(e,t,i,r,n){var o=this;return this._parseAsync(e,t,i,n).then(function(t){return o._log("Loading "+(n||"")),o._loader=o._getLoader(t),o._loader.loadAsync(e,t,i,r,n)})},r.prototype.loadAssetContainerAsync=function(t,i,r,n,o){var s=this;return this._parseAsync(t,i,r,o).then(function(i){return s._log("Loading "+(o||"")),s._loader=s._getLoader(i),s._loader.importMeshAsync(null,t,i,r,n,o).then(function(i){var r=new e.AssetContainer(t);return Array.prototype.push.apply(r.meshes,i.meshes),Array.prototype.push.apply(r.particleSystems,i.particleSystems),Array.prototype.push.apply(r.skeletons,i.skeletons),Array.prototype.push.apply(r.animationGroups,i.animationGroups),r.removeAllFromScene(),r})})},r.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},r.prototype.createPlugin=function(){return new r},Object.defineProperty(r.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!0,configurable:!0}),r.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t,i){e.onCompleteObservable.addOnce(function(){t()}),e.onErrorObservable.addOnce(function(e){i(e)})})},r.prototype._parseAsync=function(e,t,i,r){var n=this;return Promise.resolve().then(function(){var o=t instanceof ArrayBuffer?n._unpackBinary(t):{json:t,bin:null};return n._validateAsync(e,o.json,i,r).then(function(){n._startPerformanceCounter("Parse JSON"),n._log("JSON length: "+o.json.length);var e={json:JSON.parse(o.json),bin:o.bin};return n._endPerformanceCounter("Parse JSON"),n.onParsedObservable.notifyObservers(e),n.onParsedObservable.clear(),e})})},r.prototype._validateAsync=function(e,t,i,r){var n=this;if(!this.validate||"undefined"==typeof GLTFValidator)return Promise.resolve();this._startPerformanceCounter("Validate JSON");var o={externalResourceFunction:function(t){return n.preprocessUrlAsync(i+t).then(function(t){return e._loadFileAsync(t,!0,!0)}).then(function(e){return new Uint8Array(e)})}};return r&&"data:"!==r.substr(0,5)&&(o.uri="file:"===i?r:""+i+r),GLTFValidator.validateString(t,o).then(function(e){n._endPerformanceCounter("Validate JSON"),n.onValidatedObservable.notifyObservers(e),n.onValidatedObservable.clear()})},r.prototype._getLoader=function(e){var t=e.json.asset||{};this._log("Asset version: "+t.version),t.minVersion&&this._log("Asset minimum version: "+t.minVersion),t.generator&&this._log("Asset generator: "+t.generator);var i=r._parseVersion(t.version);if(!i)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){var n=r._parseVersion(t.minVersion);if(!n)throw new Error("Invalid minimum version: "+t.minVersion);if(r._compareVersion(n,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}var o={1:r._CreateGLTFLoaderV1,2:r._CreateGLTFLoaderV2}[i.major];if(!o)throw new Error("Unsupported version: "+t.version);return o(this)},r.prototype._unpackBinary=function(e){this._startPerformanceCounter("Unpack binary"),this._log("Binary length: "+e.byteLength);var t=new n(e),i=t.readUint32();if(1179937895!==i)throw new Error("Unexpected magic: "+i);var r,o=t.readUint32();switch(this.loggingEnabled&&this._log("Binary version: "+o),o){case 1:r=this._unpackBinaryV1(t);break;case 2:r=this._unpackBinaryV2(t);break;default:throw new Error("Unsupported version: "+o)}return this._endPerformanceCounter("Unpack binary"),r},r.prototype._unpackBinaryV1=function(e){var t=e.readUint32();if(t!=e.getLength())throw new Error("Length in header does not match actual data length: "+t+" != "+e.getLength());var i,n=e.readUint32(),o=e.readUint32();switch(o){case 0:i=r._decodeBufferToText(e.readUint8Array(n));break;default:throw new Error("Unexpected content format: "+o)}var s=e.getLength()-e.getPosition();return{json:i,bin:e.readUint8Array(s)}},r.prototype._unpackBinaryV2=function(e){var t=1313821514,i=5130562,n=e.readUint32();if(n!==e.getLength())throw new Error("Length in header does not match actual data length: "+n+" != "+e.getLength());var o=e.readUint32();if(e.readUint32()!==t)throw new Error("First chunk format is not JSON");for(var s=r._decodeBufferToText(e.readUint8Array(o)),a=null;e.getPosition()<e.getLength();){var l=e.readUint32();switch(e.readUint32()){case t:throw new Error("Unexpected JSON chunk");case i:a=e.readUint8Array(l);break;default:e.skipBytes(l)}}return{json:s,bin:a}},r._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},r._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},r._decodeBufferToText=function(e){for(var t="",i=e.byteLength,r=0;r<i;r++)t+=String.fromCharCode(e[r]);return t},r.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},r.prototype._logClose=function(){--this._logIndentLevel},r.prototype._logEnabled=function(t){var i=r._logSpaces.substr(0,2*this._logIndentLevel);e.Tools.Log(""+i+t)},r.prototype._logDisabled=function(e){},r.prototype._startPerformanceCounterEnabled=function(t){e.Tools.StartPerformanceCounter(t)},r.prototype._startPerformanceCounterDisabled=function(e){},r.prototype._endPerformanceCounterEnabled=function(t){e.Tools.EndPerformanceCounter(t)},r.prototype._endPerformanceCounterDisabled=function(e){},r.IncrementalLoading=!0,r.HomogeneousCoordinates=!1,r._logSpaces=" ",r}();e.GLTFFileLoader=r;var n=function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}return e.prototype.getPosition=function(){return this._byteOffset},e.prototype.getLength=function(){return this._arrayBuffer.byteLength},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,t},e.prototype.skipBytes=function(e){this._byteOffset+=e},e}();e.SceneLoader&&e.SceneLoader.RegisterPlugin(new r)}(e||(e={})),function(e){!function(e){!function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(e.EComponentType||(e.EComponentType={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(e.EShaderType||(e.EShaderType={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(e.EParameterType||(e.EParameterType={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(e.ETextureWrapMode||(e.ETextureWrapMode={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(e.ETextureFilterType||(e.ETextureFilterType={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(e.ETextureFormat||(e.ETextureFormat={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(e.ECullingType||(e.ECullingType={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(e.EBlendingFunction||(e.EBlendingFunction={}))}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(t){var i;!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(i||(i={}));var r=function(){function e(e){this._pos=0,this.currentToken=i.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return i.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=i.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=i.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e}(),n=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],o=["world","view","projection","worldView","worldViewProjection","mBones"],s=["translation","rotation","scale"],a=["position","rotationQuaternion","scaling"],l=function(e,t,i){for(var r in e){var n=e[r];i[t][r]=n}},c=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},u=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},h=function(t){var i=null;if(t.translation||t.rotation||t.scale){var r=e.Vector3.FromArray(t.scale||[1,1,1]),n=e.Quaternion.FromArray(t.rotation||[0,0,0,1]),o=e.Vector3.FromArray(t.translation||[0,0,0]);i=e.Matrix.Compose(r,n,o)}else i=e.Matrix.FromArray(t.matrix);return i},d=function(t,i,r,n){for(var o=0;o<n.bones.length;o++)if(n.bones[o].name===r)return n.bones[o];var s=t.nodes;for(var a in s){var l=s[a];if(l.jointName){var c=l.children;for(o=0;o<c.length;o++){var u=t.nodes[c[o]];if(u.jointName&&u.jointName===r){var f=h(l),p=new e.Bone(l.name||"",n,d(t,i,l.jointName,n),f);return p.id=a,p}}}}return null},f=function(e,t){for(var i=0;i<e.length;i++)for(var r=e[i],n=0;n<r.node.children.length;n++){if(r.node.children[n]===t)return r.bone}return null},p=function(e,t){var i=e.nodes,r=i[t];if(r)return{node:r,id:t};for(var n in i)if((r=i[n]).jointName===t)return{node:r,id:n};return null},m=function(e,t){for(var i=0;i<e.jointNames.length;i++)if(e.jointNames[i]===t)return!0;return!1},g=function(t,i,r,n,o){if(n||(n=new e.Skeleton(i.name||"","",t.scene)),!i.babylonSkeleton)return n;var s=[],a=[];!function(t,i,r,n){for(var o in t.nodes){var s=t.nodes[o],a=o;if(s.jointName&&!m(r,s.jointName)){var l=h(s),c=new e.Bone(s.name||"",i,null,l);c.id=a,n.push({bone:c,node:s,id:a})}}for(var u=0;u<n.length;u++)for(var d=n[u],f=d.node.children,p=0;p<f.length;p++){for(var g=null,_=0;_<n.length;_++)if(n[_].id===f[p]){g=n[_];break}g&&(g.bone._parent=d.bone,d.bone.children.push(g.bone))}}(t,n,i,s),n.bones=[];for(var l=0;l<i.jointNames.length;l++){if(P=p(t,i.jointNames[l])){var c=P.node;if(c){o=P.id;var u=t.scene.getBoneByID(o);if(u)n.bones.push(u);else{for(var g=!1,_=null,v=0;v<l;v++){var A=p(t,i.jointNames[v]);if(A){var y=A.node;if(y){var b=y.children;if(b){g=!1;for(var T=0;T<b.length;T++)if(b[T]===o){_=d(t,i,i.jointNames[v],n),g=!0;break}if(g)break}}else e.Tools.Warn("Joint named "+i.jointNames[v]+" does not exist when looking for parent")}}var E=h(c);!_&&s.length>0&&(_=f(s,o))&&-1===a.indexOf(_)&&a.push(_),new e.Bone(c.jointName||"",n,_,E).id=o}}else e.Tools.Warn("Joint named "+i.jointNames[l]+" does not exist")}}var x=n.bones;n.bones=[];for(l=0;l<i.jointNames.length;l++){var P;if(P=p(t,i.jointNames[l]))for(v=0;v<x.length;v++)if(x[v].id===P.id){n.bones.push(x[v]);break}}n.prepare();for(l=0;l<a.length;l++)n.bones.push(a[l]);return n},_=function(i,r,n,o,s){if(s||((s=new e.Mesh(r.name||"",i.scene)).id=o),!r.babylonNode)return s;for(var a,l=[],u=null,h=new Array,d=new Array,f=new Array,p=new Array,m=0;m<n.length;m++){var g=n[m];if(D=i.meshes[g])for(var _=0;_<D.primitives.length;_++){var v=new e.VertexData,A=D.primitives[_];A.mode;var y=A.attributes,b=null,T=null;for(var E in y)if(b=i.accessors[y[E]],T=t.GLTFUtils.GetBufferFromAccessor(i,b),"NORMAL"===E)v.normals=new Float32Array(T.length),v.normals.set(T);else if("POSITION"===E){if(e.GLTFFileLoader.HomogeneousCoordinates){v.positions=new Float32Array(T.length-T.length/4);for(var x=0;x<T.length;x+=4)v.positions[x]=T[x],v.positions[x+1]=T[x+1],v.positions[x+2]=T[x+2]}else v.positions=new Float32Array(T.length),v.positions.set(T);d.push(v.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var P=Number(E.split("_")[1]),M=e.VertexBuffer.UVKind+(0===P?"":P+1),S=new Float32Array(T.length);S.set(T),c(S),v.set(S,M)}else"JOINT"===E?(v.matricesIndices=new Float32Array(T.length),v.matricesIndices.set(T)):"WEIGHT"===E?(v.matricesWeights=new Float32Array(T.length),v.matricesWeights.set(T)):"COLOR"===E&&(v.colors=new Float32Array(T.length),v.colors.set(T));if(b=i.accessors[A.indices])T=t.GLTFUtils.GetBufferFromAccessor(i,b),v.indices=new Int32Array(T.length),v.indices.set(T),p.push(v.indices.length);else{var C=[];for(x=0;x<v.positions.length/3;x++)C.push(x);v.indices=new Int32Array(C),p.push(v.indices.length)}u?u.merge(v):u=v;var R=i.scene.getMaterialByID(A.material);l.push(null===R?t.GLTFUtils.GetDefaultMaterial(i.scene):R),h.push(0===h.length?0:h[h.length-1]+d[d.length-2]),f.push(0===f.length?0:f[f.length-1]+p[p.length-2])}}l.length>1?(a=new e.MultiMaterial("multimat"+o,i.scene)).subMaterials=l:a=new e.StandardMaterial("multimat"+o,i.scene),1===l.length&&(a=l[0]),s.material||(s.material=a),new e.Geometry(o,i.scene,u,!1,s),s.computeWorldMatrix(!0),s.subMeshes=[];var O=0;for(m=0;m<n.length;m++){var D;g=n[m];if(D=i.meshes[g])for(_=0;_<D.primitives.length;_++)D.primitives[_].mode,e.SubMesh.AddToMesh(O,h[O],d[O],f[O],p[O],s,s,!0),O++}return s},v=function(e,t,i,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=i),e.scaling&&(e.scaling=r)},A=function(t,i,r,n){var o=null;if(t.importOnlyMeshes&&(i.skin||i.meshes)&&t.importMeshesNames&&t.importMeshesNames.length>0&&-1===t.importMeshesNames.indexOf(i.name||""))return null;if(i.skin){if(i.meshes){var s=t.skins[i.skin];(a=_(t,i,i.meshes,r,i.babylonNode)).skeleton=t.scene.getLastSkeletonByID(i.skin),null===a.skeleton&&(a.skeleton=g(t,s,0,s.babylonSkeleton,i.skin),s.babylonSkeleton||(s.babylonSkeleton=a.skeleton)),o=a}}else if(i.meshes){var a;o=a=_(t,i,i.mesh?[i.mesh]:i.meshes,r,i.babylonNode)}else if(!i.light||i.babylonNode||t.importOnlyMeshes){if(i.camera&&!i.babylonNode&&!t.importOnlyMeshes){var l=t.cameras[i.camera];if(l)if("orthographic"===l.type){var c=new e.FreeCamera(i.camera,e.Vector3.Zero(),t.scene,!1);c.name=i.name||"",c.mode=e.Camera.ORTHOGRAPHIC_CAMERA,c.attachControl(t.scene.getEngine().getRenderingCanvas()),o=c}else if("perspective"===l.type){var u=l[l.type],h=new e.FreeCamera(i.camera,e.Vector3.Zero(),t.scene,!1);h.name=i.name||"",h.attachControl(t.scene.getEngine().getRenderingCanvas()),u.aspectRatio||(u.aspectRatio=t.scene.getEngine().getRenderWidth()/t.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(h.maxZ=u.zfar,h.minZ=u.znear),o=h}}}else{var d=t.lights[i.light];if(d)if("ambient"===d.type){var f=d[d.type],p=new e.HemisphericLight(i.light,e.Vector3.Zero(),t.scene);p.name=i.name||"",f.color&&(p.diffuse=e.Color3.FromArray(f.color)),o=p}else if("directional"===d.type){var m=d[d.type],A=new e.DirectionalLight(i.light,e.Vector3.Zero(),t.scene);A.name=i.name||"",m.color&&(A.diffuse=e.Color3.FromArray(m.color)),o=A}else if("point"===d.type){var y=d[d.type],b=new e.PointLight(i.light,e.Vector3.Zero(),t.scene);b.name=i.name||"",y.color&&(b.diffuse=e.Color3.FromArray(y.color)),o=b}else if("spot"===d.type){var T=d[d.type],E=new e.SpotLight(i.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,t.scene);E.name=i.name||"",T.color&&(E.diffuse=e.Color3.FromArray(T.color)),T.fallOfAngle&&(E.angle=T.fallOfAngle),T.fallOffExponent&&(E.exponent=T.fallOffExponent),o=E}}if(!i.jointName){if(i.babylonNode)return i.babylonNode;if(null===o){var x=new e.Mesh(i.name||"",t.scene);i.babylonNode=x,o=x}}if(null!==o){if(i.matrix&&o instanceof e.Mesh)!function(t,i,r){if(i.matrix){var n=new e.Vector3(0,0,0),o=new e.Quaternion,s=new e.Vector3(0,0,0);e.Matrix.FromArray(i.matrix).decompose(s,o,n),v(t,n,o,s)}else i.translation&&i.rotation&&i.scale&&v(t,e.Vector3.FromArray(i.translation),e.Quaternion.FromArray(i.rotation),e.Vector3.FromArray(i.scale));t.computeWorldMatrix(!0)}(o,i);else{var P=i.translation||[0,0,0],M=i.rotation||[0,0,0,1],S=i.scale||[1,1,1];v(o,e.Vector3.FromArray(P),e.Quaternion.FromArray(M),e.Vector3.FromArray(S))}o.updateCache(!0),i.babylonNode=o}return o},y=function(e,t,i,r){void 0===r&&(r=!1);var n=e.nodes[t],o=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(n.name||"")||0===e.importMeshesNames.length),!n.jointName&&r&&null!==(o=A(e,n,t))&&(o.id=t,o.parent=i),n.children)for(var s=0;s<n.children.length;s++)y(e,n.children[s],o,r)},b=function(i){var r=i.currentScene;if(r)for(var n=0;n<r.nodes.length;n++)y(i,r.nodes[n],null);else for(var o in i.scenes){r=i.scenes[o];for(n=0;n<r.nodes.length;n++)y(i,r.nodes[n],null)}!function(i){for(var r in i.animations){var n=i.animations[r];if(n.channels&&n.samplers)for(var o=null,l=0;l<n.channels.length;l++){var c=n.channels[l],u=n.samplers[c.sampler];if(u){var h=null,d=null;n.parameters?(h=n.parameters[u.input],d=n.parameters[u.output]):(h=u.input,d=u.output);var f=t.GLTFUtils.GetBufferFromAccessor(i,i.accessors[h]),p=t.GLTFUtils.GetBufferFromAccessor(i,i.accessors[d]),m=c.target.id,g=i.scene.getNodeByID(m);if(null===g&&(g=i.scene.getNodeByName(m)),null!==g){var _=g instanceof e.Bone,v=c.target.path,A=s.indexOf(v);-1!==A&&(v=a[A]);var y=e.Animation.ANIMATIONTYPE_MATRIX;_||("rotationQuaternion"===v?(y=e.Animation.ANIMATIONTYPE_QUATERNION,g.rotationQuaternion=new e.Quaternion):y=e.Animation.ANIMATIONTYPE_VECTOR3);var b=null,T=[],E=0,x=!1;_&&o&&o.getKeys().length===f.length&&(b=o,x=!0),x||(b=new e.Animation(r,_?"_matrix":v,1,y,e.Animation.ANIMATIONLOOPMODE_CYCLE));for(var P=0;P<f.length;P++){var M=null;if("rotationQuaternion"===v?(M=e.Quaternion.FromArray([p[E],p[E+1],p[E+2],p[E+3]]),E+=4):(M=e.Vector3.FromArray([p[E],p[E+1],p[E+2]]),E+=3),_){var S=g,C=e.Vector3.Zero(),R=new e.Quaternion,O=e.Vector3.Zero(),D=S.getBaseMatrix();x&&o&&(D=o.getKeys()[P].value),D.decompose(O,R,C),"position"===v?C=M:"rotationQuaternion"===v?R=M:O=M,M=e.Matrix.Compose(O,R,C)}x?o&&(o.getKeys()[P].value=M):T.push({frame:f[P],value:M})}!x&&b&&(b.setKeys(T),g.animations.push(b)),o=b,i.scene.stopAnimation(g),i.scene.beginAnimation(g,0,f[f.length-1],!0,1)}else e.Tools.Warn("Creating animation named "+r+". But cannot find node named "+m+" to attach to")}}}}(i);for(n=0;n<i.scene.skeletons.length;n++){var l=i.scene.skeletons[n];i.scene.beginAnimation(l,0,Number.MAX_VALUE,!0,1)}},T=function(e,i,r,n,o,s){return function(a){!function(e,i,r,n,o){var s=n.values||r.parameters,a=r.uniforms;for(var l in o){var c=o[l],u=c.type,h=s[a[l]];if(void 0===h&&(h=c.value),h){var d=function(e){return function(t){c.value&&e&&(i.setTexture(e,t),delete o[e])}};u===t.EParameterType.SAMPLER_2D?t.GLTFLoaderExtension.LoadTextureAsync(e,n.values?h:c.value,d(l),function(){return d(null)}):c.value&&t.GLTFUtils.SetUniform(i,l,n.values?h:c.value,u)&&delete o[l]}}}(e,i,r,n,o),i.onBind=function(a){!function(e,i,r,n,o,s,a){var l=s.values||o.parameters;for(var c in r){var u=r[c],h=u.type;if(h===t.EParameterType.FLOAT_MAT2||h===t.EParameterType.FLOAT_MAT3||h===t.EParameterType.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var d=i.scene.getNodeByName(u.source||u.node||"");if(null===d&&(d=i.scene.getNodeByID(u.source||u.node||"")),null===d)continue;t.GLTFUtils.SetMatrix(i.scene,d,u,c,n.getEffect())}}else t.GLTFUtils.SetMatrix(i.scene,e,u,c,n.getEffect());else{var f=l[o.uniforms[c]];if(!f)continue;if(h===t.EParameterType.SAMPLER_2D){var p=i.textures[s.values?f:u.value].babylonTexture;if(null===p||void 0===p)continue;n.getEffect().setTexture(c,p)}else t.GLTFUtils.SetUniform(n.getEffect(),c,f,h)}}a(n)}(a,e,o,i,r,n,s)}}},E=function(e,t,i){for(var r in t.uniforms){var s=t.uniforms[r],a=t.parameters[s];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var l=n.indexOf(a.semantic);if(-1!==l)return delete i[r],o[l]}}return e.currentIdentifier},x=function(e){for(var i in e.materials)t.GLTFLoaderExtension.LoadMaterialAsync(e,i,function(e){},function(){})},P=function(){function s(){}return s.CreateRuntime=function(e,t,i){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:i,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[]};return e.extensions&&l(e.extensions,"extensions",r),e.extensionsUsed&&l(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var i in e){var r=e[i];t.buffers[i]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&l(e.bufferViews,"bufferViews",r),e.accessors&&l(e.accessors,"accessors",r),e.meshes&&l(e.meshes,"meshes",r),e.lights&&l(e.lights,"lights",r),e.cameras&&l(e.cameras,"cameras",r),e.nodes&&l(e.nodes,"nodes",r),e.images&&l(e.images,"images",r),e.textures&&l(e.textures,"textures",r),e.shaders&&function(e,t){for(var i in e){var r=e[i];t.shaders[i]=r,t.shaderscount++}}(e.shaders,r),e.programs&&l(e.programs,"programs",r),e.samplers&&l(e.samplers,"samplers",r),e.techniques&&l(e.techniques,"techniques",r),e.materials&&l(e.materials,"materials",r),e.animations&&l(e.animations,"animations",r),e.skins&&l(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},s.LoadBufferAsync=function(t,i,r,n,o){var s=t.buffers[i];e.Tools.IsBase64(s.uri)?setTimeout(function(){return r(new Uint8Array(e.Tools.DecodeBase64(s.uri)))}):e.Tools.LoadFile(t.rootUrl+s.uri,function(e){return r(new Uint8Array(e))},o,void 0,!0,function(e){e&&n(e.status+" "+e.statusText)})},s.LoadTextureBufferAsync=function(t,i,r,n){var o=t.textures[i];if(o&&o.source)if(o.babylonTexture)r(null);else{var s=t.images[o.source];e.Tools.IsBase64(s.uri)?setTimeout(function(){return r(new Uint8Array(e.Tools.DecodeBase64(s.uri)))}):e.Tools.LoadFile(t.rootUrl+s.uri,function(e){return r(new Uint8Array(e))},void 0,void 0,!0,function(e){e&&n(e.status+" "+e.statusText)})}else n("")},s.CreateTextureAsync=function(i,r,n,o,s){var a=i.textures[r];if(a.babylonTexture)o(a.babylonTexture);else{var l=i.samplers[a.sampler],c=l.minFilter===t.ETextureFilterType.NEAREST_MIPMAP_NEAREST||l.minFilter===t.ETextureFilterType.NEAREST_MIPMAP_LINEAR||l.minFilter===t.ETextureFilterType.LINEAR_MIPMAP_NEAREST||l.minFilter===t.ETextureFilterType.LINEAR_MIPMAP_LINEAR,u=e.Texture.BILINEAR_SAMPLINGMODE,h=null==n?new Blob:new Blob([n]),d=URL.createObjectURL(h),f=function(){return URL.revokeObjectURL(d)},p=new e.Texture(d,i.scene,!c,!0,u,f,f);void 0!==l.wrapS&&(p.wrapU=t.GLTFUtils.GetWrapMode(l.wrapS)),void 0!==l.wrapT&&(p.wrapV=t.GLTFUtils.GetWrapMode(l.wrapT)),p.name=r,a.babylonTexture=p,o(p)}},s.LoadShaderStringAsync=function(t,i,r,n){var o=t.shaders[i];if(e.Tools.IsBase64(o.uri)){var s=atob(o.uri.split(",")[1]);r&&r(s)}else e.Tools.LoadFile(t.rootUrl+o.uri,r,void 0,void 0,!1,function(e){e&&n&&n(e.status+" "+e.statusText)})},s.LoadMaterialAsync=function(s,a,l,c){var h=s.materials[a];if(h.technique){var d=s.techniques[h.technique];if(!d){var f=new e.StandardMaterial(a,s.scene);return f.diffuseColor=new e.Color3(.5,.5,.5),f.sideOrientation=e.Material.CounterClockWiseSideOrientation,void l(f)}var p=s.programs[d.program],m=d.states,g=e.Effect.ShadersStore[p.vertexShader+"VertexShader"],_=e.Effect.ShadersStore[p.fragmentShader+"PixelShader"],v="",A="",y=new r(g),b=new r(_),x={},P=[],M=[],S=[];for(var C in d.uniforms){var R=d.uniforms[C],O=d.parameters[R];if(x[C]=O,!O.semantic||O.node||O.source)O.type===t.EParameterType.SAMPLER_2D?S.push(C):P.push(C);else{var D=n.indexOf(O.semantic);-1!==D?(P.push(o[D]),delete x[C]):P.push(C)}}for(var I in d.attributes){var w=d.attributes[I];if((F=d.parameters[w]).semantic){var L=u(F);L&&M.push(L)}}for(;!y.isEnd()&&y.getNextToken();){if(y.currentToken===i.IDENTIFIER){var B=!1;for(var I in d.attributes){w=d.attributes[I];var F=d.parameters[w];if(y.currentIdentifier===I&&F.semantic){v+=u(F),B=!0;break}}B||(v+=E(y,d,x))}else v+=y.currentString}for(;!b.isEnd()&&b.getNextToken();){b.currentToken===i.IDENTIFIER?A+=E(b,d,x):A+=b.currentString}var N={vertex:p.vertexShader+a,fragment:p.fragmentShader+a},V={attributes:M,uniforms:P,samplers:S,needAlphaBlending:m&&m.enable&&-1!==m.enable.indexOf(3042)};e.Effect.ShadersStore[p.vertexShader+a+"VertexShader"]=v,e.Effect.ShadersStore[p.fragmentShader+a+"PixelShader"]=A;var U=new e.ShaderMaterial(a,s.scene,N,V);if(U.onError=function(e,t,i){return function(r,n){t.dispose(!0),i("Cannot compile program named "+e.name+". Error: "+n+". Default material will be applied")}}(p,U,c),U.onCompiled=T(s,U,d,h,x,l),U.sideOrientation=e.Material.CounterClockWiseSideOrientation,m&&m.functions){var G=m.functions;G.cullFace&&G.cullFace[0]!==t.ECullingType.BACK&&(U.backFaceCulling=!1);var k=G.blendFuncSeparate;k&&(k[0]===t.EBlendingFunction.SRC_ALPHA&&k[1]===t.EBlendingFunction.ONE_MINUS_SRC_ALPHA&&k[2]===t.EBlendingFunction.ONE&&k[3]===t.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_COMBINE:k[0]===t.EBlendingFunction.ONE&&k[1]===t.EBlendingFunction.ONE&&k[2]===t.EBlendingFunction.ZERO&&k[3]===t.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ONEONE:k[0]===t.EBlendingFunction.SRC_ALPHA&&k[1]===t.EBlendingFunction.ONE&&k[2]===t.EBlendingFunction.ZERO&&k[3]===t.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ADD:k[0]===t.EBlendingFunction.ZERO&&k[1]===t.EBlendingFunction.ONE_MINUS_SRC_COLOR&&k[2]===t.EBlendingFunction.ONE&&k[3]===t.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_SUBTRACT:k[0]===t.EBlendingFunction.DST_COLOR&&k[1]===t.EBlendingFunction.ZERO&&k[2]===t.EBlendingFunction.ONE&&k[3]===t.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_MULTIPLY:k[0]===t.EBlendingFunction.SRC_ALPHA&&k[1]===t.EBlendingFunction.ONE_MINUS_SRC_COLOR&&k[2]===t.EBlendingFunction.ONE&&k[3]===t.EBlendingFunction.ONE&&(U.alphaMode=e.Engine.ALPHA_MAXIMIZED))}}else c&&c("No technique found.")},s}();t.GLTFLoaderBase=P;var M=function(){function i(){this.state=null}return i.RegisterExtension=function(t){i.Extensions[t.name]?e.Tools.Error('Tool with the same name "'+t.name+'" already exists'):i.Extensions[t.name]=t},i.prototype.dispose=function(){},i.prototype._importMeshAsync=function(i,r,n,o,s,a,l){var c=this;return r.useRightHandedSystem=!0,t.GLTFLoaderExtension.LoadRuntimeAsync(r,n,o,function(t){t.importOnlyMeshes=!0,""===i?t.importMeshesNames=[]:"string"==typeof i?t.importMeshesNames=[i]:!i||i instanceof Array?(t.importMeshesNames=[],e.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[i],c._createNodes(t);var r=new Array,n=new Array;for(var o in t.nodes){var l=t.nodes[o];l.babylonNode instanceof e.AbstractMesh&&r.push(l.babylonNode)}for(var u in t.skins){var h=t.skins[u];h.babylonSkeleton instanceof e.Skeleton&&n.push(h.babylonSkeleton)}c._loadBuffersAsync(t,function(){c._loadShadersAsync(t,function(){x(t),b(t),!e.GLTFFileLoader.IncrementalLoading&&s&&s(r,n)})},a),e.GLTFFileLoader.IncrementalLoading&&s&&s(r,n)},l),!0},i.prototype.importMeshAsync=function(e,t,i,r,n){var o=this;return new Promise(function(s,a){o._importMeshAsync(e,t,i,r,function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[]})},n,function(e){a(new Error(e))})})},i.prototype._loadAsync=function(i,r,n,o,s,a){var l=this;i.useRightHandedSystem=!0,t.GLTFLoaderExtension.LoadRuntimeAsync(i,r,n,function(i){t.GLTFLoaderExtension.LoadRuntimeExtensionsAsync(i,function(){l._createNodes(i),l._loadBuffersAsync(i,function(){l._loadShadersAsync(i,function(){x(i),b(i),e.GLTFFileLoader.IncrementalLoading||o()})}),e.GLTFFileLoader.IncrementalLoading&&o()},a)},a)},i.prototype.loadAsync=function(e,t,i,r){var n=this;return new Promise(function(o,s){n._loadAsync(e,t,i,function(){o()},r,function(e){s(new Error(e))})})},i.prototype._loadShadersAsync=function(i,r){var n=!1,o=function(n,o){t.GLTFLoaderExtension.LoadShaderStringAsync(i,n,function(s){s instanceof ArrayBuffer||(i.loadedShaderCount++,s&&(e.Effect.ShadersStore[n+(o.type===t.EShaderType.VERTEX?"VertexShader":"PixelShader")]=s),i.loadedShaderCount===i.shaderscount&&r())},function(){e.Tools.Error("Error when loading shader program named "+n+" located at "+o.uri)})};for(var s in i.shaders){n=!0;var a=i.shaders[s];a?o.bind(this,s,a)():e.Tools.Error("No shader named: "+s)}n||r()},i.prototype._loadBuffersAsync=function(i,r,n){var o=!1,s=function(n,o){t.GLTFLoaderExtension.LoadBufferAsync(i,n,function(t){i.loadedBufferCount++,t&&(t.byteLength!=i.buffers[n].byteLength&&e.Tools.Error("Buffer named "+n+" is length "+t.byteLength+". Expected: "+o.byteLength),i.loadedBufferViews[n]=t),i.loadedBufferCount===i.buffersCount&&r()},function(){e.Tools.Error("Error when loading buffer named "+n+" located at "+o.uri)})};for(var a in i.buffers){o=!0;var l=i.buffers[a];l?s.bind(this,a,l)():e.Tools.Error("No buffer named: "+a)}o||r()},i.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var i=0;i<t.nodes.length;i++)y(e,t.nodes[i],null);else for(var r in e.scenes){t=e.scenes[r];for(i=0;i<t.nodes.length;i++)y(e,t.nodes[i],null)}},i.Extensions={},i}();t.GLTFLoader=M,e.GLTFFileLoader._CreateGLTFLoaderV1=function(){return new M}}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(t){var i=function(){function i(){}return i.SetMatrix=function(i,r,n,o,s){var a=null;if("MODEL"===n.semantic?a=r.getWorldMatrix():"PROJECTION"===n.semantic?a=i.getProjectionMatrix():"VIEW"===n.semantic?a=i.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?a=e.Matrix.Transpose(r.getWorldMatrix().multiply(i.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?a=r.getWorldMatrix().multiply(i.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?a=r.getWorldMatrix().multiply(i.getTransformMatrix()):"MODELINVERSE"===n.semantic?a=r.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?a=i.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?a=i.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?a=r.getWorldMatrix().multiply(i.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?a=r.getWorldMatrix().multiply(i.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(a=e.Matrix.Transpose(r.getWorldMatrix().invert())),a)switch(n.type){case t.EParameterType.FLOAT_MAT2:s.setMatrix2x2(o,e.Matrix.GetAsMatrix2x2(a));break;case t.EParameterType.FLOAT_MAT3:s.setMatrix3x3(o,e.Matrix.GetAsMatrix3x3(a));break;case t.EParameterType.FLOAT_MAT4:s.setMatrix(o,a)}},i.SetUniform=function(i,r,n,o){switch(o){case t.EParameterType.FLOAT:return i.setFloat(r,n),!0;case t.EParameterType.FLOAT_VEC2:return i.setVector2(r,e.Vector2.FromArray(n)),!0;case t.EParameterType.FLOAT_VEC3:return i.setVector3(r,e.Vector3.FromArray(n)),!0;case t.EParameterType.FLOAT_VEC4:return i.setVector4(r,e.Vector4.FromArray(n)),!0;default:return!1}},i.GetWrapMode=function(i){switch(i){case t.ETextureWrapMode.CLAMP_TO_EDGE:return e.Texture.CLAMP_ADDRESSMODE;case t.ETextureWrapMode.MIRRORED_REPEAT:return e.Texture.MIRROR_ADDRESSMODE;case t.ETextureWrapMode.REPEAT:default:return e.Texture.WRAP_ADDRESSMODE}},i.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},i.GetTextureFilterMode=function(i){switch(i){case t.ETextureFilterType.LINEAR:case t.ETextureFilterType.LINEAR_MIPMAP_NEAREST:case t.ETextureFilterType.LINEAR_MIPMAP_LINEAR:return e.Texture.TRILINEAR_SAMPLINGMODE;case t.ETextureFilterType.NEAREST:case t.ETextureFilterType.NEAREST_MIPMAP_NEAREST:return e.Texture.NEAREST_SAMPLINGMODE;default:return e.Texture.BILINEAR_SAMPLINGMODE}},i.GetBufferFromBufferView=function(e,i,r,n,o){r=i.byteOffset+r;var s=e.loadedBufferViews[i.buffer];if(r+n>s.byteLength)throw new Error("Buffer access is out of range");var a=s.buffer;switch(r+=s.byteOffset,o){case t.EComponentType.BYTE:return new Int8Array(a,r,n);case t.EComponentType.UNSIGNED_BYTE:return new Uint8Array(a,r,n);case t.EComponentType.SHORT:return new Int16Array(a,r,n);case t.EComponentType.UNSIGNED_SHORT:return new Uint16Array(a,r,n);default:return new Float32Array(a,r,n)}},i.GetBufferFromAccessor=function(e,t){var r=e.bufferViews[t.bufferView],n=t.count*i.GetByteStrideFromType(t);return i.GetBufferFromBufferView(e,r,t.byteOffset,n,t.componentType)},i.DecodeBufferToText=function(e){for(var t="",i=e.byteLength,r=0;r<i;++r)t+=String.fromCharCode(e[r]);return t},i.GetDefaultMaterial=function(t){if(!i._DefaultMaterial){e.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),e.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};i._DefaultMaterial=new e.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),i._DefaultMaterial.setColor4("u_emission",new e.Color4(.5,.5,.5,1))}return i._DefaultMaterial},i._DefaultMaterial=null,i}();t.GLTFUtils=i}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(e){var t=function(){function t(e){this._name=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.loadRuntimeAsync=function(e,t,i,r,n){return!1},t.prototype.loadRuntimeExtensionsAsync=function(e,t,i){return!1},t.prototype.loadBufferAsync=function(e,t,i,r,n){return!1},t.prototype.loadTextureBufferAsync=function(e,t,i,r){return!1},t.prototype.createTextureAsync=function(e,t,i,r,n){return!1},t.prototype.loadShaderStringAsync=function(e,t,i,r){return!1},t.prototype.loadMaterialAsync=function(e,t,i,r){return!1},t.LoadRuntimeAsync=function(i,r,n,o,s){t.ApplyExtensions(function(e){return e.loadRuntimeAsync(i,r,n,o,s)},function(){setTimeout(function(){o&&o(e.GLTFLoaderBase.CreateRuntime(r.json,i,n))})})},t.LoadRuntimeExtensionsAsync=function(e,i,r){t.ApplyExtensions(function(t){return t.loadRuntimeExtensionsAsync(e,i,r)},function(){setTimeout(function(){i()})})},t.LoadBufferAsync=function(i,r,n,o,s){t.ApplyExtensions(function(e){return e.loadBufferAsync(i,r,n,o,s)},function(){e.GLTFLoaderBase.LoadBufferAsync(i,r,n,o,s)})},t.LoadTextureAsync=function(e,i,r,n){t.LoadTextureBufferAsync(e,i,function(o){o&&t.CreateTextureAsync(e,i,o,r,n)},n)},t.LoadShaderStringAsync=function(i,r,n,o){t.ApplyExtensions(function(e){return e.loadShaderStringAsync(i,r,n,o)},function(){e.GLTFLoaderBase.LoadShaderStringAsync(i,r,n,o)})},t.LoadMaterialAsync=function(i,r,n,o){t.ApplyExtensions(function(e){return e.loadMaterialAsync(i,r,n,o)},function(){e.GLTFLoaderBase.LoadMaterialAsync(i,r,n,o)})},t.LoadTextureBufferAsync=function(i,r,n,o){t.ApplyExtensions(function(e){return e.loadTextureBufferAsync(i,r,n,o)},function(){e.GLTFLoaderBase.LoadTextureBufferAsync(i,r,n,o)})},t.CreateTextureAsync=function(i,r,n,o,s){t.ApplyExtensions(function(e){return e.createTextureAsync(i,r,n,o,s)},function(){e.GLTFLoaderBase.CreateTextureAsync(i,r,n,o,s)})},t.ApplyExtensions=function(t,i){for(var r in e.GLTFLoader.Extensions){if(t(e.GLTFLoader.Extensions[r]))return}i()},t}();e.GLTFLoaderExtension=t}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(e){var i=function(i){function r(){return i.call(this,"KHR_binary_glTF")||this}return t(r,i),r.prototype.loadRuntimeAsync=function(t,i,r,n,o){var s=i.json.extensionsUsed;return!(!s||-1===s.indexOf(this.name)||!i.bin)&&(this._bin=i.bin,n(e.GLTFLoaderBase.CreateRuntime(i.json,t,r)),!0)},r.prototype.loadBufferAsync=function(e,t,i,r){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===t&&(i(this._bin),!0))},r.prototype.loadTextureBufferAsync=function(t,i,r,n){var o=t.textures[i],s=t.images[o.source];if(!(s.extensions&&this.name in s.extensions))return!1;var a=s.extensions[this.name],l=t.bufferViews[a.bufferView];return r(e.GLTFUtils.GetBufferFromBufferView(t,l,0,l.byteLength,e.EComponentType.UNSIGNED_BYTE)),!0},r.prototype.loadShaderStringAsync=function(t,i,r,n){var o=t.shaders[i];if(!(o.extensions&&this.name in o.extensions))return!1;var s=o.extensions[this.name],a=t.bufferViews[s.bufferView],l=e.GLTFUtils.GetBufferFromBufferView(t,a,0,a.byteLength,e.EComponentType.UNSIGNED_BYTE);return setTimeout(function(){var t=e.GLTFUtils.DecodeBufferToText(l);r(t)}),!0},r}(e.GLTFLoaderExtension);e.GLTFBinaryExtension=i,e.GLTFLoader.RegisterExtension(new i)}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(i){var r=function(r){function n(){return r.call(this,"KHR_materials_common")||this}return t(n,r),n.prototype.loadRuntimeExtensionsAsync=function(t,i,r){if(!t.extensions)return!1;var n=t.extensions[this.name];if(!n)return!1;var o=n.lights;if(o)for(var s in o){var a=o[s];switch(a.type){case"ambient":var l=new e.HemisphericLight(a.name,new e.Vector3(0,1,0),t.scene),c=a.ambient;c&&(l.diffuse=e.Color3.FromArray(c.color||[1,1,1]));break;case"point":var u=new e.PointLight(a.name,new e.Vector3(10,10,10),t.scene),h=a.point;h&&(u.diffuse=e.Color3.FromArray(h.color||[1,1,1]));break;case"directional":var d=new e.DirectionalLight(a.name,new e.Vector3(0,-1,0),t.scene),f=a.directional;f&&(d.diffuse=e.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var p=a.spot;if(p)new e.SpotLight(a.name,new e.Vector3(0,10,0),new e.Vector3(0,-1,0),p.fallOffAngle||Math.PI,p.fallOffExponent||0,t.scene).diffuse=e.Color3.FromArray(p.color||[1,1,1]);break;default:e.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},n.prototype.loadMaterialAsync=function(t,i,r,n){var o=t.materials[i];if(!o||!o.extensions)return!1;var s=o.extensions[this.name];if(!s)return!1;var a=new e.StandardMaterial(i,t.scene);return a.sideOrientation=e.Material.CounterClockWiseSideOrientation,"CONSTANT"===s.technique&&(a.disableLighting=!0),a.backFaceCulling=void 0!==s.doubleSided&&!s.doubleSided,a.alpha=void 0===s.values.transparency?1:s.values.transparency,a.specularPower=void 0===s.values.shininess?0:s.values.shininess,"string"==typeof s.values.ambient?this._loadTexture(t,s.values.ambient,a,"ambientTexture",n):a.ambientColor=e.Color3.FromArray(s.values.ambient||[0,0,0]),"string"==typeof s.values.diffuse?this._loadTexture(t,s.values.diffuse,a,"diffuseTexture",n):a.diffuseColor=e.Color3.FromArray(s.values.diffuse||[0,0,0]),"string"==typeof s.values.emission?this._loadTexture(t,s.values.emission,a,"emissiveTexture",n):a.emissiveColor=e.Color3.FromArray(s.values.emission||[0,0,0]),"string"==typeof s.values.specular?this._loadTexture(t,s.values.specular,a,"specularTexture",n):a.specularColor=e.Color3.FromArray(s.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,t,r,n,o){i.GLTFLoaderBase.LoadTextureBufferAsync(e,t,function(s){i.GLTFLoaderBase.CreateTextureAsync(e,t,s,function(e){return r[n]=e},o)},o)},n}(i.GLTFLoaderExtension);i.GLTFMaterialsCommonExtension=r,i.GLTFLoader.RegisterExtension(new r)}(e.GLTF1||(e.GLTF1={}))}(e||(e={})),function(e){!function(t){var i=function(){function e(){}return e.Get=function(e,t,i){if(!t||void 0==i||!t[i])throw new Error(e+": Failed to find index ("+i+")");return t[i]},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}();t.ArrayItem=i;var r=function(){function t(e){this._completePromises=new Array,this._disposed=!1,this._state=null,this._extensions={},this._defaultBabylonMaterialData={},this._requests=new Array,this._parent=e}return t.RegisterExtension=function(i,r){t.UnregisterExtension(i)&&e.Tools.Warn("Extension with the name '"+i+"' already exists"),t._ExtensionFactories[i]=r,t._ExtensionNames.push(i)},t.UnregisterExtension=function(e){if(!t._ExtensionFactories[e])return!1;delete t._ExtensionFactories[e];var i=t._ExtensionNames.indexOf(e);return-1!==i&&t._ExtensionNames.splice(i,1),!0},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){if(!this._disposed){this._disposed=!0;for(var e=0,t=this._requests;e<t.length;e++){t[e].abort()}for(var i in this._requests.length=0,delete this.gltf,delete this.babylonScene,this._completePromises.length=0,this._extensions){this._extensions[i].dispose&&this._extensions[i].dispose()}this._extensions={},delete this._rootBabylonMesh,delete this._progressCallback,this._parent._clear()}},t.prototype.importMeshAsync=function(e,t,i,r,n,o){var s=this;return Promise.resolve().then(function(){s.babylonScene=t,s._rootUrl=r,s._fileName=o||"scene",s._progressCallback=n,s._loadData(i);var a=null;if(e){var l={};if(s.gltf.nodes)for(var c=0,u=s.gltf.nodes;c<u.length;c++){var h=u[c];h.name&&(l[h.name]=h.index)}a=(e instanceof Array?e:[e]).map(function(e){var t=l[e];if(void 0===t)throw new Error("Failed to find node '"+e+"'");return t})}return s._loadAsync(a,function(){return{meshes:s._getMeshes(),particleSystems:[],skeletons:s._getSkeletons(),animationGroups:s._getAnimationGroups()}})})},t.prototype.loadAsync=function(e,t,i,r,n){var o=this;return Promise.resolve().then(function(){return o.babylonScene=e,o._rootUrl=i,o._fileName=n||"scene",o._progressCallback=r,o._loadData(t),o._loadAsync(null,function(){})})},t.prototype._loadAsync=function(t,r){var n=this;return Promise.resolve().then(function(){n._uniqueRootUrl=-1===n._rootUrl.indexOf("file:")&&n._fileName?n._rootUrl:""+n._rootUrl+Date.now()+"/",n._loadExtensions(),n._checkExtensions();var o=e.GLTFLoaderState[e.GLTFLoaderState.LOADING]+" => "+e.GLTFLoaderState[e.GLTFLoaderState.READY],s=e.GLTFLoaderState[e.GLTFLoaderState.LOADING]+" => "+e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE];n._parent._startPerformanceCounter(o),n._parent._startPerformanceCounter(s),n._setState(e.GLTFLoaderState.LOADING),n._extensionsOnLoading();var a=new Array;if(t)a.push(n.loadSceneAsync("#/nodes",{nodes:t,index:-1}));else{var l=i.Get("#/scene",n.gltf.scenes,n.gltf.scene||0);a.push(n.loadSceneAsync("#/scenes/"+l.index,l))}n._parent.compileMaterials&&a.push(n._compileMaterialsAsync()),n._parent.compileShadowGenerators&&a.push(n._compileShadowGeneratorsAsync());var c=Promise.all(a).then(function(){return n._setState(e.GLTFLoaderState.READY),n._extensionsOnReady(),n._startAnimations(),r()});return c.then(function(){n._parent._endPerformanceCounter(o),e.Tools.SetImmediate(function(){n._disposed||Promise.all(n._completePromises).then(function(){n._parent._endPerformanceCounter(s),n._setState(e.GLTFLoaderState.COMPLETE),n._parent.onCompleteObservable.notifyObservers(void 0),n._parent.onCompleteObservable.clear(),n.dispose()},function(e){n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()})})}),c},function(e){throw n._disposed||(n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()),e})},t.prototype._loadData=function(t){if(this.gltf=t.json,this._setupData(),t.bin){var i=this.gltf.buffers;if(i&&i[0]&&!i[0].uri){var r=i[0];(r.byteLength<t.bin.byteLength-3||r.byteLength>t.bin.byteLength)&&e.Tools.Warn("Binary buffer length ("+r.byteLength+") from JSON does not match chunk length ("+t.bin.byteLength+")"),r._data=Promise.resolve(t.bin)}else e.Tools.Warn("Unexpected BIN chunk")}},t.prototype._setupData=function(){if(i.Assign(this.gltf.accessors),i.Assign(this.gltf.animations),i.Assign(this.gltf.buffers),i.Assign(this.gltf.bufferViews),i.Assign(this.gltf.cameras),i.Assign(this.gltf.images),i.Assign(this.gltf.materials),i.Assign(this.gltf.meshes),i.Assign(this.gltf.nodes),i.Assign(this.gltf.samplers),i.Assign(this.gltf.scenes),i.Assign(this.gltf.skins),i.Assign(this.gltf.textures),this.gltf.nodes){for(var e={},t=0,r=this.gltf.nodes;t<r.length;t++){if((c=r[t]).children)for(var n=0,o=c.children;n<o.length;n++){e[o[n]]=c.index}}for(var s=this._createRootNode(),a=0,l=this.gltf.nodes;a<l.length;a++){var c,u=e[(c=l[a]).index];c.parent=void 0===u?s:this.gltf.nodes[u]}}},t.prototype._loadExtensions=function(){for(var e=0,i=t._ExtensionNames;e<i.length;e++){var r=i[e],n=t._ExtensionFactories[r](this);this._extensions[r]=n,this._parent.onExtensionLoadedObservable.notifyObservers(n)}this._parent.onExtensionLoadedObservable.clear()},t.prototype._checkExtensions=function(){if(this.gltf.extensionsRequired)for(var e=0,t=this.gltf.extensionsRequired;e<t.length;e++){var i=t[e],r=this._extensions[i];if(!r||!r.enabled)throw new Error("Require extension "+i+" is not available")}},t.prototype._setState=function(t){this._state=t,this.log(e.GLTFLoaderState[this._state])},t.prototype._createRootNode=function(){this._rootBabylonMesh=new e.Mesh("__root__",this.babylonScene);var i={_babylonMesh:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this.babylonScene.useRightHandedSystem||(i.rotation=[0,1,0,0],i.scale=[1,1,-1],t._LoadTransform(i,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this.babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode ("+this._parent.coordinateSystemMode+")")}return this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),i},t.prototype.loadSceneAsync=function(e,t){var r=this,n=this._extensionsLoadSceneAsync(e,t);if(n)return n;var o=new Array;if(this.logOpen(e+" "+(t.name||"")),t.nodes)for(var s=0,a=t.nodes;s<a.length;s++){var l=a[s],c=i.Get(e+"/nodes/"+l,this.gltf.nodes,l);o.push(this.loadNodeAsync("#/nodes/"+c.index,c,function(e){e.parent=r._rootBabylonMesh}))}return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then(function(){})},t.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var i=0,r=e._primitiveBabylonMeshes;i<r.length;i++){t(r[i])}else t(e._babylonMesh)},t.prototype._getMeshes=function(){var e=new Array;e.push(this._rootBabylonMesh);var t=this.gltf.nodes;if(t)for(var i=0,r=t;i<r.length;i++){var n=r[i];if(n._babylonMesh&&e.push(n._babylonMesh),n._primitiveBabylonMeshes)for(var o=0,s=n._primitiveBabylonMeshes;o<s.length;o++){var a=s[o];e.push(a)}}return e},t.prototype._getSkeletons=function(){var e=new Array,t=this.gltf.skins;if(t)for(var i=0,r=t;i<r.length;i++){var n=r[i];n._babylonSkeleton&&e.push(n._babylonSkeleton)}return e},t.prototype._getAnimationGroups=function(){var e=new Array,t=this.gltf.animations;if(t)for(var i=0,r=t;i<r.length;i++){var n=r[i];n._babylonAnimationGroup&&e.push(n._babylonAnimationGroup)}return e},t.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:0!==(t=this._getAnimationGroups()).length&&t[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var t,i=0,r=t=this._getAnimationGroups();i<r.length;i++){r[i].start(!0)}break;default:return void e.Tools.Error("Invalid animation start mode ("+this._parent.animationStartMode+")")}},t.prototype.loadNodeAsync=function(r,n,o){var s=this;void 0===o&&(o=function(){});var a=this._extensionsLoadNodeAsync(r,n,o);if(a)return a;if(n._babylonMesh)throw new Error(r+": Invalid recursive node hierarchy");var l=new Array;this.logOpen(r+" "+(n.name||""));var c=new e.Mesh(n.name||"node"+n.index,this.babylonScene);if(n._babylonMesh=c,c.setEnabled(!1),t._LoadTransform(n,c),void 0!=n.mesh){var u=i.Get(r+"/mesh",this.gltf.meshes,n.mesh);l.push(this._loadMeshAsync("#/meshes/"+u.index,n,u,c))}if(void 0!=n.camera){var h=i.Get(r+"/camera",this.gltf.cameras,n.camera);l.push(this.loadCameraAsync("#/cameras/"+h.index,h,function(e){e.parent=c}))}if(n.children)for(var d=function(e){var t=i.Get(r+"/children/"+e,f.gltf.nodes,e);l.push(f.loadNodeAsync("#/nodes/"+n.index,t,function(e){void 0==t.skin?e.parent=c:e.parent=s._rootBabylonMesh}))},f=this,p=0,m=n.children;p<m.length;p++){d(m[p])}return o(c),this._parent.onMeshLoadedObservable.notifyObservers(c),this.logClose(),Promise.all(l).then(function(){return c.setEnabled(!0),c})},t.prototype._loadMeshAsync=function(t,r,n,o){var s=this,a=new Array;this.logOpen(t+" "+(n.name||""));var l=n.primitives;if(!l||0===l.length)throw new Error(t+": Primitives are missing");if(i.Assign(l),1===l.length){var c=l[0];a.push(this._loadMeshPrimitiveAsync(t+"/primitives/"+c.index,r,n,c,o))}else{r._primitiveBabylonMeshes=[];for(var u=0,h=l;u<h.length;u++){c=h[u];var d=new e.Mesh((n.name||o.name)+"_"+c.index,this.babylonScene,o);r._primitiveBabylonMeshes.push(d),a.push(this._loadMeshPrimitiveAsync(t+"/primitives/"+c.index,r,n,c,d)),this._parent.onMeshLoadedObservable.notifyObservers(o)}}if(void 0!=r.skin){var f=i.Get(t+"/skin",this.gltf.skins,r.skin);a.push(this._loadSkinAsync("#/skins/"+f.index,r,f))}return this.logClose(),Promise.all(a).then(function(){s._forEachPrimitive(r,function(e){e._refreshBoundingInfo(!0)})})},t.prototype._loadMeshPrimitiveAsync=function(e,r,n,o,s){var a=this,l=new Array;this.logOpen(""+e),this._createMorphTargets(e,r,n,o,s),l.push(this._loadVertexDataAsync(e,o,s).then(function(t){return a._loadMorphTargetsAsync(e,o,s,t).then(function(){t.applyToMesh(s)})}));var c=t._GetDrawMode(e,o.mode);if(void 0==o.material){var u=this._defaultBabylonMaterialData[c];u||(u=this._createDefaultMaterial("__gltf_default",c),this._parent.onMaterialLoadedObservable.notifyObservers(u),this._defaultBabylonMaterialData[c]=u),s.material=u}else{var h=i.Get(e+"/material",this.gltf.materials,o.material);l.push(this._loadMaterialAsync("#/materials/"+h.index,h,s,c,function(e){s.material=e}))}return this.logClose(),Promise.all(l).then(function(){})},t.prototype._loadVertexDataAsync=function(t,r,n){var o=this,s=this._extensionsLoadVertexDataAsync(t,r,n);if(s)return s;var a=r.attributes;if(!a)throw new Error(t+": Attributes are missing");var l=new Array,c=new e.Geometry(n.name,this.babylonScene);if(void 0==r.indices)n.isUnIndexed=!0;else{var u=i.Get(t+"/indices",this.gltf.accessors,r.indices);l.push(this._loadIndicesAccessorAsync("#/accessors/"+u.index,u).then(function(e){c.setIndices(e)}))}var h=function(e,r,s){if(void 0!=a[e]){n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(r)&&n._delayInfo.push(r);var u=i.Get(t+"/attributes/"+e,o.gltf.accessors,a[e]);l.push(o._loadVertexAccessorAsync("#/accessors/"+u.index,u,r).then(function(e){c.setVerticesBuffer(e,u.count)})),s&&s(u)}};return h("POSITION",e.VertexBuffer.PositionKind),h("NORMAL",e.VertexBuffer.NormalKind),h("TANGENT",e.VertexBuffer.TangentKind),h("TEXCOORD_0",e.VertexBuffer.UVKind),h("TEXCOORD_1",e.VertexBuffer.UV2Kind),h("JOINTS_0",e.VertexBuffer.MatricesIndicesKind),h("WEIGHTS_0",e.VertexBuffer.MatricesWeightsKind),h("COLOR_0",e.VertexBuffer.ColorKind,function(e){"VEC4"===e.type&&(n.hasVertexAlpha=!0)}),Promise.all(l).then(function(){return c})},t.prototype._createMorphTargets=function(t,i,r,n,o){if(n.targets){if(void 0==i._numMorphTargets)i._numMorphTargets=n.targets.length;else if(n.targets.length!==i._numMorphTargets)throw new Error(t+": Primitives do not have the same number of targets");o.morphTargetManager=new e.MorphTargetManager;for(var s=0;s<n.targets.length;s++){var a=i.weights?i.weights[s]:r.weights?r.weights[s]:0;o.morphTargetManager.addTarget(new e.MorphTarget("morphTarget"+s,a))}}},t.prototype._loadMorphTargetsAsync=function(e,t,i,r){if(!t.targets)return Promise.resolve();for(var n=new Array,o=i.morphTargetManager,s=0;s<o.numTargets;s++){var a=o.getTarget(s);n.push(this._loadMorphTargetVertexDataAsync(e+"/targets/"+s,r,t.targets[s],a))}return Promise.all(n).then(function(){})},t.prototype._loadMorphTargetVertexDataAsync=function(t,r,n,o){var s=this,a=new Array,l=function(e,o,l){if(void 0!=n[e]){var c=r.getVertexBuffer(o);if(c){var u=i.Get(t+"/"+e,s.gltf.accessors,n[e]);a.push(s._loadFloatAccessorAsync("#/accessors/"+u.index,u).then(function(e){l(c,e)}))}}};return l("POSITION",e.VertexBuffer.PositionKind,function(e,t){e.forEach(t.length,function(e,i){t[i]+=e}),o.setPositions(t)}),l("NORMAL",e.VertexBuffer.NormalKind,function(e,t){e.forEach(t.length,function(e,i){t[i]+=e}),o.setNormals(t)}),l("TANGENT",e.VertexBuffer.TangentKind,function(e,t){var i=0;e.forEach(t.length/3*4,function(e,r){(r+1)%4!=0&&(t[i++]+=e)}),o.setTangents(t)}),Promise.all(a).then(function(){})},t._LoadTransform=function(t,i){var r=e.Vector3.Zero(),n=e.Quaternion.Identity(),o=e.Vector3.One();t.matrix?e.Matrix.FromArray(t.matrix).decompose(o,n,r):(t.translation&&(r=e.Vector3.FromArray(t.translation)),t.rotation&&(n=e.Quaternion.FromArray(t.rotation)),t.scale&&(o=e.Vector3.FromArray(t.scale)));i.position=r,i.rotationQuaternion=n,i.scaling=o},t.prototype._loadSkinAsync=function(t,i,r){var n=this,o=function(t){n._forEachPrimitive(i,function(e){e.skeleton=t}),i._babylonMesh.position=e.Vector3.Zero(),i._babylonMesh.rotationQuaternion=e.Quaternion.Identity(),i._babylonMesh.scaling=e.Vector3.One()};if(r._promise)return r._promise.then(function(){o(r._babylonSkeleton)});var s="skeleton"+r.index,a=new e.Skeleton(r.name||s,s,this.babylonScene);return r._babylonSkeleton=a,this._loadBones(t,r),o(a),r._promise=this._loadSkinInverseBindMatricesDataAsync(t,r).then(function(e){n._updateBoneMatrices(a,e)})},t.prototype._loadBones=function(e,t){for(var r={},n=0,o=t.joints;n<o.length;n++){var s=o[n],a=i.Get(e+"/joints/"+s,this.gltf.nodes,s);this._loadBone(a,t,r)}},t.prototype._loadBone=function(t,i,r){var n=r[t.index];if(n)return n;var o=null;t.parent&&t.parent._babylonMesh!==this._rootBabylonMesh&&(o=this._loadBone(t.parent,i,r));var s=i.joints.indexOf(t.index);return n=new e.Bone(t.name||"joint"+t.index,i._babylonSkeleton,o,this._getNodeMatrix(t),null,null,s),r[t.index]=n,t._babylonBones=t._babylonBones||[],t._babylonBones.push(n),n},t.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(void 0==t.inverseBindMatrices)return Promise.resolve(null);var r=i.Get(e+"/inverseBindMatrices",this.gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("#/accessors/"+r.index,r)},t.prototype._updateBoneMatrices=function(t,i){for(var r=0,n=t.bones;r<n.length;r++){var o=n[r],s=e.Matrix.Identity(),a=o._index;i&&-1!==a&&(e.Matrix.FromArrayToRef(i,16*a,s),s.invertToRef(s));var l=o.getParent();l&&s.multiplyToRef(l.getInvertedAbsoluteTransform(),s),o.updateMatrix(s,!1,!1),o._updateDifferenceMatrix(void 0,!1)}},t.prototype._getNodeMatrix=function(t){return t.matrix?e.Matrix.FromArray(t.matrix):e.Matrix.Compose(t.scale?e.Vector3.FromArray(t.scale):e.Vector3.One(),t.rotation?e.Quaternion.FromArray(t.rotation):e.Quaternion.Identity(),t.translation?e.Vector3.FromArray(t.translation):e.Vector3.Zero())},t.prototype.loadCameraAsync=function(t,i,r){void 0===r&&(r=function(){});var n=this._extensionsLoadCameraAsync(t,i,r);if(n)return n;var o=new Array;this.logOpen(t+" "+(i.name||""));var s=new e.FreeCamera(i.name||"camera"+i.index,e.Vector3.Zero(),this.babylonScene,!1);switch(s.rotation=new e.Vector3(0,Math.PI,0),i.type){case"perspective":var a=i.perspective;if(!a)throw new Error(t+": Camera perspective properties are missing");s.fov=a.yfov,s.minZ=a.znear,s.maxZ=a.zfar||Number.MAX_VALUE;break;case"orthographic":if(!i.orthographic)throw new Error(t+": Camera orthographic properties are missing");s.mode=e.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-i.orthographic.xmag,s.orthoRight=i.orthographic.xmag,s.orthoBottom=-i.orthographic.ymag,s.orthoTop=i.orthographic.ymag,s.minZ=i.orthographic.znear,s.maxZ=i.orthographic.zfar;break;default:throw new Error(t+": Invalid camera type ("+i.type+")")}return r(s),this._parent.onCameraLoadedObservable.notifyObservers(s),Promise.all(o).then(function(){return s})},t.prototype._loadAnimationsAsync=function(){var e=this.gltf.animations;if(!e)return Promise.resolve();for(var t=new Array,i=0;i<e.length;i++){var r=e[i];t.push(this.loadAnimationAsync("#/animations/"+r.index,r))}return Promise.all(t).then(function(){})},t.prototype.loadAnimationAsync=function(t,r){var n=this._extensionsLoadAnimationAsync(t,r);if(n)return n;var o=new e.AnimationGroup(r.name||"animation"+r.index,this.babylonScene);r._babylonAnimationGroup=o;var s=new Array;i.Assign(r.channels),i.Assign(r.samplers);for(var a=0,l=r.channels;a<l.length;a++){var c=l[a];s.push(this._loadAnimationChannelAsync(t+"/channels/"+c.index,t,r,c,o))}return Promise.all(s).then(function(){return o.normalize(0),o})},t.prototype._loadAnimationChannelAsync=function(t,r,n,o,s){var a=this,l=i.Get(t+"/target/node",this.gltf.nodes,o.target.node);if("weights"===o.target.path&&!l._numMorphTargets||"weights"!==o.target.path&&!l._babylonMesh)return Promise.resolve();if(void 0!=l.skin&&"weights"!==o.target.path)return Promise.resolve();var c=i.Get(t+"/sampler",n.samplers,o.sampler);return this._loadAnimationSamplerAsync(r+"/samplers/"+o.sampler,c).then(function(i){var r,n;switch(o.target.path){case"translation":r="position",n=e.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":r="rotationQuaternion",n=e.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":r="scaling",n=e.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":r="influence",n=e.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error(t+"/target/path: Invalid value ("+o.target.path+")")}var c,u,h=0;switch(r){case"position":c=function(){var t=e.Vector3.FromArray(i.output,h);return h+=3,t};break;case"rotationQuaternion":c=function(){var t=e.Quaternion.FromArray(i.output,h);return h+=4,t};break;case"scaling":c=function(){var t=e.Vector3.FromArray(i.output,h);return h+=3,t};break;case"influence":c=function(){for(var e=new Array(l._numMorphTargets),t=0;t<l._numMorphTargets;t++)e[t]=i.output[h++];return e}}switch(i.interpolation){case"STEP":u=function(t){return{frame:i.input[t],value:c(),interpolation:e.AnimationKeyInterpolation.STEP}};break;case"LINEAR":u=function(e){return{frame:i.input[e],value:c()}};break;case"CUBICSPLINE":u=function(e){return{frame:i.input[e],inTangent:c(),value:c(),outTangent:c()}}}for(var d=new Array(i.input.length),f=0;f<i.input.length;f++)d[f]=u(f);if("influence"===r)for(var p=function(t){var i=s.name+"_channel"+s.targetedAnimations.length,o=new e.Animation(i,r,1,n);o.setKeys(d.map(function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[t]:void 0,value:e.value[t],outTangent:e.outTangent?e.outTangent[t]:void 0}})),a._forEachPrimitive(l,function(e){var i=e.morphTargetManager.getTarget(t),r=o.clone();i.animations.push(r),s.addTargetedAnimation(r,i)})},m=0;m<l._numMorphTargets;m++)p(m);else{var g=s.name+"_channel"+s.targetedAnimations.length,_=new e.Animation(g,r,1,n);if(_.setKeys(d),l._babylonBones){for(var v=[l._babylonMesh].concat(l._babylonBones),A=0,y=v;A<y.length;A++){y[A].animations.push(_)}s.addTargetedAnimation(_,v)}else l._babylonMesh.animations.push(_),s.addTargetedAnimation(_,l._babylonMesh)}})},t.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var r=t.interpolation||"LINEAR";switch(r){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(e+"/interpolation: Invalid value ("+t.interpolation+")")}var n=i.Get(e+"/input",this.gltf.accessors,t.input),o=i.Get(e+"/output",this.gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("#/accessors/"+n.index,n),this._loadFloatAccessorAsync("#/accessors/"+o.index,o)]).then(function(e){var t=e[0],i=e[1];return{input:t,interpolation:r,output:i}}),t._data},t.prototype._loadBufferAsync=function(e,t){if(t._data)return t._data;if(!t.uri)throw new Error(e+"/uri: Value is missing");return t._data=this.loadUriAsync(e+"/uri",t.uri),t._data},t.prototype.loadBufferViewAsync=function(e,t){if(t._data)return t._data;var r=i.Get(e+"/buffer",this.gltf.buffers,t.buffer);return t._data=this._loadBufferAsync("#/buffers/"+r.index,r).then(function(i){try{return new Uint8Array(i.buffer,i.byteOffset+(t.byteOffset||0),t.byteLength)}catch(t){throw new Error(e+": "+t.message)}}),t._data},t.prototype._loadIndicesAccessorAsync=function(e,r){if("SCALAR"!==r.type)throw new Error(e+"/type: Invalid value "+r.type);if(5121!==r.componentType&&5123!==r.componentType&&5125!==r.componentType)throw new Error(e+"/componentType: Invalid value "+r.componentType);if(r._data)return r._data;var n=i.Get(e+"/bufferView",this.gltf.bufferViews,r.bufferView);return r._data=this.loadBufferViewAsync("#/bufferViews/"+n.index,n).then(function(i){return t._GetTypedArray(e,r.componentType,i,r.byteOffset,r.count)}),r._data},t.prototype._loadFloatAccessorAsync=function(e,r){var n=this;if(5126!==r.componentType)throw new Error("Invalid component type "+r.componentType);if(r._data)return r._data;var o=t._GetNumComponents(e,r.type),s=o*r.count;if(void 0==r.bufferView)r._data=Promise.resolve(new Float32Array(s));else{var a=i.Get(e+"/bufferView",this.gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync("#/bufferViews/"+a.index,a).then(function(i){return t._GetTypedArray(e,r.componentType,i,r.byteOffset,s)})}if(r.sparse){var l=r.sparse;r._data=r._data.then(function(s){var a=i.Get(e+"/sparse/indices/bufferView",n.gltf.bufferViews,l.indices.bufferView),c=i.Get(e+"/sparse/values/bufferView",n.gltf.bufferViews,l.values.bufferView);return Promise.all([n.loadBufferViewAsync("#/bufferViews/"+a.index,a),n.loadBufferViewAsync("#/bufferViews/"+c.index,c)]).then(function(i){for(var n=i[0],a=i[1],c=t._GetTypedArray(e+"/sparse/indices",l.indices.componentType,n,l.indices.byteOffset,l.count),u=t._GetTypedArray(e+"/sparse/values",r.componentType,a,l.values.byteOffset,o*l.count),h=0,d=0;d<c.length;d++)for(var f=c[d]*o,p=0;p<o;p++)s[f++]=u[h++];return s})})}return r._data},t.prototype._loadVertexBufferViewAsync=function(t,i){var r=this;return t._babylonBuffer?t._babylonBuffer:(t._babylonBuffer=this.loadBufferViewAsync("#/bufferViews/"+t.index,t).then(function(t){return new e.Buffer(r.babylonScene.getEngine(),t,!1)}),t._babylonBuffer)},t.prototype._loadVertexAccessorAsync=function(r,n,o){var s=this;if(n._babylonVertexBuffer)return n._babylonVertexBuffer;if(n.sparse)n._babylonVertexBuffer=this._loadFloatAccessorAsync("#/accessors/"+n.index,n).then(function(t){return new e.VertexBuffer(s.babylonScene.getEngine(),t,o,!1)});else if(n.byteOffset&&n.byteOffset%e.VertexBuffer.GetTypeByteLength(n.componentType)!=0)e.Tools.Warn("Accessor byte offset is not a multiple of component type byte length"),n._babylonVertexBuffer=this._loadFloatAccessorAsync("#/accessors/"+n.index,n).then(function(t){return new e.VertexBuffer(s.babylonScene.getEngine(),t,o,!1)});else{var a=i.Get(r+"/bufferView",this.gltf.bufferViews,n.bufferView);n._babylonVertexBuffer=this._loadVertexBufferViewAsync(a,o).then(function(i){var l=t._GetNumComponents(r,n.type);return new e.VertexBuffer(s.babylonScene.getEngine(),i,o,!1,!1,a.byteStride,!1,n.byteOffset,l,n.componentType,n.normalized,!0)})}return n._babylonVertexBuffer},t.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(t,i,r){if(!(r instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var n=new Array;return i&&(i.baseColorFactor?(r.albedoColor=e.Color3.FromArray(i.baseColorFactor),r.alpha=i.baseColorFactor[3]):r.albedoColor=e.Color3.White(),r.metallic=void 0==i.metallicFactor?1:i.metallicFactor,r.roughness=void 0==i.roughnessFactor?1:i.roughnessFactor,i.baseColorTexture&&n.push(this.loadTextureInfoAsync(t+"/baseColorTexture",i.baseColorTexture,function(e){r.albedoTexture=e})),i.metallicRoughnessTexture&&(n.push(this.loadTextureInfoAsync(t+"/metallicRoughnessTexture",i.metallicRoughnessTexture,function(e){r.metallicTexture=e})),r.useMetallnessFromMetallicTextureBlue=!0,r.useRoughnessFromMetallicTextureGreen=!0,r.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(n).then(function(){})},t.prototype._loadMaterialAsync=function(e,t,i,r,n){void 0===n&&(n=function(){});var o=this._extensionsLoadMaterialAsync(e,t,i,r,n);if(o)return o;t._babylonData=t._babylonData||{};var s=t._babylonData[r];if(!s){this.logOpen(e+" "+(t.name||""));var a=this.createMaterial(e,t,r);s={material:a,meshes:[],promise:this.loadMaterialPropertiesAsync(e,t,a)},t._babylonData[r]=s,this._parent.onMaterialLoadedObservable.notifyObservers(a),this.logClose()}return s.meshes.push(i),i.onDisposeObservable.addOnce(function(){var e=s.meshes.indexOf(i);-1!==e&&s.meshes.splice(e,1)}),n(s.material),s.promise.then(function(){return s.material})},t.prototype._createDefaultMaterial=function(t,i){var r=new e.PBRMaterial(t,this.babylonScene);return r.sideOrientation=this.babylonScene.useRightHandedSystem?e.Material.CounterClockWiseSideOrientation:e.Material.ClockWiseSideOrientation,r.fillMode=i,r.enableSpecularAntiAliasing=!0,r.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,r.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,r.transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,r.metallic=1,r.roughness=1,r},t.prototype.createMaterial=function(e,t,i){var r=this._extensionsCreateMaterial(e,t,i);if(r)return r;var n=t.name||"material"+t.index;return this._createDefaultMaterial(n,i)},t.prototype.loadMaterialPropertiesAsync=function(e,t,i){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,i);if(r)return r;var n=new Array;return n.push(this.loadMaterialBasePropertiesAsync(e,t,i)),t.pbrMetallicRoughness&&n.push(this._loadMaterialMetallicRoughnessPropertiesAsync(e+"/pbrMetallicRoughness",t.pbrMetallicRoughness,i)),this.loadMaterialAlphaProperties(e,t,i),Promise.all(n).then(function(){})},t.prototype.loadMaterialBasePropertiesAsync=function(t,i,r){if(!(r instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var n=new Array;return r.emissiveColor=i.emissiveFactor?e.Color3.FromArray(i.emissiveFactor):new e.Color3(0,0,0),i.doubleSided&&(r.backFaceCulling=!1,r.twoSidedLighting=!0),i.normalTexture&&(n.push(this.loadTextureInfoAsync(t+"/normalTexture",i.normalTexture,function(e){r.bumpTexture=e})),r.invertNormalMapX=!this.babylonScene.useRightHandedSystem,r.invertNormalMapY=this.babylonScene.useRightHandedSystem,void 0!=i.normalTexture.scale&&(r.bumpTexture.level=i.normalTexture.scale)),i.occlusionTexture&&(n.push(this.loadTextureInfoAsync(t+"/occlusionTexture",i.occlusionTexture,function(e){r.ambientTexture=e})),r.useAmbientInGrayScale=!0,void 0!=i.occlusionTexture.strength&&(r.ambientTextureStrength=i.occlusionTexture.strength)),i.emissiveTexture&&n.push(this.loadTextureInfoAsync(t+"/emissiveTexture",i.emissiveTexture,function(e){r.emissiveTexture=e})),Promise.all(n).then(function(){})},t.prototype.loadMaterialAlphaProperties=function(t,i,r){if(!(r instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");switch(i.alphaMode||"OPAQUE"){case"OPAQUE":r.transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":r.transparencyMode=e.PBRMaterial.PBRMATERIAL_ALPHATEST,r.alphaCutOff=void 0==i.alphaCutoff?.5:i.alphaCutoff,r.albedoTexture&&(r.albedoTexture.hasAlpha=!0);break;case"BLEND":r.transparencyMode=e.PBRMaterial.PBRMATERIAL_ALPHABLEND,r.albedoTexture&&(r.albedoTexture.hasAlpha=!0,r.useAlphaFromAlbedoTexture=!0);break;default:throw new Error(t+"/alphaMode: Invalid value ("+i.alphaMode+")")}},t.prototype.loadTextureInfoAsync=function(e,t,r){void 0===r&&(r=function(){});var n=this._extensionsLoadTextureInfoAsync(e,t,r);if(n)return n;this.logOpen(""+e);var o=i.Get(e+"/index",this.gltf.textures,t.index),s=this._loadTextureAsync("#/textures/"+t.index,o,function(e){e.coordinatesIndex=t.texCoord||0,r(e)});return this.logClose(),s},t.prototype._loadTextureAsync=function(r,n,o){var s=this;void 0===o&&(o=function(){});var a=new Array;this.logOpen(r+" "+(n.name||""));var l=void 0==n.sampler?t._DefaultSampler:i.Get(r+"/sampler",this.gltf.samplers,n.sampler),c=this._loadSampler("#/samplers/"+l.index,l),u=new e.Deferred,h=new e.Texture(null,this.babylonScene,c.noMipMaps,!1,c.samplingMode,function(){s._disposed||u.resolve()},function(e,t){s._disposed||u.reject(new Error(r+": "+(t&&t.message?t.message:e||"Failed to load texture")))});a.push(u.promise),h.name=n.name||"texture"+n.index,h.wrapU=c.wrapU,h.wrapV=c.wrapV;var d=i.Get(r+"/source",this.gltf.images,n.source);return a.push(this.loadImageAsync("#/images/"+d.index,d).then(function(e){var t=d.uri||s._fileName+"#image"+d.index,i="data:"+s._uniqueRootUrl+t;h.updateURL(i,new Blob([e],{type:d.mimeType}))})),o(h),this._parent.onTextureLoadedObservable.notifyObservers(h),this.logClose(),Promise.all(a).then(function(){return h})},t.prototype._loadSampler=function(e,i){return i._data||(i._data={noMipMaps:9728===i.minFilter||9729===i.minFilter,samplingMode:t._GetTextureSamplingMode(e,i),wrapU:t._GetTextureWrapMode(e+"/wrapS",i.wrapS),wrapV:t._GetTextureWrapMode(e+"/wrapT",i.wrapT)}),i._data},t.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+" "+(t.name||"")),t.uri)t._data=this.loadUriAsync(e+"/uri",t.uri);else{var r=i.Get(e+"/bufferView",this.gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("#/bufferViews/"+r.index,r)}this.logClose()}return t._data},t.prototype.loadUriAsync=function(i,r){var n=this,o=this._extensionsLoadUriAsync(i,r);if(o)return o;if(!t._ValidateUri(r))throw new Error(i+": '"+r+"' is invalid");if(e.Tools.IsBase64(r)){var s=new Uint8Array(e.Tools.DecodeBase64(r));return this.log("Decoded "+r.substr(0,64)+"... ("+s.length+" bytes)"),Promise.resolve(s)}return this.log("Loading "+r),this._parent.preprocessUrlAsync(this._rootUrl+r).then(function(t){return new Promise(function(o,s){if(!n._disposed){var a=e.Tools.LoadFile(t,function(e){if(!n._disposed){var t=new Uint8Array(e);n.log("Loaded "+r+" ("+t.length+" bytes)"),o(t)}},function(t){if(!n._disposed&&(a&&(a._lengthComputable=t.lengthComputable,a._loaded=t.loaded,a._total=t.total),n._state===e.GLTFLoaderState.LOADING))try{n._onProgress()}catch(e){s(e)}},n.babylonScene.database,!0,function(t,o){n._disposed||s(new e.LoadFileError(i+": Failed to load '"+r+"'"+(t?": "+t.status+" "+t.statusText:""),t))});n._requests.push(a)}})})},t.prototype._onProgress=function(){if(this._progressCallback){for(var t=!0,i=0,r=0,n=0,o=this._requests;n<o.length;n++){var s=o[n];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;t=t&&s._lengthComputable,i+=s._loaded,r+=s._total}this._progressCallback(new e.SceneLoaderProgressEvent(t,i,t?r:0))}},t._GetTextureWrapMode=function(t,i){switch(i=void 0==i?10497:i){case 33071:return e.Texture.CLAMP_ADDRESSMODE;case 33648:return e.Texture.MIRROR_ADDRESSMODE;case 10497:return e.Texture.WRAP_ADDRESSMODE;default:return e.Tools.Warn(t+": Invalid value ("+i+")"),e.Texture.WRAP_ADDRESSMODE}},t._GetTextureSamplingMode=function(t,i){var r=void 0==i.magFilter?9729:i.magFilter,n=void 0==i.minFilter?9987:i.minFilter;if(9729===r)switch(n){case 9728:return e.Texture.LINEAR_NEAREST;case 9729:return e.Texture.LINEAR_LINEAR;case 9984:return e.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return e.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return e.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return e.Texture.LINEAR_LINEAR_MIPLINEAR;default:return e.Tools.Warn(t+"/minFilter: Invalid value ("+n+")"),e.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&e.Tools.Warn(t+"/magFilter: Invalid value ("+r+")"),n){case 9728:return e.Texture.NEAREST_NEAREST;case 9729:return e.Texture.NEAREST_LINEAR;case 9984:return e.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return e.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return e.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return e.Texture.NEAREST_LINEAR_MIPLINEAR;default:return e.Tools.Warn(t+"/minFilter: Invalid value ("+n+")"),e.Texture.NEAREST_NEAREST_MIPNEAREST}},t._GetTypedArray=function(e,t,i,r,n){var o=i.buffer;r=i.byteOffset+(r||0);try{switch(t){case 5120:return new Int8Array(o,r,n);case 5121:return new Uint8Array(o,r,n);case 5122:return new Int16Array(o,r,n);case 5123:return new Uint16Array(o,r,n);case 5125:return new Uint32Array(o,r,n);case 5126:return new Float32Array(o,r,n);default:throw new Error("Invalid component type "+t)}}catch(t){throw new Error(e+": "+t)}},t._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(e+": Invalid type ("+t+")")},t._ValidateUri=function(t){return e.Tools.IsBase64(t)||-1===t.indexOf("..")},t._GetDrawMode=function(t,i){switch(void 0==i&&(i=4),i){case 0:return e.Material.PointListDrawMode;case 1:return e.Material.LineListDrawMode;case 2:return e.Material.LineLoopDrawMode;case 3:return e.Material.LineStripDrawMode;case 4:return e.Material.TriangleFillMode;case 5:return e.Material.TriangleStripDrawMode;case 6:return e.Material.TriangleFanDrawMode}throw new Error(t+": Invalid mesh primitive mode ("+i+")")},t.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this.gltf.materials)for(var i=0,r=this.gltf.materials;i<r.length;i++){var n=r[i];if(n._babylonData)for(var o in n._babylonData)for(var s=n._babylonData[o],a=0,l=s.meshes;a<l.length;a++){var c=l[a];c.computeWorldMatrix(!0);var u=s.material;t.push(u.forceCompilationAsync(c)),this._parent.useClipPlane&&t.push(u.forceCompilationAsync(c,{clipPlane:!0}))}}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile materials")})},t.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,i=0,r=this.babylonScene.lights;i<r.length;i++){var n=r[i].getShadowGenerator();n&&t.push(n.forceCompilationAsync())}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile shadow generators")})},t.prototype._forEachExtensions=function(e){for(var i=0,r=t._ExtensionNames;i<r.length;i++){var n=r[i],o=this._extensions[n];o.enabled&&e(o)}},t.prototype._applyExtensions=function(e,i){for(var r=0,n=t._ExtensionNames;r<n.length;r++){var o=n[r],s=this._extensions[o];if(s.enabled){var a=e;a._activeLoaderExtensions=a._activeLoaderExtensions||{};var l=a._activeLoaderExtensions;if(!l[o]){l[o]=!0;try{var c=i(s);if(c)return c}finally{delete l[o]}}}}return null},t.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(e){return e.onLoading&&e.onLoading()})},t.prototype._extensionsOnReady=function(){this._forEachExtensions(function(e){return e.onReady&&e.onReady()})},t.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,function(i){return i.loadSceneAsync&&i.loadSceneAsync(e,t)})},t.prototype._extensionsLoadNodeAsync=function(e,t,i){return this._applyExtensions(t,function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,i)})},t.prototype._extensionsLoadCameraAsync=function(e,t,i){return this._applyExtensions(t,function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,i)})},t.prototype._extensionsLoadVertexDataAsync=function(e,t,i){return this._applyExtensions(t,function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,i)})},t.prototype._extensionsLoadMaterialAsync=function(e,t,i,r,n){return this._applyExtensions(t,function(o){return o._loadMaterialAsync&&o._loadMaterialAsync(e,t,i,r,n)})},t.prototype._extensionsCreateMaterial=function(e,t,i){return this._applyExtensions({},function(r){return r.createMaterial&&r.createMaterial(e,t,i)})},t.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,i){return this._applyExtensions(t,function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,i)})},t.prototype._extensionsLoadTextureInfoAsync=function(e,t,i){return this._applyExtensions(t,function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,i)})},t.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,function(i){return i.loadAnimationAsync&&i.loadAnimationAsync(e,t)})},t.prototype._extensionsLoadUriAsync=function(e,t){return this._applyExtensions({},function(i){return i._loadUriAsync&&i._loadUriAsync(e,t)})},t.LoadExtensionAsync=function(e,t,i,r){if(!t.extensions)return null;var n=t.extensions[i];return n?r(e+"/extensions/"+i,n):null},t.LoadExtraAsync=function(e,t,i,r){if(!t.extras)return null;var n=t.extras[i];return n?r(e+"/extras/"+i,n):null},t.prototype.logOpen=function(e){this._parent._logOpen(e)},t.prototype.logClose=function(){this._parent._logClose()},t.prototype.log=function(e){this._parent._log(e)},t.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},t.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},t._DefaultSampler={index:-1},t._ExtensionNames=new Array,t._ExtensionFactories={},t}();t.GLTFLoader=r,e.GLTFFileLoader._CreateGLTFLoaderV2=function(e){return new r(e)}}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="MSFT_lod",n=function(){function i(t){this.name=r,this.enabled=!0,this.maxLODsToLoad=Number.MAX_VALUE,this.onNodeLODsLoadedObservable=new e.Observable,this.onMaterialLODsLoadedObservable=new e.Observable,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._loader=t}return i.prototype.dispose=function(){delete this._loader,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},i.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(i._nodePromiseLODs[t]).then(function(){0!==t&&e._loader.endPerformanceCounter("Node LOD "+t),e._loader.log("Loaded node LOD "+t),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD "+(t+1)),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())});i._loader._completePromises.push(r)},i=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var n=function(t){var i=Promise.all(o._materialPromiseLODs[t]).then(function(){0!==t&&e._loader.endPerformanceCounter("Material LOD "+t),e._loader.log("Loaded material LOD "+t),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD "+(t+1)),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())});o._loader._completePromises.push(i)},o=this;for(r=0;r<this._materialPromiseLODs.length;r++)n(r)},i.prototype.loadNodeAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtensionAsync(i,r,this.name,function(t,i){var n,s=o._getLODs(t,r,o._loader.gltf.nodes,i.ids);o._loader.logOpen(""+t);for(var a=function(t){var i=s[t];0!==t&&(o._nodeIndexLOD=t,o._nodeSignalLODs[t]=o._nodeSignalLODs[t]||new e.Deferred);var r=o._loader.loadNodeAsync("#/nodes/"+i.index,i).then(function(e){if(0!==t){var i=s[t-1];i._babylonMesh&&(i._babylonMesh.dispose(),delete i._babylonMesh,o._disposeUnusedMaterials())}return e});0===t?n=r:o._nodeIndexLOD=null,o._nodePromiseLODs[t]=o._nodePromiseLODs[t]||[],o._nodePromiseLODs[t].push(r)},l=0;l<s.length;l++)a(l);return o._loader.logClose(),n})},i.prototype._loadMaterialAsync=function(e,i,r,n,o){var s=this;return this._nodeIndexLOD?null:t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(e,t){var a,l=s._getLODs(e,i,s._loader.gltf.materials,t.ids);s._loader.logOpen(""+e);for(var c=function(e){var t=l[e];0!==e&&(s._materialIndexLOD=e);var i=s._loader._loadMaterialAsync("#/materials/"+t.index,t,r,n,function(t){0===e&&o(t)}).then(function(t){if(0!==e){o(t);var i=l[e-1]._babylonData;i[n]&&(i[n].material.dispose(),delete i[n])}return t});0===e?a=i:s._materialIndexLOD=null,s._materialPromiseLODs[e]=s._materialPromiseLODs[e]||[],s._materialPromiseLODs[e].push(i)},u=0;u<l.length;u++)c(u);return s._loader.logClose(),a})},i.prototype._loadUriAsync=function(t,i){var r=this;if(null!==this._materialIndexLOD){this._loader.log("deferred");var n=this._materialIndexLOD-1;return this._materialSignalLODs[n]=this._materialSignalLODs[n]||new e.Deferred,this._materialSignalLODs[n].promise.then(function(){return r._loader.loadUriAsync(t,i)})}if(null!==this._nodeIndexLOD){this._loader.log("deferred");n=this._nodeIndexLOD-1;return this._nodeSignalLODs[n]=this._nodeSignalLODs[n]||new e.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return r._loader.loadUriAsync(t,i)})}return null},i.prototype._getLODs=function(e,i,r,n){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=new Array,s=n.length-1;s>=0;s--)if(o.push(t.ArrayItem.Get(e+"/ids/"+n[s],r,n[s])),o.length===this.maxLODsToLoad)return o;return o.push(i),o},i.prototype._disposeUnusedMaterials=function(){var e=this._loader.gltf.materials;if(e)for(var t=0,i=e;t<i.length;t++){var r=i[t];if(r._babylonData)for(var n in r._babylonData){var o=r._babylonData[n];0===o.meshes.length&&(o.material.dispose(!1,!0),delete r._babylonData[n])}}},i}();i.MSFT_lod=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="MSFT_minecraftMesh",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader},i.prototype.loadMaterialPropertiesAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtraAsync(i,r,this.name,function(t,s){if(s){if(!(n instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var a=o._loader.loadMaterialPropertiesAsync(i,r,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,a}return null})},i}();i.MSFT_minecraftMesh=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="MSFT_sRGBFactors",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader},i.prototype.loadMaterialPropertiesAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtraAsync(i,r,this.name,function(t,s){if(s){if(!(n instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var a=o._loader.loadMaterialPropertiesAsync(i,r,n);return n.albedoTexture||n.albedoColor.toLinearSpaceToRef(n.albedoColor),n.reflectivityTexture||n.reflectivityColor.toLinearSpaceToRef(n.reflectivityColor),a}return null})},i}();i.MSFT_sRGBFactors=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="MSFT_audio_emitter",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader,delete this._clips,delete this._emitters},i.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var i=e[this.name];this._clips=i.clips,this._emitters=i.emitters,t.ArrayItem.Assign(this._clips),t.ArrayItem.Assign(this._emitters)}},i.prototype.loadSceneAsync=function(e,i){var r=this;return t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(n,o){var s=new Array;s.push(r._loader.loadSceneAsync(e,i));for(var a=0,l=o.emitters;a<l.length;a++){var c=l[a],u=t.ArrayItem.Get(n+"/emitters",r._emitters,c);if(void 0!=u.refDistance||void 0!=u.maxDistance||void 0!=u.rolloffFactor||void 0!=u.distanceModel||void 0!=u.innerAngle||void 0!=u.outerAngle)throw new Error(n+": Direction or Distance properties are not allowed on emitters attached to a scene");s.push(r._loadEmitterAsync(n+"/emitters/"+u.index,u))}return Promise.all(s).then(function(){})})},i.prototype.loadNodeAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtensionAsync(i,r,this.name,function(i,s){var a=new Array;return o._loader.loadNodeAsync(i,r,function(r){for(var l=function(n){var s=t.ArrayItem.Get(i+"/emitters",o._emitters,n);a.push(o._loadEmitterAsync(i+"/emitters/"+s.index,s).then(function(){for(var t=0,i=s._babylonSounds;t<i.length;t++){var n=i[t];n.attachToMesh(r),void 0==s.innerAngle&&void 0==s.outerAngle||(n.setLocalDirectionToMesh(e.Vector3.Forward()),n.setDirectionalCone(2*e.Tools.ToDegrees(void 0==s.innerAngle?Math.PI:s.innerAngle),2*e.Tools.ToDegrees(void 0==s.outerAngle?Math.PI:s.outerAngle),0))}}))},c=0,u=s.emitters;c<u.length;c++){l(u[c])}n(r)}).then(function(e){return Promise.all(a).then(function(){return e})})})},i.prototype.loadAnimationAsync=function(e,i){var r=this;return t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(n,o){return r._loader.loadAnimationAsync(e,i).then(function(s){var a=new Array;t.ArrayItem.Assign(o.events);for(var l=0,c=o.events;l<c.length;l++){var u=c[l];a.push(r._loadAnimationEventAsync(n+"/events/"+u.index,e,i,u,s))}return Promise.all(a).then(function(){return s})})})},i.prototype._loadClipAsync=function(e,i){if(i._objectURL)return i._objectURL;var r;if(i.uri)r=this._loader.loadUriAsync(e,i.uri);else{var n=t.ArrayItem.Get(e+"/bufferView",this._loader.gltf.bufferViews,i.bufferView);r=this._loader.loadBufferViewAsync("#/bufferViews/"+n.index,n)}return i._objectURL=r.then(function(e){return URL.createObjectURL(new Blob([e],{type:i.mimeType}))}),i._objectURL},i.prototype._loadEmitterAsync=function(i,r){var n=this;if(r._babylonSounds=r._babylonSounds||[],!r._babylonData){for(var o=new Array,s=r.name||"emitter"+r.index,a={loop:!1,autoplay:!1,volume:void 0==r.volume?1:r.volume},l=function(i){var l="#/extensions/"+c.name+"/clips",u=t.ArrayItem.Get(l,c._clips,r.clips[i].clip);o.push(c._loadClipAsync(l+"/"+r.clips[i].clip,u).then(function(t){var o=r._babylonSounds[i]=new e.Sound(s,t,n._loader.babylonScene,null,a);o.refDistance=r.refDistance||1,o.maxDistance=r.maxDistance||256,o.rolloffFactor=r.rolloffFactor||1,o.distanceModel=r.distanceModel||"exponential",o._positionInEmitterSpace=!0}))},c=this,u=0;u<r.clips.length;u++)l(u);var h=Promise.all(o).then(function(){var t=r.clips.map(function(e){return e.weight||1}),i=new e.WeightedSound(r.loop||!1,r._babylonSounds,t);r.innerAngle&&(i.directionalConeInnerAngle=2*e.Tools.ToDegrees(r.innerAngle)),r.outerAngle&&(i.directionalConeOuterAngle=2*e.Tools.ToDegrees(r.outerAngle)),r.volume&&(i.volume=r.volume),r._babylonData.sound=i});r._babylonData={loaded:h}}return r._babylonData.loaded},i.prototype._getEventAction=function(e,t,i,r,n){switch(i){case"play":return function(e){var i=(n||0)+(e-r);t.play(i)};case"stop":return function(e){t.stop()};case"pause":return function(e){t.pause()};default:throw new Error(e+": Unsupported action "+i)}},i.prototype._loadAnimationEventAsync=function(i,r,n,o,s){var a=this;if(0==s.targetedAnimations.length)return Promise.resolve();var l=s.targetedAnimations[0],c=o.emitter,u=t.ArrayItem.Get("#/extensions/"+this.name+"/emitters",this._emitters,c);return this._loadEmitterAsync(i,u).then(function(){var t=u._babylonData.sound;if(t){var r=new e.AnimationEvent(o.time,a._getEventAction(i,t,o.action,o.time,o.startOffset));l.animation.addEvent(r),s.onAnimationGroupEndObservable.add(function(){t.stop()}),s.onAnimationGroupPauseObservable.add(function(){t.pause()})}})},i}();i.MSFT_audio_emitter=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="KHR_draco_mesh_compression",n=function(){function i(t){this.name=r,this.enabled=e.DracoCompression.DecoderAvailable,this._loader=t}return i.prototype.dispose=function(){this._dracoCompression&&(this._dracoCompression.dispose(),delete this._dracoCompression),delete this._loader},i.prototype._loadVertexDataAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtensionAsync(i,r,this.name,function(s,a){if(void 0!=r.mode){if(5!==r.mode&&4!==r.mode)throw new Error(i+": Unsupported mode "+r.mode);if(5===r.mode)throw new Error(i+": Mode "+r.mode+" is not currently supported")}var l={},c=function(e,t){var i=a.attributes[e];void 0!=i&&(n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(t)&&n._delayInfo.push(t),l[t]=i)};c("POSITION",e.VertexBuffer.PositionKind),c("NORMAL",e.VertexBuffer.NormalKind),c("TANGENT",e.VertexBuffer.TangentKind),c("TEXCOORD_0",e.VertexBuffer.UVKind),c("TEXCOORD_1",e.VertexBuffer.UV2Kind),c("JOINTS_0",e.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",e.VertexBuffer.MatricesWeightsKind),c("COLOR_0",e.VertexBuffer.ColorKind);var u=t.ArrayItem.Get(s,o._loader.gltf.bufferViews,a.bufferView);return u._dracoBabylonGeometry||(u._dracoBabylonGeometry=o._loader.loadBufferViewAsync("#/bufferViews/"+u.index,u).then(function(t){return o._dracoCompression||(o._dracoCompression=new e.DracoCompression),o._dracoCompression.decodeMeshAsync(t,l).then(function(t){var i=new e.Geometry(n.name,o._loader.babylonScene);return t.applyToGeometry(i),i}).catch(function(e){throw new Error(i+": "+e.message)})})),u._dracoBabylonGeometry})},i}();i.KHR_draco_mesh_compression=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="KHR_materials_pbrSpecularGlossiness",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader},i.prototype.loadMaterialPropertiesAsync=function(e,i,r){var n=this;return t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(t,o){var s=new Array;return s.push(n._loader.loadMaterialBasePropertiesAsync(e,i,r)),s.push(n._loadSpecularGlossinessPropertiesAsync(t,i,o,r)),n._loader.loadMaterialAlphaProperties(e,i,r),Promise.all(s).then(function(){})})},i.prototype._loadSpecularGlossinessPropertiesAsync=function(t,i,r,n){if(!(n instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var o=new Array;return n.metallic=null,n.roughness=null,r.diffuseFactor?(n.albedoColor=e.Color3.FromArray(r.diffuseFactor),n.alpha=r.diffuseFactor[3]):n.albedoColor=e.Color3.White(),n.reflectivityColor=r.specularFactor?e.Color3.FromArray(r.specularFactor):e.Color3.White(),n.microSurface=void 0==r.glossinessFactor?1:r.glossinessFactor,r.diffuseTexture&&o.push(this._loader.loadTextureInfoAsync(t+"/diffuseTexture",r.diffuseTexture,function(e){return n.albedoTexture=e,Promise.resolve()})),r.specularGlossinessTexture&&(o.push(this._loader.loadTextureInfoAsync(t+"/specularGlossinessTexture",r.specularGlossinessTexture,function(e){return n.reflectivityTexture=e,Promise.resolve()})),n.reflectivityTexture.hasAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(o).then(function(){})},i}();i.KHR_materials_pbrSpecularGlossiness=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="KHR_materials_unlit",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader},i.prototype.loadMaterialPropertiesAsync=function(e,i,r){var n=this;return t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(){return n._loadUnlitPropertiesAsync(e,i,r)})},i.prototype._loadUnlitPropertiesAsync=function(t,i,r){if(!(r instanceof e.PBRMaterial))throw new Error(t+": Material type not supported");var n=new Array;r.unlit=!0;var o=i.pbrMetallicRoughness;return o&&(o.baseColorFactor?(r.albedoColor=e.Color3.FromArray(o.baseColorFactor),r.alpha=o.baseColorFactor[3]):r.albedoColor=e.Color3.White(),o.baseColorTexture&&n.push(this._loader.loadTextureInfoAsync(t+"/baseColorTexture",o.baseColorTexture,function(e){return r.albedoTexture=e,Promise.resolve()}))),i.doubleSided&&(r.backFaceCulling=!1,r.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(t,i,r),Promise.all(n).then(function(){})},i}();i.KHR_materials_unlit=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r,n="KHR_lights_punctual";!function(e){e.DIRECTIONAL="directional",e.POINT="point",e.SPOT="spot"}(r||(r={}));var o=function(){function i(e){this.name=n,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader,delete this._lights},i.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},i.prototype.loadNodeAsync=function(i,n,o){var s=this;return t.GLTFLoader.LoadExtensionAsync(i,n,this.name,function(a,l){return s._loader.loadNodeAsync(i,n,function(i){var n,c=t.ArrayItem.Get(a,s._lights,l.light),u=c.name||i.name;switch(c.type){case r.DIRECTIONAL:n=new e.DirectionalLight(u,e.Vector3.Backward(),s._loader.babylonScene);break;case r.POINT:n=new e.PointLight(u,e.Vector3.Zero(),s._loader.babylonScene);break;case r.SPOT:var h=new e.SpotLight(u,e.Vector3.Zero(),e.Vector3.Backward(),0,1,s._loader.babylonScene);h.angle=2*(c.spot&&c.spot.outerConeAngle||Math.PI/4),h.innerAngle=2*(c.spot&&c.spot.innerConeAngle||0),n=h;break;default:throw new Error(a+": Invalid light type ("+c.type+")")}n.falloffType=e.Light.FALLOFF_GLTF,n.diffuse=c.color?e.Color3.FromArray(c.color):e.Color3.White(),n.intensity=void 0==c.intensity?1:c.intensity,n.range=void 0==c.range?Number.MAX_VALUE:c.range,n.parent=i,o(i)})})},i}();i.KHR_lights=o,t.GLTFLoader.RegisterExtension(n,function(e){return new o(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="KHR_texture_transform",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader},i.prototype.loadTextureInfoAsync=function(i,r,n){var o=this;return t.GLTFLoader.LoadExtensionAsync(i,r,this.name,function(t,s){return o._loader.loadTextureInfoAsync(i,r,function(i){if(!(i instanceof e.Texture))throw new Error(t+": Texture type not supported");s.offset&&(i.uOffset=s.offset[0],i.vOffset=s.offset[1]),i.uRotationCenter=0,i.vRotationCenter=0,s.rotation&&(i.wAng=-s.rotation),s.scale&&(i.uScale=s.scale[0],i.vScale=s.scale[1]),void 0!=s.texCoord&&(i.coordinatesIndex=s.texCoord),n(i)})})},i}();i.KHR_texture_transform=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),function(e){!function(t){!function(i){!function(i){var r="EXT_lights_image_based",n=function(){function i(e){this.name=r,this.enabled=!0,this._loader=e}return i.prototype.dispose=function(){delete this._loader,delete this._lights},i.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},i.prototype.loadSceneAsync=function(e,i){var r=this;return t.GLTFLoader.LoadExtensionAsync(e,i,this.name,function(n,o){var s=new Array;s.push(r._loader.loadSceneAsync(e,i)),r._loader.logOpen(""+n);var a=t.ArrayItem.Get(n+"/light",r._lights,o.light);return s.push(r._loadLightAsync("#/extensions/"+r.name+"/lights/"+o.light,a).then(function(e){r._loader.babylonScene.environmentTexture=e})),r._loader.logClose(),Promise.all(s).then(function(){})})},i.prototype._loadLightAsync=function(i,r){var n=this;if(!r._loaded){var o=new Array;this._loader.logOpen(""+i);for(var s=new Array(r.specularImages.length),a=function(e){var n=r.specularImages[e];s[e]=new Array(n.length);for(var a=function(r){var a=i+"/specularImages/"+e+"/"+r;l._loader.logOpen(""+a);var c=n[r],u=t.ArrayItem.Get(a,l._loader.gltf.images,c);o.push(l._loader.loadImageAsync("#/images/"+c,u).then(function(t){s[e][r]=t})),l._loader.logClose()},c=0;c<n.length;c++)a(c)},l=this,c=0;c<r.specularImages.length;c++)a(c);this._loader.logClose(),r._loaded=Promise.all(o).then(function(){var t=new e.RawCubeTexture(n._loader.babylonScene,null,r.specularImageSize);if(r._babylonTexture=t,void 0!=r.intensity&&(t.level=r.intensity),r.rotation){var i=e.Quaternion.FromArray(r.rotation);n._loader.babylonScene.useRightHandedSystem||(i=e.Quaternion.Inverse(i)),e.Matrix.FromQuaternionToRef(i,t.getReflectionTextureMatrix())}var o=e.SphericalHarmonics.FromArray(r.irradianceCoefficients);o.scale(r.intensity),o.convertIrradianceToLambertianRadiance();var a=e.SphericalPolynomial.FromHarmonics(o),l=(s.length-1)/e.Scalar.Log2(r.specularImageSize);return t.updateRGBDAsync(s,a,l)})}return r._loaded.then(function(){return r._babylonTexture})},i}();i.EXT_lights_image_based=n,t.GLTFLoader.RegisterExtension(r,function(e){return new n(e)})}(i.Extensions||(i.Extensions={}))}(t.Loader||(t.Loader={}))}(e.GLTF2||(e.GLTF2={}))}(e||(e={})),e})},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}(i(12))},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(e,t,i){void 0===i&&(i=[]),this.internalFormat=e,this.type=t,this.source=i}return Object.defineProperty(e.prototype,"Width",{get:function(){return this.source&&this.source[0]&&this.source[0][0]?this.source[0][0].width:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Height",{get:function(){return this.source&&this.source[0]&&this.source[0][0]?this.source[0][0].height:0},enumerable:!0,configurable:!0}),e}();t.TextureCube=n;var o=function(){function e(){}return e.GetBabylonCubeTexture=function(t,i,o,s,a){if(void 0===s&&(s=!1),void 0===a&&(a=!1),!i)throw new Error("no texture cube provided");var l;l=s?a?e._EnvironmentSingleMipSampling:e._EnvironmentSampling:{magFilter:9728,minFilter:9728,wrapS:33071,wrapT:33071};var c=e.BabylonTextureKeyPrefix+l.magFilter+""+l.minFilter+l.wrapS+l.wrapT,u=i[c];if(!u){u=new r.CubeTexture("",t),s&&(u.lodGenerationOffset=e.EnvironmentLODOffset,u.lodGenerationScale=e.EnvironmentLODScale),u.gammaSpace=!1;var h=new r.InternalTexture(t.getEngine(),r.InternalTexture.DATASOURCE_CUBERAW),d=h._webGLTexture;h.isCube=!0,h.generateMipMaps=!1,u._texture=h,e.ApplySamplingParameters(u,l);for(var f=o?0:i.source.length-1,p=0,m=function(){return p===6*(f+1)},g=function(l,c,u){if(d){0===l&&0===c&&(h.width=u.width,h.height=u.height);var f=t.getEngine()._gl;if(f.bindTexture(f.TEXTURE_CUBE_MAP,d),t.getEngine()._unpackFlipY(!1),u instanceof HTMLElement||u instanceof ImageData)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+l,c,i.internalFormat,i.internalFormat,i.type,u);else{var g=u;f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+l,c,i.internalFormat,g.width,g.height,0,g.format,i.type,g.data)}if(p++,m()){if(o){var _=u.width,v=u.height;0===(0!==_&&_&_-1)&&0===(0!==v&&v&v-1)&&f.generateMipmap(f.TEXTURE_CUBE_MAP)}if(s&&!t.getEngine().getCaps().textureLOD&&!a)for(var A=0;A<3;A++){var y=e.BabylonTextureKeyPrefix+"lod"+A,b=i[y];if(null==b&&i.Width){var T=1-A/2,E=(T*T+5e-4)*i.Width,x=e.EnvironmentLODScale*r.Scalar.Log2(E)+e.EnvironmentLODOffset,P=i.source.length-1,M=Math.min(Math.max(Math.round(x),0),P);b=e.GetBabylonCubeTexture(t,new n(6408,5121,[i.source[M]]),!1,!0,!0),0===A?h._lodTextureLow=b:1===A?h._lodTextureMid=b:h._lodTextureHigh=b,i[y]=b}}h.isReady=!0}f.bindTexture(f.TEXTURE_CUBE_MAP,null),t.getEngine().resetTextureCache()}},_=function(e){for(var t=i.source[e],r=function(i){var r=t[i];r instanceof HTMLImageElement&&!r.complete?r.addEventListener("load",function(){g(i,e,r)},!1):g(i,e,r)},n=0;n<t.length;n++)r(n)},v=0;v<=f;v++)_(v);t.getEngine().resetTextureCache(),u.isReady=function(){return m()},i[c]=u}return u},e.ApplySamplingParameters=function(e,t){var i=e.getScene();if(i){var n=i.getEngine()._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D,s=e._texture;if(s){var a=s._webGLTexture;switch(n.bindTexture(o,a),null!=t.magFilter&&n.texParameteri(o,n.TEXTURE_MAG_FILTER,t.magFilter),null!=t.minFilter&&n.texParameteri(o,n.TEXTURE_MIN_FILTER,t.minFilter),null!=t.wrapS&&n.texParameteri(o,n.TEXTURE_WRAP_S,t.wrapS),null!=t.wrapT&&n.texParameteri(o,n.TEXTURE_WRAP_T,t.wrapT),t.wrapS){case 10497:e.wrapU=r.Texture.WRAP_ADDRESSMODE;break;case 33071:e.wrapU=r.Texture.CLAMP_ADDRESSMODE;break;case 33648:e.wrapU=r.Texture.MIRROR_ADDRESSMODE;break;default:e.wrapU=r.Texture.CLAMP_ADDRESSMODE}switch(t.wrapT){case 10497:e.wrapV=r.Texture.WRAP_ADDRESSMODE;break;case 33071:e.wrapV=r.Texture.CLAMP_ADDRESSMODE;break;case 33648:e.wrapV=r.Texture.MIRROR_ADDRESSMODE;break;default:e.wrapV=r.Texture.CLAMP_ADDRESSMODE}if(null!=t.maxAnisotropy&&t.maxAnisotropy>1){var l=n.getExtension("EXT_texture_filter_anisotropic");if(l){var c=n.getParameter(l.MAX_TEXTURE_MAX_ANISOTROPY_EXT),u=Math.min(t.maxAnisotropy,c);n.texParameterf(o,l.TEXTURE_MAX_ANISOTROPY_EXT,u),e.anisotropicFilteringLevel=u}}n.bindTexture(o,null),i.getEngine().resetTextureCache()}}},e.BabylonTextureKeyPrefix="__babylonTexture_",e.MaxAnisotropy=4,e._EnvironmentSampling={magFilter:9729,minFilter:9987,wrapS:33071,wrapT:33071,maxAnisotropy:1},e._EnvironmentSingleMipSampling={magFilter:9729,minFilter:9729,wrapS:33071,wrapT:33071,maxAnisotropy:1},e.EnvironmentLODScale=.8,e.EnvironmentLODOffset=1,e}();t.TextureUtils=o},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(62),n={};t.getCustomOptimizerByName=function(e,t){if(!n[e])switch(e){case"extended":return t?r.extendedUpgrade:r.extendedDegrade}return n[e]},t.registerCustomOptimizer=function(e,t){n[e]=t}},function(e,t,i){
- /**!
- @license
- handlebars v4.0.11
- Copyright (C) 2011-2017 by Yehuda Katz
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- */
- !function(t,i){e.exports=i()}(0,function(){return function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,i),n.loaded=!0,n.exports}return i.m=e,i.c=t,i.p="",i(0)}([function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=r(i(2)),o=r(i(35)),s=i(36),a=i(41),l=r(i(42)),c=r(i(39)),u=r(i(34)),h=n.default.create;function d(){var e=h();return e.compile=function(t,i){return a.compile(t,i,e)},e.precompile=function(t,i){return a.precompile(t,i,e)},e.AST=o.default,e.Compiler=a.Compiler,e.JavaScriptCompiler=l.default,e.Parser=s.parser,e.parse=s.parse,e}var f=d();f.create=d,u.default(f),f.Visitor=c.default,f.default=f,t.default=f,e.exports=t.default},function(e,t){"use strict";t.default=function(e){return e&&e.__esModule?e:{default:e}},t.__esModule=!0},function(e,t,i){"use strict";var r=i(3).default,n=i(1).default;t.__esModule=!0;var o=r(i(4)),s=n(i(21)),a=n(i(6)),l=r(i(5)),c=r(i(22)),u=n(i(34));function h(){var e=new o.HandlebarsEnvironment;return l.extend(e,o),e.SafeString=s.default,e.Exception=a.default,e.Utils=l,e.escapeExpression=l.escapeExpression,e.VM=c,e.template=function(t){return c.template(t,e)},e}var d=h();d.create=h,u.default(d),d.default=d,t.default=d,e.exports=t.default},function(e,t){"use strict";t.default=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t},t.__esModule=!0},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0,t.HandlebarsEnvironment=c;var n=i(5),o=r(i(6)),s=i(10),a=i(18),l=r(i(20));t.VERSION="4.0.11";t.COMPILER_REVISION=7;t.REVISION_CHANGES={1:"<= 1.0.rc.2",2:"== 1.0.0-rc.3",3:"== 1.0.0-rc.4",4:"== 1.x.x",5:"== 2.0.0-alpha.x",6:">= 2.0.0-beta.1",7:">= 4.0.0"};function c(e,t,i){this.helpers=e||{},this.partials=t||{},this.decorators=i||{},s.registerDefaultHelpers(this),a.registerDefaultDecorators(this)}c.prototype={constructor:c,logger:l.default,log:l.default.log,registerHelper:function(e,t){if("[object Object]"===n.toString.call(e)){if(t)throw new o.default("Arg not supported with multiple helpers");n.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if("[object Object]"===n.toString.call(e))n.extend(this.partials,e);else{if(void 0===t)throw new o.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if("[object Object]"===n.toString.call(e)){if(t)throw new o.default("Arg not supported with multiple decorators");n.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]}};var u=l.default.log;t.log=u,t.createFrame=n.createFrame,t.logger=l.default},function(e,t){"use strict";t.__esModule=!0,t.extend=s,t.indexOf=function(e,t){for(var i=0,r=e.length;i<r;i++)if(e[i]===t)return i;return-1},t.escapeExpression=function(e){if("string"!=typeof e){if(e&&e.toHTML)return e.toHTML();if(null==e)return"";if(!e)return e+"";e=""+e}if(!n.test(e))return e;return e.replace(r,o)},t.isEmpty=function(e){return!e&&0!==e||!(!c(e)||0!==e.length)},t.createFrame=function(e){var t=s({},e);return t._parent=e,t},t.blockParams=function(e,t){return e.path=t,e},t.appendContextPath=function(e,t){return(e?e+".":"")+t};var i={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},r=/[&<>"'`=]/g,n=/[&<>"'`=]/;function o(e){return i[e]}function s(e){for(var t=1;t<arguments.length;t++)for(var i in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],i)&&(e[i]=arguments[t][i]);return e}var a=Object.prototype.toString;t.toString=a;var l=function(e){return"function"==typeof e};l(/x/)&&(t.isFunction=l=function(e){return"function"==typeof e&&"[object Function]"===a.call(e)}),t.isFunction=l;var c=Array.isArray||function(e){return!(!e||"object"!=typeof e)&&"[object Array]"===a.call(e)};t.isArray=c},function(e,t,i){"use strict";var r=i(7).default;t.__esModule=!0;var n=["description","fileName","lineNumber","message","name","number","stack"];function o(e,t){var i=t&&t.loc,s=void 0,a=void 0;i&&(e+=" - "+(s=i.start.line)+":"+(a=i.start.column));for(var l=Error.prototype.constructor.call(this,e),c=0;c<n.length;c++)this[n[c]]=l[n[c]];Error.captureStackTrace&&Error.captureStackTrace(this,o);try{i&&(this.lineNumber=s,r?Object.defineProperty(this,"column",{value:a,enumerable:!0}):this.column=a)}catch(e){}}o.prototype=new Error,t.default=o,e.exports=t.default},function(e,t,i){e.exports={default:i(8),__esModule:!0}},function(e,t,i){var r=i(9);e.exports=function(e,t,i){return r.setDesc(e,t,i)}},function(e,t){var i=Object;e.exports={create:i.create,getProto:i.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:i.getOwnPropertyDescriptor,setDesc:i.defineProperty,setDescs:i.defineProperties,getKeys:i.keys,getNames:i.getOwnPropertyNames,getSymbols:i.getOwnPropertySymbols,each:[].forEach}},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0,t.registerDefaultHelpers=function(e){n.default(e),o.default(e),s.default(e),a.default(e),l.default(e),c.default(e),u.default(e)};var n=r(i(11)),o=r(i(12)),s=r(i(13)),a=r(i(14)),l=r(i(15)),c=r(i(16)),u=r(i(17))},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5);t.default=function(e){e.registerHelper("blockHelperMissing",function(t,i){var n=i.inverse,o=i.fn;if(!0===t)return o(this);if(!1===t||null==t)return n(this);if(r.isArray(t))return t.length>0?(i.ids&&(i.ids=[i.name]),e.helpers.each(t,i)):n(this);if(i.data&&i.ids){var s=r.createFrame(i.data);s.contextPath=r.appendContextPath(i.data.contextPath,i.name),i={data:s}}return o(t,i)})},e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=i(5),o=r(i(6));t.default=function(e){e.registerHelper("each",function(e,t){if(!t)throw new o.default("Must pass iterator to #each");var i=t.fn,r=t.inverse,s=0,a="",l=void 0,c=void 0;function u(t,r,o){l&&(l.key=t,l.index=r,l.first=0===r,l.last=!!o,c&&(l.contextPath=c+t)),a+=i(e[t],{data:l,blockParams:n.blockParams([e[t],t],[c+t,null])})}if(t.data&&t.ids&&(c=n.appendContextPath(t.data.contextPath,t.ids[0])+"."),n.isFunction(e)&&(e=e.call(this)),t.data&&(l=n.createFrame(t.data)),e&&"object"==typeof e)if(n.isArray(e))for(var h=e.length;s<h;s++)s in e&&u(s,s,s===e.length-1);else{var d=void 0;for(var f in e)e.hasOwnProperty(f)&&(void 0!==d&&u(d,s-1),d=f,s++);void 0!==d&&u(d,s-1,!0)}return 0===s&&(a=r(this)),a})},e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=r(i(6));t.default=function(e){e.registerHelper("helperMissing",function(){if(1!==arguments.length)throw new n.default('Missing helper: "'+arguments[arguments.length-1].name+'"')})},e.exports=t.default},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5);t.default=function(e){e.registerHelper("if",function(e,t){return r.isFunction(e)&&(e=e.call(this)),!t.hash.includeZero&&!e||r.isEmpty(e)?t.inverse(this):t.fn(this)}),e.registerHelper("unless",function(t,i){return e.helpers.if.call(this,t,{fn:i.inverse,inverse:i.fn,hash:i.hash})})},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("log",function(){for(var t=[void 0],i=arguments[arguments.length-1],r=0;r<arguments.length-1;r++)t.push(arguments[r]);var n=1;null!=i.hash.level?n=i.hash.level:i.data&&null!=i.data.level&&(n=i.data.level),t[0]=n,e.log.apply(e,t)})},e.exports=t.default},function(e,t){"use strict";t.__esModule=!0,t.default=function(e){e.registerHelper("lookup",function(e,t){return e&&e[t]})},e.exports=t.default},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5);t.default=function(e){e.registerHelper("with",function(e,t){r.isFunction(e)&&(e=e.call(this));var i=t.fn;if(r.isEmpty(e))return t.inverse(this);var n=t.data;return t.data&&t.ids&&((n=r.createFrame(t.data)).contextPath=r.appendContextPath(t.data.contextPath,t.ids[0])),i(e,{data:n,blockParams:r.blockParams([e],[n&&n.contextPath])})})},e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0,t.registerDefaultDecorators=function(e){n.default(e)};var n=r(i(19))},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5);t.default=function(e){e.registerDecorator("inline",function(e,t,i,n){var o=e;return t.partials||(t.partials={},o=function(n,o){var s=i.partials;i.partials=r.extend({},s,t.partials);var a=e(n,o);return i.partials=s,a}),t.partials[n.args[0]]=n.fn,o})},e.exports=t.default},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5),n={methodMap:["debug","info","warn","error"],level:"info",lookupLevel:function(e){if("string"==typeof e){var t=r.indexOf(n.methodMap,e.toLowerCase());e=t>=0?t:parseInt(e,10)}return e},log:function(e){if(e=n.lookupLevel(e),"undefined"!=typeof console&&n.lookupLevel(n.level)<=e){var t=n.methodMap[e];console[t]||(t="log");for(var i=arguments.length,r=Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];console[t].apply(console,r)}}};t.default=n,e.exports=t.default},function(e,t){"use strict";function i(e){this.string=e}t.__esModule=!0,i.prototype.toString=i.prototype.toHTML=function(){return""+this.string},t.default=i,e.exports=t.default},function(e,t,i){"use strict";var r=i(23).default,n=i(3).default,o=i(1).default;t.__esModule=!0,t.checkRevision=function(e){var t=e&&e[0]||1,i=l.COMPILER_REVISION;if(t!==i){if(t<i){var r=l.REVISION_CHANGES[i],n=l.REVISION_CHANGES[t];throw new a.default("Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version ("+r+") or downgrade your runtime to an older version ("+n+").")}throw new a.default("Template was precompiled with a newer version of Handlebars than the current runtime. Please update your runtime to a newer version ("+e[1]+").")}},t.template=function(e,t){if(!t)throw new a.default("No environment passed to template");if(!e||!e.main)throw new a.default("Unknown template object: "+typeof e);e.main.decorator=e.main_d,t.VM.checkRevision(e.compiler);var i={strict:function(e,t){if(!(t in e))throw new a.default('"'+t+'" not defined in '+e);return e[t]},lookup:function(e,t){for(var i=e.length,r=0;r<i;r++)if(e[r]&&null!=e[r][t])return e[r][t]},lambda:function(e,t){return"function"==typeof e?e.call(t):e},escapeExpression:s.escapeExpression,invokePartial:function(i,r,n){n.hash&&(r=s.extend({},r,n.hash),n.ids&&(n.ids[0]=!0));i=t.VM.resolvePartial.call(this,i,r,n);var o=t.VM.invokePartial.call(this,i,r,n);null==o&&t.compile&&(n.partials[n.name]=t.compile(i,e.compilerOptions,t),o=n.partials[n.name](r,n));if(null!=o){if(n.indent){for(var l=o.split("\n"),c=0,u=l.length;c<u&&(l[c]||c+1!==u);c++)l[c]=n.indent+l[c];o=l.join("\n")}return o}throw new a.default("The partial "+n.name+" could not be compiled when running in runtime-only mode")},fn:function(t){var i=e[t];return i.decorator=e[t+"_d"],i},programs:[],program:function(e,t,i,r,n){var o=this.programs[e],s=this.fn(e);return t||n||r||i?o=c(this,e,s,t,i,r,n):o||(o=this.programs[e]=c(this,e,s)),o},data:function(e,t){for(;e&&t--;)e=e._parent;return e},merge:function(e,t){var i=e||t;return e&&t&&e!==t&&(i=s.extend({},t,e)),i},nullContext:r({}),noop:t.VM.noop,compilerInfo:e.compiler};function n(t){var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],o=r.data;n._setup(r),!r.partial&&e.useData&&(o=function(e,t){t&&"root"in t||((t=t?l.createFrame(t):{}).root=e);return t}(t,o));var s=void 0,a=e.useBlockParams?[]:void 0;function c(t){return""+e.main(i,t,i.helpers,i.partials,o,a,s)}return e.useDepths&&(s=r.depths?t!=r.depths[0]?[t].concat(r.depths):r.depths:[t]),(c=h(e.main,c,i,r.depths||[],o,a))(t,r)}return n.isTop=!0,n._setup=function(r){r.partial?(i.helpers=r.helpers,i.partials=r.partials,i.decorators=r.decorators):(i.helpers=i.merge(r.helpers,t.helpers),e.usePartial&&(i.partials=i.merge(r.partials,t.partials)),(e.usePartial||e.useDecorators)&&(i.decorators=i.merge(r.decorators,t.decorators)))},n._child=function(t,r,n,o){if(e.useBlockParams&&!n)throw new a.default("must pass block params");if(e.useDepths&&!o)throw new a.default("must pass parent depths");return c(i,t,e[t],r,0,n,o)},n},t.wrapProgram=c,t.resolvePartial=function(e,t,i){e?e.call||i.name||(i.name=e,e=i.partials[e]):e="@partial-block"===i.name?i.data["partial-block"]:i.partials[i.name];return e},t.invokePartial=function(e,t,i){var r=i.data&&i.data["partial-block"];i.partial=!0,i.ids&&(i.data.contextPath=i.ids[0]||i.data.contextPath);var n=void 0;i.fn&&i.fn!==u&&function(){i.data=l.createFrame(i.data);var e=i.fn;n=i.data["partial-block"]=function(t){var i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return i.data=l.createFrame(i.data),i.data["partial-block"]=r,e(t,i)},e.partials&&(i.partials=s.extend({},i.partials,e.partials))}();void 0===e&&n&&(e=n);if(void 0===e)throw new a.default("The partial "+i.name+" could not be found");if(e instanceof Function)return e(t,i)},t.noop=u;var s=n(i(5)),a=o(i(6)),l=i(4);function c(e,t,i,r,n,o,s){function a(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],a=s;return!s||t==s[0]||t===e.nullContext&&null===s[0]||(a=[t].concat(s)),i(e,t,e.helpers,e.partials,n.data||r,o&&[n.blockParams].concat(o),a)}return(a=h(i,a,e,s,r,o)).program=t,a.depth=s?s.length:0,a.blockParams=n||0,a}function u(){return""}function h(e,t,i,r,n,o){if(e.decorator){var a={};t=e.decorator(t,a,i,r&&r[0],n,o,r),s.extend(t,a)}return t}},function(e,t,i){e.exports={default:i(24),__esModule:!0}},function(e,t,i){i(25),e.exports=i(30).Object.seal},function(e,t,i){var r=i(26);i(27)("seal",function(e){return function(t){return e&&r(t)?e(t):t}})},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,i){var r=i(28),n=i(30),o=i(33);e.exports=function(e,t){var i=(n.Object||{})[e]||Object[e],s={};s[e]=t(i),r(r.S+r.F*o(function(){i(1)}),"Object",s)}},function(e,t,i){var r=i(29),n=i(30),o=i(31),s=function(e,t,i){var a,l,c,u=e&s.F,h=e&s.G,d=e&s.S,f=e&s.P,p=e&s.B,m=e&s.W,g=h?n:n[t]||(n[t]={}),_=h?r:d?r[t]:(r[t]||{}).prototype;for(a in h&&(i=t),i)(l=!u&&_&&a in _)&&a in g||(c=l?_[a]:i[a],g[a]=h&&"function"!=typeof _[a]?i[a]:p&&l?o(c,r):m&&_[a]==c?function(e){var t=function(t){return this instanceof e?new e(t):e(t)};return t.prototype=e.prototype,t}(c):f&&"function"==typeof c?o(Function.call,c):c,f&&((g.prototype||(g.prototype={}))[a]=c))};s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,e.exports=s},function(e,t){var i=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=i)},function(e,t){var i=e.exports={version:"1.2.6"};"number"==typeof __e&&(__e=i)},function(e,t,i){var r=i(32);e.exports=function(e,t,i){if(r(e),void 0===t)return e;switch(i){case 1:return function(i){return e.call(t,i)};case 2:return function(i,r){return e.call(t,i,r)};case 3:return function(i,r,n){return e.call(t,i,r,n)}}return function(){return e.apply(t,arguments)}}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t){(function(i){"use strict";t.__esModule=!0,t.default=function(e){var t=void 0!==i?i:window,r=t.Handlebars;e.noConflict=function(){return t.Handlebars===e&&(t.Handlebars=r),e}},e.exports=t.default}).call(t,function(){return this}())},function(e,t){"use strict";t.__esModule=!0;var i={helpers:{helperExpression:function(e){return"SubExpression"===e.type||("MustacheStatement"===e.type||"BlockStatement"===e.type)&&!!(e.params&&e.params.length||e.hash)},scopedId:function(e){return/^\.|this\b/.test(e.original)},simpleId:function(e){return 1===e.parts.length&&!i.helpers.scopedId(e)&&!e.depth}}};t.default=i,e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default,n=i(3).default;t.__esModule=!0,t.parse=function(e,t){if("Program"===e.type)return e;return o.default.yy=c,c.locInfo=function(e){return new c.SourceLocation(t&&t.srcName,e)},new s.default(t).accept(o.default.parse(e))};var o=r(i(37)),s=r(i(38)),a=n(i(40)),l=i(5);t.parser=o.default;var c={};l.extend(c,a)},function(e,t){"use strict";t.__esModule=!0;var i=function(){var e={trace:function(){},yy:{},symbols_:{error:2,root:3,program:4,EOF:5,program_repetition0:6,statement:7,mustache:8,block:9,rawBlock:10,partial:11,partialBlock:12,content:13,COMMENT:14,CONTENT:15,openRawBlock:16,rawBlock_repetition_plus0:17,END_RAW_BLOCK:18,OPEN_RAW_BLOCK:19,helperName:20,openRawBlock_repetition0:21,openRawBlock_option0:22,CLOSE_RAW_BLOCK:23,openBlock:24,block_option0:25,closeBlock:26,openInverse:27,block_option1:28,OPEN_BLOCK:29,openBlock_repetition0:30,openBlock_option0:31,openBlock_option1:32,CLOSE:33,OPEN_INVERSE:34,openInverse_repetition0:35,openInverse_option0:36,openInverse_option1:37,openInverseChain:38,OPEN_INVERSE_CHAIN:39,openInverseChain_repetition0:40,openInverseChain_option0:41,openInverseChain_option1:42,inverseAndProgram:43,INVERSE:44,inverseChain:45,inverseChain_option0:46,OPEN_ENDBLOCK:47,OPEN:48,mustache_repetition0:49,mustache_option0:50,OPEN_UNESCAPED:51,mustache_repetition1:52,mustache_option1:53,CLOSE_UNESCAPED:54,OPEN_PARTIAL:55,partialName:56,partial_repetition0:57,partial_option0:58,openPartialBlock:59,OPEN_PARTIAL_BLOCK:60,openPartialBlock_repetition0:61,openPartialBlock_option0:62,param:63,sexpr:64,OPEN_SEXPR:65,sexpr_repetition0:66,sexpr_option0:67,CLOSE_SEXPR:68,hash:69,hash_repetition_plus0:70,hashSegment:71,ID:72,EQUALS:73,blockParams:74,OPEN_BLOCK_PARAMS:75,blockParams_repetition_plus0:76,CLOSE_BLOCK_PARAMS:77,path:78,dataName:79,STRING:80,NUMBER:81,BOOLEAN:82,UNDEFINED:83,NULL:84,DATA:85,pathSegments:86,SEP:87,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",14:"COMMENT",15:"CONTENT",18:"END_RAW_BLOCK",19:"OPEN_RAW_BLOCK",23:"CLOSE_RAW_BLOCK",29:"OPEN_BLOCK",33:"CLOSE",34:"OPEN_INVERSE",39:"OPEN_INVERSE_CHAIN",44:"INVERSE",47:"OPEN_ENDBLOCK",48:"OPEN",51:"OPEN_UNESCAPED",54:"CLOSE_UNESCAPED",55:"OPEN_PARTIAL",60:"OPEN_PARTIAL_BLOCK",65:"OPEN_SEXPR",68:"CLOSE_SEXPR",72:"ID",73:"EQUALS",75:"OPEN_BLOCK_PARAMS",77:"CLOSE_BLOCK_PARAMS",80:"STRING",81:"NUMBER",82:"BOOLEAN",83:"UNDEFINED",84:"NULL",85:"DATA",87:"SEP"},productions_:[0,[3,2],[4,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[13,1],[10,3],[16,5],[9,4],[9,4],[24,6],[27,6],[38,6],[43,2],[45,3],[45,1],[26,3],[8,5],[8,5],[11,5],[12,3],[59,5],[63,1],[63,1],[64,5],[69,1],[71,3],[74,3],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[20,1],[56,1],[56,1],[79,2],[78,1],[86,3],[86,1],[6,0],[6,2],[17,1],[17,2],[21,0],[21,2],[22,0],[22,1],[25,0],[25,1],[28,0],[28,1],[30,0],[30,2],[31,0],[31,1],[32,0],[32,1],[35,0],[35,2],[36,0],[36,1],[37,0],[37,1],[40,0],[40,2],[41,0],[41,1],[42,0],[42,1],[46,0],[46,1],[49,0],[49,2],[50,0],[50,1],[52,0],[52,2],[53,0],[53,1],[57,0],[57,2],[58,0],[58,1],[61,0],[61,2],[62,0],[62,1],[66,0],[66,2],[67,0],[67,1],[70,1],[70,2],[76,1],[76,2]],performAction:function(e,t,i,r,n,o,s){var a=o.length-1;switch(n){case 1:return o[a-1];case 2:this.$=r.prepareProgram(o[a]);break;case 3:case 4:case 5:case 6:case 7:case 8:this.$=o[a];break;case 9:this.$={type:"CommentStatement",value:r.stripComment(o[a]),strip:r.stripFlags(o[a],o[a]),loc:r.locInfo(this._$)};break;case 10:this.$={type:"ContentStatement",original:o[a],value:o[a],loc:r.locInfo(this._$)};break;case 11:this.$=r.prepareRawBlock(o[a-2],o[a-1],o[a],this._$);break;case 12:this.$={path:o[a-3],params:o[a-2],hash:o[a-1]};break;case 13:this.$=r.prepareBlock(o[a-3],o[a-2],o[a-1],o[a],!1,this._$);break;case 14:this.$=r.prepareBlock(o[a-3],o[a-2],o[a-1],o[a],!0,this._$);break;case 15:this.$={open:o[a-5],path:o[a-4],params:o[a-3],hash:o[a-2],blockParams:o[a-1],strip:r.stripFlags(o[a-5],o[a])};break;case 16:case 17:this.$={path:o[a-4],params:o[a-3],hash:o[a-2],blockParams:o[a-1],strip:r.stripFlags(o[a-5],o[a])};break;case 18:this.$={strip:r.stripFlags(o[a-1],o[a-1]),program:o[a]};break;case 19:var l=r.prepareBlock(o[a-2],o[a-1],o[a],o[a],!1,this._$),c=r.prepareProgram([l],o[a-1].loc);c.chained=!0,this.$={strip:o[a-2].strip,program:c,chain:!0};break;case 20:this.$=o[a];break;case 21:this.$={path:o[a-1],strip:r.stripFlags(o[a-2],o[a])};break;case 22:case 23:this.$=r.prepareMustache(o[a-3],o[a-2],o[a-1],o[a-4],r.stripFlags(o[a-4],o[a]),this._$);break;case 24:this.$={type:"PartialStatement",name:o[a-3],params:o[a-2],hash:o[a-1],indent:"",strip:r.stripFlags(o[a-4],o[a]),loc:r.locInfo(this._$)};break;case 25:this.$=r.preparePartialBlock(o[a-2],o[a-1],o[a],this._$);break;case 26:this.$={path:o[a-3],params:o[a-2],hash:o[a-1],strip:r.stripFlags(o[a-4],o[a])};break;case 27:case 28:this.$=o[a];break;case 29:this.$={type:"SubExpression",path:o[a-3],params:o[a-2],hash:o[a-1],loc:r.locInfo(this._$)};break;case 30:this.$={type:"Hash",pairs:o[a],loc:r.locInfo(this._$)};break;case 31:this.$={type:"HashPair",key:r.id(o[a-2]),value:o[a],loc:r.locInfo(this._$)};break;case 32:this.$=r.id(o[a-1]);break;case 33:case 34:this.$=o[a];break;case 35:this.$={type:"StringLiteral",value:o[a],original:o[a],loc:r.locInfo(this._$)};break;case 36:this.$={type:"NumberLiteral",value:Number(o[a]),original:Number(o[a]),loc:r.locInfo(this._$)};break;case 37:this.$={type:"BooleanLiteral",value:"true"===o[a],original:"true"===o[a],loc:r.locInfo(this._$)};break;case 38:this.$={type:"UndefinedLiteral",original:void 0,value:void 0,loc:r.locInfo(this._$)};break;case 39:this.$={type:"NullLiteral",original:null,value:null,loc:r.locInfo(this._$)};break;case 40:case 41:this.$=o[a];break;case 42:this.$=r.preparePath(!0,o[a],this._$);break;case 43:this.$=r.preparePath(!1,o[a],this._$);break;case 44:o[a-2].push({part:r.id(o[a]),original:o[a],separator:o[a-1]}),this.$=o[a-2];break;case 45:this.$=[{part:r.id(o[a]),original:o[a]}];break;case 46:this.$=[];break;case 47:o[a-1].push(o[a]);break;case 48:this.$=[o[a]];break;case 49:o[a-1].push(o[a]);break;case 50:this.$=[];break;case 51:o[a-1].push(o[a]);break;case 58:this.$=[];break;case 59:o[a-1].push(o[a]);break;case 64:this.$=[];break;case 65:o[a-1].push(o[a]);break;case 70:this.$=[];break;case 71:o[a-1].push(o[a]);break;case 78:this.$=[];break;case 79:o[a-1].push(o[a]);break;case 82:this.$=[];break;case 83:o[a-1].push(o[a]);break;case 86:this.$=[];break;case 87:o[a-1].push(o[a]);break;case 90:this.$=[];break;case 91:o[a-1].push(o[a]);break;case 94:this.$=[];break;case 95:o[a-1].push(o[a]);break;case 98:this.$=[o[a]];break;case 99:o[a-1].push(o[a]);break;case 100:this.$=[o[a]];break;case 101:o[a-1].push(o[a])}},table:[{3:1,4:2,5:[2,46],6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{1:[3]},{5:[1,4]},{5:[2,2],7:5,8:6,9:7,10:8,11:9,12:10,13:11,14:[1,12],15:[1,20],16:17,19:[1,23],24:15,27:16,29:[1,21],34:[1,22],39:[2,2],44:[2,2],47:[2,2],48:[1,13],51:[1,14],55:[1,18],59:19,60:[1,24]},{1:[2,1]},{5:[2,47],14:[2,47],15:[2,47],19:[2,47],29:[2,47],34:[2,47],39:[2,47],44:[2,47],47:[2,47],48:[2,47],51:[2,47],55:[2,47],60:[2,47]},{5:[2,3],14:[2,3],15:[2,3],19:[2,3],29:[2,3],34:[2,3],39:[2,3],44:[2,3],47:[2,3],48:[2,3],51:[2,3],55:[2,3],60:[2,3]},{5:[2,4],14:[2,4],15:[2,4],19:[2,4],29:[2,4],34:[2,4],39:[2,4],44:[2,4],47:[2,4],48:[2,4],51:[2,4],55:[2,4],60:[2,4]},{5:[2,5],14:[2,5],15:[2,5],19:[2,5],29:[2,5],34:[2,5],39:[2,5],44:[2,5],47:[2,5],48:[2,5],51:[2,5],55:[2,5],60:[2,5]},{5:[2,6],14:[2,6],15:[2,6],19:[2,6],29:[2,6],34:[2,6],39:[2,6],44:[2,6],47:[2,6],48:[2,6],51:[2,6],55:[2,6],60:[2,6]},{5:[2,7],14:[2,7],15:[2,7],19:[2,7],29:[2,7],34:[2,7],39:[2,7],44:[2,7],47:[2,7],48:[2,7],51:[2,7],55:[2,7],60:[2,7]},{5:[2,8],14:[2,8],15:[2,8],19:[2,8],29:[2,8],34:[2,8],39:[2,8],44:[2,8],47:[2,8],48:[2,8],51:[2,8],55:[2,8],60:[2,8]},{5:[2,9],14:[2,9],15:[2,9],19:[2,9],29:[2,9],34:[2,9],39:[2,9],44:[2,9],47:[2,9],48:[2,9],51:[2,9],55:[2,9],60:[2,9]},{20:25,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:36,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:37,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{4:38,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{13:40,15:[1,20],17:39},{20:42,56:41,64:43,65:[1,44],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:45,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{5:[2,10],14:[2,10],15:[2,10],18:[2,10],19:[2,10],29:[2,10],34:[2,10],39:[2,10],44:[2,10],47:[2,10],48:[2,10],51:[2,10],55:[2,10],60:[2,10]},{20:46,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:47,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:48,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:42,56:49,64:43,65:[1,44],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[2,78],49:50,65:[2,78],72:[2,78],80:[2,78],81:[2,78],82:[2,78],83:[2,78],84:[2,78],85:[2,78]},{23:[2,33],33:[2,33],54:[2,33],65:[2,33],68:[2,33],72:[2,33],75:[2,33],80:[2,33],81:[2,33],82:[2,33],83:[2,33],84:[2,33],85:[2,33]},{23:[2,34],33:[2,34],54:[2,34],65:[2,34],68:[2,34],72:[2,34],75:[2,34],80:[2,34],81:[2,34],82:[2,34],83:[2,34],84:[2,34],85:[2,34]},{23:[2,35],33:[2,35],54:[2,35],65:[2,35],68:[2,35],72:[2,35],75:[2,35],80:[2,35],81:[2,35],82:[2,35],83:[2,35],84:[2,35],85:[2,35]},{23:[2,36],33:[2,36],54:[2,36],65:[2,36],68:[2,36],72:[2,36],75:[2,36],80:[2,36],81:[2,36],82:[2,36],83:[2,36],84:[2,36],85:[2,36]},{23:[2,37],33:[2,37],54:[2,37],65:[2,37],68:[2,37],72:[2,37],75:[2,37],80:[2,37],81:[2,37],82:[2,37],83:[2,37],84:[2,37],85:[2,37]},{23:[2,38],33:[2,38],54:[2,38],65:[2,38],68:[2,38],72:[2,38],75:[2,38],80:[2,38],81:[2,38],82:[2,38],83:[2,38],84:[2,38],85:[2,38]},{23:[2,39],33:[2,39],54:[2,39],65:[2,39],68:[2,39],72:[2,39],75:[2,39],80:[2,39],81:[2,39],82:[2,39],83:[2,39],84:[2,39],85:[2,39]},{23:[2,43],33:[2,43],54:[2,43],65:[2,43],68:[2,43],72:[2,43],75:[2,43],80:[2,43],81:[2,43],82:[2,43],83:[2,43],84:[2,43],85:[2,43],87:[1,51]},{72:[1,35],86:52},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{52:53,54:[2,82],65:[2,82],72:[2,82],80:[2,82],81:[2,82],82:[2,82],83:[2,82],84:[2,82],85:[2,82]},{25:54,38:56,39:[1,58],43:57,44:[1,59],45:55,47:[2,54]},{28:60,43:61,44:[1,59],47:[2,56]},{13:63,15:[1,20],18:[1,62]},{15:[2,48],18:[2,48]},{33:[2,86],57:64,65:[2,86],72:[2,86],80:[2,86],81:[2,86],82:[2,86],83:[2,86],84:[2,86],85:[2,86]},{33:[2,40],65:[2,40],72:[2,40],80:[2,40],81:[2,40],82:[2,40],83:[2,40],84:[2,40],85:[2,40]},{33:[2,41],65:[2,41],72:[2,41],80:[2,41],81:[2,41],82:[2,41],83:[2,41],84:[2,41],85:[2,41]},{20:65,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:66,47:[1,67]},{30:68,33:[2,58],65:[2,58],72:[2,58],75:[2,58],80:[2,58],81:[2,58],82:[2,58],83:[2,58],84:[2,58],85:[2,58]},{33:[2,64],35:69,65:[2,64],72:[2,64],75:[2,64],80:[2,64],81:[2,64],82:[2,64],83:[2,64],84:[2,64],85:[2,64]},{21:70,23:[2,50],65:[2,50],72:[2,50],80:[2,50],81:[2,50],82:[2,50],83:[2,50],84:[2,50],85:[2,50]},{33:[2,90],61:71,65:[2,90],72:[2,90],80:[2,90],81:[2,90],82:[2,90],83:[2,90],84:[2,90],85:[2,90]},{20:75,33:[2,80],50:72,63:73,64:76,65:[1,44],69:74,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{72:[1,80]},{23:[2,42],33:[2,42],54:[2,42],65:[2,42],68:[2,42],72:[2,42],75:[2,42],80:[2,42],81:[2,42],82:[2,42],83:[2,42],84:[2,42],85:[2,42],87:[1,51]},{20:75,53:81,54:[2,84],63:82,64:76,65:[1,44],69:83,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{26:84,47:[1,67]},{47:[2,55]},{4:85,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],39:[2,46],44:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{47:[2,20]},{20:86,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{4:87,6:3,14:[2,46],15:[2,46],19:[2,46],29:[2,46],34:[2,46],47:[2,46],48:[2,46],51:[2,46],55:[2,46],60:[2,46]},{26:88,47:[1,67]},{47:[2,57]},{5:[2,11],14:[2,11],15:[2,11],19:[2,11],29:[2,11],34:[2,11],39:[2,11],44:[2,11],47:[2,11],48:[2,11],51:[2,11],55:[2,11],60:[2,11]},{15:[2,49],18:[2,49]},{20:75,33:[2,88],58:89,63:90,64:76,65:[1,44],69:91,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{65:[2,94],66:92,68:[2,94],72:[2,94],80:[2,94],81:[2,94],82:[2,94],83:[2,94],84:[2,94],85:[2,94]},{5:[2,25],14:[2,25],15:[2,25],19:[2,25],29:[2,25],34:[2,25],39:[2,25],44:[2,25],47:[2,25],48:[2,25],51:[2,25],55:[2,25],60:[2,25]},{20:93,72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:75,31:94,33:[2,60],63:95,64:76,65:[1,44],69:96,70:77,71:78,72:[1,79],75:[2,60],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:75,33:[2,66],36:97,63:98,64:76,65:[1,44],69:99,70:77,71:78,72:[1,79],75:[2,66],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:75,22:100,23:[2,52],63:101,64:76,65:[1,44],69:102,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{20:75,33:[2,92],62:103,63:104,64:76,65:[1,44],69:105,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,106]},{33:[2,79],65:[2,79],72:[2,79],80:[2,79],81:[2,79],82:[2,79],83:[2,79],84:[2,79],85:[2,79]},{33:[2,81]},{23:[2,27],33:[2,27],54:[2,27],65:[2,27],68:[2,27],72:[2,27],75:[2,27],80:[2,27],81:[2,27],82:[2,27],83:[2,27],84:[2,27],85:[2,27]},{23:[2,28],33:[2,28],54:[2,28],65:[2,28],68:[2,28],72:[2,28],75:[2,28],80:[2,28],81:[2,28],82:[2,28],83:[2,28],84:[2,28],85:[2,28]},{23:[2,30],33:[2,30],54:[2,30],68:[2,30],71:107,72:[1,108],75:[2,30]},{23:[2,98],33:[2,98],54:[2,98],68:[2,98],72:[2,98],75:[2,98]},{23:[2,45],33:[2,45],54:[2,45],65:[2,45],68:[2,45],72:[2,45],73:[1,109],75:[2,45],80:[2,45],81:[2,45],82:[2,45],83:[2,45],84:[2,45],85:[2,45],87:[2,45]},{23:[2,44],33:[2,44],54:[2,44],65:[2,44],68:[2,44],72:[2,44],75:[2,44],80:[2,44],81:[2,44],82:[2,44],83:[2,44],84:[2,44],85:[2,44],87:[2,44]},{54:[1,110]},{54:[2,83],65:[2,83],72:[2,83],80:[2,83],81:[2,83],82:[2,83],83:[2,83],84:[2,83],85:[2,83]},{54:[2,85]},{5:[2,13],14:[2,13],15:[2,13],19:[2,13],29:[2,13],34:[2,13],39:[2,13],44:[2,13],47:[2,13],48:[2,13],51:[2,13],55:[2,13],60:[2,13]},{38:56,39:[1,58],43:57,44:[1,59],45:112,46:111,47:[2,76]},{33:[2,70],40:113,65:[2,70],72:[2,70],75:[2,70],80:[2,70],81:[2,70],82:[2,70],83:[2,70],84:[2,70],85:[2,70]},{47:[2,18]},{5:[2,14],14:[2,14],15:[2,14],19:[2,14],29:[2,14],34:[2,14],39:[2,14],44:[2,14],47:[2,14],48:[2,14],51:[2,14],55:[2,14],60:[2,14]},{33:[1,114]},{33:[2,87],65:[2,87],72:[2,87],80:[2,87],81:[2,87],82:[2,87],83:[2,87],84:[2,87],85:[2,87]},{33:[2,89]},{20:75,63:116,64:76,65:[1,44],67:115,68:[2,96],69:117,70:77,71:78,72:[1,79],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{33:[1,118]},{32:119,33:[2,62],74:120,75:[1,121]},{33:[2,59],65:[2,59],72:[2,59],75:[2,59],80:[2,59],81:[2,59],82:[2,59],83:[2,59],84:[2,59],85:[2,59]},{33:[2,61],75:[2,61]},{33:[2,68],37:122,74:123,75:[1,121]},{33:[2,65],65:[2,65],72:[2,65],75:[2,65],80:[2,65],81:[2,65],82:[2,65],83:[2,65],84:[2,65],85:[2,65]},{33:[2,67],75:[2,67]},{23:[1,124]},{23:[2,51],65:[2,51],72:[2,51],80:[2,51],81:[2,51],82:[2,51],83:[2,51],84:[2,51],85:[2,51]},{23:[2,53]},{33:[1,125]},{33:[2,91],65:[2,91],72:[2,91],80:[2,91],81:[2,91],82:[2,91],83:[2,91],84:[2,91],85:[2,91]},{33:[2,93]},{5:[2,22],14:[2,22],15:[2,22],19:[2,22],29:[2,22],34:[2,22],39:[2,22],44:[2,22],47:[2,22],48:[2,22],51:[2,22],55:[2,22],60:[2,22]},{23:[2,99],33:[2,99],54:[2,99],68:[2,99],72:[2,99],75:[2,99]},{73:[1,109]},{20:75,63:126,64:76,65:[1,44],72:[1,35],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,23],14:[2,23],15:[2,23],19:[2,23],29:[2,23],34:[2,23],39:[2,23],44:[2,23],47:[2,23],48:[2,23],51:[2,23],55:[2,23],60:[2,23]},{47:[2,19]},{47:[2,77]},{20:75,33:[2,72],41:127,63:128,64:76,65:[1,44],69:129,70:77,71:78,72:[1,79],75:[2,72],78:26,79:27,80:[1,28],81:[1,29],82:[1,30],83:[1,31],84:[1,32],85:[1,34],86:33},{5:[2,24],14:[2,24],15:[2,24],19:[2,24],29:[2,24],34:[2,24],39:[2,24],44:[2,24],47:[2,24],48:[2,24],51:[2,24],55:[2,24],60:[2,24]},{68:[1,130]},{65:[2,95],68:[2,95],72:[2,95],80:[2,95],81:[2,95],82:[2,95],83:[2,95],84:[2,95],85:[2,95]},{68:[2,97]},{5:[2,21],14:[2,21],15:[2,21],19:[2,21],29:[2,21],34:[2,21],39:[2,21],44:[2,21],47:[2,21],48:[2,21],51:[2,21],55:[2,21],60:[2,21]},{33:[1,131]},{33:[2,63]},{72:[1,133],76:132},{33:[1,134]},{33:[2,69]},{15:[2,12]},{14:[2,26],15:[2,26],19:[2,26],29:[2,26],34:[2,26],47:[2,26],48:[2,26],51:[2,26],55:[2,26],60:[2,26]},{23:[2,31],33:[2,31],54:[2,31],68:[2,31],72:[2,31],75:[2,31]},{33:[2,74],42:135,74:136,75:[1,121]},{33:[2,71],65:[2,71],72:[2,71],75:[2,71],80:[2,71],81:[2,71],82:[2,71],83:[2,71],84:[2,71],85:[2,71]},{33:[2,73],75:[2,73]},{23:[2,29],33:[2,29],54:[2,29],65:[2,29],68:[2,29],72:[2,29],75:[2,29],80:[2,29],81:[2,29],82:[2,29],83:[2,29],84:[2,29],85:[2,29]},{14:[2,15],15:[2,15],19:[2,15],29:[2,15],34:[2,15],39:[2,15],44:[2,15],47:[2,15],48:[2,15],51:[2,15],55:[2,15],60:[2,15]},{72:[1,138],77:[1,137]},{72:[2,100],77:[2,100]},{14:[2,16],15:[2,16],19:[2,16],29:[2,16],34:[2,16],44:[2,16],47:[2,16],48:[2,16],51:[2,16],55:[2,16],60:[2,16]},{33:[1,139]},{33:[2,75]},{33:[2,32]},{72:[2,101],77:[2,101]},{14:[2,17],15:[2,17],19:[2,17],29:[2,17],34:[2,17],39:[2,17],44:[2,17],47:[2,17],48:[2,17],51:[2,17],55:[2,17],60:[2,17]}],defaultActions:{4:[2,1],55:[2,55],57:[2,20],61:[2,57],74:[2,81],83:[2,85],87:[2,18],91:[2,89],102:[2,53],105:[2,93],111:[2,19],112:[2,77],117:[2,97],120:[2,63],123:[2,69],124:[2,12],136:[2,75],137:[2,32]},parseError:function(e,t){throw new Error(e)},parse:function(e){var t=this,i=[0],r=[null],n=[],o=this.table,s="",a=0,l=0,c=0;this.lexer.setInput(e),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var u=this.lexer.yylloc;n.push(u);var h=this.lexer.options&&this.lexer.options.ranges;function d(){var e;return"number"!=typeof(e=t.lexer.lex()||1)&&(e=t.symbols_[e]||e),e}"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var f,p,m,g,_,v,A,y,b,T={};;){if(m=i[i.length-1],this.defaultActions[m]?g=this.defaultActions[m]:(null!==f&&void 0!==f||(f=d()),g=o[m]&&o[m][f]),void 0===g||!g.length||!g[0]){var E="";if(!c){for(v in b=[],o[m])this.terminals_[v]&&v>2&&b.push("'"+this.terminals_[v]+"'");E=this.lexer.showPosition?"Parse error on line "+(a+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+b.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(E,{text:this.lexer.match,token:this.terminals_[f]||f,line:this.lexer.yylineno,loc:u,expected:b})}}if(g[0]instanceof Array&&g.length>1)throw new Error("Parse Error: multiple actions possible at state: "+m+", token: "+f);switch(g[0]){case 1:i.push(f),r.push(this.lexer.yytext),n.push(this.lexer.yylloc),i.push(g[1]),f=null,p?(f=p,p=null):(l=this.lexer.yyleng,s=this.lexer.yytext,a=this.lexer.yylineno,u=this.lexer.yylloc,c>0&&c--);break;case 2:if(A=this.productions_[g[1]][1],T.$=r[r.length-A],T._$={first_line:n[n.length-(A||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(A||1)].first_column,last_column:n[n.length-1].last_column},h&&(T._$.range=[n[n.length-(A||1)].range[0],n[n.length-1].range[1]]),void 0!==(_=this.performAction.call(T,s,l,a,this.yy,g[1],r,n)))return _;A&&(i=i.slice(0,-1*A*2),r=r.slice(0,-1*A),n=n.slice(0,-1*A)),i.push(this.productions_[g[1]][0]),r.push(T.$),n.push(T._$),y=o[i[i.length-2]][i[i.length-1]],i.push(y);break;case 3:return!0}}return!0}},t=function(){var e={EOF:1,parseError:function(e,t){if(!this.yy.parser)throw new Error(e);this.yy.parser.parseError(e,t)},setInput:function(e){return this._input=e,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var e=this._input[0];return this.yytext+=e,this.yyleng++,this.offset++,this.match+=e,this.matched+=e,e.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),e},unput:function(e){var t=e.length,i=e.split(/(?:\r\n?|\n)/g);this._input=e+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-t-1),this.offset-=t;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var n=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===r.length?this.yylloc.first_column:0)+r[r.length-i.length].length-i[0].length:this.yylloc.first_column-t},this.options.ranges&&(this.yylloc.range=[n[0],n[0]+this.yyleng-t]),this},more:function(){return this._more=!0,this},less:function(e){this.unput(this.match.slice(e))},pastInput:function(){var e=this.matched.substr(0,this.matched.length-this.match.length);return(e.length>20?"...":"")+e.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var e=this.match;return e.length<20&&(e+=this._input.substr(0,20-e.length)),(e.substr(0,20)+(e.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var e=this.pastInput(),t=new Array(e.length+1).join("-");return e+this.upcomingInput()+"\n"+t+"^"},next:function(){if(this.done)return this.EOF;var e,t,i,r,n;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),s=0;s<o.length&&(!(i=this._input.match(this.rules[o[s]]))||t&&!(i[0].length>t[0].length)||(t=i,r=s,this.options.flex));s++);return t?((n=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=n.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:n?n[n.length-1].length-n[n.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],e=this.performAction.call(this,this.yy,this,o[r],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),e||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var e=this.next();return void 0!==e?e:this.lex()},begin:function(e){this.conditionStack.push(e)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(e){this.begin(e)},options:{},performAction:function(e,t,i,r){function n(e,i){return t.yytext=t.yytext.substr(e,t.yyleng-i)}switch(i){case 0:if("\\\\"===t.yytext.slice(-2)?(n(0,1),this.begin("mu")):"\\"===t.yytext.slice(-1)?(n(0,1),this.begin("emu")):this.begin("mu"),t.yytext)return 15;break;case 1:return 15;case 2:return this.popState(),15;case 3:return this.begin("raw"),15;case 4:return this.popState(),"raw"===this.conditionStack[this.conditionStack.length-1]?15:(t.yytext=t.yytext.substr(5,t.yyleng-9),"END_RAW_BLOCK");case 5:return 15;case 6:return this.popState(),14;case 7:return 65;case 8:return 68;case 9:return 19;case 10:return this.popState(),this.begin("raw"),23;case 11:return 55;case 12:return 60;case 13:return 29;case 14:return 47;case 15:case 16:return this.popState(),44;case 17:return 34;case 18:return 39;case 19:return 51;case 20:return 48;case 21:this.unput(t.yytext),this.popState(),this.begin("com");break;case 22:return this.popState(),14;case 23:return 48;case 24:return 73;case 25:case 26:return 72;case 27:return 87;case 28:break;case 29:return this.popState(),54;case 30:return this.popState(),33;case 31:return t.yytext=n(1,2).replace(/\\"/g,'"'),80;case 32:return t.yytext=n(1,2).replace(/\\'/g,"'"),80;case 33:return 85;case 34:case 35:return 82;case 36:return 83;case 37:return 84;case 38:return 81;case 39:return 75;case 40:return 77;case 41:return 72;case 42:return t.yytext=t.yytext.replace(/\\([\\\]])/g,"$1"),72;case 43:return"INVALID";case 44:return 5}},rules:[/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/,/^(?:\{\{\{\{(?=[^\/]))/,/^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/,/^(?:[^\x00]*?(?=(\{\{\{\{)))/,/^(?:[\s\S]*?--(~)?\}\})/,/^(?:\()/,/^(?:\))/,/^(?:\{\{\{\{)/,/^(?:\}\}\}\})/,/^(?:\{\{(~)?>)/,/^(?:\{\{(~)?#>)/,/^(?:\{\{(~)?#\*?)/,/^(?:\{\{(~)?\/)/,/^(?:\{\{(~)?\^\s*(~)?\}\})/,/^(?:\{\{(~)?\s*else\s*(~)?\}\})/,/^(?:\{\{(~)?\^)/,/^(?:\{\{(~)?\s*else\b)/,/^(?:\{\{(~)?\{)/,/^(?:\{\{(~)?&)/,/^(?:\{\{(~)?!--)/,/^(?:\{\{(~)?![\s\S]*?\}\})/,/^(?:\{\{(~)?\*?)/,/^(?:=)/,/^(?:\.\.)/,/^(?:\.(?=([=~}\s\/.)|])))/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}(~)?\}\})/,/^(?:(~)?\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=([~}\s)])))/,/^(?:false(?=([~}\s)])))/,/^(?:undefined(?=([~}\s)])))/,/^(?:null(?=([~}\s)])))/,/^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/,/^(?:as\s+\|)/,/^(?:\|)/,/^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/,/^(?:\[(\\\]|[^\]])*\])/,/^(?:.)/,/^(?:$)/],conditions:{mu:{rules:[7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44],inclusive:!1},emu:{rules:[2],inclusive:!1},com:{rules:[6],inclusive:!1},raw:{rules:[3,4,5],inclusive:!1},INITIAL:{rules:[0,1,44],inclusive:!0}}};return e}();function i(){this.yy={}}return e.lexer=t,i.prototype=e,e.Parser=i,new i}();t.default=i,e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=r(i(39));function o(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.options=e}function s(e,t,i){void 0===t&&(t=e.length);var r=e[t-1],n=e[t-2];return r?"ContentStatement"===r.type?(n||!i?/\r?\n\s*?$/:/(^|\r?\n)\s*?$/).test(r.original):void 0:i}function a(e,t,i){void 0===t&&(t=-1);var r=e[t+1],n=e[t+2];return r?"ContentStatement"===r.type?(n||!i?/^\s*?\r?\n/:/^\s*?(\r?\n|$)/).test(r.original):void 0:i}function l(e,t,i){var r=e[null==t?0:t+1];if(r&&"ContentStatement"===r.type&&(i||!r.rightStripped)){var n=r.value;r.value=r.value.replace(i?/^\s+/:/^[ \t]*\r?\n?/,""),r.rightStripped=r.value!==n}}function c(e,t,i){var r=e[null==t?e.length-1:t-1];if(r&&"ContentStatement"===r.type&&(i||!r.leftStripped)){var n=r.value;return r.value=r.value.replace(i?/\s+$/:/[ \t]+$/,""),r.leftStripped=r.value!==n,r.leftStripped}}o.prototype=new n.default,o.prototype.Program=function(e){var t=!this.options.ignoreStandalone,i=!this.isRootSeen;this.isRootSeen=!0;for(var r=e.body,n=0,o=r.length;n<o;n++){var u=r[n],h=this.accept(u);if(h){var d=s(r,n,i),f=a(r,n,i),p=h.openStandalone&&d,m=h.closeStandalone&&f,g=h.inlineStandalone&&d&&f;h.close&&l(r,n,!0),h.open&&c(r,n,!0),t&&g&&(l(r,n),c(r,n)&&"PartialStatement"===u.type&&(u.indent=/([ \t]+$)/.exec(r[n-1].original)[1])),t&&p&&(l((u.program||u.inverse).body),c(r,n)),t&&m&&(l(r,n),c((u.inverse||u.program).body))}}return e},o.prototype.BlockStatement=o.prototype.DecoratorBlock=o.prototype.PartialBlockStatement=function(e){this.accept(e.program),this.accept(e.inverse);var t=e.program||e.inverse,i=e.program&&e.inverse,r=i,n=i;if(i&&i.chained)for(r=i.body[0].program;n.chained;)n=n.body[n.body.length-1].program;var o={open:e.openStrip.open,close:e.closeStrip.close,openStandalone:a(t.body),closeStandalone:s((r||t).body)};if(e.openStrip.close&&l(t.body,null,!0),i){var u=e.inverseStrip;u.open&&c(t.body,null,!0),u.close&&l(r.body,null,!0),e.closeStrip.open&&c(n.body,null,!0),!this.options.ignoreStandalone&&s(t.body)&&a(r.body)&&(c(t.body),l(r.body))}else e.closeStrip.open&&c(t.body,null,!0);return o},o.prototype.Decorator=o.prototype.MustacheStatement=function(e){return e.strip},o.prototype.PartialStatement=o.prototype.CommentStatement=function(e){var t=e.strip||{};return{inlineStandalone:!0,open:t.open,close:t.close}},t.default=o,e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=r(i(6));function o(){this.parents=[]}function s(e){this.acceptRequired(e,"path"),this.acceptArray(e.params),this.acceptKey(e,"hash")}function a(e){s.call(this,e),this.acceptKey(e,"program"),this.acceptKey(e,"inverse")}function l(e){this.acceptRequired(e,"name"),this.acceptArray(e.params),this.acceptKey(e,"hash")}o.prototype={constructor:o,mutating:!1,acceptKey:function(e,t){var i=this.accept(e[t]);if(this.mutating){if(i&&!o.prototype[i.type])throw new n.default('Unexpected node type "'+i.type+'" found when accepting '+t+" on "+e.type);e[t]=i}},acceptRequired:function(e,t){if(this.acceptKey(e,t),!e[t])throw new n.default(e.type+" requires "+t)},acceptArray:function(e){for(var t=0,i=e.length;t<i;t++)this.acceptKey(e,t),e[t]||(e.splice(t,1),t--,i--)},accept:function(e){if(e){if(!this[e.type])throw new n.default("Unknown type: "+e.type,e);this.current&&this.parents.unshift(this.current),this.current=e;var t=this[e.type](e);return this.current=this.parents.shift(),!this.mutating||t?t:!1!==t?e:void 0}},Program:function(e){this.acceptArray(e.body)},MustacheStatement:s,Decorator:s,BlockStatement:a,DecoratorBlock:a,PartialStatement:l,PartialBlockStatement:function(e){l.call(this,e),this.acceptKey(e,"program")},ContentStatement:function(){},CommentStatement:function(){},SubExpression:s,PathExpression:function(){},StringLiteral:function(){},NumberLiteral:function(){},BooleanLiteral:function(){},UndefinedLiteral:function(){},NullLiteral:function(){},Hash:function(e){this.acceptArray(e.pairs)},HashPair:function(e){this.acceptRequired(e,"value")}},t.default=o,e.exports=t.default},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0,t.SourceLocation=function(e,t){this.source=e,this.start={line:t.first_line,column:t.first_column},this.end={line:t.last_line,column:t.last_column}},t.id=function(e){return/^\[.*\]$/.test(e)?e.substr(1,e.length-2):e},t.stripFlags=function(e,t){return{open:"~"===e.charAt(2),close:"~"===t.charAt(t.length-3)}},t.stripComment=function(e){return e.replace(/^\{\{~?\!-?-?/,"").replace(/-?-?~?\}\}$/,"")},t.preparePath=function(e,t,i){i=this.locInfo(i);for(var r=e?"@":"",o=[],s=0,a=0,l=t.length;a<l;a++){var c=t[a].part,u=t[a].original!==c;if(r+=(t[a].separator||"")+c,u||".."!==c&&"."!==c&&"this"!==c)o.push(c);else{if(o.length>0)throw new n.default("Invalid path: "+r,{loc:i});".."===c&&(s++,"../")}}return{type:"PathExpression",data:e,depth:s,parts:o,original:r,loc:i}},t.prepareMustache=function(e,t,i,r,n,o){var s=r.charAt(3)||r.charAt(2),a="{"!==s&&"&"!==s;return{type:/\*/.test(r)?"Decorator":"MustacheStatement",path:e,params:t,hash:i,escaped:a,strip:n,loc:this.locInfo(o)}},t.prepareRawBlock=function(e,t,i,r){o(e,i),r=this.locInfo(r);var n={type:"Program",body:t,strip:{},loc:r};return{type:"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:n,openStrip:{},inverseStrip:{},closeStrip:{},loc:r}},t.prepareBlock=function(e,t,i,r,s,a){r&&r.path&&o(e,r);var l=/\*/.test(e.open);t.blockParams=e.blockParams;var c=void 0,u=void 0;if(i){if(l)throw new n.default("Unexpected inverse block on decorator",i);i.chain&&(i.program.body[0].closeStrip=r.strip),u=i.strip,c=i.program}s&&(s=c,c=t,t=s);return{type:l?"DecoratorBlock":"BlockStatement",path:e.path,params:e.params,hash:e.hash,program:t,inverse:c,openStrip:e.strip,inverseStrip:u,closeStrip:r&&r.strip,loc:this.locInfo(a)}},t.prepareProgram=function(e,t){if(!t&&e.length){var i=e[0].loc,r=e[e.length-1].loc;i&&r&&(t={source:i.source,start:{line:i.start.line,column:i.start.column},end:{line:r.end.line,column:r.end.column}})}return{type:"Program",body:e,strip:{},loc:t}},t.preparePartialBlock=function(e,t,i,r){return o(e,i),{type:"PartialBlockStatement",name:e.path,params:e.params,hash:e.hash,program:t,openStrip:e.strip,closeStrip:i&&i.strip,loc:this.locInfo(r)}};var n=r(i(6));function o(e,t){if(t=t.path?t.path.original:t,e.path.original!==t){var i={loc:e.path.loc};throw new n.default(e.path.original+" doesn't match "+t,i)}}},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0,t.Compiler=l,t.precompile=function(e,t,i){if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new n.default("You must pass a string or Handlebars AST to Handlebars.precompile. You passed "+e);"data"in(t=t||{})||(t.data=!0);t.compat&&(t.useDepths=!0);var r=i.parse(e,t),o=(new i.Compiler).compile(r,t);return(new i.JavaScriptCompiler).compile(o,t)},t.compile=function(e,t,i){void 0===t&&(t={});if(null==e||"string"!=typeof e&&"Program"!==e.type)throw new n.default("You must pass a string or Handlebars AST to Handlebars.compile. You passed "+e);"data"in(t=o.extend({},t))||(t.data=!0);t.compat&&(t.useDepths=!0);var r=void 0;function s(){var r=i.parse(e,t),n=(new i.Compiler).compile(r,t),o=(new i.JavaScriptCompiler).compile(n,t,void 0,!0);return i.template(o)}function a(e,t){return r||(r=s()),r.call(this,e,t)}return a._setup=function(e){return r||(r=s()),r._setup(e)},a._child=function(e,t,i,n){return r||(r=s()),r._child(e,t,i,n)},a};var n=r(i(6)),o=i(5),s=r(i(35)),a=[].slice;function l(){}function c(e,t){if(e===t)return!0;if(o.isArray(e)&&o.isArray(t)&&e.length===t.length){for(var i=0;i<e.length;i++)if(!c(e[i],t[i]))return!1;return!0}}function u(e){if(!e.path.parts){var t=e.path;e.path={type:"PathExpression",data:!1,depth:0,parts:[t.original+""],original:t.original+"",loc:t.loc}}}l.prototype={compiler:l,equals:function(e){var t=this.opcodes.length;if(e.opcodes.length!==t)return!1;for(var i=0;i<t;i++){var r=this.opcodes[i],n=e.opcodes[i];if(r.opcode!==n.opcode||!c(r.args,n.args))return!1}t=this.children.length;for(i=0;i<t;i++)if(!this.children[i].equals(e.children[i]))return!1;return!0},guid:0,compile:function(e,t){this.sourceNode=[],this.opcodes=[],this.children=[],this.options=t,this.stringParams=t.stringParams,this.trackIds=t.trackIds,t.blockParams=t.blockParams||[];var i=t.knownHelpers;if(t.knownHelpers={helperMissing:!0,blockHelperMissing:!0,each:!0,if:!0,unless:!0,with:!0,log:!0,lookup:!0},i)for(var r in i)r in i&&(this.options.knownHelpers[r]=i[r]);return this.accept(e)},compileProgram:function(e){var t=(new this.compiler).compile(e,this.options),i=this.guid++;return this.usePartial=this.usePartial||t.usePartial,this.children[i]=t,this.useDepths=this.useDepths||t.useDepths,i},accept:function(e){if(!this[e.type])throw new n.default("Unknown type: "+e.type,e);this.sourceNode.unshift(e);var t=this[e.type](e);return this.sourceNode.shift(),t},Program:function(e){this.options.blockParams.unshift(e.blockParams);for(var t=e.body,i=t.length,r=0;r<i;r++)this.accept(t[r]);return this.options.blockParams.shift(),this.isSimple=1===i,this.blockParams=e.blockParams?e.blockParams.length:0,this},BlockStatement:function(e){u(e);var t=e.program,i=e.inverse;t=t&&this.compileProgram(t),i=i&&this.compileProgram(i);var r=this.classifySexpr(e);"helper"===r?this.helperSexpr(e,t,i):"simple"===r?(this.simpleSexpr(e),this.opcode("pushProgram",t),this.opcode("pushProgram",i),this.opcode("emptyHash"),this.opcode("blockValue",e.path.original)):(this.ambiguousSexpr(e,t,i),this.opcode("pushProgram",t),this.opcode("pushProgram",i),this.opcode("emptyHash"),this.opcode("ambiguousBlockValue")),this.opcode("append")},DecoratorBlock:function(e){var t=e.program&&this.compileProgram(e.program),i=this.setupFullMustacheParams(e,t,void 0),r=e.path;this.useDecorators=!0,this.opcode("registerDecorator",i.length,r.original)},PartialStatement:function(e){this.usePartial=!0;var t=e.program;t&&(t=this.compileProgram(e.program));var i=e.params;if(i.length>1)throw new n.default("Unsupported number of partial arguments: "+i.length,e);i.length||(this.options.explicitPartialContext?this.opcode("pushLiteral","undefined"):i.push({type:"PathExpression",parts:[],depth:0}));var r=e.name.original,o="SubExpression"===e.name.type;o&&this.accept(e.name),this.setupFullMustacheParams(e,t,void 0,!0);var s=e.indent||"";this.options.preventIndent&&s&&(this.opcode("appendContent",s),s=""),this.opcode("invokePartial",o,r,s),this.opcode("append")},PartialBlockStatement:function(e){this.PartialStatement(e)},MustacheStatement:function(e){this.SubExpression(e),e.escaped&&!this.options.noEscape?this.opcode("appendEscaped"):this.opcode("append")},Decorator:function(e){this.DecoratorBlock(e)},ContentStatement:function(e){e.value&&this.opcode("appendContent",e.value)},CommentStatement:function(){},SubExpression:function(e){u(e);var t=this.classifySexpr(e);"simple"===t?this.simpleSexpr(e):"helper"===t?this.helperSexpr(e):this.ambiguousSexpr(e)},ambiguousSexpr:function(e,t,i){var r=e.path,n=r.parts[0],o=null!=t||null!=i;this.opcode("getContext",r.depth),this.opcode("pushProgram",t),this.opcode("pushProgram",i),r.strict=!0,this.accept(r),this.opcode("invokeAmbiguous",n,o)},simpleSexpr:function(e){var t=e.path;t.strict=!0,this.accept(t),this.opcode("resolvePossibleLambda")},helperSexpr:function(e,t,i){var r=this.setupFullMustacheParams(e,t,i),o=e.path,a=o.parts[0];if(this.options.knownHelpers[a])this.opcode("invokeKnownHelper",r.length,a);else{if(this.options.knownHelpersOnly)throw new n.default("You specified knownHelpersOnly, but used the unknown helper "+a,e);o.strict=!0,o.falsy=!0,this.accept(o),this.opcode("invokeHelper",r.length,o.original,s.default.helpers.simpleId(o))}},PathExpression:function(e){this.addDepth(e.depth),this.opcode("getContext",e.depth);var t=e.parts[0],i=s.default.helpers.scopedId(e),r=!e.depth&&!i&&this.blockParamIndex(t);r?this.opcode("lookupBlockParam",r,e.parts):t?e.data?(this.options.data=!0,this.opcode("lookupData",e.depth,e.parts,e.strict)):this.opcode("lookupOnContext",e.parts,e.falsy,e.strict,i):this.opcode("pushContext")},StringLiteral:function(e){this.opcode("pushString",e.value)},NumberLiteral:function(e){this.opcode("pushLiteral",e.value)},BooleanLiteral:function(e){this.opcode("pushLiteral",e.value)},UndefinedLiteral:function(){this.opcode("pushLiteral","undefined")},NullLiteral:function(){this.opcode("pushLiteral","null")},Hash:function(e){var t=e.pairs,i=0,r=t.length;for(this.opcode("pushHash");i<r;i++)this.pushParam(t[i].value);for(;i--;)this.opcode("assignToHash",t[i].key);this.opcode("popHash")},opcode:function(e){this.opcodes.push({opcode:e,args:a.call(arguments,1),loc:this.sourceNode[0].loc})},addDepth:function(e){e&&(this.useDepths=!0)},classifySexpr:function(e){var t=s.default.helpers.simpleId(e.path),i=t&&!!this.blockParamIndex(e.path.parts[0]),r=!i&&s.default.helpers.helperExpression(e),n=!i&&(r||t);if(n&&!r){var o=e.path.parts[0],a=this.options;a.knownHelpers[o]?r=!0:a.knownHelpersOnly&&(n=!1)}return r?"helper":n?"ambiguous":"simple"},pushParams:function(e){for(var t=0,i=e.length;t<i;t++)this.pushParam(e[t])},pushParam:function(e){var t=null!=e.value?e.value:e.original||"";if(this.stringParams)t.replace&&(t=t.replace(/^(\.?\.\/)*/g,"").replace(/\//g,".")),e.depth&&this.addDepth(e.depth),this.opcode("getContext",e.depth||0),this.opcode("pushStringParam",t,e.type),"SubExpression"===e.type&&this.accept(e);else{if(this.trackIds){var i=void 0;if(!e.parts||s.default.helpers.scopedId(e)||e.depth||(i=this.blockParamIndex(e.parts[0])),i){var r=e.parts.slice(1).join(".");this.opcode("pushId","BlockParam",i,r)}else(t=e.original||t).replace&&(t=t.replace(/^this(?:\.|$)/,"").replace(/^\.\//,"").replace(/^\.$/,"")),this.opcode("pushId",e.type,t)}this.accept(e)}},setupFullMustacheParams:function(e,t,i,r){var n=e.params;return this.pushParams(n),this.opcode("pushProgram",t),this.opcode("pushProgram",i),e.hash?this.accept(e.hash):this.opcode("emptyHash",r),n},blockParamIndex:function(e){for(var t=0,i=this.options.blockParams.length;t<i;t++){var r=this.options.blockParams[t],n=r&&o.indexOf(r,e);if(r&&n>=0)return[t,n]}}}},function(e,t,i){"use strict";var r=i(1).default;t.__esModule=!0;var n=i(4),o=r(i(6)),s=i(5),a=r(i(43));function l(e){this.value=e}function c(){}c.prototype={nameLookup:function(e,t){return c.isValidJavaScriptVariableName(t)?[e,".",t]:[e,"[",JSON.stringify(t),"]"]},depthedLookup:function(e){return[this.aliasable("container.lookup"),'(depths, "',e,'")']},compilerInfo:function(){var e=n.COMPILER_REVISION;return[e,n.REVISION_CHANGES[e]]},appendToBuffer:function(e,t,i){return s.isArray(e)||(e=[e]),e=this.source.wrap(e,t),this.environment.isSimple?["return ",e,";"]:i?["buffer += ",e,";"]:(e.appendToBuffer=!0,e)},initializeBuffer:function(){return this.quotedString("")},compile:function(e,t,i,r){this.environment=e,this.options=t,this.stringParams=this.options.stringParams,this.trackIds=this.options.trackIds,this.precompile=!r,this.name=this.environment.name,this.isChild=!!i,this.context=i||{decorators:[],programs:[],environments:[]},this.preamble(),this.stackSlot=0,this.stackVars=[],this.aliases={},this.registers={list:[]},this.hashes=[],this.compileStack=[],this.inlineStack=[],this.blockParams=[],this.compileChildren(e,t),this.useDepths=this.useDepths||e.useDepths||e.useDecorators||this.options.compat,this.useBlockParams=this.useBlockParams||e.useBlockParams;var n=e.opcodes,s=void 0,a=void 0,l=void 0,c=void 0;for(l=0,c=n.length;l<c;l++)s=n[l],this.source.currentLocation=s.loc,a=a||s.loc,this[s.opcode].apply(this,s.args);if(this.source.currentLocation=a,this.pushSource(""),this.stackSlot||this.inlineStack.length||this.compileStack.length)throw new o.default("Compile completed with content left on stack");this.decorators.isEmpty()?this.decorators=void 0:(this.useDecorators=!0,this.decorators.prepend("var decorators = container.decorators;\n"),this.decorators.push("return fn;"),r?this.decorators=Function.apply(this,["fn","props","container","depth0","data","blockParams","depths",this.decorators.merge()]):(this.decorators.prepend("function(fn, props, container, depth0, data, blockParams, depths) {\n"),this.decorators.push("}\n"),this.decorators=this.decorators.merge()));var u=this.createFunctionContext(r);if(this.isChild)return u;var h={compiler:this.compilerInfo(),main:u};this.decorators&&(h.main_d=this.decorators,h.useDecorators=!0);var d=this.context,f=d.programs,p=d.decorators;for(l=0,c=f.length;l<c;l++)f[l]&&(h[l]=f[l],p[l]&&(h[l+"_d"]=p[l],h.useDecorators=!0));return this.environment.usePartial&&(h.usePartial=!0),this.options.data&&(h.useData=!0),this.useDepths&&(h.useDepths=!0),this.useBlockParams&&(h.useBlockParams=!0),this.options.compat&&(h.compat=!0),r?h.compilerOptions=this.options:(h.compiler=JSON.stringify(h.compiler),this.source.currentLocation={start:{line:1,column:0}},h=this.objectLiteral(h),t.srcName?(h=h.toStringWithSourceMap({file:t.destName})).map=h.map&&h.map.toString():h=h.toString()),h},preamble:function(){this.lastContext=0,this.source=new a.default(this.options.srcName),this.decorators=new a.default(this.options.srcName)},createFunctionContext:function(e){var t="",i=this.stackVars.concat(this.registers.list);i.length>0&&(t+=", "+i.join(", "));var r=0;for(var n in this.aliases){var o=this.aliases[n];this.aliases.hasOwnProperty(n)&&o.children&&o.referenceCount>1&&(t+=", alias"+ ++r+"="+n,o.children[0]="alias"+r)}var s=["container","depth0","helpers","partials","data"];(this.useBlockParams||this.useDepths)&&s.push("blockParams"),this.useDepths&&s.push("depths");var a=this.mergeSource(t);return e?(s.push(a),Function.apply(this,s)):this.source.wrap(["function(",s.join(","),") {\n ",a,"}"])},mergeSource:function(e){var t=this.environment.isSimple,i=!this.forceBuffer,r=void 0,n=void 0,o=void 0,s=void 0;return this.source.each(function(e){e.appendToBuffer?(o?e.prepend(" + "):o=e,s=e):(o&&(n?o.prepend("buffer += "):r=!0,s.add(";"),o=s=void 0),n=!0,t||(i=!1))}),i?o?(o.prepend("return "),s.add(";")):n||this.source.push('return "";'):(e+=", buffer = "+(r?"":this.initializeBuffer()),o?(o.prepend("return buffer + "),s.add(";")):this.source.push("return buffer;")),e&&this.source.prepend("var "+e.substring(2)+(r?"":";\n")),this.source.merge()},blockValue:function(e){var t=this.aliasable("helpers.blockHelperMissing"),i=[this.contextName(0)];this.setupHelperArgs(e,0,i);var r=this.popStack();i.splice(1,0,r),this.push(this.source.functionCall(t,"call",i))},ambiguousBlockValue:function(){var e=this.aliasable("helpers.blockHelperMissing"),t=[this.contextName(0)];this.setupHelperArgs("",0,t,!0),this.flushInline();var i=this.topStack();t.splice(1,0,i),this.pushSource(["if (!",this.lastHelper,") { ",i," = ",this.source.functionCall(e,"call",t),"}"])},appendContent:function(e){this.pendingContent?e=this.pendingContent+e:this.pendingLocation=this.source.currentLocation,this.pendingContent=e},append:function(){if(this.isInline())this.replaceStack(function(e){return[" != null ? ",e,' : ""']}),this.pushSource(this.appendToBuffer(this.popStack()));else{var e=this.popStack();this.pushSource(["if (",e," != null) { ",this.appendToBuffer(e,void 0,!0)," }"]),this.environment.isSimple&&this.pushSource(["else { ",this.appendToBuffer("''",void 0,!0)," }"])}},appendEscaped:function(){this.pushSource(this.appendToBuffer([this.aliasable("container.escapeExpression"),"(",this.popStack(),")"]))},getContext:function(e){this.lastContext=e},pushContext:function(){this.pushStackLiteral(this.contextName(this.lastContext))},lookupOnContext:function(e,t,i,r){var n=0;r||!this.options.compat||this.lastContext?this.pushContext():this.push(this.depthedLookup(e[n++])),this.resolvePath("context",e,n,t,i)},lookupBlockParam:function(e,t){this.useBlockParams=!0,this.push(["blockParams[",e[0],"][",e[1],"]"]),this.resolvePath("context",t,1)},lookupData:function(e,t,i){e?this.pushStackLiteral("container.data(data, "+e+")"):this.pushStackLiteral("data"),this.resolvePath("data",t,0,!0,i)},resolvePath:function(e,t,i,r,n){var o=this;if(this.options.strict||this.options.assumeObjects)this.push(function(e,t,i,r){var n=t.popStack(),o=0,s=i.length;e&&s--;for(;o<s;o++)n=t.nameLookup(n,i[o],r);return e?[t.aliasable("container.strict"),"(",n,", ",t.quotedString(i[o]),")"]:n}(this.options.strict&&n,this,t,e));else for(var s=t.length;i<s;i++)this.replaceStack(function(n){var s=o.nameLookup(n,t[i],e);return r?[" && ",s]:[" != null ? ",s," : ",n]})},resolvePossibleLambda:function(){this.push([this.aliasable("container.lambda"),"(",this.popStack(),", ",this.contextName(0),")"])},pushStringParam:function(e,t){this.pushContext(),this.pushString(t),"SubExpression"!==t&&("string"==typeof e?this.pushString(e):this.pushStackLiteral(e))},emptyHash:function(e){this.trackIds&&this.push("{}"),this.stringParams&&(this.push("{}"),this.push("{}")),this.pushStackLiteral(e?"undefined":"{}")},pushHash:function(){this.hash&&this.hashes.push(this.hash),this.hash={values:[],types:[],contexts:[],ids:[]}},popHash:function(){var e=this.hash;this.hash=this.hashes.pop(),this.trackIds&&this.push(this.objectLiteral(e.ids)),this.stringParams&&(this.push(this.objectLiteral(e.contexts)),this.push(this.objectLiteral(e.types))),this.push(this.objectLiteral(e.values))},pushString:function(e){this.pushStackLiteral(this.quotedString(e))},pushLiteral:function(e){this.pushStackLiteral(e)},pushProgram:function(e){null!=e?this.pushStackLiteral(this.programExpression(e)):this.pushStackLiteral(null)},registerDecorator:function(e,t){var i=this.nameLookup("decorators",t,"decorator"),r=this.setupHelperArgs(t,e);this.decorators.push(["fn = ",this.decorators.functionCall(i,"",["fn","props","container",r])," || fn;"])},invokeHelper:function(e,t,i){var r=this.popStack(),n=this.setupHelper(e,t),o=i?[n.name," || "]:"",s=["("].concat(o,r);this.options.strict||s.push(" || ",this.aliasable("helpers.helperMissing")),s.push(")"),this.push(this.source.functionCall(s,"call",n.callParams))},invokeKnownHelper:function(e,t){var i=this.setupHelper(e,t);this.push(this.source.functionCall(i.name,"call",i.callParams))},invokeAmbiguous:function(e,t){this.useRegister("helper");var i=this.popStack();this.emptyHash();var r=this.setupHelper(0,e,t),n=["(","(helper = ",this.lastHelper=this.nameLookup("helpers",e,"helper")," || ",i,")"];this.options.strict||(n[0]="(helper = ",n.push(" != null ? helper : ",this.aliasable("helpers.helperMissing"))),this.push(["(",n,r.paramsInit?["),(",r.paramsInit]:[],"),","(typeof helper === ",this.aliasable('"function"')," ? ",this.source.functionCall("helper","call",r.callParams)," : helper))"])},invokePartial:function(e,t,i){var r=[],n=this.setupParams(t,1,r);e&&(t=this.popStack(),delete n.name),i&&(n.indent=JSON.stringify(i)),n.helpers="helpers",n.partials="partials",n.decorators="container.decorators",e?r.unshift(t):r.unshift(this.nameLookup("partials",t,"partial")),this.options.compat&&(n.depths="depths"),n=this.objectLiteral(n),r.push(n),this.push(this.source.functionCall("container.invokePartial","",r))},assignToHash:function(e){var t=this.popStack(),i=void 0,r=void 0,n=void 0;this.trackIds&&(n=this.popStack()),this.stringParams&&(r=this.popStack(),i=this.popStack());var o=this.hash;i&&(o.contexts[e]=i),r&&(o.types[e]=r),n&&(o.ids[e]=n),o.values[e]=t},pushId:function(e,t,i){"BlockParam"===e?this.pushStackLiteral("blockParams["+t[0]+"].path["+t[1]+"]"+(i?" + "+JSON.stringify("."+i):"")):"PathExpression"===e?this.pushString(t):"SubExpression"===e?this.pushStackLiteral("true"):this.pushStackLiteral("null")},compiler:c,compileChildren:function(e,t){for(var i=e.children,r=void 0,n=void 0,o=0,s=i.length;o<s;o++){r=i[o],n=new this.compiler;var a=this.matchExistingProgram(r);if(null==a){this.context.programs.push("");var l=this.context.programs.length;r.index=l,r.name="program"+l,this.context.programs[l]=n.compile(r,t,this.context,!this.precompile),this.context.decorators[l]=n.decorators,this.context.environments[l]=r,this.useDepths=this.useDepths||n.useDepths,this.useBlockParams=this.useBlockParams||n.useBlockParams,r.useDepths=this.useDepths,r.useBlockParams=this.useBlockParams}else r.index=a.index,r.name="program"+a.index,this.useDepths=this.useDepths||a.useDepths,this.useBlockParams=this.useBlockParams||a.useBlockParams}},matchExistingProgram:function(e){for(var t=0,i=this.context.environments.length;t<i;t++){var r=this.context.environments[t];if(r&&r.equals(e))return r}},programExpression:function(e){var t=this.environment.children[e],i=[t.index,"data",t.blockParams];return(this.useBlockParams||this.useDepths)&&i.push("blockParams"),this.useDepths&&i.push("depths"),"container.program("+i.join(", ")+")"},useRegister:function(e){this.registers[e]||(this.registers[e]=!0,this.registers.list.push(e))},push:function(e){return e instanceof l||(e=this.source.wrap(e)),this.inlineStack.push(e),e},pushStackLiteral:function(e){this.push(new l(e))},pushSource:function(e){this.pendingContent&&(this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent),this.pendingLocation)),this.pendingContent=void 0),e&&this.source.push(e)},replaceStack:function(e){var t=["("],i=void 0,r=void 0,n=void 0;if(!this.isInline())throw new o.default("replaceStack on non-inline");var s=this.popStack(!0);if(s instanceof l)t=["(",i=[s.value]],n=!0;else{r=!0;var a=this.incrStack();t=["((",this.push(a)," = ",s,")"],i=this.topStack()}var c=e.call(this,i);n||this.popStack(),r&&this.stackSlot--,this.push(t.concat(c,")"))},incrStack:function(){return this.stackSlot++,this.stackSlot>this.stackVars.length&&this.stackVars.push("stack"+this.stackSlot),this.topStackName()},topStackName:function(){return"stack"+this.stackSlot},flushInline:function(){var e=this.inlineStack;this.inlineStack=[];for(var t=0,i=e.length;t<i;t++){var r=e[t];if(r instanceof l)this.compileStack.push(r);else{var n=this.incrStack();this.pushSource([n," = ",r,";"]),this.compileStack.push(n)}}},isInline:function(){return this.inlineStack.length},popStack:function(e){var t=this.isInline(),i=(t?this.inlineStack:this.compileStack).pop();if(!e&&i instanceof l)return i.value;if(!t){if(!this.stackSlot)throw new o.default("Invalid stack pop");this.stackSlot--}return i},topStack:function(){var e=this.isInline()?this.inlineStack:this.compileStack,t=e[e.length-1];return t instanceof l?t.value:t},contextName:function(e){return this.useDepths&&e?"depths["+e+"]":"depth"+e},quotedString:function(e){return this.source.quotedString(e)},objectLiteral:function(e){return this.source.objectLiteral(e)},aliasable:function(e){var t=this.aliases[e];return t?(t.referenceCount++,t):((t=this.aliases[e]=this.source.wrap(e)).aliasable=!0,t.referenceCount=1,t)},setupHelper:function(e,t,i){var r=[];return{params:r,paramsInit:this.setupHelperArgs(t,e,r,i),name:this.nameLookup("helpers",t,"helper"),callParams:[this.aliasable(this.contextName(0)+" != null ? "+this.contextName(0)+" : (container.nullContext || {})")].concat(r)}},setupParams:function(e,t,i){var r={},n=[],o=[],s=[],a=!i,l=void 0;a&&(i=[]),r.name=this.quotedString(e),r.hash=this.popStack(),this.trackIds&&(r.hashIds=this.popStack()),this.stringParams&&(r.hashTypes=this.popStack(),r.hashContexts=this.popStack());var c=this.popStack(),u=this.popStack();(u||c)&&(r.fn=u||"container.noop",r.inverse=c||"container.noop");for(var h=t;h--;)l=this.popStack(),i[h]=l,this.trackIds&&(s[h]=this.popStack()),this.stringParams&&(o[h]=this.popStack(),n[h]=this.popStack());return a&&(r.args=this.source.generateArray(i)),this.trackIds&&(r.ids=this.source.generateArray(s)),this.stringParams&&(r.types=this.source.generateArray(o),r.contexts=this.source.generateArray(n)),this.options.data&&(r.data="data"),this.useBlockParams&&(r.blockParams="blockParams"),r},setupHelperArgs:function(e,t,i,r){var n=this.setupParams(e,t,i);return n=this.objectLiteral(n),r?(this.useRegister("options"),i.push("options"),["options=",n]):i?(i.push(n),""):n}},function(){for(var e="break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public let yield await null true false".split(" "),t=c.RESERVED_WORDS={},i=0,r=e.length;i<r;i++)t[e[i]]=!0}(),c.isValidJavaScriptVariableName=function(e){return!c.RESERVED_WORDS[e]&&/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(e)},t.default=c,e.exports=t.default},function(e,t,i){"use strict";t.__esModule=!0;var r=i(5),n=void 0;try{}catch(e){}function o(e,t,i){if(r.isArray(e)){for(var n=[],o=0,s=e.length;o<s;o++)n.push(t.wrap(e[o],i));return n}return"boolean"==typeof e||"number"==typeof e?e+"":e}function s(e){this.srcFile=e,this.source=[]}n||((n=function(e,t,i,r){this.src="",r&&this.add(r)}).prototype={add:function(e){r.isArray(e)&&(e=e.join("")),this.src+=e},prepend:function(e){r.isArray(e)&&(e=e.join("")),this.src=e+this.src},toStringWithSourceMap:function(){return{code:this.toString()}},toString:function(){return this.src}}),s.prototype={isEmpty:function(){return!this.source.length},prepend:function(e,t){this.source.unshift(this.wrap(e,t))},push:function(e,t){this.source.push(this.wrap(e,t))},merge:function(){var e=this.empty();return this.each(function(t){e.add([" ",t,"\n"])}),e},each:function(e){for(var t=0,i=this.source.length;t<i;t++)e(this.source[t])},empty:function(){var e=this.currentLocation||{start:{}};return new n(e.start.line,e.start.column,this.srcFile)},wrap:function(e){var t=arguments.length<=1||void 0===arguments[1]?this.currentLocation||{start:{}}:arguments[1];return e instanceof n?e:(e=o(e,this,t),new n(t.start.line,t.start.column,this.srcFile,e))},functionCall:function(e,t,i){return i=this.generateList(i),this.wrap([e,t?"."+t+"(":"(",i,")"])},quotedString:function(e){return'"'+(e+"").replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")+'"'},objectLiteral:function(e){var t=[];for(var i in e)if(e.hasOwnProperty(i)){var r=o(e[i],this);"undefined"!==r&&t.push([this.quotedString(i),":",r])}var n=this.generateList(t);return n.prepend("{"),n.add("}"),n},generateList:function(e){for(var t=this.empty(),i=0,r=e.length;i<r;i++)i&&t.add(","),t.add(o(e[i],this));return t},generateArray:function(e){var t=this.generateList(e);return t.prepend("["),t.add("]"),t}},t.default=s,e.exports=t.default}])})},function(e,t,i){e.exports=i(20)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(3);t.mapperManager=r.mapperManager;var n=i(4);t.viewerGlobals=n.viewerGlobals;var o=i(8);t.viewerManager=o.viewerManager;var s=i(9);t.DefaultViewer=s.DefaultViewer;var a=i(10);t.AbstractViewer=a.AbstractViewer;var l=i(6);t.telemetryManager=l.telemetryManager;var c=i(13);t.ModelLoader=c.ModelLoader;var u=i(5);t.ViewerModel=u.ViewerModel,t.ModelState=u.ModelState;var h=i(7);t.AbstractViewerNavbarButton=h.AbstractViewerNavbarButton;var d=i(17);t.registerCustomOptimizer=d.registerCustomOptimizer;var f=i(0);t.BABYLON=f,i(14),i(67);var p=i(68);t.InitTags=p.InitTags,f.PromisePolyfill.Apply(),p.initListeners();var m=n.viewerGlobals.disableInit;t.disableInit=m,t.disposeAll=function(){o.viewerManager.dispose(),r.mapperManager.dispose(),l.telemetryManager.dispose()};var g=n.viewerGlobals.version;t.Version=g,console.log("Babylon.js viewer (v"+g+")"),function(e){for(var i in e)t.hasOwnProperty(i)||(t[i]=e[i])}(i(15))},function(e,t){var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t){if("undefined"==typeof CANNON){var i=new Error("Cannot find module 'CANNON'");throw i.code="MODULE_NOT_FOUND",i}e.exports=CANNON},function(e,t){if("undefined"==typeof OIMO){var i=new Error("Cannot find module 'OIMO'");throw i.code="MODULE_NOT_FOUND",i}e.exports=OIMO},function(e,t){if("undefined"==typeof earcut){var i=new Error("Cannot find module 'earcut'");throw i.code="MODULE_NOT_FOUND",i}e.exports=earcut},function(e,t,i){"use strict";i.r(t);var r=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)};var n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a(function(e){return Array.isArray(e)?[]:{}}(e),e,t):e}function s(e,t,i){return e.concat(t).map(function(e){return o(e,i)})}function a(e,t,i){(i=i||{}).arrayMerge=i.arrayMerge||s,i.isMergeableObject=i.isMergeableObject||r;var n=Array.isArray(t);return n===Array.isArray(e)?n?i.arrayMerge(e,t,i):function(e,t,i){var r={};return i.isMergeableObject(e)&&Object.keys(e).forEach(function(t){r[t]=o(e[t],i)}),Object.keys(t).forEach(function(n){i.isMergeableObject(t[n])&&e[n]?r[n]=a(e[n],t[n],i):r[n]=o(t[n],i)}),r}(e,t,i):o(t,i)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,i){return a(e,i,t)},{})};var l=a;t.default=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){return function(){this.mainColor=r.Color3.White(),this.reflectionColor=r.Color3.White()}}();t.ConfigurationContainer=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(3),n=i(28),o=i(11),s=i(1),a=i(0),l=function(){function e(e){void 0===e&&(e=!1),this._enableCache=e,this._configurationCache={},this._loadRequests=[]}return e.prototype.loadConfiguration=function(e,t){var i=this;void 0===e&&(e={});var a=s.deepmerge({},e);this._processInitialConfiguration(a);var l=n.getConfigurationType(a.extends||"extended");if(a.configuration){var c="json";return Promise.resolve().then(function(){if("string"==typeof a.configuration||a.configuration&&a.configuration.url){var e="";if("string"==typeof a.configuration&&(e=a.configuration),"object"==typeof a.configuration&&a.configuration.url){e=a.configuration.url;var t=a.configuration.mapper;t||(t=a.configuration.url.split(".").pop()),c=t||c}return i._loadFile(e)}return"object"==typeof a.configuration?(c=a.configuration.mapper||c,a.configuration.payload||{}):{}}).then(function(e){var i=r.mapperManager.getMapper(c),n=s.deepmerge(i.map(e),a),u=s.deepmerge(l,n);return o.processConfigurationCompatibility(u),t&&t(u),u})}return a=s.deepmerge(l,a),o.processConfigurationCompatibility(a),t&&t(a),Promise.resolve(a)},e.prototype.dispose=function(){this._loadRequests.forEach(function(e){e.abort()}),this._loadRequests.length=0},e.prototype._processInitialConfiguration=function(e){e.model&&"string"==typeof e.model&&(e.model={url:e.model})},e.prototype._loadFile=function(e){var t=this,i=this._configurationCache;return this._enableCache&&i[e]?Promise.resolve(i[e]):new Promise(function(r,n){var o=a.Tools.LoadFile(e,function(n){var s=t._loadRequests.indexOf(o);-1!==s&&t._loadRequests.splice(s,1),t._enableCache&&(i[e]=n),r(n)},void 0,void 0,!1,function(e,i){var r=t._loadRequests.indexOf(o);-1!==r&&t._loadRequests.splice(r,1),n(i)});t._loadRequests.push(o)})},e}();t.ConfigurationLoader=l},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(29);t.minimalConfiguration=r.minimalConfiguration;var n=i(48);t.defaultConfiguration=n.defaultConfiguration;var o=i(49),s=i(50),a=i(51),l=i(1),c=function(e){var t={};return e.split(",").forEach(function(e){switch(e.trim()){case"environmentMap":t=l.deepmerge(t,a.environmentMapConfiguration);break;case"shadowDirectionalLight":t=l.deepmerge(t,s.shadowDirectionalLightConfiguration);break;case"shadowSpotLight":t=l.deepmerge(t,s.shadowSpotlLightConfiguration);break;case"default":t=l.deepmerge(t,n.defaultConfiguration);break;case"minimal":t=l.deepmerge(t,r.minimalConfiguration);break;case"none":break;case"extended":default:t=l.deepmerge(t,o.extendedConfiguration)}t.extends&&(t=l.deepmerge(t,c(t.extends)))}),t};t.getConfigurationType=c},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(2),n=i(2);t.minimalConfiguration={version:"0.1",templates:{main:{html:r.defaultTemplate},fillContainer:{html:r.fillContainer,params:{disable:!1}},loadingScreen:{html:r.loadingScreen,params:{backgroundColor:"#000000",loadingImage:n.loading}},viewer:{html:r.defaultViewer},overlay:{html:r.overlay,params:{closeImage:n.close,closeText:"Close"}},error:{html:r.error}},engine:{antialiasing:!0}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.babylonFont=i(31)},function(e,t){e.exports="data:application/font-woff;charset=utf-8;base64,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"},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.babylonLogo=i(33),t.close=i(34),t.fullscreen=i(35),t.helpCircle=i(36),t.loading=i(37)},function(e,t){e.exports="data:image/png;base64,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"},function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAAAt0lEQVR42u2WAQbDQBBFQ9IbRtDcrrqK3LBbXrEH6OuHEPMBjPd2xHyZKtdNpcLMg11Pr7y4/YdvwIdd4jtw4BU0Rjrbz9mNzkjzgpU3wNhCvH5M3i1fKzzeK3K8V+R4r8jxTpHjlULhc0WOd8fU6e4I8y3y13tFjHel4GswwAvFSR/ZN6Zv2gjvmzbGhwqPzxUenys83is8Pld4vFac/9sy8/SVNrbgYJl8WGhsvkpoA1+pVK6ZLyLNXm2txsT5AAAAAElFTkSuQmCC"},function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQAAAAB/ecQqAAAAAnRSTlMAAHaTzTgAAAAeSURBVHgBY6ASsP/A/wcXZQNGhCkyAfE24HUndQAAXlkXcQ24P7gAAAAASUVORK5CYII="},function(e,t){e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAAB/ElEQVR42u3Xs4JdQRzH8X9sqYrNNnbqtPELxKgWD7AsI71B7BcI21W9rNa+d27zjSac/5kzZ2J8yqPfGUn++xMwis2UcpsGuilQoJt6blHCJkbKt2I+FbSRpJVy5kos5nAVQxrDJWbFfP4wXYTqYL9kwRiuk9VFRksYJvKEGA+ZEPb3+udrOcNaJjGJtZyhTo8IKIVaOXmOMfKrrnsCo1WU+HFE/fxu9dk9asR+f8fswnU08fmTuDo8nZarat2P/DjobtFPP3dY8bGi6jNUE/MxuM58vNsFVvfHiHNqleqjmwo0a+zdW3zutr26Dk2ZPqW1oZli7/fzuT57dQqaFmUaZDNZ9HoDYIMbUEoWt+xb69EVuwG3CdfNcvtWNbqbbkB9ePVgK4DFDKGrcwO6CNPHJvvGdGpI0uEGGELk2WGfn8or33OxAUc/TulP8cnHVVENI5Vhp+mIa+TT9tm9pKkN7ab6tHEDRVo3LUGjTxuNpClyAzaRSiwGSbPeDRhJC99Ls7rno5zvpUw0zMMQQV1wdFzmezgvSZhJR1Aj+3QyW5Jx8JsD9okfV74p4ELIceNudMAjRodtfh8T4yETg7fvEf3pAqMlCw7QQah29kl2zOIiedLkOc9MicVcymkhSQtlzJVvxUg2UMxNaunCYOiihpsUsZ6R8t8f4DUz8hFGPnrb0AAAAABJRU5ErkJggg=="},function(e,t){e.exports="data:image/png;base64,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"},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultTemplate=i(39),t.defaultViewer=i(40),t.error=i(41),t.fillContainer=i(42),t.help=i(43),t.loadingScreen=i(44),t.navbar=i(45),t.overlay=i(46),t.share=i(47)},function(e,t){e.exports="<style>@font-face{font-family:babylon;src:url({{babylonFont}}) format('woff');font-weight:400;font-style:normal}.icon{font-family:babylon}</style> {{#if fillScreen}} <style>body,html{width:100%;height:100%;margin:0;padding:0}</style> {{/if}} <fill-container></fill-container>"},function(e,t){e.exports="<style>viewer{position:relative;overflow:hidden;z-index:1;justify-content:center;align-items:center;width:100%;height:100%}.babylonjs-canvas{flex:1;width:100%;height:100%;touch-action:none}</style> <canvas class=babylonjs-canvas touch-action=none> </canvas> <nav-bar></nav-bar>"},function(e,t){e.exports="<style>.narrator-readable-text{border:none;background:0 0;color:inherit;border:none;padding:0;font:inherit;cursor:pointer;outline:inherit}</style> <button class=narrator-readable-text>Error loading the model</button>"},function(e,t){e.exports="<style>fill-container{display:flex}fill-container>*{touch-action:none}</style> {{#unless disable}} <style>fill-container{width:100%;height:100%;justify-content:flex-start;align-items:stretch;align-content:stretch}fill-container>*{flex:1 1 auto;flex-direction:row;justify-content:flex-start;align-items:stretch;align-content:stretch}</style> {{/unless}} <viewer></viewer> <loading-screen></loading-screen> <overlay></overlay>"},function(e,t){e.exports="HELP"},function(e,t){e.exports="<style>loading-screen{position:absolute;left:0;z-index:100;opacity:1;pointer-events:none;display:flex;justify-content:center;align-items:center;-webkit-transition:opacity 1s ease;-moz-transition:opacity 1s ease;transition:opacity 1s ease}img.loading-image{-webkit-animation:spin 2s linear infinite;animation:spin 2s linear infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style> <img class=loading-image src={{loadingImage}}>"},function(e,t){e.exports='<style>nav-bar{position:absolute;height:48px;width:100%;bottom:10px;display:flex;justify-content:center}nav-bar .nav-container{display:flex;flex-direction:row;margin:0 10px;height:100%;width:100%;justify-content:center}nav-bar .animation-control{background-color:rgba(91,93,107,.75);display:flex;flex-direction:row;height:100%;width:100%;max-width:1280px;justify-content:center}nav-bar .flex-container{display:flex;flex-direction:row;justify-content:center;height:100%;width:100%}nav-bar button{background:0 0;border:none;color:#fff;margin:0;padding:0;height:100%;min-width:48px;cursor:pointer}nav-bar button:active,nav-bar button:focus,nav-bar button:hover{background:0 0;border:none;outline:0}nav-bar button:hover{background-color:rgba(22,24,26,.2)}nav-bar .control-text{font-family:"Segoe UI";font-size:12px;font-weight:400;pointer-events:none}nav-bar .icon,nav-bar img{pointer-events:none}.logo-button{display:flex;align-items:center;flex-direction:row;justify-content:center;background-color:rgba(91,93,107,.75);height:48px;min-width:48px;margin-right:4px}.logo-button img{height:20px;width:20px}.types{display:flex;flex-direction:column;width:48px}.speed .flex-container,.types .flex-container{align-items:center}.menu-options{position:absolute;bottom:48px;width:48px;background-color:rgba(22,24,26,.9)}.animation-label,.help,.logo-button,.speed,.types-icon{display:none}.types-icon:after{font-size:16px;content:"\\F6BE"}.up-icon:after{line-height:16px;font-size:12px;content:"\\E70E"}.play-icon:after{font-size:16px;content:"\\E768"}.pause-icon:after{font-size:16px;content:"\\E769"}.fullscreen-icon:after{font-size:16px;content:"\\E740"}viewer.in-fullscreen .fullscreen-icon:after{content:"\\E73F"}.help-icon:after{font-size:16px;content:"\\EF4E"}viewer.in-vr .vr-icon:after{font-size:16px;content:"\\E7F4"}.vr-icon:after{font-size:16px;content:"\\F119"}.progress-control{display:flex;flex:1;position:relative;overflow:hidden;cursor:pointer;align-items:center}.animation-number{margin:0 6px}.speed-text{margin-right:6px}.progress-circle{width:12px;height:12px;border:2px solid #fff;border-radius:50%;background-color:#5b5d6b;cursor:pointer;position:relative;bottom:10px;pointer-events:none}.default-control{display:flex;flex-direction:row;height:100%;background-color:rgba(91,93,107,.75)}.menu-options button{width:100%;height:48px;color:#8e939b}.menu-options button{width:100%;height:48px;color:#8e939b}.menu-options button:hover{background-color:transparent;color:#fff}.menu-options .animation-number{margin:0 18px 0 6px}.menu-options .speed-text{margin-right:18px}.menu-options{visibility:hidden}.open .menu-options{visibility:visible}.types .menu-options{width:144px}.types .menu-options button{padding:0 8px;justify-content:left}.types .menu-options button>*{display:flex;margin:8px}.types .menu-options button span.animation-number{display:none}.fullscreen{display:none}@media screen and (min-width:540px){.help,.speed,.types-icon{display:inline-block}.logo-button{display:flex}.types{width:84px}.progress-bar-container{margin:0 12px}.speed{width:64px}.speed .menu-options{width:64px}.fullscreen{display:block}}@media screen and (min-width:1024px){.animation-label{display:block;margin-left:6px;text-overflow:ellipsis;overflow:hidden}nav-bar button.animation-buttons{padding:0 8px;justify-content:left}.icon.up-icon{margin-left:8px}nav-bar button.animation-buttons>div{display:flex;pointer-events:none}.animation-number{display:none}.progress-bar-container{margin:0 12px}.types{width:144px}}.progress-wrapper{-webkit-appearance:none;cursor:pointer;width:100%;outline:0;margin:0 12px;height:30px;background-color:transparent}.progress-wrapper::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;border:2px solid #fff;border-radius:50%;background:rgba(91,93,107,1);margin-top:-10px}.progress-wrapper::-webkit-slider-runnable-track{height:2px;-webkit-appearance:none;background-color:#fff}.progress-wrapper::-moz-range-progress{background-color:#fff;height:2px}.progress-wrapper::-moz-range-thumb{width:20px;height:20px;border:2px solid #fff;border-radius:50%;background:rgba(91,93,107,1)}.progress-wrapper::-moz-range-track{background:#fff;height:2px}.progress-wrapper::-ms-track{height:2px;background:0 0;border-color:transparent;border-width:10px 0;color:transparent}.progress-wrapper::-ms-fill-lower{background:#fff;border-radius:5px}.progress-wrapper::-ms-fill-upper{background:#fff;border-radius:5px}.progress-wrapper::-ms-thumb{width:16px;height:16px;border:2px solid #fff;border-radius:50%;background:rgba(91,93,107,1);margin-top:0}span{display:inline-block}</style> {{#if (or (not animations) hideAnimations)}} {{#if hideLogo}} <style>nav-bar .nav-container{justify-content:flex-end}</style> {{else}} <style>nav-bar .nav-container{justify-content:space-between}</style> {{/if}} {{/if}} {{#if disableOnFullscreen}} <style>viewer.in-fullscreen nav-bar{display:none}</style> {{/if}} <div class="nav-container navbar-control"> {{#unless hideLogo}} <div class=logo-button title={{logoText}}> {{#if logoLink}} <a href={{logoLink}} target=_blank> <img src={{logoImage}}> </a> {{else}} <img src={{logoImage}}> {{/if}} </div> {{/unless}}{{#unless (or (not animations) hideAnimations)}} <div class=animation-control> <div class=types> <button class="flex-container types-button animation-buttons"> <span class="icon types-icon"></span> <span class="control-text animation-label">{{selectedAnimationName}}</span> <span class="control-text animation-number">{{selectedAnimation}}</span> {{#if (gt (count animations) 1)}} <span class="icon up-icon"></span> {{/if}} </button> <div class=menu-options> {{#each animations}} {{#unless (eq ../selectedAnimation (add @index 1))}} <button class="flex-container label-option-button animation-buttons" data-value="{{this.value}} "> <span class="icon types-icon"></span> <span class="control-text animation-label">{{this.label}}</span> <span class="control-text animation-number">{{add @index 1}}</span> </button> {{/unless}} {{/each}} </div> </div> <div class=progress-control> <button class="play-pause play-pause-button"> {{#if paused}} <span class="icon play-icon"></span> {{else}} <span class="icon pause-icon"></span> {{/if}} </button> <input class=progress-wrapper type=range min=0 max=100 step=0.01> </div> <div class=speed> <button class="flex-container speed-button"> <span class="control-text speed-text">{{selectedSpeed}}</span> <span class="icon up-icon"></span> </button> <div class=menu-options> {{#eachInMap speedList}} {{#unless (eq ../selectedSpeed id)}} <button class="flex-container speed-option-button" data-value={{value}}> <span class="control-text speed-text">{{id}}</span> </button> {{/unless}} {{/eachInMap}} </div> </div> </div> {{/unless}} <div class=default-control> {{#unless hideVr}} <button class="vr vr-button" title="{{text.vrButton}} "> <span class="icon vr-icon"></span> </button> {{/unless}}{{#unless hideHelp}} <button class="help help-button" title="{{text.helpButton}} "> <span class="icon help-icon"></span> </button> {{/unless}} {{#unless hideFullscreen}} <button class="fullscreen fullscreen-button" title="{{text.fullscreenButton}} " name=fullscreenToggle> <span class="icon fullscreen-icon"></span> </button> {{/unless}} </div> </div>'},function(e,t){e.exports="<style>overlay{position:absolute;z-index:99;opacity:0;display:none;justify-content:center;align-items:center;-webkit-transition:opacity 1s ease;-moz-transition:opacity 1s ease;transition:opacity 1s ease}.overlay-item{width:100%;height:100%;display:none;align-items:center;justify-content:center;background-color:rgba(121,121,121,.3)}error.overlay-item{background-color:rgba(121,121,121,1)}div#close-button{position:absolute;top:10px;right:10px;width:30px;height:30px;cursor:pointer}div#close-button img{width:100%}</style> <div id=close-button> <img src={{closeImage}} alt={{closeText}}> </div> <help class=overlay-item></help> <error class=overlay-item></error> <share class=overlay-item></share>"},function(e,t){e.exports="SHARE"},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(2),n=i(2),o=i(2);t.defaultConfiguration={version:"3.2.0-alpha4",templates:{main:{html:r.defaultTemplate,params:{babylonFont:n.babylonFont,noEscape:!0}},fillContainer:{html:r.fillContainer,params:{disable:!1}},loadingScreen:{html:r.loadingScreen,params:{backgroundColor:"#000000",loadingImage:o.loading}},viewer:{html:r.defaultViewer,params:{enableDragAndDrop:!1}},navBar:{html:r.navbar,params:{speedList:{"0.5x":"0.5","1.0x":"1.0","1.5x":"1.5","2.0x":"2.0"},logoImage:o.babylonLogo,logoText:"BabylonJS",logoLink:"https://babylonjs.com",hideHelp:!0,hideHd:!0,hideVr:!0,hidePrint:!0,disableOnFullscreen:!1,text:{hdButton:"Toggle HD",fullscreenButton:"Toggle Fullscreen",helpButton:"Help",vrButton:"Toggle VR",printButton:"3D Print Object"}},events:{click:{".navbar-control":!0},pointerdown:{".help-button":!0},input:{".progress-wrapper":!0},pointerup:{".progress-wrapper":!0}}},overlay:{html:r.overlay,params:{closeImage:o.close,closeText:"Close"}},help:{html:r.help},share:{html:r.share},error:{html:r.error}},camera:{behaviors:{autoRotate:{type:0},framing:{type:2,zoomOnBoundingInfo:!0,zoomStopsAnimation:!1},bouncing:{type:1}}},skybox:{},ground:{receiveShadows:!0},engine:{antialiasing:!0},scene:{}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0);t.extendedConfiguration={version:"3.2.0",extends:"default",camera:{exposure:3.034578,fov:.7853981633974483,contrast:1.6,toneMappingEnabled:!0,upperBetaLimit:1.3962634015954636+Math.PI/2,lowerBetaLimit:Math.PI/2-1.4835298641951802,behaviors:{framing:{type:2,mode:0,positionScale:.5,defaultElevation:.2617993877991494,elevationReturnWaitTime:3e3,elevationReturnTime:2e3,framingTime:500,zoomStopsAnimation:!1,radiusScale:.866},autoRotate:{type:0,idleRotationWaitTime:4e3,idleRotationSpeed:.17453292519943295,idleRotationSpinupTime:2500,zoomStopsAnimation:!1},bouncing:{type:1,lowerRadiusTransitionRange:.05,upperRadiusTransitionRange:-.2}},upperRadiusLimit:5,lowerRadiusLimit:.5,frameOnModelLoad:!0,framingElevation:.2617993877991494,framingRotation:1.5707963267948966,radius:2,alpha:1.5708,beta:.5*Math.PI-.2618,wheelPrecision:300,minZ:.1,maxZ:50,fovMode:0,pinchPrecision:1500,panningSensibility:3e3},lights:{light0:{type:0,frustumEdgeFalloff:0,intensity:7,intensityMode:0,radius:.6,range:4.4,spotAngle:60,diffuse:{r:1,g:1,b:1},position:{x:-2,y:2.5,z:2},target:{x:0,y:0,z:0},enabled:!0,shadowEnabled:!0,shadowBufferSize:512,shadowMinZ:1,shadowMaxZ:10,shadowFieldOfView:60,shadowFrustumSize:2,shadowConfig:{useBlurCloseExponentialShadowMap:!0,useKernelBlur:!0,blurScale:1,bias:.001,depthScale:450,frustumEdgeFalloff:0}},light1:{type:0,frustumEdgeFalloff:0,intensity:7,intensityMode:0,radius:.4,range:5.8,spotAngle:57,diffuse:{r:1,g:1,b:1},position:{x:4,y:3,z:-.5},target:{x:0,y:0,z:0},enabled:!0,shadowEnabled:!1,shadowBufferSize:512,shadowMinZ:.2,shadowMaxZ:10,shadowFieldOfView:28,shadowFrustumSize:2},light2:{type:0,frustumEdgeFalloff:0,intensity:1,intensityMode:0,radius:.5,range:6,spotAngle:42.85,diffuse:{r:.8,g:.8,b:.8},position:{x:-1,y:3,z:-3},target:{x:0,y:0,z:0},enabled:!0,shadowEnabled:!1,shadowBufferSize:512,shadowMinZ:.2,shadowMaxZ:10,shadowFieldOfView:45,shadowFrustumSize:2}},ground:{shadowLevel:.9,texture:"Ground_2.0-1024.png",material:{primaryColorHighlightLevel:.035,primaryColorShadowLevel:0,enableNoise:!0,useRGBColor:!1,maxSimultaneousLights:1,diffuseTexture:{gammaSpace:!0}},opacity:1,mirror:!1,receiveShadows:!0,size:5},skybox:{scale:11,cubeTexture:{url:"Skybox_2.0-256.dds"},material:{primaryColorHighlightLevel:.03,primaryColorShadowLevel:.03,enableNoise:!0,useRGBColor:!1,reflectionTexture:{gammaSpace:!0}}},engine:{renderInBackground:!0},scene:{flags:{shadowsEnabled:!0,particlesEnabled:!1,collisionsEnabled:!1,lightsEnabled:!0,texturesEnabled:!0,lensFlaresEnabled:!1,proceduralTexturesEnabled:!1,renderTargetsEnabled:!0,spritesEnabled:!1,skeletonsEnabled:!0,audioEnabled:!1},defaultMaterial:{materialType:"pbr",reflectivityColor:{r:.1,g:.1,b:.1},microSurface:.6},clearColor:{r:.9,g:.9,b:.9,a:1},imageProcessingConfiguration:{vignetteCentreX:0,vignetteCentreY:0,vignetteColor:{r:.086,g:.184,b:.259,a:1},vignetteWeight:.855,vignetteStretch:.5,vignetteBlendMode:0,vignetteCameraFov:.7853981633974483,isEnabled:!0,colorCurves:{shadowsHue:0,shadowsDensity:0,shadowsSaturation:0,shadowsExposure:0,midtonesHue:0,midtonesDensity:0,midtonesExposure:0,midtonesSaturation:0,highlightsHue:0,highlightsDensity:0,highlightsExposure:0,highlightsSaturation:0}},assetsRootURL:"https://viewer.babylonjs.com/assets/environment/"},loaderPlugins:{extendedMaterial:!0,applyMaterialConfig:!0,msftLod:!0,telemetry:!0},model:{rotationOffsetAxis:{x:0,y:-1,z:0},rotationOffsetAngle:r.Tools.ToRadians(210),material:{directEnabled:!0,directIntensity:.884,emissiveIntensity:1.04,environmentIntensity:.6},entryAnimation:{scaling:{x:0,y:0,z:0},time:.5,easingFunction:4,easingMode:1},exitAnimation:{scaling:{x:0,y:0,z:0},time:.5,easingFunction:4,easingMode:1},normalize:!0,castShadow:!0,receiveShadows:!0},environmentMap:{texture:"EnvMap_3.0-256.env",rotationY:3,tintLevel:.4,mainColor:{r:.8823529411764706,g:.8823529411764706,b:.8823529411764706}},lab:{defaultRenderingPipelines:{bloomEnabled:!0,bloomThreshold:1,fxaaEnabled:!0,bloomWeight:.05}}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.shadowDirectionalLightConfiguration={model:{receiveShadows:!0,castShadow:!0},ground:{receiveShadows:!0},lights:{shadowDirectionalLight:{type:1,shadowEnabled:!0,target:{x:0,y:0,z:.5},position:{x:1.49,y:2.39,z:-1.33},diffuse:{r:.867,g:.816,b:.788},intensity:4.887,intensityMode:0,shadowBufferSize:1024,shadowFrustumSize:6,shadowFieldOfView:50.977,shadowMinZ:.1,shadowMaxZ:10,shadowConfig:{blurKernel:32,useBlurCloseExponentialShadowMap:!0}}}},t.shadowSpotlLightConfiguration={model:{receiveShadows:!0,castShadow:!0},ground:{receiveShadows:!0},lights:{shadowSpotLight:{type:2,intensity:2,shadowEnabled:!0,target:{x:0,y:0,z:.5},position:{x:0,y:3.5,z:3.7},angle:1,shadowOrthoScale:.5,shadowBufferSize:1024,shadowMinZ:.1,shadowMaxZ:50,shadowConfig:{frustumEdgeFalloff:.5,blurKernel:32,useBlurExponentialShadowMap:!0}}}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.environmentMapConfiguration={lab:{assetsRootURL:"/assets/environment/",environmentMap:{texture:"EnvMap_2.0-256.env",rotationY:0,tintLevel:.4}}}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){var t=this;this._animationGroup=e,this._state=0,this._playMode=1,this._animationGroup.onAnimationEndObservable.add(function(){t.stop(),t._state=4})}return Object.defineProperty(e.prototype,"name",{get:function(){return this._animationGroup.name},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._animationGroup.speedRatio},set:function(e){this._animationGroup.speedRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frames",{get:function(){return this._animationGroup.to-this._animationGroup.from},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._animationGroup.targetedAnimations[0]&&this._animationGroup.targetedAnimations[0].animation.runtimeAnimations[0]?this._animationGroup.targetedAnimations[0].animation.runtimeAnimations[0].currentFrame-this._animationGroup.from:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fps",{get:function(){for(var e=0;e<this._animationGroup.animatables.length;++e){var t=this._animationGroup.animatables[e].getAnimations();if(t&&t.length)for(var i=0;i<t.length;++i)if(t[i].animation&&t[i].animation.framePerSecond)return t[i].animation.framePerSecond}return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"playMode",{get:function(){return this._playMode},set:function(e){e!==this._playMode&&(this._playMode=e,1===this.state?this._animationGroup.play(1===this._playMode):(this._animationGroup.reset(),this._state=0))},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._animationGroup.reset()},e.prototype.restart=function(){2===this.state?this._animationGroup.restart():this.start()},e.prototype.goToFrame=function(e){this._animationGroup.goToFrame(e+this._animationGroup.from)},e.prototype.start=function(){this._animationGroup.start(1===this.playMode,this.speedRatio),this._animationGroup.isStarted&&(this._state=1)},e.prototype.pause=function(){this._animationGroup.pause(),this._state=2},e.prototype.stop=function(){this._animationGroup.stop(),this._animationGroup.isStarted||(this._state=3)},e.prototype.dispose=function(){this._animationGroup.dispose()},e}();t.GroupModelAnimation=r},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(54);t.TelemetryLoaderPlugin=r.TelemetryLoaderPlugin;var n=i(55);t.MSFTLodLoaderPlugin=n.MSFTLodLoaderPlugin;var o=i(56);t.ApplyMaterialConfigPlugin=o.ApplyMaterialConfigPlugin;var s=i(57);t.ExtendedMaterialLoaderPlugin=s.ExtendedMaterialLoaderPlugin;var a=i(0),l={};t.getLoaderPluginByName=function(e){if(!l[e])switch(e){case"telemetry":l[e]=new r.TelemetryLoaderPlugin;break;case"msftLod":l[e]=new n.MSFTLodLoaderPlugin;break;case"applyMaterialConfig":l[e]=new o.ApplyMaterialConfigPlugin;break;case"extendedMaterial":l[e]=new s.ExtendedMaterialLoaderPlugin}return l[e]},t.addLoaderPlugin=function(e,t){l[e]&&a.Tools.Warn("Overwriting plugin with the same name - "+e),l[e]=t}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(6),n=i(0),o=function(){function e(){}return e.prototype.onInit=function(e,t){this._model=t,this._loadStart=n.Tools.Now},e.prototype.onLoaded=function(e){r.telemetryManager.broadcast("Model Loaded",e.getViewerId(),{model:e,loadTime:n.Tools.Now-this._loadStart}),r.telemetryManager.flushWebGLErrors(e.rootMesh.getEngine(),e.getViewerId())},e.prototype.onError=function(e,t){this._loadEnd=n.Tools.Now,r.telemetryManager.broadcast("Load Error",this._model.getViewerId(),{model:this._model,loadTime:this._loadEnd-this._loadStart}),r.telemetryManager.flushWebGLErrors(this._model.rootMesh.getEngine(),this._model.getViewerId())},e.prototype.onComplete=function(){this._loadEnd=n.Tools.Now,r.telemetryManager.broadcast("Load Complete",this._model.getViewerId(),{model:this._model,loadTime:this._loadEnd-this._loadStart}),r.telemetryManager.flushWebGLErrors(this._model.rootMesh.getEngine(),this._model.getViewerId())},e}();t.TelemetryLoaderPlugin=o},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.prototype.onInit=function(e,t){this._model=t},e.prototype.onExtensionLoaded=function(e){if("MSFT_lod"===e.name&&this._model.configuration.loaderConfiguration){var t=e;t.enabled=!!this._model.configuration.loaderConfiguration.progressiveLoading,t.maxLODsToLoad=this._model.configuration.loaderConfiguration.maxLODsToLoad||Number.MAX_VALUE}},e}();t.MSFTLodLoaderPlugin=r},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.prototype.onInit=function(e,t){this._model=t},e.prototype.onMaterialLoaded=function(e){this._model&&this._model._applyModelMaterialConfiguration(e)},e}();t.ApplyMaterialConfigPlugin=r},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(){}return e.prototype.onMaterialLoaded=function(e){e.alphaMode=r.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF},e}();t.ExtendedMaterialLoaderPlugin=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=function(){function e(){this.onSceneInitObservable=new r.Observable,this.onEngineInitObservable=new r.Observable,this.onModelLoadedObservable=new r.Observable,this.onModelLoadProgressObservable=new r.Observable,this.onModelLoadErrorObservable=new r.Observable,this.onModelAddedObservable=new r.Observable,this.onModelRemovedObservable=new r.Observable,this.onViewerInitDoneObservable=new r.Observable,this.onViewerInitStartedObservable=new r.Observable,this.onLoaderInitObservable=new r.Observable,this.onFrameRenderedObservable=new r.Observable,this.onEnteringVRObservable=new r.Observable,this.onExitingVRObservable=new r.Observable}return e.prototype.dispose=function(){this.onSceneInitObservable.clear(),this.onEngineInitObservable.clear(),this.onModelLoadedObservable.clear(),this.onModelLoadProgressObservable.clear(),this.onModelLoadErrorObservable.clear(),this.onModelAddedObservable.clear(),this.onModelRemovedObservable.clear(),this.onViewerInitDoneObservable.clear(),this.onLoaderInitObservable.clear(),this.onFrameRenderedObservable.clear(),this.onEnteringVRObservable.clear(),this.onExitingVRObservable.clear()},e}();t.ObservablesManager=n},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(15),o=i(5),s=i(1),a=i(60),l=i(17),c=i(1),u=function(){function e(e,t,i){var n=this;this._engine=e,this._configurationContainer=t,this._observablesManager=i,this._animationBlendingEnabled=!0,this._white=r.Color3.White(),this._forceShadowUpdate=!1,this._processShadows=!0,this._groundEnabled=!0,this._groundMirrorEnabled=!0,this._defaultRenderingPipelineEnabled=!1,this._globalConfiguration={},this._defaultRenderingPipelineShouldBuild=!0,this._bloomEnabled=!1,this._fxaaEnabled=!1,this._focusOnModel=function(e){var t=e.rootMesh.getHierarchyBoundingVectors(!0),i=t.max.subtract(t.min),r=i.scale(.5),o=t.min.add(r);n.camera.setTarget(o),n.camera.alpha=n._globalConfiguration.camera&&n._globalConfiguration.camera.alpha||n.camera.alpha,n.camera.beta=n._globalConfiguration.camera&&n._globalConfiguration.camera.beta||n.camera.beta,n.camera.radius=n._globalConfiguration.camera&&n._globalConfiguration.camera.radius||n.camera.radius;var s=i.length();isFinite(s)&&(n.camera.upperRadiusLimit=4*s),n._configurationContainer.configuration&&n._configureEnvironment(n._configurationContainer.configuration.skybox,n._configurationContainer.configuration.ground)},this._cameraBehaviorMapping={},this.models=[],this.onCameraConfiguredObservable=new r.Observable,this.onLightsConfiguredObservable=new r.Observable,this.onModelsConfiguredObservable=new r.Observable,this.onSceneConfiguredObservable=new r.Observable,this.onSceneInitObservable=new r.Observable,this.onSceneOptimizerConfiguredObservable=new r.Observable,this.onEnvironmentConfiguredObservable=new r.Observable,this.onVRConfiguredObservable=new r.Observable,this._handleHardwareLimitations(),this.onSceneInitObservable.add(function(e){n.scene.animationPropertiesOverride=n.scene.animationPropertiesOverride||new r.AnimationPropertiesOverride,n.labs=new a.ViewerLabs(e);var t=function(){for(var e=0,t=n.scene.lights;e<t.length;e++){var i=t[e].getShadowGenerator();if(i){var o=i.getShadowMap();o&&(o.refreshRate=r.RenderTargetTexture.REFRESHRATE_RENDER_ONCE)}}};return e.registerBeforeRender(function(){n._forceShadowUpdate||e.animatables&&e.animatables.length>0?(t(),n._forceShadowUpdate=!1):n.models.every(function(e){return e.shadowsRenderedAfterLoad?e.state===o.ModelState.COMPLETE&&!e.currentAnimation:(e.shadowsRenderedAfterLoad=!0,!1)})||t()}),n._observablesManager&&n._observablesManager.onSceneInitObservable.notifyObserversWithPromise(n.scene)}),this._observablesManager&&(this._observablesManager.onModelLoadedObservable.add(function(e){for(var t=0,i=n.scene.lights;t<i.length;t++){var o=i[t].getShadowGenerator();if(o){var s=o.getShadowMap();s&&(s.refreshRate=r.RenderTargetTexture.REFRESHRATE_RENDER_ONCE)}}n._focusOnModel(e)}),this._observablesManager.onModelAddedObservable.add(function(e){n.models.push(e)}),this._observablesManager.onModelRemovedObservable.add(function(e){n.models.splice(n.models.indexOf(e),1)}))}return Object.defineProperty(e.prototype,"defaultRenderingPipeline",{get:function(){return this._defaultRenderingPipeline},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrHelper",{get:function(){return this._vrHelper},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isHdrSupported",{get:function(){return this._hdrSupport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mainColor",{get:function(){return this._configurationContainer.mainColor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reflectionColor",{get:function(){return this._configurationContainer.reflectionColor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationBlendingEnabled",{get:function(){return this.scene&&this.scene.animationPropertiesOverride.enableBlending},set:function(e){this.scene.animationPropertiesOverride.enableBlending=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"observablesManager",{get:function(){return this._observablesManager},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"processShadows",{get:function(){return this._processShadows},set:function(e){for(var t=e?r.RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME:r.RenderTargetTexture.REFRESHRATE_RENDER_ONCE,i=0,n=this.scene.lights;i<n.length;i++){var o=n[i].getShadowGenerator();if(o){var s=o.getShadowMap();s&&(s.refreshRate=t)}}this._processShadows=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundEnabled",{get:function(){return this._groundEnabled},set:function(e){e!==this._groundEnabled&&(this._groundEnabled=e,this.environmentHelper&&this.environmentHelper.ground&&this.environmentHelper.ground.setEnabled(this._groundEnabled))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorEnabled",{get:function(){return this._groundMirrorEnabled},set:function(e){this._groundMirrorEnabled!==e&&(this._groundMirrorEnabled=e,this.environmentHelper&&this.environmentHelper.groundMaterial&&this.environmentHelper.groundMirror&&(this.environmentHelper.groundMaterial.reflectionTexture=e?this.environmentHelper.groundMirror:null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultRenderingPipelineEnabled",{get:function(){return this._defaultRenderingPipelineEnabled},set:function(e){e!==this._defaultRenderingPipelineEnabled&&(this._defaultRenderingPipelineEnabled=e,this._rebuildPostprocesses(),this._defaultRenderingPipeline&&(this._defaultRenderingPipelineShouldBuild=!1,this._defaultRenderingPipeline.prepare(),this.scene.imageProcessingConfiguration.applyByPostProcess=!0))},enumerable:!0,configurable:!0}),e.prototype.unlockBabylonFeatures=function(){this.scene.shadowsEnabled=!0,this.scene.particlesEnabled=!0,this.scene.postProcessesEnabled=!0,this.scene.collisionsEnabled=!0,this.scene.lightsEnabled=!0,this.scene.texturesEnabled=!0,this.scene.lensFlaresEnabled=!0,this.scene.proceduralTexturesEnabled=!0,this.scene.renderTargetsEnabled=!0,this.scene.spritesEnabled=!0,this.scene.skeletonsEnabled=!0,this.scene.audioEnabled=!0},e.prototype.initScene=function(e,t){if(void 0===e&&(e={}),this.scene&&this.scene.dispose(),this.scene=new r.Scene(this._engine),this._configurationContainer.scene=this.scene,!e.defaultMaterial){var i=new BABYLON.PBRMaterial("defaultMaterial",this.scene);i.reflectivityColor=new BABYLON.Color3(.1,.1,.1),i.microSurface=.6,this.scene.defaultMaterial&&this.scene.defaultMaterial.dispose(),this.scene.defaultMaterial=i}return this.scene.animationPropertiesOverride=new r.AnimationPropertiesOverride,r.Animation.AllowMatricesInterpolation=!0,this.onSceneInitObservable.notifyObserversWithPromise(this.scene)},e.prototype.clearScene=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!1),e&&(this.models.forEach(function(e){return e.dispose()}),this.models.length=0),t&&this.scene.lights.forEach(function(e){return e.dispose()})},e.prototype.updateConfiguration=function(e){var t=this;if(this._configurationContainer?this._globalConfiguration=this._configurationContainer.configuration:this._globalConfiguration=e,e.scene&&this._configureScene(e.scene),void 0!==e.optimizer&&this._configureOptimizer(e.optimizer),this._configureLights(e.lights),void 0===e.skybox&&void 0===e.ground||this._configureEnvironment(e.skybox,e.ground),this._configureCamera(e.camera),void 0!==e.environmentMap&&this._configureEnvironmentMap(e.environmentMap),void 0!==e.vr&&this._configureVR(e.vr),e.lab){if(e.lab.defaultRenderingPipelines){var i=e.lab.defaultRenderingPipelines;this.defaultRenderingPipelineEnabled="boolean"!=typeof i||i}if(this.environmentHelper&&e.lab.environmentMainColor){var n=(new r.Color3).copyFrom(e.lab.environmentMainColor);this.environmentHelper.setMainColor(n)}void 0!==e.lab.globalLightRotation&&(this.scene.lights.filter(function(e){return e instanceof r.ShadowLight}).forEach(function(i){t.labs.rotateShadowLight(i,e.lab.globalLightRotation)}),this._forceShadowUpdate=!0)}this._defaultRenderingPipeline&&this._defaultRenderingPipeline.imageProcessing&&(this._defaultRenderingPipeline.imageProcessing.fromLinearSpace=!0),this._defaultRenderingPipelineShouldBuild&&this._defaultRenderingPipeline&&(this._defaultRenderingPipelineShouldBuild=!1,this._defaultRenderingPipeline.prepare())},e.prototype._rebuildPostprocesses=function(e){if(this._defaultRenderingPipelineEnabled&&n.getConfigurationKey("scene.imageProcessingConfiguration.isEnabled",this._globalConfiguration)){var t=e||this._globalConfiguration.lab&&this._globalConfiguration.lab.defaultRenderingPipelines;if(t){this._defaultRenderingPipeline||(this._defaultRenderingPipeline=new r.DefaultRenderingPipeline("default rendering pipeline",this._hdrSupport,this.scene,[this.camera],!1)),this.scene.autoClear=!1,this.scene.autoClearDepthAndStencil=!1,this._defaultRenderingPipelineShouldBuild=!0;var i=this._bloomEnabled;"boolean"!=typeof t&&(s.extendClassWithConfig(this._defaultRenderingPipeline,t),this._bloomEnabled=!!t.bloomEnabled,this._fxaaEnabled=!!t.fxaaEnabled,i=this._bloomEnabled&&void 0!==t.bloomWeight&&t.bloomWeight>0,this._defaultRenderingPipeline.bloomWeight=void 0!==t.bloomWeight&&t.bloomWeight||this._defaultRenderingPipeline.bloomWeight),this._defaultRenderingPipeline.bloomEnabled=i,this._defaultRenderingPipeline.fxaaEnabled=this.fxaaEnabled}}else this._defaultRenderingPipeline&&(this._defaultRenderingPipeline.dispose(),this._defaultRenderingPipeline=null,this.scene.autoClearDepthAndStencil=!0,this.scene.autoClear=!0,this.scene.imageProcessingConfiguration.applyByPostProcess=!1)},Object.defineProperty(e.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._rebuildPostprocesses(),this._defaultRenderingPipeline&&(this._defaultRenderingPipelineShouldBuild=!1,this._defaultRenderingPipeline.prepare(),this.scene.imageProcessingConfiguration.applyByPostProcess=!0))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._rebuildPostprocesses(),this._defaultRenderingPipeline&&(this._defaultRenderingPipelineShouldBuild=!1,this._defaultRenderingPipeline.prepare(),this.scene.imageProcessingConfiguration.applyByPostProcess=!0))},enumerable:!0,configurable:!0}),e.prototype._configureScene=function(e){if(this.scene){var t=e.clearColor,i=this.scene.clearColor;if(t&&(void 0!==t.r&&(i.r=t.r),void 0!==t.g&&(i.g=t.g),void 0!==t.b&&(i.b=t.b),void 0!==t.a&&(i.a=t.a)),e.assetsRootURL&&(this._assetsRootURL=e.assetsRootURL),e.imageProcessingConfiguration&&s.extendClassWithConfig(this.scene.imageProcessingConfiguration,e.imageProcessingConfiguration),e.animationPropertiesOverride&&s.extendClassWithConfig(this.scene.animationPropertiesOverride,e.animationPropertiesOverride),e.environmentTexture&&(!this.scene.environmentTexture||this.scene.environmentTexture.url!==e.environmentTexture)){this.scene.environmentTexture&&this.scene.environmentTexture.dispose&&this.scene.environmentTexture.dispose();var n=r.CubeTexture.CreateFromPrefilteredData(e.environmentTexture,this.scene);this.scene.environmentTexture=n}!0===e.debug?this.scene.debugLayer.show():!1===e.debug&&this.scene.debugLayer.isVisible()&&this.scene.debugLayer.hide(),e.disableHdr?this._handleHardwareLimitations(!1):this._handleHardwareLimitations(!0),void 0!==e.renderInBackground&&(this._engine.renderEvenInBackground=!!e.renderInBackground);var o=this._engine.getRenderingCanvas();if(o&&(this.camera&&e.disableCameraControl?this.camera.detachControl(o):this.camera&&!1===e.disableCameraControl&&this.camera.attachControl(o)),e.defaultMaterial){var a=e.defaultMaterial;("standard"===a.materialType&&"StandardMaterial"!==this.scene.defaultMaterial.getClassName()||"pbr"===a.materialType&&"PBRMaterial"!==this.scene.defaultMaterial.getClassName())&&(this.scene.defaultMaterial.dispose(),"standard"===a.materialType?this.scene.defaultMaterial=new r.StandardMaterial("defaultMaterial",this.scene):this.scene.defaultMaterial=new r.PBRMaterial("defaultMaterial",this.scene)),s.extendClassWithConfig(this.scene.defaultMaterial,a)}e.flags&&s.extendClassWithConfig(this.scene,e.flags),this.onSceneConfiguredObservable.notifyObservers({sceneManager:this,object:this.scene,newConfiguration:e})}},e.prototype._configureOptimizer=function(e){var t=this;if("boolean"==typeof e)this.sceneOptimizer&&(this.sceneOptimizer.stop(),this.sceneOptimizer.dispose(),delete this.sceneOptimizer),e&&(this.sceneOptimizer=new r.SceneOptimizer(this.scene),this.sceneOptimizer.start());else{var i=new r.SceneOptimizerOptions(e.targetFrameRate,e.trackerDuration);if(e.degradation)switch(e.degradation){case"low":i=r.SceneOptimizerOptions.LowDegradationAllowed(e.targetFrameRate);break;case"moderate":i=r.SceneOptimizerOptions.ModerateDegradationAllowed(e.targetFrameRate);break;case"hight":i=r.SceneOptimizerOptions.HighDegradationAllowed(e.targetFrameRate)}if(this.sceneOptimizer&&(this.sceneOptimizer.stop(),this.sceneOptimizer.dispose()),e.custom){var n=l.getCustomOptimizerByName(e.custom,e.improvementMode);n&&i.addCustomOptimization(function(){return n(t)},function(){return"Babylon Viewer "+e.custom+" custom optimization"})}this.sceneOptimizer=new r.SceneOptimizer(this.scene,i,e.autoGeneratePriorities,e.improvementMode),this.sceneOptimizer.start()}this.onSceneOptimizerConfiguredObservable.notifyObservers({sceneManager:this,object:this.sceneOptimizer,newConfiguration:e})},e.prototype._configureVR=function(e){var t=this;if(e.disabled)this._vrHelper&&(this._vrHelper.isInVRMode&&this._vrHelper.exitVR(),this._vrHelper.dispose(),this._vrHelper=void 0);else{var i,n=c.deepmerge({useCustomVRButton:!0,createDeviceOrientationCamera:!1,trackPosition:!0},e.vrOptions||{});if(this._vrHelper=this.scene.createDefaultVRExperience(n),e.disableInteractions||this._vrHelper.enableInteractions(),!e.disableTeleportation){var o=e.overrideFloorMeshName||"BackgroundPlane";this._vrHelper.enableTeleportation({floorMeshName:o})}if(e.rotateUsingControllers)this._vrHelper.onControllerMeshLoadedObservable.add(function(e){e.onTriggerStateChangedObservable.add(function(n){e.mesh&&e.mesh.rotationQuaternion&&(n.pressed?i||(t.models[0].rootMesh.rotationQuaternion=t.models[0].rootMesh.rotationQuaternion||new r.Quaternion,i=e.mesh.rotationQuaternion.conjugate().multiply(t.models[0].rootMesh.rotationQuaternion)):i=null)}),t.scene.registerBeforeRender(function(){t.models[0]&&(i&&e.mesh&&e.mesh.rotationQuaternion?t.models[0].rootMesh.rotationQuaternion.copyFrom(e.mesh.rotationQuaternion).multiplyInPlace(i):t.models[0].rootMesh.rotationQuaternion=null)})});this._vrHelper.onEnteringVRObservable.add(function(){t._observablesManager&&t._observablesManager.onEnteringVRObservable.notifyObservers(t)}),this._vrHelper.onExitingVRObservable.add(function(){t._observablesManager&&t._observablesManager.onExitingVRObservable.notifyObservers(t)}),this.onVRConfiguredObservable.notifyObservers({sceneManager:this,object:this._vrHelper,newConfiguration:e})}},e.prototype._configureEnvironmentMap=function(e){if(e.texture&&(this.scene.environmentTexture=new BABYLON.CubeTexture(this._getAssetUrl(e.texture),this.scene)),this.scene.environmentTexture){var t=r.Quaternion.RotationAxis(r.Axis.Y,e.rotationY||0);r.Matrix.FromQuaternionToRef(t,this.scene.environmentTexture.getReflectionTextureMatrix())}if(e.mainColor){this._configurationContainer.mainColor=this.mainColor||r.Color3.White();var i=e.mainColor;void 0!==i.r&&(this.mainColor.r=i.r),void 0!==i.g&&(this.mainColor.g=i.g),void 0!==i.b&&(this.mainColor.b=i.b),this.reflectionColor.copyFrom(this.mainColor);var o=n.getConfigurationKey("environmentMap.tintLevel",this._globalConfiguration)||0;this.reflectionColor.toLinearSpaceToRef(this.reflectionColor),this.reflectionColor.scaleToRef(1/this.scene.imageProcessingConfiguration.exposure,this.reflectionColor);var s=r.Color3.Lerp(this._white,this.reflectionColor,o);this.reflectionColor.copyFrom(s),this.environmentHelper&&(this.environmentHelper.groundMaterial&&(this.environmentHelper.groundMaterial._perceptualColor=this.mainColor),this.environmentHelper.skyboxMaterial&&(this.environmentHelper.skyboxMaterial._perceptualColor=this.mainColor))}},e.prototype._configureCamera=function(e){var t=this;if(void 0===e&&(e={}),!this.scene.activeCamera){var i=!0;this._globalConfiguration.scene&&this._globalConfiguration.scene.disableCameraControl&&(i=!1),this.scene.createDefaultCamera(!0,!0,i),this.camera=this.scene.activeCamera,this.camera.setTarget(r.Vector3.Zero())}if(this.camera||(this.camera=this.scene.activeCamera),e.position){var o=this.camera.position.clone();s.extendClassWithConfig(o,e.position),this.camera.setPosition(o)}if(e.target){var a=this.camera.target.clone();s.extendClassWithConfig(a,e.target),this.camera.setTarget(a)}if(e.rotation&&(this.camera.rotationQuaternion=new r.Quaternion(e.rotation.x||0,e.rotation.y||0,e.rotation.z||0,e.rotation.w||0)),e.behaviors)for(var l in e.behaviors)void 0!==e.behaviors[l]&&this._setCameraBehavior(l,e.behaviors[l]);var c=this.scene.getWorldExtends(function(e){return!t.environmentHelper||e!==t.environmentHelper.ground&&e!==t.environmentHelper.rootMesh&&e!==t.environmentHelper.skybox}),u=c.max.subtract(c.min).length();isFinite(u)&&(this.camera.upperRadiusLimit=4*u),this.scene.imageProcessingConfiguration&&(this.scene.imageProcessingConfiguration.colorCurvesEnabled=!0,this.scene.imageProcessingConfiguration.vignetteEnabled=!0,this.scene.imageProcessingConfiguration.toneMappingEnabled=!!n.getConfigurationKey("camera.toneMappingEnabled",this._globalConfiguration)),s.extendClassWithConfig(this.camera,e),this.onCameraConfiguredObservable.notifyObservers({sceneManager:this,object:this.camera,newConfiguration:e})},e.prototype._configureEnvironment=function(e,t){var i=this;if(e||t){var n={createGround:!!t&&this._groundEnabled,createSkybox:!!e,setupImageProcessing:!1};if(t){var o="boolean"==typeof t?{}:t,a=o.size||"object"==typeof e&&e.scale;a&&(n.groundSize=a),n.enableGroundShadow=!0===o||o.receiveShadows,void 0!==o.shadowLevel&&(n.groundShadowLevel=o.shadowLevel),n.enableGroundMirror=!!o.mirror&&this.groundMirrorEnabled,o.texture&&(n.groundTexture=this._getAssetUrl(o.texture)),o.color&&(n.groundColor=new r.Color3(o.color.r,o.color.g,o.color.b)),void 0!==o.opacity&&(n.groundOpacity=o.opacity),o.mirror&&(n.enableGroundMirror=!0,"object"==typeof o.mirror&&(void 0!==o.mirror.amount&&(n.groundMirrorAmount=o.mirror.amount),void 0!==o.mirror.sizeRatio&&(n.groundMirrorSizeRatio=o.mirror.sizeRatio),void 0!==o.mirror.blurKernel&&(n.groundMirrorBlurKernel=o.mirror.blurKernel),void 0!==o.mirror.fresnelWeight&&(n.groundMirrorFresnelWeight=o.mirror.fresnelWeight),void 0!==o.mirror.fallOffDistance&&(n.groundMirrorFallOffDistance=o.mirror.fallOffDistance),void 0!==this._defaultPipelineTextureType&&(n.groundMirrorTextureType=this._defaultPipelineTextureType)))}var l=!1;if(e){var c=!0===e?{}:e;c.material&&c.material.imageProcessingConfiguration&&(n.setupImageProcessing=!1);var u=c.scale;u&&(n.skyboxSize=u),n.sizeAuto=!n.skyboxSize,c.color&&(n.skyboxColor=new r.Color3(c.color.r,c.color.g,c.color.b)),c.cubeTexture&&c.cubeTexture.url&&("string"==typeof c.cubeTexture.url?n.skyboxTexture=this._getAssetUrl(c.cubeTexture.url):l=!0),c.material&&(l=!0)}if(n.setupImageProcessing=!1,this.environmentHelper)this.environmentHelper.rootMesh.getScene()!==this.scene?(this.environmentHelper.dispose(),this.environmentHelper=this.scene.createDefaultEnvironment(n)):(this.environmentHelper.ground&&this.environmentHelper.ground.dispose(),this.environmentHelper.skybox&&this.environmentHelper.skybox.dispose(),this.environmentHelper.updateOptions(n));else this.environmentHelper=this.scene.createDefaultEnvironment(n);this.environmentHelper.rootMesh&&this._globalConfiguration.scene&&void 0!==this._globalConfiguration.scene.environmentRotationY&&(this.environmentHelper.rootMesh.rotation.y=this._globalConfiguration.scene.environmentRotationY);var h="boolean"==typeof t?{}:t;if(this.environmentHelper.groundMaterial&&h&&(this.environmentHelper.groundMaterial._perceptualColor=this.mainColor,h.material&&s.extendClassWithConfig(this.environmentHelper.groundMaterial,h.material),this.environmentHelper.groundMirror)){var d=this.environmentHelper.groundMaterial._perceptualColor.toLinearSpace(),f=Math.pow(2,-this.scene.imageProcessingConfiguration.exposure)*Math.PI;d.scaleToRef(1/f,d),this.environmentHelper.groundMirror.clearColor.r=r.Scalar.Clamp(d.r),this.environmentHelper.groundMirror.clearColor.g=r.Scalar.Clamp(d.g),this.environmentHelper.groundMirror.clearColor.b=r.Scalar.Clamp(d.b),this.environmentHelper.groundMirror.clearColor.a=1,this.groundMirrorEnabled||(this.environmentHelper.groundMaterial.reflectionTexture=null)}var p=this.environmentHelper.skyboxMaterial;p&&(p._perceptualColor=this.mainColor,l&&"object"==typeof e&&e.material&&s.extendClassWithConfig(p,e.material))}else this.environmentHelper&&(this.environmentHelper.dispose(),this.environmentHelper=void 0);this._observablesManager&&this._observablesManager.onModelLoadedObservable.add(function(e){i._updateGroundMirrorRenderList(e)}),this.onEnvironmentConfiguredObservable.notifyObservers({sceneManager:this,object:this.environmentHelper,newConfiguration:{skybox:e,ground:t}})},e.prototype._configureLights=function(e){var t=this;void 0===e&&(e={});var i=Object.keys(e).filter(function(e){return"globalRotation"!==e});if(i.length){var n=this.scene.lights.map(function(e){return e.name}),o=Object.keys(this._globalConfiguration.lights||[]);Object.keys(o).length!==n.length&&n.forEach(function(e){-1===o.indexOf(e)&&t.scene.getLightByName(e).dispose()}),i.forEach(function(i,o){var a,l={type:0};if("object"==typeof e[i]&&(l=e[i]),"number"==typeof e[i]&&(l.type=e[i]),l.name=i,-1===n.indexOf(i)){if(!(c=r.Light.GetConstructorFromName(l.type,l.name,t.scene)))return;a=c()}else if(a=t.scene.getLightByName(i),"boolean"==typeof e[i]&&(l.type=a.getTypeID()),n=n.filter(function(e){return e!==i}),void 0!==l.type&&a.getTypeID()!==l.type){var c;if(a.dispose(),!(c=r.Light.GetConstructorFromName(l.type,l.name,t.scene)))return;a=c()}if(!1!==e[i]){var u=void 0!==l.enabled?l.enabled:!l.disabled;if(a.setEnabled(u),s.extendClassWithConfig(a,l),a instanceof r.ShadowLight){if(a.shadowMinZ=a.shadowMinZ||.2,a.shadowMaxZ=Math.min(10,a.shadowMaxZ||10),l.target){if(a.setDirectionToTarget){var h=r.Vector3.Zero().copyFrom(l.target);a.setDirectionToTarget(h)}}else if(l.direction){var d=r.Vector3.Zero().copyFrom(l.direction);a.direction=d}var f=!1;if(a.getTypeID()===BABYLON.Light.LIGHTTYPEID_DIRECTIONALLIGHT)a.shadowFrustumSize=l.shadowFrustumSize||2,f=!0;else if(a.getTypeID()===BABYLON.Light.LIGHTTYPEID_SPOTLIGHT){var p=a;void 0!==l.spotAngle&&(p.angle=l.spotAngle*Math.PI/180),p.angle&&l.shadowFieldOfView&&(p.shadowAngleScale=l.shadowFieldOfView/p.angle),f=!0}else a.getTypeID()===BABYLON.Light.LIGHTTYPEID_POINTLIGHT&&(l.shadowFieldOfView&&(a.shadowAngle=l.shadowFieldOfView*Math.PI/180),f=!0);var m=a.getShadowGenerator();if(f&&l.shadowEnabled&&t._maxShadows){var g=l.shadowBufferSize||256;m||(m=new r.ShadowGenerator(g,a));var _=t.getBlurKernel(a,g);m.bias=t._shadowGeneratorBias,m.blurKernel=_,s.extendClassWithConfig(m,l.shadowConfig||{}),t._observablesManager&&t._observablesManager.onModelLoadedObservable.add(function(e){t._updateShadowRenderList(m,e)}),t._updateShadowRenderList(m)}else m&&m.dispose()}}else a.dispose()});var a=this._globalConfiguration.lights||{};Object.keys(a).sort().forEach(function(e,i){a[e];var r=t.scene.getLightByName(e);r&&(r.renderPriority=-i)})}else this.scene.lights.length||this.scene.createDefaultLight(!0);this.onLightsConfiguredObservable.notifyObservers({sceneManager:this,object:this.scene.lights,newConfiguration:e})},e.prototype._updateShadowRenderList=function(e,t,i){var n=t?t.meshes:this.scene.meshes,o=e.getShadowMap();if(o){i&&o.renderList?o.renderList.length=0:o.renderList=o.renderList||[];for(var s=0;s<n.length;s++){var a=n[s];r.Tags.MatchesQuery(a,"castShadow")&&-1===o.renderList.indexOf(a)&&o.renderList.push(a)}if(this._shadowGroundPlane)e.useBlurCloseExponentialShadowMap||(this._shadowGroundPlane.dispose(),this._shadowGroundPlane=null);else if(e.useBlurCloseExponentialShadowMap){var l=r.Mesh.CreatePlane("shadowGroundPlane",100,this.scene,!1);l.useVertexColors=!1,l.material=new r.StandardMaterial("shadowGroundPlaneMaterial",this.scene),l.material.backFaceCulling=!1,l.rotation.x=.5*Math.PI,l.freezeWorldMatrix(),this._shadowGroundPlane=l,this.scene.removeMesh(l)}this._shadowGroundPlane&&-1===o.renderList.indexOf(this._shadowGroundPlane)&&o.renderList.push(this._shadowGroundPlane)}},e.prototype._updateGroundMirrorRenderList=function(e,t){if(this.environmentHelper&&this.environmentHelper.groundMirror&&this.environmentHelper.groundMirror.renderList){var i=e?e.meshes:this.scene.meshes,r=this.environmentHelper.groundMirror.renderList;t&&(r.length=0);for(var n=0;n<i.length;n++){var o=i[n];-1===r.indexOf(o)&&r.push(o)}}},e.prototype.getBlurKernel=function(e,t){var i=.05;e.getTypeID()===BABYLON.Light.LIGHTTYPEID_DIRECTIONALLIGHT?i/=e.shadowFrustumSize:e.getTypeID()===BABYLON.Light.LIGHTTYPEID_POINTLIGHT?i/=e.shadowAngle:e.getTypeID()===BABYLON.Light.LIGHTTYPEID_SPOTLIGHT&&(i/=e.angle*e.shadowAngleScale);var r=5/(t/256);return Math.max(t*i,r)},e.prototype._handleHardwareLimitations=function(e){void 0===e&&(e=!0);var t=this._engine.getCaps().maxVaryingVectors,i=this._engine.getCaps().maxTexturesImageUnits;this._maxShadows=t<8||i<8?0:3;var n=this._engine.getCaps(),o=n.textureHalfFloatRender&&n.textureHalfFloatLinearFiltering,s=n.textureFloatRender&&n.textureFloatLinearFiltering;this._hdrSupport=e&&!(!s&&!o),o?(this._defaultHighpTextureType=r.Engine.TEXTURETYPE_HALF_FLOAT,this._shadowGeneratorBias=.002):s?(this._defaultHighpTextureType=r.Engine.TEXTURETYPE_FLOAT,this._shadowGeneratorBias=.001):(this._defaultHighpTextureType=r.Engine.TEXTURETYPE_UNSIGNED_INT,this._shadowGeneratorBias=.001),this._defaultPipelineTextureType=this._hdrSupport?this._defaultHighpTextureType:r.Engine.TEXTURETYPE_UNSIGNED_INT},e.prototype.dispose=function(){this.onEnvironmentConfiguredObservable.clear(),this.onLightsConfiguredObservable.clear(),this.onModelsConfiguredObservable.clear(),this.onSceneConfiguredObservable.clear(),this.onSceneInitObservable.clear(),this.onSceneOptimizerConfiguredObservable.clear(),this.onVRConfiguredObservable.clear(),this.sceneOptimizer&&(this.sceneOptimizer.stop(),this.sceneOptimizer.dispose()),this.environmentHelper&&this.environmentHelper.dispose(),this.models.forEach(function(e){e.dispose()}),this._defaultRenderingPipeline&&this._defaultRenderingPipeline.dispose(),this.models.length=0,this.scene&&this.scene.dispose()},e.prototype._getAssetUrl=function(e){var t=e;if(e&&-1===e.toLowerCase().indexOf("//")){if(!this._assetsRootURL)return e;t=this._assetsRootURL+t}return t},e.prototype._setCameraBehavior=function(e,t,i){var r,n;if(void 0!==(n="object"==typeof t?t.type:"number"==typeof t?t:this._cameraBehaviorMapping[e])){var o="object"==typeof t?t:{},a=!0;switch("boolean"==typeof t&&(a=t),n){case 0:this.camera.useAutoRotationBehavior=a,r=this.camera.autoRotationBehavior;break;case 1:this.camera.useBouncingBehavior=a,r=this.camera.bouncingBehavior;break;case 2:this.camera.useFramingBehavior=a,r=this.camera.framingBehavior;break;default:r=null}switch(r&&(this._cameraBehaviorMapping[e]=n,"object"==typeof t&&s.extendClassWithConfig(r,t)),n){case 0:case 1:break;case 2:this._observablesManager&&this._observablesManager.onModelLoadedObservable.add(function(e){o.zoomOnBoundingInfo&&r.zoomOnMeshHierarchy(e.rootMesh)})}}},e}();t.SceneManager=u},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(61),n=i(0),o=i(16),s=function(){function e(e){this._scene=e,this.environment={irradiancePolynomialCoefficients:{x:new n.Vector3(0,0,0),y:new n.Vector3(0,0,0),z:new n.Vector3(0,0,0),xx:new n.Vector3(0,0,0),yy:new n.Vector3(0,0,0),zz:new n.Vector3(0,0,0),yz:new n.Vector3(0,0,0),zx:new n.Vector3(0,0,0),xy:new n.Vector3(0,0,0)},textureIntensityScale:1}}return e.prototype.loadEnvironment=function(e,t,i,n){var o=this;if(e instanceof ArrayBuffer)this.environment=r.EnvironmentDeserializer.Parse(e),t&&t(this.environment);else if("string"==typeof e){var s=this.getAssetUrl(e);this._scene._loadFile(s,function(e){o.environment=r.EnvironmentDeserializer.Parse(e),t&&t(o.environment)},function(e){i&&i(e.loaded,e.total)},!1,!0,function(e,t){n&&n(t)})}else this.environment=e,t&&t(e)},e.prototype.applyEnvironmentMapConfiguration=function(e){if(this.environment){var t=n.Quaternion.RotationAxis(n.Axis.Y,e||0);if(this.environment.specularTexture&&(this._scene.environmentTexture||(this._scene.environmentTexture=o.TextureUtils.GetBabylonCubeTexture(this._scene,this.environment.specularTexture,!1,!0)),this._scene.environmentTexture)){this._scene.environmentTexture.level=this.environment.textureIntensityScale,this._scene.environmentTexture.invertZ=!0,this._scene.environmentTexture.lodLevelInAlpha=!0;var i=this._scene.environmentTexture.sphericalPolynomial||new n.SphericalPolynomial;i.x=this.environment.irradiancePolynomialCoefficients.x,i.y=this.environment.irradiancePolynomialCoefficients.y,i.z=this.environment.irradiancePolynomialCoefficients.z,i.xx=this.environment.irradiancePolynomialCoefficients.xx,i.xy=this.environment.irradiancePolynomialCoefficients.xy,i.yy=this.environment.irradiancePolynomialCoefficients.yy,i.yz=this.environment.irradiancePolynomialCoefficients.yz,i.zx=this.environment.irradiancePolynomialCoefficients.zx,i.zz=this.environment.irradiancePolynomialCoefficients.zz,this._scene.environmentTexture.sphericalPolynomial=i,n.Matrix.FromQuaternionToRef(t,this._scene.environmentTexture.getReflectionTextureMatrix())}}},e.prototype.getAssetUrl=function(e){var t=e;if(e&&-1===e.toLowerCase().indexOf("//")){if(!this.assetsRootURL)return e;t=this.assetsRootURL+t}return t},e.prototype.rotateShadowLight=function(e,t,i,r,o){void 0===i&&(i=n.Vector3.Zero()),void 0===r&&(r=n.Axis.Y),void 0===o&&(o=n.Vector3.Zero()),r.normalize(),i.subtractToRef(e.position,n.Tmp.Vector3[0]),n.Matrix.TranslationToRef(n.Tmp.Vector3[0].x,n.Tmp.Vector3[0].y,n.Tmp.Vector3[0].z,n.Tmp.Matrix[0]),n.Tmp.Matrix[0].invertToRef(n.Tmp.Matrix[2]),n.Matrix.RotationAxisToRef(r,t,n.Tmp.Matrix[1]),n.Tmp.Matrix[2].multiplyToRef(n.Tmp.Matrix[1],n.Tmp.Matrix[2]),n.Tmp.Matrix[2].multiplyToRef(n.Tmp.Matrix[0],n.Tmp.Matrix[2]),n.Tmp.Matrix[2].decompose(n.Tmp.Vector3[0],n.Tmp.Quaternion[0],n.Tmp.Vector3[1]),e.position.addInPlace(n.Tmp.Vector3[1]),e.setDirectionToTarget(o)},e}();t.ViewerLabs=s},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(16),o=function(){function e(){}return e.Parse=function(t){for(var i={irradiancePolynomialCoefficients:{x:new r.Vector3(0,0,0),y:new r.Vector3(0,0,0),z:new r.Vector3(0,0,0),xx:new r.Vector3(0,0,0),yy:new r.Vector3(0,0,0),zz:new r.Vector3(0,0,0),yz:new r.Vector3(0,0,0),zx:new r.Vector3(0,0,0),xy:new r.Vector3(0,0,0)},textureIntensityScale:1},o=[134,22,135,150,246,214,150,54],s=new DataView(t),a=0,l=0;l<o.length;l++)s.getUint8(a++)!==o[l]&&r.Tools.Error("Not a Spectre environment map");var c=s.getUint16(a,!1);a+=2,1!==c&&r.Tools.Warn('Unsupported Spectre environment map version "'+c+'"');for(var u="",h=0;h=s.getUint8(a++);)u+=String.fromCharCode(h);var d=JSON.parse(u),f=a;switch(d.irradiance.type){case"irradiance_sh_coefficients_9":var p=d.irradiance;e._ConvertSHIrradianceToLambertianRadiance(p),e._ConvertSHToSP(p,i.irradiancePolynomialCoefficients);break;default:r.Tools.Error("Unhandled MapType descriptor.irradiance.type ("+d.irradiance.type+")")}switch(d.specular.type){case"cubemap_faces":var m=d.specular,g=i.specularTexture=new n.TextureCube(6408,5121);i.textureIntensityScale=null!=m.multiplier?m.multiplier:1;for(var _=m.mipmaps,v=m.imageType,A=0;A<_.length;A++){var y=_[A];g.source[A]=[];for(l=0;l<6;l++){var b=y[l],T=new Uint8Array(t,f+b.pos,b.length);switch(v){case"png":var E=new Image,x=URL.createObjectURL(new Blob([T],{type:"image/png"}));E.src=x,g.source[A][l]=E;break;default:r.Tools.Error("Unhandled ImageType descriptor.specular.imageType ("+v+")")}}}break;default:r.Tools.Error("Unhandled MapType descriptor.specular.type ("+d.specular.type+")")}return i},e._ConvertSHIrradianceToLambertianRadiance=function(t){e._ScaleSH(t,1/Math.PI)},e._ConvertSHToSP=function(e,t){var i=1/Math.PI;t.x.x=1.02333*e.l11[0]*i,t.x.y=1.02333*e.l11[1]*i,t.x.z=1.02333*e.l11[2]*i,t.y.x=1.02333*e.l1_1[0]*i,t.y.y=1.02333*e.l1_1[1]*i,t.y.z=1.02333*e.l1_1[2]*i,t.z.x=1.02333*e.l10[0]*i,t.z.y=1.02333*e.l10[1]*i,t.z.z=1.02333*e.l10[2]*i,t.xx.x=(.886277*e.l00[0]-.247708*e.l20[0]+.429043*e.l22[0])*i,t.xx.y=(.886277*e.l00[1]-.247708*e.l20[1]+.429043*e.l22[1])*i,t.xx.z=(.886277*e.l00[2]-.247708*e.l20[2]+.429043*e.l22[2])*i,t.yy.x=(.886277*e.l00[0]-.247708*e.l20[0]-.429043*e.l22[0])*i,t.yy.y=(.886277*e.l00[1]-.247708*e.l20[1]-.429043*e.l22[1])*i,t.yy.z=(.886277*e.l00[2]-.247708*e.l20[2]-.429043*e.l22[2])*i,t.zz.x=(.886277*e.l00[0]+.495417*e.l20[0])*i,t.zz.y=(.886277*e.l00[1]+.495417*e.l20[1])*i,t.zz.z=(.886277*e.l00[2]+.495417*e.l20[2])*i,t.yz.x=.858086*e.l2_1[0]*i,t.yz.y=.858086*e.l2_1[1]*i,t.yz.z=.858086*e.l2_1[2]*i,t.zx.x=.858086*e.l21[0]*i,t.zx.y=.858086*e.l21[1]*i,t.zx.z=.858086*e.l21[2]*i,t.xy.x=.858086*e.l2_2[0]*i,t.xy.y=.858086*e.l2_2[1]*i,t.xy.z=.858086*e.l2_2[2]*i},e._ScaleSH=function(e,t){e.l00[0]*=t,e.l00[1]*=t,e.l00[2]*=t,e.l1_1[0]*=t,e.l1_1[1]*=t,e.l1_1[2]*=t,e.l10[0]*=t,e.l10[1]*=t,e.l10[2]*=t,e.l11[0]*=t,e.l11[1]*=t,e.l11[2]*=t,e.l2_2[0]*=t,e.l2_2[1]*=t,e.l2_2[2]*=t,e.l2_1[0]*=t,e.l2_1[1]*=t,e.l2_1[2]*=t,e.l20[0]*=t,e.l20[1]*=t,e.l20[2]*=t,e.l21[0]*=t,e.l21[1]*=t,e.l21[2]*=t,e.l22[0]*=t,e.l22[1]*=t,e.l22[2]*=t},e}();t.EnvironmentDeserializer=o},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0);t.extendedUpgrade=function(e){var t=e.defaultRenderingPipeline;if(e.scene.getEngine().getHardwareScalingLevel()>1){var i=r.Scalar.Clamp(e.scene.getEngine().getHardwareScalingLevel()-.25,0,1);return e.scene.getEngine().setHardwareScalingLevel(i),!1}if(!e.scene.postProcessesEnabled)return e.scene.postProcessesEnabled=!0,!1;if(!e.groundEnabled)return e.groundEnabled=!0,!1;if(t&&!e.fxaaEnabled)return e.fxaaEnabled=!0,!1;var n=Math.max(.5,1/(window.devicePixelRatio||2));if(e.scene.getEngine().getHardwareScalingLevel()>n)return i=r.Scalar.Clamp(e.scene.getEngine().getHardwareScalingLevel()-.25,0,n),e.scene.getEngine().setHardwareScalingLevel(i),!1;return e.processShadows?t&&!e.bloomEnabled?(e.bloomEnabled=!0,!1):!!e.groundMirrorEnabled||(e.groundMirrorEnabled=!0,!1):(e.processShadows=!0,!1)},t.extendedDegrade=function(e){var t=e.defaultRenderingPipeline;if(e.groundMirrorEnabled)return e.groundMirrorEnabled=!1,!1;if(t&&e.bloomEnabled)return e.bloomEnabled=!1,!1;if(e.processShadows)return e.processShadows=!1,!1;if(e.scene.getEngine().getHardwareScalingLevel()<1){var i=r.Scalar.Clamp(e.scene.getEngine().getHardwareScalingLevel()+.25,0,1);return e.scene.getEngine().setHardwareScalingLevel(i),!1}if(t&&e.fxaaEnabled)return e.fxaaEnabled=!1,!1;if(e.groundEnabled)return e.groundEnabled=!1,!1;if(e.scene.postProcessesEnabled)return e.scene.postProcessesEnabled=!1,!1;if(e.scene.getEngine().getHardwareScalingLevel()<1.25)return i=r.Scalar.Clamp(e.scene.getEngine().getHardwareScalingLevel()+.25,0,1.25),e.scene.getEngine().setHardwareScalingLevel(i),!1;return!0}},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(0),n=i(1),o=i(18),s=i(64),a=i(1),l=function(){function e(e){this.containerElement=e,this.templates={},this.onTemplateInit=new r.Observable,this.onTemplateLoaded=new r.Observable,this.onTemplateStateChange=new r.Observable,this.onAllLoaded=new r.Observable,this.onEventTriggered=new r.Observable,this.eventManager=new s.EventManager(this)}return e.prototype.initTemplate=function(e){var t=this,i=function(e,r,o){var s=t.templates[r],a=(Object.keys(e).map(function(t){return i(e[t],t,s)}),function(){var e=o&&o.parent.querySelectorAll(n.camelToKebab(r)),i=e&&e.length&&e.item(e.length-1)||t.containerElement;s.appendTo(i),t._checkLoadedState()});return o&&!o.parent?o.onAppended.add(function(){a()}):a(),s};return this._buildHTMLTree(e).then(function(e){t.templates.main?i(e,"main"):t._checkLoadedState()})},e.prototype._buildHTMLTree=function(e){var t=this,i=Object.keys(e).map(function(i){if(!e[i])return Promise.resolve(!1);var r=new c(i,e[i]);return r.onLoaded.add(function(){t.onTemplateLoaded.notifyObservers(r)}),r.onStateChange.add(function(){t.onTemplateStateChange.notifyObservers(r)}),t.onTemplateInit.notifyObservers(r),r.onEventTriggered.add(function(e){return t.onEventTriggered.notifyObservers(e)}),t.templates[i]=r,r.initPromise});return Promise.all(i).then(function(){var e={},i=function(e,r){t.templates[r].isInHtmlTree=!0,t.templates[r].getChildElements().filter(function(e){return!!t.templates[e]}).forEach(function(t){e[t]={},i(e[t],t)})};return t.templates.main&&i(e,"main"),e})},e.prototype.getCanvas=function(){return this.containerElement.querySelector("canvas")},e.prototype.getTemplate=function(e){return this.templates[e]},e.prototype._checkLoadedState=function(){var e=this;(0===Object.keys(this.templates).length||Object.keys(this.templates).every(function(t){return e.templates[t].isLoaded&&!!e.templates[t].parent||!e.templates[t].isInHtmlTree}))&&this.onAllLoaded.notifyObservers(this)},e.prototype.dispose=function(){var e=this;Object.keys(this.templates).forEach(function(t){e.templates[t].dispose()}),this.templates={},this.eventManager.dispose(),this.onTemplateInit.clear(),this.onAllLoaded.clear(),this.onEventTriggered.clear(),this.onTemplateLoaded.clear(),this.onTemplateStateChange.clear()},e}();t.TemplateManager=l,o.registerHelper("eachInMap",function(e,t){var i="";return Object.keys(e).map(function(r){var n=e[r];"object"==typeof n?(n.id=n.id||r,i+=t.fn(n)):i+=t.fn({id:r,value:n})}),i}),o.registerHelper("add",function(e,t){return e+t}),o.registerHelper("eq",function(e,t){return e==t}),o.registerHelper("or",function(e,t){return e||t}),o.registerHelper("not",function(e){return!e}),o.registerHelper("count",function(e){return e.length}),o.registerHelper("gt",function(e,t){return e>t});var c=function(){function e(e,t){var i=this;this.name=e,this._configuration=t,this.onLoaded=new r.Observable,this.onAppended=new r.Observable,this.onStateChange=new r.Observable,this.onEventTriggered=new r.Observable,this.onParamsUpdated=new r.Observable,this.onHTMLRendered=new r.Observable,this.loadRequests=[],this.isLoaded=!1,this.isShown=!1,this.isInHtmlTree=!1;var n=this._getTemplateAsHtml(t);this.initPromise=n.then(function(e){if(e){i._htmlTemplate=e;var t=o.compile(e,{noEscape:i._configuration.params&&!!i._configuration.params.noEscape}),r=i._configuration.params||{};i._rawHtml=t(r);try{i._fragment=document.createRange().createContextualFragment(i._rawHtml)}catch(e){var n=document.createElement(i.name);n.innerHTML=i._rawHtml,i._fragment=n}i.isLoaded=!0,i.isShown=!0,i.onLoaded.notifyObservers(i)}return i})}return e.prototype.updateParams=function(e,t){void 0===t&&(t=!0),this._configuration.params=t?a.deepmerge(this._configuration.params,e):e,this.isLoaded;var i=o.compile(this._htmlTemplate),r=this._configuration.params||{};this._rawHtml=i(r);try{this._fragment=document.createRange().createContextualFragment(this._rawHtml)}catch(e){var n=document.createElement(this.name);n.innerHTML=this._rawHtml,this._fragment=n}this.parent&&this.appendTo(this.parent,!0)},e.prototype.redraw=function(){this.updateParams({})},Object.defineProperty(e.prototype,"configuration",{get:function(){return this._configuration},enumerable:!0,configurable:!0}),e.prototype.getChildElements=function(){var e=[],t=this._fragment&&this._fragment.children;if(!this._fragment){var i=this.parent.querySelector(this.name);i&&(t=i.querySelectorAll("*"))}t||(t=this._fragment.querySelectorAll("*"));for(var r=0;r<t.length;++r){var o=t.item(r);o&&e.push(n.kebabToCamel(o.nodeName.toLowerCase()))}return e},e.prototype.appendTo=function(e,t){var i=this;if(this.parent){if(!t||!this._addedFragment)return;this.parent.innerHTML=""}this.parent=e,this._configuration.id&&(this.parent.id=this._configuration.id),this._fragment?(this.parent.appendChild(this._fragment),this._addedFragment=this._fragment):this.parent.insertAdjacentHTML("beforeend",this._rawHtml),this.onHTMLRendered.notifyObservers(this),setTimeout(function(){i._registerEvents(),i.onAppended.notifyObservers(i)})},e.prototype.show=function(e){var t=this;return this._isHiding?Promise.resolve(this):Promise.resolve().then(function(){return t._isShowing=!0,e?e(t):(t.parent.style.display="flex","flex"!==t.parent.style.display&&(t.parent.style.display=""),t)}).then(function(){return t.isShown=!0,t._isShowing=!1,t.onStateChange.notifyObservers(t),t})},e.prototype.hide=function(e){var t=this;return this._isShowing?Promise.resolve(this):Promise.resolve().then(function(){return t._isHiding=!0,e?e(t):(t.parent.style.display="none",t)}).then(function(){return t.isShown=!1,t._isHiding=!1,t.onStateChange.notifyObservers(t),t})},e.prototype.dispose=function(){this.onAppended.clear(),this.onEventTriggered.clear(),this.onLoaded.clear(),this.onStateChange.clear(),this.isLoaded=!1;try{this.parent.removeChild(this._fragment)}catch(e){}this.loadRequests.forEach(function(e){e.abort()}),this._registeredEvents&&this._registeredEvents.forEach(function(e){e.htmlElement.removeEventListener(e.eventName,e.function)}),delete this._fragment},e.prototype._getTemplateAsHtml=function(e){var t=this;if(e){if(e.html&&!e.location)return Promise.resolve(e.html);var i=this._getTemplateLocation(e);if(n.isUrl(i))return new Promise(function(e,n){var o=r.Tools.LoadFile(i,function(t){e(t)},void 0,void 0,!1,function(e,t){n(t)});t.loadRequests.push(o)});i=i.replace("#","");var o=document.getElementById(i);return o?Promise.resolve(o.innerHTML):Promise.reject("Template ID not found")}return Promise.reject("No templateConfig provided")},e.prototype._registerEvents=function(){var e=this;if(this._registeredEvents=this._registeredEvents||[],this._registeredEvents.length&&this._registeredEvents.forEach(function(e){e.htmlElement.removeEventListener(e.eventName,e.function)}),this._configuration.events){var t=function(t){if(i._configuration.events&&i._configuration.events[t]){var r=function(t,i){e.onEventTriggered.notifyObservers({event:i,template:e,selector:t})};if("boolean"==typeof i._configuration.events[t]){var n=i.parent.id;n=n?"#"+n:i.parent.tagName;var o=r.bind(i,n);i.parent.addEventListener(t,r.bind(i,n),!1),i._registeredEvents.push({htmlElement:i.parent,eventName:t,function:o})}else if("object"==typeof i._configuration.events[t]){var s=Object.keys(i._configuration.events[t]||{}),a=i._configuration.events[t]||{};s.filter(function(e){return a[e]}).forEach(function(i){var n=e.parent.querySelector(i);if(!n){i&&0!==i.indexOf("#")&&(i="#"+i);try{n=e.parent.querySelector(i)}catch(e){}}if(n){var o=r.bind(e,i);n.addEventListener(t,o,!1),e._registeredEvents.push({htmlElement:n,eventName:t,function:o})}})}}},i=this;for(var r in this._configuration.events)t(r)}},e.prototype._getTemplateLocation=function(e){return e&&"string"!=typeof e?e.location:e},e}();t.Template=c},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e){var t=this;this._templateManager=e,this._callbacksContainer={},this._templateManager.onEventTriggered.add(function(e){t._eventTriggered(e)})}return e.prototype.registerCallback=function(e,t,i,r){this._callbacksContainer[e]||(this._callbacksContainer[e]=[]),this._callbacksContainer[e].push({eventType:i,callback:t,selector:r})},e.prototype.unregisterCallback=function(e,t,i,r){var n=this._callbacksContainer[e]||[];this._callbacksContainer[e]=n.filter(function(e){return!(e.eventType&&e.eventType!==i||e.selector&&e.selector!==r)})},e.prototype._eventTriggered=function(e){var t=e.template.name,i=e.event.type,r=e.selector;(this._callbacksContainer[t]||[]).filter(function(e){return!(e.eventType&&e.eventType!==i||e.selector&&e.selector!==r)}).forEach(function(t){t.callback(e)})},e.prototype.dispose=function(){this._callbacksContainer={}},e}();t.EventManager=r},function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=function(t,i){return(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])})(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)}}();Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){function t(i){var r=e.call(this,"hd","hd-button",t.HtmlTemplate)||this;return r._viewer=i,r}return r(t,e),t.prototype.onEvent=function(e){var t=e.template.parent.querySelector(".hd-button");t&&(t.classList.contains("hd-toggled")?t.classList.remove("hd-toggled"):t.classList.add("hd-toggled")),this._viewer.toggleHD()},t.HtmlTemplate='\n{{#unless hideHd}}\n<style>\n.hd-icon:after {\n font-size: 16px;\n content: "\\F765";\n}\n\n.hd-toggled span.hd-icon:after {\n content: "\\F766";\n}\n</style>\n<button class="hd-button" title="{{text.hdButton}}">\n <span class="icon hd-icon"></span>\n </button>\n {{/unless}}\n',t}(i(7).AbstractViewerNavbarButton);t.HDButtonPlugin=n},function(e,t,i){"use strict";var r=this&&this.__extends||function(){var e=function(t,i){return(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])})(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)}}();Object.defineProperty(t,"__esModule",{value:!0});var n=i(7),o=i(0),s=function(e){function t(i){var r=e.call(this,"print","print-button",t.HtmlTemplate)||this;return r._viewer=i,r._viewer.onModelLoadedObservable.add(function(e){if(r._currentModelUrl="",e.configuration.url){var t=o.Tools.GetFilename(e.configuration.url)||e.configuration.url,i=e.configuration.root||o.Tools.GetFolderPath(e.configuration.url),n=e.configuration.loader||t.split(".").pop()||"",s=!1;["gltf","glb","obj","stl"].forEach(function(e){-1!==n.indexOf(e)&&(s=!0)}),s&&(r._currentModelUrl=i+t)}}),r}return r(t,e),t.prototype.onEvent=function(e){if(this._currentModelUrl){var t=this._currentModelUrl.replace(/https?:\/\//,"com.microsoft.builder3d://");window.open(t,"_self")}},t.HtmlTemplate='\n{{#unless hidePrint}}\n<style>\n\n/* Show only if it\'s a windows 10 printer */\n.print-icon.not-win-10 {\n display: none;\n}\n\n.print-icon:after {\n font-size: 16px;\n content: "\\E914";\n}\n\n</style>\n<button class="print-button '+(-1===window.navigator.userAgent.indexOf("Windows NT 10.0")?"no-win-10":"")+'" title="{{text.printButton}}">\n <span class="icon print-icon"></span>\n </button>\n {{/unless}}\n',t}(n.AbstractViewerNavbarButton);t.PrintButtonPlugin=s},function(e,t,i){
- /*!
- * PEP v0.4.3 | https://github.com/jquery/PEP
- * Copyright jQuery Foundation and other contributors | http://jquery.org/license
- */
- e.exports=function(){"use strict";var e=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","pageX","pageY"],t=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0];function i(i,r){r=r||Object.create(null);var n=document.createEvent("Event");n.initEvent(i,r.bubbles||!1,r.cancelable||!1);for(var o,s=2;s<e.length;s++)o=e[s],n[o]=r[o]||t[s];n.buttons=r.buttons||0;var a=0;return a=r.pressure&&n.buttons?r.pressure:n.buttons?.5:0,n.x=n.clientX,n.y=n.clientY,n.pointerId=r.pointerId||0,n.width=r.width||0,n.height=r.height||0,n.pressure=a,n.tiltX=r.tiltX||0,n.tiltY=r.tiltY||0,n.twist=r.twist||0,n.tangentialPressure=r.tangentialPressure||0,n.pointerType=r.pointerType||"",n.hwTimestamp=r.hwTimestamp||0,n.isPrimary=r.isPrimary||!1,n}var r=window.Map&&window.Map.prototype.forEach?Map:n;function n(){this.array=[],this.size=0}n.prototype={set:function(e,t){if(void 0===t)return this.delete(e);this.has(e)||this.size++,this.array[e]=t},has:function(e){return void 0!==this.array[e]},delete:function(e){this.has(e)&&(delete this.array[e],this.size--)},get:function(e){return this.array[e]},clear:function(){this.array.length=0,this.size=0},forEach:function(e,t){return this.array.forEach(function(i,r){e.call(t,i,r,this)},this)}};var o=["bubbles","cancelable","view","detail","screenX","screenY","clientX","clientY","ctrlKey","altKey","shiftKey","metaKey","button","relatedTarget","buttons","pointerId","width","height","pressure","tiltX","tiltY","pointerType","hwTimestamp","isPrimary","type","target","currentTarget","which","pageX","pageY","timeStamp"],s=[!1,!1,null,null,0,0,0,0,!1,!1,!1,!1,0,null,0,0,0,0,0,0,0,"",0,!1,"",null,null,0,0,0,0],a={pointerover:1,pointerout:1,pointerenter:1,pointerleave:1},l="undefined"!=typeof SVGElementInstance,c={pointermap:new r,eventMap:Object.create(null),captureInfo:Object.create(null),eventSources:Object.create(null),eventSourceList:[],registerSource:function(e,t){var i=t,r=i.events;r&&(r.forEach(function(e){i[e]&&(this.eventMap[e]=i[e].bind(i))},this),this.eventSources[e]=i,this.eventSourceList.push(i))},register:function(e){for(var t,i=this.eventSourceList.length,r=0;r<i&&(t=this.eventSourceList[r]);r++)t.register.call(t,e)},unregister:function(e){for(var t,i=this.eventSourceList.length,r=0;r<i&&(t=this.eventSourceList[r]);r++)t.unregister.call(t,e)},contains:function(e,t){try{return e.contains(t)}catch(e){return!1}},down:function(e){e.bubbles=!0,this.fireEvent("pointerdown",e)},move:function(e){e.bubbles=!0,this.fireEvent("pointermove",e)},up:function(e){e.bubbles=!0,this.fireEvent("pointerup",e)},enter:function(e){e.bubbles=!1,this.fireEvent("pointerenter",e)},leave:function(e){e.bubbles=!1,this.fireEvent("pointerleave",e)},over:function(e){e.bubbles=!0,this.fireEvent("pointerover",e)},out:function(e){e.bubbles=!0,this.fireEvent("pointerout",e)},cancel:function(e){e.bubbles=!0,this.fireEvent("pointercancel",e)},leaveOut:function(e){this.out(e),this.propagate(e,this.leave,!1)},enterOver:function(e){this.over(e),this.propagate(e,this.enter,!0)},eventHandler:function(e){if(!e._handledByPE){var t=e.type,i=this.eventMap&&this.eventMap[t];i&&i(e),e._handledByPE=!0}},listen:function(e,t){t.forEach(function(t){this.addEvent(e,t)},this)},unlisten:function(e,t){t.forEach(function(t){this.removeEvent(e,t)},this)},addEvent:function(e,t){e.addEventListener(t,this.boundHandler)},removeEvent:function(e,t){e.removeEventListener(t,this.boundHandler)},makeEvent:function(e,t){this.captureInfo[t.pointerId]&&(t.relatedTarget=null);var r=new i(e,t);return t.preventDefault&&(r.preventDefault=t.preventDefault),r._target=r._target||t.target,r},fireEvent:function(e,t){var i=this.makeEvent(e,t);return this.dispatchEvent(i)},cloneEvent:function(e){for(var t,i=Object.create(null),r=0;r<o.length;r++)i[t=o[r]]=e[t]||s[r],!l||"target"!==t&&"relatedTarget"!==t||i[t]instanceof SVGElementInstance&&(i[t]=i[t].correspondingUseElement);return e.preventDefault&&(i.preventDefault=function(){e.preventDefault()}),i},getTarget:function(e){var t=this.captureInfo[e.pointerId];return t?e._target!==t&&e.type in a?void 0:t:e._target},propagate:function(e,t,i){for(var r=e.target,n=[];r!==document&&!r.contains(e.relatedTarget);)if(n.push(r),!(r=r.parentNode))return;i&&n.reverse(),n.forEach(function(i){e.target=i,t.call(this,e)},this)},setCapture:function(e,t,r){this.captureInfo[e]&&this.releaseCapture(e,r),this.captureInfo[e]=t,this.implicitRelease=this.releaseCapture.bind(this,e,r),document.addEventListener("pointerup",this.implicitRelease),document.addEventListener("pointercancel",this.implicitRelease);var n=new i("gotpointercapture");n.pointerId=e,n._target=t,r||this.asyncDispatchEvent(n)},releaseCapture:function(e,t){var r=this.captureInfo[e];if(r){this.captureInfo[e]=void 0,document.removeEventListener("pointerup",this.implicitRelease),document.removeEventListener("pointercancel",this.implicitRelease);var n=new i("lostpointercapture");n.pointerId=e,n._target=r,t||this.asyncDispatchEvent(n)}},dispatchEvent:function(e){var t=this.getTarget(e);if(t)return t.dispatchEvent(e)},asyncDispatchEvent:function(e){requestAnimationFrame(this.dispatchEvent.bind(this,e))}};c.boundHandler=c.eventHandler.bind(c);var u={shadow:function(e){if(e)return e.shadowRoot||e.webkitShadowRoot},canTarget:function(e){return e&&Boolean(e.elementFromPoint)},targetingShadow:function(e){var t=this.shadow(e);if(this.canTarget(t))return t},olderShadow:function(e){var t=e.olderShadowRoot;if(!t){var i=e.querySelector("shadow");i&&(t=i.olderShadowRoot)}return t},allShadows:function(e){for(var t=[],i=this.shadow(e);i;)t.push(i),i=this.olderShadow(i);return t},searchRoot:function(e,t,i){if(e){var r,n,o=e.elementFromPoint(t,i);for(n=this.targetingShadow(o);n;){if(r=n.elementFromPoint(t,i)){var s=this.targetingShadow(r);return this.searchRoot(s,t,i)||r}n=this.olderShadow(n)}return o}},owner:function(e){for(var t=e;t.parentNode;)t=t.parentNode;return t.nodeType!==Node.DOCUMENT_NODE&&t.nodeType!==Node.DOCUMENT_FRAGMENT_NODE&&(t=document),t},findTarget:function(e){var t=e.clientX,i=e.clientY,r=this.owner(e.target);return r.elementFromPoint(t,i)||(r=document),this.searchRoot(r,t,i)}},h=Array.prototype.forEach.call.bind(Array.prototype.forEach),d=Array.prototype.map.call.bind(Array.prototype.map),f=Array.prototype.slice.call.bind(Array.prototype.slice),p=Array.prototype.filter.call.bind(Array.prototype.filter),m=window.MutationObserver||window.WebKitMutationObserver,g={subtree:!0,childList:!0,attributes:!0,attributeOldValue:!0,attributeFilter:["touch-action"]};function _(e,t,i,r){this.addCallback=e.bind(r),this.removeCallback=t.bind(r),this.changedCallback=i.bind(r),m&&(this.observer=new m(this.mutationWatcher.bind(this)))}function v(e){return"body /shadow-deep/ "+A(e)}function A(e){return'[touch-action="'+e+'"]'}function y(e){return"{ -ms-touch-action: "+e+"; touch-action: "+e+"; }"}_.prototype={watchSubtree:function(e){this.observer&&u.canTarget(e)&&this.observer.observe(e,g)},enableOnSubtree:function(e){this.watchSubtree(e),e===document&&"complete"!==document.readyState?this.installOnLoad():this.installNewSubtree(e)},installNewSubtree:function(e){h(this.findElements(e),this.addElement,this)},findElements:function(e){return e.querySelectorAll?e.querySelectorAll("[touch-action]"):[]},removeElement:function(e){this.removeCallback(e)},addElement:function(e){this.addCallback(e)},elementChanged:function(e,t){this.changedCallback(e,t)},concatLists:function(e,t){return e.concat(f(t))},installOnLoad:function(){document.addEventListener("readystatechange",function(){"complete"===document.readyState&&this.installNewSubtree(document)}.bind(this))},isElement:function(e){return e.nodeType===Node.ELEMENT_NODE},flattenMutationTree:function(e){var t=d(e,this.findElements,this);return t.push(p(e,this.isElement)),t.reduce(this.concatLists,[])},mutationWatcher:function(e){e.forEach(this.mutationHandler,this)},mutationHandler:function(e){if("childList"===e.type){var t=this.flattenMutationTree(e.addedNodes);t.forEach(this.addElement,this);var i=this.flattenMutationTree(e.removedNodes);i.forEach(this.removeElement,this)}else"attributes"===e.type&&this.elementChanged(e.target,e.oldValue)}};var b=["none","auto","pan-x","pan-y",{rule:"pan-x pan-y",selectors:["pan-x pan-y","pan-y pan-x"]}],T="",E=window.PointerEvent||window.MSPointerEvent,x=!window.ShadowDOMPolyfill&&document.head.createShadowRoot,P=c.pointermap,M=[1,4,2,8,16],S=!1;try{S=1===new MouseEvent("test",{buttons:1}).buttons}catch(e){}var C,R={POINTER_ID:1,POINTER_TYPE:"mouse",events:["mousedown","mousemove","mouseup","mouseover","mouseout"],register:function(e){c.listen(e,this.events)},unregister:function(e){c.unlisten(e,this.events)},lastTouches:[],isEventSimulatedFromTouch:function(e){for(var t,i=this.lastTouches,r=e.clientX,n=e.clientY,o=0,s=i.length;o<s&&(t=i[o]);o++){var a=Math.abs(r-t.x),l=Math.abs(n-t.y);if(a<=25&&l<=25)return!0}},prepareEvent:function(e){var t=c.cloneEvent(e),i=t.preventDefault;return t.preventDefault=function(){e.preventDefault(),i()},t.pointerId=this.POINTER_ID,t.isPrimary=!0,t.pointerType=this.POINTER_TYPE,t},prepareButtonsForMove:function(e,t){var i=P.get(this.POINTER_ID);0!==t.which&&i?e.buttons=i.buttons:e.buttons=0,t.buttons=e.buttons},mousedown:function(e){if(!this.isEventSimulatedFromTouch(e)){var t=P.get(this.POINTER_ID),i=this.prepareEvent(e);S||(i.buttons=M[i.button],t&&(i.buttons|=t.buttons),e.buttons=i.buttons),P.set(this.POINTER_ID,e),t&&0!==t.buttons?c.move(i):c.down(i)}},mousemove:function(e){if(!this.isEventSimulatedFromTouch(e)){var t=this.prepareEvent(e);S||this.prepareButtonsForMove(t,e),t.button=-1,P.set(this.POINTER_ID,e),c.move(t)}},mouseup:function(e){if(!this.isEventSimulatedFromTouch(e)){var t=P.get(this.POINTER_ID),i=this.prepareEvent(e);if(!S){var r=M[i.button];i.buttons=t?t.buttons&~r:0,e.buttons=i.buttons}P.set(this.POINTER_ID,e),i.buttons&=~M[i.button],0===i.buttons?c.up(i):c.move(i)}},mouseover:function(e){if(!this.isEventSimulatedFromTouch(e)){var t=this.prepareEvent(e);S||this.prepareButtonsForMove(t,e),t.button=-1,P.set(this.POINTER_ID,e),c.enterOver(t)}},mouseout:function(e){if(!this.isEventSimulatedFromTouch(e)){var t=this.prepareEvent(e);S||this.prepareButtonsForMove(t,e),t.button=-1,c.leaveOut(t)}},cancel:function(e){var t=this.prepareEvent(e);c.cancel(t),this.deactivateMouse()},deactivateMouse:function(){P.delete(this.POINTER_ID)}},O=c.captureInfo,D=u.findTarget.bind(u),I=u.allShadows.bind(u),w=c.pointermap,L={events:["touchstart","touchmove","touchend","touchcancel"],register:function(e){C.enableOnSubtree(e)},unregister:function(){},elementAdded:function(e){var t=e.getAttribute("touch-action"),i=this.touchActionToScrollType(t);i&&(e._scrollType=i,c.listen(e,this.events),I(e).forEach(function(e){e._scrollType=i,c.listen(e,this.events)},this))},elementRemoved:function(e){e._scrollType=void 0,c.unlisten(e,this.events),I(e).forEach(function(e){e._scrollType=void 0,c.unlisten(e,this.events)},this)},elementChanged:function(e,t){var i=e.getAttribute("touch-action"),r=this.touchActionToScrollType(i),n=this.touchActionToScrollType(t);r&&n?(e._scrollType=r,I(e).forEach(function(e){e._scrollType=r},this)):n?this.elementRemoved(e):r&&this.elementAdded(e)},scrollTypes:{EMITTER:"none",XSCROLLER:"pan-x",YSCROLLER:"pan-y",SCROLLER:/^(?:pan-x pan-y)|(?:pan-y pan-x)|auto$/},touchActionToScrollType:function(e){var t=e,i=this.scrollTypes;return"none"===t?"none":t===i.XSCROLLER?"X":t===i.YSCROLLER?"Y":i.SCROLLER.exec(t)?"XY":void 0},POINTER_TYPE:"touch",firstTouch:null,isPrimaryTouch:function(e){return this.firstTouch===e.identifier},setPrimaryTouch:function(e){(0===w.size||1===w.size&&w.has(1))&&(this.firstTouch=e.identifier,this.firstXY={X:e.clientX,Y:e.clientY},this.scrolling=!1,this.cancelResetClickCount())},removePrimaryPointer:function(e){e.isPrimary&&(this.firstTouch=null,this.firstXY=null,this.resetClickCount())},clickCount:0,resetId:null,resetClickCount:function(){var e=function(){this.clickCount=0,this.resetId=null}.bind(this);this.resetId=setTimeout(e,200)},cancelResetClickCount:function(){this.resetId&&clearTimeout(this.resetId)},typeToButtons:function(e){var t=0;return"touchstart"!==e&&"touchmove"!==e||(t=1),t},touchToPointer:function(e){var t=this.currentTouchEvent,i=c.cloneEvent(e),r=i.pointerId=e.identifier+2;i.target=O[r]||D(i),i.bubbles=!0,i.cancelable=!0,i.detail=this.clickCount,i.button=0,i.buttons=this.typeToButtons(t.type),i.width=2*(e.radiusX||e.webkitRadiusX||0),i.height=2*(e.radiusY||e.webkitRadiusY||0),i.pressure=e.force||e.webkitForce||.5,i.isPrimary=this.isPrimaryTouch(e),i.pointerType=this.POINTER_TYPE,i.altKey=t.altKey,i.ctrlKey=t.ctrlKey,i.metaKey=t.metaKey,i.shiftKey=t.shiftKey;var n=this;return i.preventDefault=function(){n.scrolling=!1,n.firstXY=null,t.preventDefault()},i},processTouches:function(e,t){var i=e.changedTouches;this.currentTouchEvent=e;for(var r,n=0;n<i.length;n++)r=i[n],t.call(this,this.touchToPointer(r))},shouldScroll:function(e){if(this.firstXY){var t,i=e.currentTarget._scrollType;if("none"===i)t=!1;else if("XY"===i)t=!0;else{var r=e.changedTouches[0],n=i,o="Y"===i?"X":"Y",s=Math.abs(r["client"+n]-this.firstXY[n]),a=Math.abs(r["client"+o]-this.firstXY[o]);t=s>=a}return this.firstXY=null,t}},findTouch:function(e,t){for(var i,r=0,n=e.length;r<n&&(i=e[r]);r++)if(i.identifier===t)return!0},vacuumTouches:function(e){var t=e.touches;if(w.size>=t.length){var i=[];w.forEach(function(e,r){if(1!==r&&!this.findTouch(t,r-2)){var n=e.out;i.push(n)}},this),i.forEach(this.cancelOut,this)}},touchstart:function(e){this.vacuumTouches(e),this.setPrimaryTouch(e.changedTouches[0]),this.dedupSynthMouse(e),this.scrolling||(this.clickCount++,this.processTouches(e,this.overDown))},overDown:function(e){w.set(e.pointerId,{target:e.target,out:e,outTarget:e.target}),c.enterOver(e),c.down(e)},touchmove:function(e){this.scrolling||(this.shouldScroll(e)?(this.scrolling=!0,this.touchcancel(e)):(e.preventDefault(),this.processTouches(e,this.moveOverOut)))},moveOverOut:function(e){var t=e,i=w.get(t.pointerId);if(i){var r=i.out,n=i.outTarget;c.move(t),r&&n!==t.target&&(r.relatedTarget=t.target,t.relatedTarget=n,r.target=n,t.target?(c.leaveOut(r),c.enterOver(t)):(t.target=n,t.relatedTarget=null,this.cancelOut(t))),i.out=t,i.outTarget=t.target}},touchend:function(e){this.dedupSynthMouse(e),this.processTouches(e,this.upOut)},upOut:function(e){this.scrolling||(c.up(e),c.leaveOut(e)),this.cleanUpPointer(e)},touchcancel:function(e){this.processTouches(e,this.cancelOut)},cancelOut:function(e){c.cancel(e),c.leaveOut(e),this.cleanUpPointer(e)},cleanUpPointer:function(e){w.delete(e.pointerId),this.removePrimaryPointer(e)},dedupSynthMouse:function(e){var t=R.lastTouches,i=e.changedTouches[0];if(this.isPrimaryTouch(i)){var r={x:i.clientX,y:i.clientY};t.push(r);var n=function(e,t){var i=e.indexOf(t);i>-1&&e.splice(i,1)}.bind(null,t,r);setTimeout(n,2500)}}};C=new _(L.elementAdded,L.elementRemoved,L.elementChanged,L);var B,F,N,V=c.pointermap,U=window.MSPointerEvent&&"number"==typeof window.MSPointerEvent.MSPOINTER_TYPE_MOUSE,G={events:["MSPointerDown","MSPointerMove","MSPointerUp","MSPointerOut","MSPointerOver","MSPointerCancel","MSGotPointerCapture","MSLostPointerCapture"],register:function(e){c.listen(e,this.events)},unregister:function(e){c.unlisten(e,this.events)},POINTER_TYPES:["","unavailable","touch","pen","mouse"],prepareEvent:function(e){var t=e;return U&&((t=c.cloneEvent(e)).pointerType=this.POINTER_TYPES[e.pointerType]),t},cleanup:function(e){V.delete(e)},MSPointerDown:function(e){V.set(e.pointerId,e);var t=this.prepareEvent(e);c.down(t)},MSPointerMove:function(e){var t=this.prepareEvent(e);c.move(t)},MSPointerUp:function(e){var t=this.prepareEvent(e);c.up(t),this.cleanup(e.pointerId)},MSPointerOut:function(e){var t=this.prepareEvent(e);c.leaveOut(t)},MSPointerOver:function(e){var t=this.prepareEvent(e);c.enterOver(t)},MSPointerCancel:function(e){var t=this.prepareEvent(e);c.cancel(t),this.cleanup(e.pointerId)},MSLostPointerCapture:function(e){var t=c.makeEvent("lostpointercapture",e);c.dispatchEvent(t)},MSGotPointerCapture:function(e){var t=c.makeEvent("gotpointercapture",e);c.dispatchEvent(t)}};function k(e){if(!c.pointermap.has(e)){var t=new Error("InvalidPointerId");throw t.name="InvalidPointerId",t}}function z(e){for(var t=e.parentNode;t&&t!==e.ownerDocument;)t=t.parentNode;if(!t){var i=new Error("InvalidStateError");throw i.name="InvalidStateError",i}}function H(e){var t=c.pointermap.get(e);return 0!==t.buttons}return window.navigator.msPointerEnabled?(B=function(e){k(e),z(this),H(e)&&(c.setCapture(e,this,!0),this.msSetPointerCapture(e))},F=function(e){k(e),c.releaseCapture(e,!0),this.msReleasePointerCapture(e)}):(B=function(e){k(e),z(this),H(e)&&c.setCapture(e,this)},F=function(e){k(e),c.releaseCapture(e)}),N=function(e){return!!c.captureInfo[e]},function(){if(E){b.forEach(function(e){String(e)===e?(T+=A(e)+y(e)+"\n",x&&(T+=v(e)+y(e)+"\n")):(T+=e.selectors.map(A)+y(e.rule)+"\n",x&&(T+=e.selectors.map(v)+y(e.rule)+"\n"))});var e=document.createElement("style");e.textContent=T,document.head.appendChild(e)}}(),function(){if(!window.PointerEvent){if(window.PointerEvent=i,window.navigator.msPointerEnabled){var e=window.navigator.msMaxTouchPoints;Object.defineProperty(window.navigator,"maxTouchPoints",{value:e,enumerable:!0}),c.registerSource("ms",G)}else Object.defineProperty(window.navigator,"maxTouchPoints",{value:0,enumerable:!0}),c.registerSource("mouse",R),void 0!==window.ontouchstart&&c.registerSource("touch",L);c.register(document)}}(),window.Element&&!Element.prototype.setPointerCapture&&Object.defineProperties(Element.prototype,{setPointerCapture:{value:B},releasePointerCapture:{value:F},hasPointerCapture:{value:N}}),{dispatcher:c,Installer:_,PointerEvent:i,PointerMap:r,targetFinding:u}}()},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=i(9),n=i(3),o=i(4);function s(e){void 0===e&&(e="babylon");for(var t=document.querySelectorAll(e),i=0;i<t.length;++i){var o=t.item(i),s=n.mapperManager.getMapper("dom").map(o);new r.DefaultViewer(o,s)}}t.initListeners=function(){document.addEventListener("DOMContentLoaded",function e(t){document.removeEventListener("DOMContentLoaded",e),o.viewerGlobals.disableInit||s()})},t.InitTags=s}]);
-
- return BabylonViewer;
- });
|