mx3d 0.0.36 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/core/mx3d.kernel.min.js +2 -16
  2. package/core/mx3d.loaders.min.js +7 -49
  3. package/index.d.ts +2304 -26
  4. package/mx3d.js +112 -10131
  5. package/mx3d.min.js +6 -6
  6. package/package.json +2 -2
  7. package/core/mx3d.dazzle.min.js +0 -85
  8. package/docs/.nojekyll +0 -0
  9. package/docs/README.md +0 -24
  10. package/docs/_sidebar.md +0 -18
  11. package/docs/camera.md +0 -24
  12. package/docs/css/dark.css +0 -979
  13. package/docs/css/local.google.fonts.css +0 -295
  14. package/docs/css/vue.css +0 -1025
  15. package/docs/fonts/6xK3dSBYKcSV-LCoeQqfX1RYOo3qOK7l.woff2 +0 -0
  16. package/docs/fonts/6xKydSBYKcSV-LCoeQqfX1RYOo3i54rwlxdu.woff2 +0 -0
  17. package/docs/fonts/6xKydSBYKcSV-LCoeQqfX1RYOo3ik4zwlxdu.woff2 +0 -0
  18. package/docs/gui/2D.md +0 -53
  19. package/docs/gui/3D.md +0 -46
  20. package/docs/gui/test1.png +0 -0
  21. package/docs/gui/test2.png +0 -0
  22. package/docs/gui/test3.png +0 -0
  23. package/docs/heatMap/heatMap.md +0 -115
  24. package/docs/heatMap/test1.png +0 -0
  25. package/docs/heatMap/test2.png +0 -0
  26. package/docs/index.html +0 -50
  27. package/docs/js/docsify@4.min.js +0 -1
  28. package/docs/models/modelmgr.md +0 -251
  29. package/docs/project/projectmgr.md +0 -73
  30. package/docs/project/scenetree.jpg +0 -0
  31. package/docs/started/environment.md +0 -42
  32. package/docs/started/quickstart.md +0 -89
  33. package/lib/App.d.ts +0 -45
  34. package/lib/ArrayEx.d.ts +0 -3
  35. package/lib/Builder/BaseNode.d.ts +0 -9
  36. package/lib/Builder/Builder.d.ts +0 -0
  37. package/lib/Builder/HeatMap.d.ts +0 -0
  38. package/lib/Builder/Icon.d.ts +0 -0
  39. package/lib/Builder/IconFromMesh.d.ts +0 -0
  40. package/lib/Camera.d.ts +0 -18
  41. package/lib/Cryptojs.d.ts +0 -3
  42. package/lib/Dictionary.d.ts +0 -13
  43. package/lib/EffectControls.d.ts +0 -42
  44. package/lib/EffectMgr.d.ts +0 -10
  45. package/lib/EffectType.d.ts +0 -5
  46. package/lib/Environment.d.ts +0 -22
  47. package/lib/EventType.d.ts +0 -8
  48. package/lib/GUID.d.ts +0 -3
  49. package/lib/HeatMapMgr.d.ts +0 -2
  50. package/lib/Optimized/OptimizedRegion.d.ts +0 -11
  51. package/lib/ReadJSON.d.ts +0 -3
  52. package/lib/Resources.d.ts +0 -23
  53. package/lib/TipsTool.d.ts +0 -15
  54. package/lib/ToolTip.d.ts +0 -0
  55. package/lib/Tools.d.ts +0 -19
  56. package/lib/UI.d.ts +0 -9
  57. package/lib/VisualAngle.d.ts +0 -13
  58. package/lib/components/AirFlowObject.d.ts +0 -10
  59. package/lib/components/BuildingObject.d.ts +0 -5
  60. package/lib/components/CabinetObject.d.ts +0 -3
  61. package/lib/components/ConduitObject.d.ts +0 -10
  62. package/lib/components/CornerObject.d.ts +0 -5
  63. package/lib/components/DefaultObject.d.ts +0 -46
  64. package/lib/components/DoorObject.d.ts +0 -5
  65. package/lib/components/FloorObject.d.ts +0 -5
  66. package/lib/components/IObject.d.ts +0 -27
  67. package/lib/components/Ibase.d.ts +0 -8
  68. package/lib/components/LeakWaterObject.d.ts +0 -7
  69. package/lib/components/ObjectType.d.ts +0 -47
  70. package/lib/components/OptimizedWallObject.d.ts +0 -5
  71. package/lib/components/Project.d.ts +0 -29
  72. package/lib/components/Region.d.ts +0 -14
  73. package/lib/components/UI3DTextObject.d.ts +0 -4
  74. package/lib/components/VirtualBoxObject.d.ts +0 -4
  75. package/lib/components/WallObject.d.ts +0 -7
  76. package/lib/components/WindowObject.d.ts +0 -5
  77. package/lib/lights/Directional.d.ts +0 -7
  78. package/lib/lights/Hemispheric.d.ts +0 -6
  79. package/lib/lights/ILightObject.d.ts +0 -10
  80. package/lib/lights/LightObject.d.ts +0 -15
  81. package/lib/lights/LightType.d.ts +0 -8
  82. package/lib/lights/Point.d.ts +0 -7
  83. package/lib/lights/Spot.d.ts +0 -10
@@ -1,49 +1,7 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=20)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return i}));var r=n(0),o=n(2),a=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error(e+": Failed to find index ("+n+")");return t[n]},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}(),i=function(){function e(e){this._completePromises=new Array,this._forAssetContainer=!1,this._babylonLights=[],this._disableInstancedMesh=0,this._disposed=!1,this._state=null,this._extensions=new Array,this._defaultBabylonMaterialData={},this._parent=e}return e.RegisterExtension=function(t,n){e.UnregisterExtension(t)&&r.Logger.Warn("Extension with the name '"+t+"' already exists"),e._RegisteredExtensions[t]={factory:n}},e.UnregisterExtension=function(t){return!!e._RegisteredExtensions[t]&&(delete e._RegisteredExtensions[t],!0)},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gltf",{get:function(){return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"babylonScene",{get:function(){return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){if(!this._disposed){for(var e in this._disposed=!0,this._completePromises.length=0,this._extensions){var t=this._extensions[e];t.dispose&&t.dispose(),delete this._extensions[e]}this._gltf=null,this._babylonScene=null,this._rootBabylonMesh=null,this._parent.dispose()}},e.prototype.importMeshAsync=function(e,t,n,r,o,a,i){var s=this;return Promise.resolve().then((function(){s._babylonScene=t,s._rootUrl=o,s._fileName=i||"scene",s._forAssetContainer=n,s._loadData(r);var a=null;if(e){var l={};if(s._gltf.nodes)for(var u=0,c=s._gltf.nodes;u<c.length;u++){var d=c[u];d.name&&(l[d.name]=d.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(),lights:s._babylonLights,transformNodes:s._getTransformNodes(),geometries:s._getGeometries()}}))}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a._babylonScene=e,a._rootUrl=n,a._fileName=o||"scene",a._loadData(t),a._loadAsync(null,(function(){}))}))},e.prototype._loadAsync=function(e,t){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 i=o.GLTFLoaderState[o.GLTFLoaderState.LOADING]+" => "+o.GLTFLoaderState[o.GLTFLoaderState.READY],s=o.GLTFLoaderState[o.GLTFLoaderState.LOADING]+" => "+o.GLTFLoaderState[o.GLTFLoaderState.COMPLETE];n._parent._startPerformanceCounter(i),n._parent._startPerformanceCounter(s),n._setState(o.GLTFLoaderState.LOADING),n._extensionsOnLoading();var l=new Array,u=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)l.push(n.loadSceneAsync("/nodes",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var c=a.Get("/scene",n._gltf.scenes,n._gltf.scene||0);l.push(n.loadSceneAsync("/scenes/"+c.index,c))}if(n.parent.loadAllMaterials&&n._gltf.materials)for(var d=0;d<n._gltf.materials.length;++d){var f=n._gltf.materials[d],h="/materials/"+d,p=r.Material.TriangleFillMode;l.push(n._loadMaterialAsync(h,f,null,p,(function(e){})))}n._babylonScene.blockMaterialDirtyMechanism=u,n._parent.compileMaterials&&l.push(n._compileMaterialsAsync()),n._parent.compileShadowGenerators&&l.push(n._compileShadowGeneratorsAsync());var _=Promise.all(l).then((function(){return n._rootBabylonMesh&&n._rootBabylonMesh.setEnabled(!0),n._extensionsOnReady(),n._setState(o.GLTFLoaderState.READY),n._startAnimations(),t()}));return _.then((function(){n._parent._endPerformanceCounter(i),r.Tools.SetImmediate((function(){n._disposed||Promise.all(n._completePromises).then((function(){n._parent._endPerformanceCounter(s),n._setState(o.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()}))}))})),_})).catch((function(e){throw n._disposed||(n._parent.onErrorObservable.notifyObservers(e),n._parent.onErrorObservable.clear(),n.dispose()),e}))},e.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLength<e.bin.byteLength-3||n.byteLength>e.bin.byteLength)&&r.Logger.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+e.bin.byteLength+")"),this._bin=e.bin}else r.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(a.Assign(this._gltf.accessors),a.Assign(this._gltf.animations),a.Assign(this._gltf.buffers),a.Assign(this._gltf.bufferViews),a.Assign(this._gltf.cameras),a.Assign(this._gltf.images),a.Assign(this._gltf.materials),a.Assign(this._gltf.meshes),a.Assign(this._gltf.nodes),a.Assign(this._gltf.samplers),a.Assign(this._gltf.scenes),a.Assign(this._gltf.skins),a.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++){if((u=n[t]).children)for(var r=0,o=u.children;r<o.length;r++){e[o[r]]=u.index}}for(var i=this._createRootNode(),s=0,l=this._gltf.nodes;s<l.length;s++){var u,c=e[(u=l[s]).index];u.parent=void 0===c?i:this._gltf.nodes[c]}}},e.prototype._loadExtensions=function(){for(var t in e._RegisteredExtensions){var n=e._RegisteredExtensions[t].factory(this);n.name!==t&&r.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: "+n.name+" !== "+t),this._extensions.push(n),this._parent.onExtensionLoadedObservable.notifyObservers(n)}this._extensions.sort((function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)})),this._parent.onExtensionLoadedObservable.clear()},e.prototype._checkExtensions=function(){if(this._gltf.extensionsRequired)for(var e=function(e){if(!t._extensions.some((function(t){return t.name===e&&t.enabled})))throw new Error("Require extension "+e+" is not available")},t=this,n=0,r=this._gltf.extensionsRequired;n<r.length;n++){e(r[n])}},e.prototype._setState=function(e){this._state=e,this.log(o.GLTFLoaderState[this._state])},e.prototype._createRootNode=function(){this._babylonScene._blockEntityCollection=this._forAssetContainer,this._rootBabylonMesh=new r.Mesh("__root__",this._babylonScene),this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var t={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case o.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],e._LoadTransform(t,this._rootBabylonMesh));break;case o.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),t},e.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen(e+" "+(t.name||"")),t.nodes)for(var i=0,s=t.nodes;i<s.length;i++){var l=s[i],u=a.Get(e+"/nodes/"+l,this._gltf.nodes,l);o.push(this.loadNodeAsync("/nodes/"+u.index,u,(function(e){e.parent=n._rootBabylonMesh})))}if(this._gltf.nodes)for(var c=0,d=this._gltf.nodes;c<d.length;c++){if((u=d[c])._babylonTransformNode&&u._babylonBones)for(var f=0,h=u._babylonBones;f<h.length;f++){h[f].linkTransformNode(u._babylonTransformNode)}}return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then((function(){}))},e.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++){t(r[n])}},e.prototype._getGeometries=function(){var e=new Array,t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)}))}return e},e.prototype._getMeshes=function(){var e=new Array;e.push(this._rootBabylonMesh);var t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){e.push(t)}))}return e},e.prototype._getTransformNodes=function(){var e=new Array,t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode)}return e},e.prototype._getSkeletons=function(){var e=new Array,t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},e.prototype._getAnimationGroups=function(){var e=new Array,t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},e.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case o.GLTFLoaderAnimationStartMode.NONE:break;case o.GLTFLoaderAnimationStartMode.FIRST:0!==(e=this._getAnimationGroups()).length&&e[0].start(!0);break;case o.GLTFLoaderAnimationStartMode.ALL:for(var e,t=0,n=e=this._getAnimationGroups();t<n.length;t++){n[t].start(!0)}break;default:return void r.Logger.Error("Invalid animation start mode ("+this._parent.animationStartMode+")")}},e.prototype.loadNodeAsync=function(t,n,o){var i=this;void 0===o&&(o=function(){});var s=this._extensionsLoadNodeAsync(t,n,o);if(s)return s;if(n._babylonTransformNode)throw new Error(t+": Invalid recursive node hierarchy");var l=new Array;this.logOpen(t+" "+(n.name||""));var u=function(r){if(e.AddPointerMetadata(r,t),e._LoadTransform(n,r),null!=n.camera){var s=a.Get(t+"/camera",i._gltf.cameras,n.camera);l.push(i.loadCameraAsync("/cameras/"+s.index,s,(function(e){e.parent=r})))}if(n.children)for(var u=0,c=n.children;u<c.length;u++){var d=c[u],f=a.Get(t+"/children/"+d,i._gltf.nodes,d);l.push(i.loadNodeAsync("/nodes/"+f.index,f,(function(e){e.parent=r})))}o(r)};if(null==n.mesh){var c=n.name||"node"+n.index;this._babylonScene._blockEntityCollection=this._forAssetContainer,n._babylonTransformNode=new r.TransformNode(c,this._babylonScene),this._babylonScene._blockEntityCollection=!1,u(n._babylonTransformNode)}else{var d=a.Get(t+"/mesh",this._gltf.meshes,n.mesh);l.push(this._loadMeshAsync("/meshes/"+d.index,n,d,u))}return this.logClose(),Promise.all(l).then((function(){return i._forEachPrimitive(n,(function(e){e.geometry&&e.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0)})),n._babylonTransformNode}))},e.prototype._loadMeshAsync=function(e,t,n,o){var i=n.primitives;if(!i||!i.length)throw new Error(e+": Primitives are missing");null==i[0].index&&a.Assign(i);var s=new Array;this.logOpen(e+" "+(n.name||""));var l=t.name||"node"+t.index;if(1===i.length){var u=n.primitives[0];s.push(this._loadMeshPrimitiveAsync(e+"/primitives/"+u.index,l,t,n,u,(function(e){t._babylonTransformNode=e,t._primitiveBabylonMeshes=[e]})))}else{this._babylonScene._blockEntityCollection=this._forAssetContainer,t._babylonTransformNode=new r.TransformNode(l,this._babylonScene),this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(var c=0,d=i;c<d.length;c++){u=d[c];s.push(this._loadMeshPrimitiveAsync(e+"/primitives/"+u.index,l+"_primitive"+u.index,t,n,u,(function(e){e.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(e)})))}}if(null!=t.skin){var f=a.Get(e+"/skin",this._gltf.skins,t.skin);s.push(this._loadSkinAsync("/skins/"+f.index,t,f))}return o(t._babylonTransformNode),this.logClose(),Promise.all(s).then((function(){return t._babylonTransformNode}))},e.prototype._loadMeshPrimitiveAsync=function(t,n,o,i,s,l){var u=this,c=this._extensionsLoadMeshPrimitiveAsync(t,n,o,i,s,l);if(c)return c;this.logOpen(""+t);var d,f,h=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!i.primitives[0].targets;if(h&&s._instanceData)d=s._instanceData.babylonSourceMesh.createInstance(n),f=s._instanceData.promise;else{var p=new Array;this._babylonScene._blockEntityCollection=this._forAssetContainer;var _=new r.Mesh(n,this._babylonScene);this._babylonScene._blockEntityCollection=!1,_.overrideMaterialSideOrientation=this._babylonScene.useRightHandedSystem?r.Material.CounterClockWiseSideOrientation:r.Material.ClockWiseSideOrientation,this._createMorphTargets(t,o,i,s,_),p.push(this._loadVertexDataAsync(t,s,_).then((function(e){return u._loadMorphTargetsAsync(t,s,_,e).then((function(){u._babylonScene._blockEntityCollection=u._forAssetContainer,e.applyToMesh(_),u._babylonScene._blockEntityCollection=!1}))})));var m=e._GetDrawMode(t,s.mode);if(null==s.material){var y=this._defaultBabylonMaterialData[m];y||(y=this._createDefaultMaterial("__GLTFLoader._default",m),this._parent.onMaterialLoadedObservable.notifyObservers(y),this._defaultBabylonMaterialData[m]=y),_.material=y}else{var b=a.Get(t+"/material",this._gltf.materials,s.material);p.push(this._loadMaterialAsync("/materials/"+b.index,b,_,m,(function(e){_.material=e})))}f=Promise.all(p),h&&(s._instanceData={babylonSourceMesh:_,promise:f}),d=_}return e.AddPointerMetadata(d,t),this._parent.onMeshLoadedObservable.notifyObservers(d),l(d),this.logClose(),f.then((function(){return d}))},e.prototype._loadVertexDataAsync=function(e,t,n){var o=this,i=this._extensionsLoadVertexDataAsync(e,t,n);if(i)return i;var s=t.attributes;if(!s)throw new Error(e+": Attributes are missing");var l=new Array,u=new r.Geometry(n.name,this._babylonScene);if(null==t.indices)n.isUnIndexed=!0;else{var c=a.Get(e+"/indices",this._gltf.accessors,t.indices);l.push(this._loadIndicesAccessorAsync("/accessors/"+c.index,c).then((function(e){u.setIndices(e)})))}var d=function(t,i,c){if(null!=s[t]){n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(i)&&n._delayInfo.push(i);var d=a.Get(e+"/attributes/"+t,o._gltf.accessors,s[t]);l.push(o._loadVertexAccessorAsync("/accessors/"+d.index,d,i).then((function(e){if(e.getKind()===r.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!n.skeleton){var t=d.min,a=d.max;if(void 0!==t&&void 0!==a){var i=r.TmpVectors.Vector3[0],s=r.TmpVectors.Vector3[1];i.copyFromFloats.apply(i,t),s.copyFromFloats.apply(s,a),u._boundingInfo=new r.BoundingInfo(i,s),u.useBoundingInfoFromGeometry=!0}}u.setVerticesBuffer(e,d.count)}))),i==r.VertexBuffer.MatricesIndicesExtraKind&&(n.numBoneInfluencers=8),c&&c(d)}};return d("POSITION",r.VertexBuffer.PositionKind),d("NORMAL",r.VertexBuffer.NormalKind),d("TANGENT",r.VertexBuffer.TangentKind),d("TEXCOORD_0",r.VertexBuffer.UVKind),d("TEXCOORD_1",r.VertexBuffer.UV2Kind),d("JOINTS_0",r.VertexBuffer.MatricesIndicesKind),d("WEIGHTS_0",r.VertexBuffer.MatricesWeightsKind),d("JOINTS_1",r.VertexBuffer.MatricesIndicesExtraKind),d("WEIGHTS_1",r.VertexBuffer.MatricesWeightsExtraKind),d("COLOR_0",r.VertexBuffer.ColorKind,(function(e){"VEC4"===e.type&&(n.hasVertexAlpha=!0)})),Promise.all(l).then((function(){return u}))},e.prototype._createMorphTargets=function(e,t,n,o,a){if(o.targets){if(null==t._numMorphTargets)t._numMorphTargets=o.targets.length;else if(o.targets.length!==t._numMorphTargets)throw new Error(e+": Primitives do not have the same number of targets");var i=n.extras?n.extras.targetNames:null;a.morphTargetManager=new r.MorphTargetManager(a.getScene());for(var s=0;s<o.targets.length;s++){var l=t.weights?t.weights[s]:n.weights?n.weights[s]:0,u=i?i[s]:"morphTarget"+s;a.morphTargetManager.addTarget(new r.MorphTarget(u,l,a.getScene()))}}},e.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync(e+"/targets/"+i,r,t.targets[i],s))}return Promise.all(o).then((function(){}))},e.prototype._loadMorphTargetVertexDataAsync=function(e,t,n,o){var i=this,s=new Array,l=function(r,o,l){if(null!=n[r]){var u=t.getVertexBuffer(o);if(u){var c=a.Get(e+"/"+r,i._gltf.accessors,n[r]);s.push(i._loadFloatAccessorAsync("/accessors/"+c.index,c).then((function(e){l(u,e)})))}}};return l("POSITION",r.VertexBuffer.PositionKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,(function(e,r){n[r]=t[r]+e})),o.setPositions(n)})),l("NORMAL",r.VertexBuffer.NormalKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,(function(e,r){n[r]=t[r]+e})),o.setNormals(n)})),l("TANGENT",r.VertexBuffer.TangentKind,(function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,(function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)})),o.setTangents(n)})),Promise.all(s).then((function(){}))},e._LoadTransform=function(e,t){if(null==e.skin){var n=r.Vector3.Zero(),o=r.Quaternion.Identity(),a=r.Vector3.One();if(e.matrix)r.Matrix.FromArray(e.matrix).decompose(a,o,n);else e.translation&&(n=r.Vector3.FromArray(e.translation)),e.rotation&&(o=r.Quaternion.FromArray(e.rotation)),e.scale&&(a=r.Vector3.FromArray(e.scale));t.position=n,t.rotationQuaternion=o,t.scaling=a}},e.prototype._loadSkinAsync=function(e,t,n){var o=this,a=this._extensionsLoadSkinAsync(e,t,n);if(a)return a;var i=function(e){o._forEachPrimitive(t,(function(t){t.skeleton=e}))};if(n._data)return i(n._data.babylonSkeleton),n._data.promise;var s="skeleton"+n.index;this._babylonScene._blockEntityCollection=this._forAssetContainer;var l=new r.Skeleton(n.name||s,s,this._babylonScene);this._babylonScene._blockEntityCollection=!1,l.overrideMesh=this._rootBabylonMesh,this._loadBones(e,n,l),i(l);var u=this._loadSkinInverseBindMatricesDataAsync(e,n).then((function(e){o._updateBoneMatrices(l,e)}));return n._data={babylonSkeleton:l,promise:u},u},e.prototype._loadBones=function(e,t,n){for(var r={},o=0,i=t.joints;o<i.length;o++){var s=i[o],l=a.Get(e+"/joints/"+s,this._gltf.nodes,s);this._loadBone(l,t,n,r)}},e.prototype._loadBone=function(e,t,n,o){var a=o[e.index];if(a)return a;var i=null;e.parent&&e.parent._babylonTransformNode!==this._rootBabylonMesh&&(i=this._loadBone(e.parent,t,n,o));var s=t.joints.indexOf(e.index);return a=new r.Bone(e.name||"joint"+e.index,n,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,e._babylonBones=e._babylonBones||[],e._babylonBones.push(a),a},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=a.Get(e+"/inverseBindMatrices",this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/"+n.index,n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,o=e.bones;n<o.length;n++){var a=o[n],i=r.Matrix.Identity(),s=a._index;t&&-1!==s&&(r.Matrix.FromArrayToRef(t,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getInvertedAbsoluteTransform(),i),a.setBindPose(i),a.updateMatrix(i,!1,!1),a._updateDifferenceMatrix(void 0,!1)}},e.prototype._getNodeMatrix=function(e){return e.matrix?r.Matrix.FromArray(e.matrix):r.Matrix.Compose(e.scale?r.Vector3.FromArray(e.scale):r.Vector3.One(),e.rotation?r.Quaternion.FromArray(e.rotation):r.Quaternion.Identity(),e.translation?r.Vector3.FromArray(e.translation):r.Vector3.Zero())},e.prototype.loadCameraAsync=function(t,n,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(t,n,o);if(a)return a;var i=new Array;this.logOpen(t+" "+(n.name||"")),this._babylonScene._blockEntityCollection=this._forAssetContainer;var s=new r.FreeCamera(n.name||"camera"+n.index,r.Vector3.Zero(),this._babylonScene,!1);switch(this._babylonScene._blockEntityCollection=!1,s.ignoreParentScaling=!0,s.rotation=new r.Vector3(0,Math.PI,0),n.type){case"perspective":var l=n.perspective;if(!l)throw new Error(t+": Camera perspective properties are missing");s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||Number.MAX_VALUE;break;case"orthographic":if(!n.orthographic)throw new Error(t+": Camera orthographic properties are missing");s.mode=r.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-n.orthographic.xmag,s.orthoRight=n.orthographic.xmag,s.orthoBottom=-n.orthographic.ymag,s.orthoTop=n.orthographic.ymag,s.minZ=n.orthographic.znear,s.maxZ=n.orthographic.zfar;break;default:throw new Error(t+": Invalid camera type ("+n.type+")")}return e.AddPointerMetadata(s,t),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then((function(){return s}))},e.prototype._loadAnimationsAsync=function(){var e=this._gltf.animations;if(!e)return Promise.resolve();for(var t=new Array,n=0;n<e.length;n++){var r=e[n];t.push(this.loadAnimationAsync("/animations/"+r.index,r))}return Promise.all(t).then((function(){}))},e.prototype.loadAnimationAsync=function(e,t){var n=this._extensionsLoadAnimationAsync(e,t);if(n)return n;this._babylonScene._blockEntityCollection=this._forAssetContainer;var o=new r.AnimationGroup(t.name||"animation"+t.index,this._babylonScene);this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=o;var i=new Array;a.Assign(t.channels),a.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var u=l[s];i.push(this._loadAnimationChannelAsync(e+"/channels/"+u.index,e,t,u,o))}return Promise.all(i).then((function(){return o.normalize(0),o}))},e.prototype._loadAnimationChannelAsync=function(e,t,n,o,i,s){var l=this;if(void 0===s&&(s=null),null==o.target.node)return Promise.resolve();var u=a.Get(e+"/target/node",this._gltf.nodes,o.target.node);if("weights"===o.target.path&&!u._numMorphTargets||"weights"!==o.target.path&&!u._babylonTransformNode)return Promise.resolve();var c=a.Get(e+"/sampler",n.samplers,o.sampler);return this._loadAnimationSamplerAsync(t+"/samplers/"+o.sampler,c).then((function(t){var n,a;switch(o.target.path){case"translation":n="position",a=r.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":n="rotationQuaternion",a=r.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":n="scaling",a=r.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":n="influence",a=r.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error(e+"/target/path: Invalid value ("+o.target.path+")")}var c,d,f=0;switch(n){case"position":c=function(){var e=r.Vector3.FromArray(t.output,f);return f+=3,e};break;case"rotationQuaternion":c=function(){var e=r.Quaternion.FromArray(t.output,f);return f+=4,e};break;case"scaling":c=function(){var e=r.Vector3.FromArray(t.output,f);return f+=3,e};break;case"influence":c=function(){for(var e=new Array(u._numMorphTargets),n=0;n<u._numMorphTargets;n++)e[n]=t.output[f++];return e}}switch(t.interpolation){case"STEP":d=function(e){return{frame:t.input[e],value:c(),interpolation:r.AnimationKeyInterpolation.STEP}};break;case"LINEAR":d=function(e){return{frame:t.input[e],value:c()}};break;case"CUBICSPLINE":d=function(e){return{frame:t.input[e],inTangent:c(),value:c(),outTangent:c()}}}for(var h=new Array(t.input.length),p=0;p<t.input.length;p++)h[p]=d(p);if("influence"===n)for(var _=function(e){var t=i.name+"_channel"+i.targetedAnimations.length,o=new r.Animation(t,n,1,a);o.setKeys(h.map((function(t){return{frame:t.frame,inTangent:t.inTangent?t.inTangent[e]:void 0,value:t.value[e],outTangent:t.outTangent?t.outTangent[e]:void 0}}))),l._forEachPrimitive(u,(function(t){var n=t.morphTargetManager.getTarget(e),r=o.clone();n.animations.push(r),i.addTargetedAnimation(r,n)}))},m=0;m<u._numMorphTargets;m++)_(m);else{var y=i.name+"_channel"+i.targetedAnimations.length,b=new r.Animation(y,n,1,a);b.setKeys(h),null!=s&&null!=s.animations?(s.animations.push(b),i.addTargetedAnimation(b,s)):(u._babylonTransformNode.animations.push(b),i.addTargetedAnimation(b,u._babylonTransformNode))}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(e+"/interpolation: Invalid value ("+t.interpolation+")")}var r=a.Get(e+"/input",this._gltf.accessors,t.input),o=a.Get(e+"/output",this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/"+r.index,r),this._loadFloatAccessorAsync("/accessors/"+o.index,o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype._loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync(e+"/uri",t,t.uri);else{if(!this._bin)throw new Error(e+": Uri is missing or the binary glTF is missing its binary chunk");t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error(e+": "+t.message)}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=a.Get(e+"/buffer",this._gltf.buffers,t.buffer);return t._data=this._loadBufferAsync("/buffers/"+r.index,r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,o){var i=this;if(n._data)return n._data;var s=e._GetNumComponents(t,n.type),l=s*r.VertexBuffer.GetTypeByteLength(n.componentType),u=s*n.count;if(null==n.bufferView)n._data=Promise.resolve(new o(u));else{var c=a.Get(t+"/bufferView",this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/"+c.index,c).then((function(a){if(5126!==n.componentType||n.normalized||c.byteStride&&c.byteStride!==l){var i=new o(u);return r.VertexBuffer.ForEach(a,n.byteOffset||0,c.byteStride||l,s,n.componentType,i.length,n.normalized||!1,(function(e,t){i[t]=e})),i}return e._GetTypedArray(t,n.componentType,a,n.byteOffset,u)}))}if(n.sparse){var d=n.sparse;n._data=n._data.then((function(u){var c=u,f=a.Get(t+"/sparse/indices/bufferView",i._gltf.bufferViews,d.indices.bufferView),h=a.Get(t+"/sparse/values/bufferView",i._gltf.bufferViews,d.values.bufferView);return Promise.all([i.loadBufferViewAsync("/bufferViews/"+f.index,f),i.loadBufferViewAsync("/bufferViews/"+h.index,h)]).then((function(a){var i,u=a[0],f=a[1],h=e._GetTypedArray(t+"/sparse/indices",d.indices.componentType,u,d.indices.byteOffset,d.count),p=s*d.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray(t+"/sparse/values",n.componentType,f,d.values.byteOffset,p);i=new o(p),r.VertexBuffer.ForEach(_,0,l,s,n.componentType,i.length,n.normalized||!1,(function(e,t){i[t]=e}))}else i=e._GetTypedArray(t+"/sparse/values",n.componentType,f,d.values.byteOffset,p);for(var m=0,y=0;y<h.length;y++)for(var b=h[y]*s,v=0;v<s;v++)c[b++]=i[m++];return c}))}))}return n._data},e.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},e.prototype._loadIndicesAccessorAsync=function(t,n){if("SCALAR"!==n.type)throw new Error(t+"/type: Invalid value "+n.type);if(5121!==n.componentType&&5123!==n.componentType&&5125!==n.componentType)throw new Error(t+"/componentType: Invalid value "+n.componentType);if(n._data)return n._data;if(n.sparse){var r=e._GetTypedArrayConstructor(t+"/componentType",n.componentType);n._data=this._loadAccessorAsync(t,n,r)}else{var o=a.Get(t+"/bufferView",this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/"+o.index,o).then((function(r){return e._GetTypedArray(t,n.componentType,r,n.byteOffset,n.count)}))}return n._data},e.prototype._loadVertexBufferViewAsync=function(e,t){var n=this;return e._babylonBuffer||(e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/"+e.index,e).then((function(e){return new r.Buffer(n._babylonScene.getEngine(),e,!1)}))),e._babylonBuffer},e.prototype._loadVertexAccessorAsync=function(t,n,o){var i=this;if(n._babylonVertexBuffer)return n._babylonVertexBuffer;if(n.sparse)n._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+n.index,n).then((function(e){return new r.VertexBuffer(i._babylonScene.getEngine(),e,o,!1)}));else if(n.byteOffset&&n.byteOffset%r.VertexBuffer.GetTypeByteLength(n.componentType)!=0)r.Logger.Warn("Accessor byte offset is not a multiple of component type byte length"),n._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+n.index,n).then((function(e){return new r.VertexBuffer(i._babylonScene.getEngine(),e,o,!1)}));else if(o===r.VertexBuffer.MatricesIndicesKind||o===r.VertexBuffer.MatricesIndicesExtraKind)n._babylonVertexBuffer=this._loadFloatAccessorAsync("/accessors/"+n.index,n).then((function(e){return new r.VertexBuffer(i._babylonScene.getEngine(),e,o,!1)}));else{var s=a.Get(t+"/bufferView",this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer=this._loadVertexBufferViewAsync(s,o).then((function(a){var l=e._GetNumComponents(t,n.type);return new r.VertexBuffer(i._babylonScene.getEngine(),a,o,!1,!1,s.byteStride,!1,n.byteOffset,l,n.componentType,n.normalized,!0,1,!0)}))}return n._babylonVertexBuffer},e.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;return t&&(t.baseColorFactor?(n.albedoColor=r.Color3.FromArray(t.baseColorFactor),n.alpha=t.baseColorFactor[3]):n.albedoColor=r.Color3.White(),n.metallic=null==t.metallicFactor?1:t.metallicFactor,n.roughness=null==t.roughnessFactor?1:t.roughnessFactor,t.baseColorTexture&&o.push(this.loadTextureInfoAsync(e+"/baseColorTexture",t.baseColorTexture,(function(e){e.name=n.name+" (Base Color)",n.albedoTexture=e}))),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync(e+"/metallicRoughnessTexture",t.metallicRoughnessTexture,(function(e){e.name=n.name+" (Metallic Roughness)",n.metallicTexture=e}))),n.useMetallnessFromMetallicTextureBlue=!0,n.useRoughnessFromMetallicTextureGreen=!0,n.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(o).then((function(){}))},e.prototype._loadMaterialAsync=function(t,n,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(t,n,r,o,a);if(i)return i;n._data=n._data||{};var s=n._data[o];if(!s){this.logOpen(t+" "+(n.name||""));var l=this.createMaterial(t,n,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(t,n,l)},n._data[o]=s,e.AddPointerMetadata(l,t),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce((function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)}))),a(s.babylonMaterial),s.promise.then((function(){return s.babylonMaterial}))},e.prototype._createDefaultMaterial=function(e,t){this._babylonScene._blockEntityCollection=this._forAssetContainer;var n=new r.PBRMaterial(e,this._babylonScene);return this._babylonScene._blockEntityCollection=!1,n.fillMode=t,n.enableSpecularAntiAliasing=!0,n.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,n.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,n.transparencyMode=r.PBRMaterial.PBRMATERIAL_OPAQUE,n.metallic=1,n.roughness=1,n},e.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material"+t.index;return this._createDefaultMaterial(o,n)},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync(e+"/pbrMetallicRoughness",t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then((function(){}))},e.prototype.loadMaterialBasePropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;return n.emissiveColor=t.emissiveFactor?r.Color3.FromArray(t.emissiveFactor):new r.Color3(0,0,0),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync(e+"/normalTexture",t.normalTexture,(function(e){e.name=n.name+" (Normal)",n.bumpTexture=e}))),n.invertNormalMapX=!this._babylonScene.useRightHandedSystem,n.invertNormalMapY=this._babylonScene.useRightHandedSystem,null!=t.normalTexture.scale&&(n.bumpTexture.level=t.normalTexture.scale),n.forceIrradianceInFragment=!0),t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync(e+"/occlusionTexture",t.occlusionTexture,(function(e){e.name=n.name+" (Occlusion)",n.ambientTexture=e}))),n.useAmbientInGrayScale=!0,null!=t.occlusionTexture.strength&&(n.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&o.push(this.loadTextureInfoAsync(e+"/emissiveTexture",t.emissiveTexture,(function(e){e.name=n.name+" (Emissive)",n.emissiveTexture=e}))),Promise.all(o).then((function(){}))},e.prototype.loadMaterialAlphaProperties=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");switch(t.alphaMode||"OPAQUE"){case"OPAQUE":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_ALPHATEST,n.alphaCutOff=null==t.alphaCutoff?.5:t.alphaCutoff,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0);break;case"BLEND":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_ALPHABLEND,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0,n.useAlphaFromAlbedoTexture=!0);break;default:throw new Error(e+"/alphaMode: Invalid value ("+t.alphaMode+")")}},e.prototype.loadTextureInfoAsync=function(t,n,r){var o=this;void 0===r&&(r=function(){});var i=this._extensionsLoadTextureInfoAsync(t,n,r);if(i)return i;if(this.logOpen(""+t),n.texCoord>=2)throw new Error(t+"/texCoord: Invalid value ("+n.texCoord+")");var s=a.Get(t+"/index",this._gltf.textures,n.index);s._textureInfo=n;var l=this._loadTextureAsync("/textures/"+n.index,s,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),l},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen(t+" "+(n.name||""));var i=null==n.sampler?e.DefaultSampler:a.Get(t+"/sampler",this._gltf.samplers,n.sampler),s=a.Get(t+"/source",this._gltf.images,n.source),l=this._createTextureAsync(t,i,s,r);return this.logClose(),l},e.prototype._createTextureAsync=function(e,t,n,o,a){var i=this;void 0===o&&(o=function(){});var s=this._loadSampler("/samplers/"+t.index,t),l=new Array,u=new r.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var c=new r.Texture(null,this._babylonScene,s.noMipMaps,!1,s.samplingMode,(function(){i._disposed||u.resolve()}),(function(t,n){i._disposed||u.reject(new Error(e+": "+(n&&n.message?n.message:t||"Failed to load texture")))}),void 0,void 0,void 0,n.mimeType,a);return this._babylonScene._blockEntityCollection=!1,l.push(u.promise),l.push(this.loadImageAsync("/images/"+n.index,n).then((function(e){var t=n.uri||i._fileName+"#image"+n.index,r="data:"+i._uniqueRootUrl+t;c.updateURL(r,e)}))),c.wrapU=s.wrapU,c.wrapV=s.wrapV,o(c),Promise.all(l).then((function(){return c}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode(t+"/wrapS",n.wrapS),wrapV:e._GetTextureWrapMode(t+"/wrapT",n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+" "+(t.name||"")),t.uri)t._data=this.loadUriAsync(e+"/uri",t,t.uri);else{var n=a.Get(e+"/bufferView",this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/"+n.index,n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,o){var a=this,i=this._extensionsLoadUriAsync(t,n,o);if(i)return i;if(!e._ValidateUri(o))throw new Error(t+": '"+o+"' is invalid");if(r.Tools.IsBase64(o)){var s=new Uint8Array(r.Tools.DecodeBase64(o));return this.log("Decoded "+o.substr(0,64)+"... ("+s.length+" bytes)"),Promise.resolve(s)}return this.log("Loading "+o),this._parent.preprocessUrlAsync(this._rootUrl+o).then((function(e){return new Promise((function(n,i){a._parent._loadFile(e,a._babylonScene,(function(e){a._disposed||(a.log("Loaded "+o+" ("+e.byteLength+" bytes)"),n(new Uint8Array(e)))}),!0,(function(e){i(new r.LoadFileError(t+": Failed to load '"+o+"'"+(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){var n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return r.Texture.CLAMP_ADDRESSMODE;case 33648:return r.Texture.MIRROR_ADDRESSMODE;case 10497:return r.Texture.WRAP_ADDRESSMODE;default:return r.Logger.Warn(e+": Invalid value ("+t+")"),r.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,o=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(o){case 9728:return r.Texture.LINEAR_NEAREST;case 9729:return r.Texture.LINEAR_LINEAR;case 9984:return r.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return r.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return r.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return r.Texture.LINEAR_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+"/minFilter: Invalid value ("+o+")"),r.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&r.Logger.Warn(e+"/magFilter: Invalid value ("+n+")"),o){case 9728:return r.Texture.NEAREST_NEAREST;case 9729:return r.Texture.NEAREST_LINEAR;case 9984:return r.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return r.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return r.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return r.Texture.NEAREST_LINEAR_MIPLINEAR;default:return r.Logger.Warn(e+"/minFilter: Invalid value ("+o+")"),r.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error(e+": Invalid component type "+t)}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor(t+"/componentType",n);try{return new s(i,o,a)}catch(e){throw new Error(t+": "+e)}},e._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+")")},e._ValidateUri=function(e){return r.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return r.Material.PointListDrawMode;case 1:return r.Material.LineListDrawMode;case 2:return r.Material.LineLoopDrawMode;case 3:return r.Material.LineStripDrawMode;case 4:return r.Material.TriangleFillMode;case 5:return r.Material.TriangleStripDrawMode;case 6:return r.Material.TriangleFanDrawMode}throw new Error(e+": Invalid mesh primitive mode ("+t+")")},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var u=l[s];u.computeWorldMatrix(!0);var c=i.babylonMaterial;t.push(c.forceCompilationAsync(u)),t.push(c.forceCompilationAsync(u,{useInstances:!0})),this._parent.useClipPlane&&(t.push(c.forceCompilationAsync(u,{clipPlane:!0})),t.push(c.forceCompilationAsync(u,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile materials")}))},e.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile shadow generators")}))},e.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},e.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i=a.name+"."+t,s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var u=n(a);if(u)return u}finally{delete l[i]}}}}return null},e.prototype._extensionsOnLoading=function(){this._forEachExtensions((function(e){return e.onLoading&&e.onLoading()}))},e.prototype._extensionsOnReady=function(){this._forEachExtensions((function(e){return e.onReady&&e.onReady()}))},e.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",(function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)}))},e.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",(function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)}))},e.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",(function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)}))},e.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",(function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)}))},e.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",(function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)}))},e.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",(function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)}))},e.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",(function(r){return r.createMaterial&&r.createMaterial(e,t,n)}))},e.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",(function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)}))},e.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",(function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)}))},e.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",(function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)}))},e.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",(function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)}))},e.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",(function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)}))},e.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",(function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)}))},e.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",(function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)}))},e.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",(function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)}))},e.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r(e+"/extensions/"+n,o):null},e.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r(e+"/extras/"+n,o):null},e.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},e.prototype.logOpen=function(e){this._parent._logOpen(e)},e.prototype.logClose=function(){this._parent._logClose()},e.prototype.log=function(e){this._parent._log(e)},e.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},e.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},e._RegisteredExtensions={},e.DefaultSampler={index:-1},e}();o.GLTFFileLoader._CreateGLTF2Loader=function(e){return new i(e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFLoaderCoordinateSystemMode",(function(){return r})),n.d(t,"GLTFLoaderAnimationStartMode",(function(){return o})),n.d(t,"GLTFLoaderState",(function(){return a})),n.d(t,"GLTFFileLoader",(function(){return l}));var r,o,a,i=n(0),s=n(3);!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(r||(r={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(o||(o={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(a||(a={}));var l=function(){function e(){this.onParsedObservable=new i.Observable,this.coordinateSystemMode=r.AUTO,this.animationStartMode=o.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new i.Observable,this.onTextureLoadedObservable=new i.Observable,this.onMaterialLoadedObservable=new i.Observable,this.onCameraLoadedObservable=new i.Observable,this.onCompleteObservable=new i.Observable,this.onErrorObservable=new i.Observable,this.onDisposeObservable=new i.Observable,this.onExtensionLoadedObservable=new i.Observable,this.validate=!1,this.onValidatedObservable=new i.Observable,this._loader=null,this._requests=new Array,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(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.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:!1,configurable:!0}),Object.defineProperty(e.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++){t[e].abort()}this._requests.length=0,delete this._progressCallback,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(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},e.prototype.requestFile=function(e,t,n,r,o,a){var s=this;if(this._progressCallback=r,o){if(this.useRangeRequests){this.validate&&i.Logger.Warn("glTF validation is not supported when range requests are enabled");var l={abort:function(){},onCompleteObservable:new i.Observable},u={readAsync:function(n,r){return new Promise((function(o,a){s._requestFile(t,e,(function(e){o(new Uint8Array(e))}),!0,(function(e){a(e)}),(function(e){e.setRequestHeader("Range","bytes="+n+"-"+(n+r-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new i.DataReader(u)).then((function(e){l.onCompleteObservable.notifyObservers(l),n(e)}),a),l}return this._requestFile(t,e,(function(e,t){var r=e;s._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(r,e,t))},byteLength:r.byteLength})).then((function(e){n(e,t)}),a)}),!0,a)}return this._requestFile(t,e,(function(r,o){s._validate(e,r,i.Tools.GetFolderPath(t),i.Tools.GetFilename(t)),n({json:s._parseJson(r)},o)}),o,a)},e.prototype.readFile=function(e,t,n,r,o,a){var s=this;return e._readFile(t,(function(r){if(s._validate(e,r,"file:",t.name),o){var l=r;s._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(l,e,t))},byteLength:l.byteLength})).then(n,a)}else n({json:s._parseJson(r)})}),r,o,a)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading "+(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,!1,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading "+(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading "+(o||"")),a._loader=a._getLoader(t);var s=new i.AssetContainer(e),l=[];a.onMaterialLoadedObservable.add((function(e){l.push(e),e.onDisposeObservable.addOnce((function(){var t=s.materials.indexOf(e);t>-1&&s.materials.splice(t,1),(t=l.indexOf(e))>-1&&l.splice(t,1)}))}));var u=[];a.onTextureLoadedObservable.add((function(e){u.push(e),e.onDisposeObservable.addOnce((function(){var t=s.textures.indexOf(e);t>-1&&s.textures.splice(t,1),(t=u.indexOf(e))>-1&&u.splice(t,1)}))}));var c=[];return a.onCameraLoadedObservable.add((function(e){c.push(e)})),a._loader.importMeshAsync(null,e,!0,t,n,r,o).then((function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),s}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||i.StringTools.StartsWith(t,"data:base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:model/gltf-binary;base64,"+e.magicBase64Encoded)},e.prototype.directLoad=function(t,n){if(i.StringTools.StartsWith(n,"base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"model/gltf-binary;base64,"+e.magicBase64Encoded)){var r=i.Tools.DecodeBase64(n);return this._validate(t,r),this._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(r,e,t))},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._loadFile=function(e,t,n,r,o){var a=this,i=t._loadFile(e,n,(function(e){a._onProgress(e,i)}),void 0,r,o);return i.onCompleteObservable.add((function(e){a._requests.splice(a._requests.indexOf(e),1)})),this._requests.push(i),i},e.prototype._requestFile=function(e,t,n,r,o,a){var i=this,s=t._requestFile(e,n,(function(e){i._onProgress(e,s)}),void 0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},e.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),s.GLTFValidation.ValidateAsync(t,n,r,(function(t){return o.preprocessUrlAsync(n+t).then((function(t){return e._loadFileAsync(t,void 0,!0,!0)}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),i.Tools.Warn("Failed to validate: "+e.message),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(t){var n=t.json.asset||{};this._log("Asset version: "+n.version),n.minVersion&&this._log("Asset minimum version: "+n.minVersion),n.generator&&this._log("Asset generator: "+n.generator);var r=e._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=e._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+e.length);var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new Error("Unexpected magic: "+n);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: "+r);var o,a=e.readUint32();if(0!==e.buffer.byteLength&&a!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+a+" != "+e.buffer.byteLength);switch(r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: "+r);var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=5130562,a=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+a===t?e.loadAsync(a).then((function(){return{json:n._parseJson(e.readString(a)),bin:null}})):e.loadAsync(a+8).then((function(){var i={json:n._parseJson(e.readString(a)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case o:var a=e.byteOffset;i.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(i)};return s()}))},e._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},e._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},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(t){var n=e._logSpaces.substr(0,2*this._logIndentLevel);i.Logger.Log(""+n+t)},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){i.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){i.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e.magicBase64Encoded="Z2xURg",e._logSpaces=" ",e}();i.SceneLoader&&i.SceneLoader.RegisterPlugin(new l)},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFValidation",(function(){return i}));var r=n(0);function o(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function a(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":o(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var i=function(){function e(){}return e.ValidateAsync=function(e,t,n,i){var s=this;return"function"==typeof Worker?new Promise((function(l,u){var c=o+"("+a+")()",d=URL.createObjectURL(new Blob([c],{type:"application/javascript"})),f=new Worker(d),h=function(e){f.removeEventListener("error",h),f.removeEventListener("message",p),u(e)},p=function(e){var t=e.data;switch(t.id){case"getExternalResource":i(t.uri).then((function(e){f.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e])}),(function(e){f.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":f.removeEventListener("error",h),f.removeEventListener("message",p),l(t.value);break;case"validate.reject":f.removeEventListener("error",h),f.removeEventListener("message",p),u(t.reason)}};f.addEventListener("error",h),f.addEventListener("message",p),f.postMessage({id:"init",url:r.Tools.GetAbsoluteUrl(s.Configuration.url)}),f.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=r.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return o(e,t,n,i)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return a}));
2
- /*! *****************************************************************************
3
- Copyright (c) Microsoft Corporation.
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
- PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */
16
- var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};Object.create;Object.create},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t)},function(e,t,n){"use strict";n.r(t),n.d(t,"EXT_lights_image_based",(function(){return i})),n.d(t,"EXT_mesh_gpu_instancing",(function(){return s})),n.d(t,"EXT_texture_webp",(function(){return l})),n.d(t,"KHR_draco_mesh_compression",(function(){return u})),n.d(t,"KHR_lights",(function(){return c})),n.d(t,"KHR_materials_pbrSpecularGlossiness",(function(){return d})),n.d(t,"KHR_materials_unlit",(function(){return f})),n.d(t,"KHR_materials_clearcoat",(function(){return h})),n.d(t,"KHR_materials_sheen",(function(){return p})),n.d(t,"KHR_materials_specular",(function(){return _})),n.d(t,"KHR_materials_ior",(function(){return m})),n.d(t,"KHR_materials_variants",(function(){return y})),n.d(t,"KHR_materials_transmission",(function(){return g})),n.d(t,"KHR_materials_translucency",(function(){return A})),n.d(t,"KHR_mesh_quantization",(function(){return T})),n.d(t,"KHR_texture_basisu",(function(){return x})),n.d(t,"KHR_texture_transform",(function(){return E})),n.d(t,"MSFT_audio_emitter",(function(){return L})),n.d(t,"MSFT_lod",(function(){return O})),n.d(t,"MSFT_minecraftMesh",(function(){return M})),n.d(t,"MSFT_sRGBFactors",(function(){return S})),n.d(t,"ExtrasAsMetadata",(function(){return w}));var r=n(0),o=n(1),a="EXT_lights_image_based",i=function(){function e(e){this.name=a,this._loader=e,this.enabled=this._loader.isExtensionUsed(a)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){var i=new Array;i.push(n._loader.loadSceneAsync(e,t)),n._loader.logOpen(""+r);var s=o.a.Get(r+"/light",n._lights,a.light);return i.push(n._loadLightAsync("/extensions/"+n.name+"/lights/"+a.light,s).then((function(e){n._loader.babylonScene.environmentTexture=e}))),n._loader.logClose(),Promise.all(i).then((function(){}))}))},e.prototype._loadLightAsync=function(e,t){var n=this;if(!t._loaded){var a=new Array;this._loader.logOpen(""+e);for(var i=new Array(t.specularImages.length),s=function(n){var r=t.specularImages[n];i[n]=new Array(r.length);for(var s=function(t){var s=e+"/specularImages/"+n+"/"+t;l._loader.logOpen(""+s);var u=r[t],c=o.a.Get(s,l._loader.gltf.images,u);a.push(l._loader.loadImageAsync("/images/"+u,c).then((function(e){i[n][t]=e}))),l._loader.logClose()},u=0;u<r.length;u++)s(u)},l=this,u=0;u<t.specularImages.length;u++)s(u);this._loader.logClose(),t._loaded=Promise.all(a).then((function(){var e=new r.RawCubeTexture(n._loader.babylonScene,null,t.specularImageSize);if(e.name=t.name||"environment",t._babylonTexture=e,null!=t.intensity&&(e.level=t.intensity),t.rotation){var o=r.Quaternion.FromArray(t.rotation);n._loader.babylonScene.useRightHandedSystem||(o=r.Quaternion.Inverse(o)),r.Matrix.FromQuaternionToRef(o,e.getReflectionTextureMatrix())}var a=r.SphericalHarmonics.FromArray(t.irradianceCoefficients);a.scaleInPlace(t.intensity),a.convertIrradianceToLambertianRadiance();var s=r.SphericalPolynomial.FromHarmonics(a),l=(i.length-1)/r.Scalar.Log2(t.specularImageSize);return e.updateRGBDAsync(i,s,l)}))}return t._loaded.then((function(){return t._babylonTexture}))},e}();o.b.RegisterExtension(a,(function(e){return new i(e)}));var s=function(){function e(e){this.name="EXT_mesh_gpu_instancing",this._loader=e,this.enabled=this._loader.isExtensionUsed("EXT_mesh_gpu_instancing")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,i){a._loader._disableInstancedMesh++;var s=a._loader.loadNodeAsync("/nodes/"+t.index,t,n);if(a._loader._disableInstancedMesh--,!t._primitiveBabylonMeshes)return s;var l=new Array,u=0,c=function(t){if(null!=i.attributes[t]){var n=o.a.Get(e+"/attributes/"+t,a._loader.gltf.accessors,i.attributes[t]);if(l.push(a._loader._loadFloatAccessorAsync("/accessors/"+n.bufferView,n)),0===u)u=n.count;else if(u!==n.count)throw new Error(e+"/attributes: Instance buffer accessors do not have the same count.")}else l.push(Promise.resolve(null))};return c("TRANSLATION"),c("ROTATION"),c("SCALE"),s.then((function(e){return Promise.all(l).then((function(n){var o=n[0],a=n[1],i=n[2],s=new Float32Array(16*u);r.TmpVectors.Vector3[0].copyFromFloats(0,0,0),r.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),r.TmpVectors.Vector3[1].copyFromFloats(1,1,1);for(var l=0;l<u;++l)o&&r.Vector3.FromArrayToRef(o,3*l,r.TmpVectors.Vector3[0]),a&&r.Quaternion.FromArrayToRef(a,4*l,r.TmpVectors.Quaternion[0]),i&&r.Vector3.FromArrayToRef(i,3*l,r.TmpVectors.Vector3[1]),r.Matrix.ComposeToRef(r.TmpVectors.Vector3[1],r.TmpVectors.Quaternion[0],r.TmpVectors.Vector3[0],r.TmpVectors.Matrix[0]),r.TmpVectors.Matrix[0].copyToArray(s,16*l);for(var c=0,d=t._primitiveBabylonMeshes;c<d.length;c++){d[c].thinInstanceSetBuffer("matrix",s,16,!0)}return e}))}))}))},e}();o.b.RegisterExtension("EXT_mesh_gpu_instancing",(function(e){return new s(e)}));var l=function(){function e(e){this.name="EXT_texture_webp",this._loader=e,this.enabled=e.isExtensionUsed("EXT_texture_webp")}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(a,i){var s=null==t.sampler?o.b.DefaultSampler:o.a.Get(e+"/sampler",r._loader.gltf.samplers,t.sampler),l=o.a.Get(a+"/source",r._loader.gltf.images,i.source);return r._loader._createTextureAsync(e,s,l,(function(e){n(e)}))}))},e}();o.b.RegisterExtension("EXT_texture_webp",(function(e){return new l(e)}));var u=function(){function e(e){this.name="KHR_draco_mesh_compression",this._loader=e,this.enabled=r.DracoCompression.DecoderAvailable&&this._loader.isExtensionUsed("KHR_draco_mesh_compression")}return e.prototype.dispose=function(){delete this.dracoCompression,this._loader=null},e.prototype._loadVertexDataAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(i,s){if(null!=t.mode){if(5!==t.mode&&4!==t.mode)throw new Error(e+": Unsupported mode "+t.mode);if(5===t.mode)throw new Error(e+": Mode "+t.mode+" is not currently supported")}var l={},u=function(e,t){var r=s.attributes[e];null!=r&&(n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(t)&&n._delayInfo.push(t),l[t]=r)};u("POSITION",r.VertexBuffer.PositionKind),u("NORMAL",r.VertexBuffer.NormalKind),u("TANGENT",r.VertexBuffer.TangentKind),u("TEXCOORD_0",r.VertexBuffer.UVKind),u("TEXCOORD_1",r.VertexBuffer.UV2Kind),u("JOINTS_0",r.VertexBuffer.MatricesIndicesKind),u("WEIGHTS_0",r.VertexBuffer.MatricesWeightsKind),u("COLOR_0",r.VertexBuffer.ColorKind);var c=o.a.Get(i,a._loader.gltf.bufferViews,s.bufferView);return c._dracoBabylonGeometry||(c._dracoBabylonGeometry=a._loader.loadBufferViewAsync("/bufferViews/"+c.index,c).then((function(t){return(a.dracoCompression||r.DracoCompression.Default).decodeMeshAsync(t,l).then((function(e){var t=new r.Geometry(n.name,a._loader.babylonScene);return e.applyToGeometry(t),t})).catch((function(t){throw new Error(e+": "+t.message)}))}))),c._dracoBabylonGeometry}))},e}();o.b.RegisterExtension("KHR_draco_mesh_compression",(function(e){return new u(e)}));var c=function(){function e(e){this.name="KHR_lights_punctual",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_lights_punctual")}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(i,s){return a._loader.loadNodeAsync(e,t,(function(e){var t,l=o.a.Get(i,a._lights,s.light),u=l.name||e.name;switch(a._loader.babylonScene._blockEntityCollection=a._loader._forAssetContainer,l.type){case"directional":t=new r.DirectionalLight(u,r.Vector3.Backward(),a._loader.babylonScene);break;case"point":t=new r.PointLight(u,r.Vector3.Zero(),a._loader.babylonScene);break;case"spot":var c=new r.SpotLight(u,r.Vector3.Zero(),r.Vector3.Backward(),0,1,a._loader.babylonScene);c.angle=2*(l.spot&&l.spot.outerConeAngle||Math.PI/4),c.innerAngle=2*(l.spot&&l.spot.innerConeAngle||0),t=c;break;default:throw a._loader.babylonScene._blockEntityCollection=!1,new Error(i+": Invalid light type ("+l.type+")")}a._loader.babylonScene._blockEntityCollection=!1,t.falloffType=r.Light.FALLOFF_GLTF,t.diffuse=l.color?r.Color3.FromArray(l.color):r.Color3.White(),t.intensity=null==l.intensity?1:l.intensity,t.range=null==l.range?Number.MAX_VALUE:l.range,t.parent=e,a._loader._babylonLights.push(t),o.b.AddPointerMetadata(t,i),n(e)}))}))},e}();o.b.RegisterExtension("KHR_lights_punctual",(function(e){return new c(e)}));var d=function(){function e(e){this.name="KHR_materials_pbrSpecularGlossiness",this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_pbrSpecularGlossiness")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loadSpecularGlossinessPropertiesAsync(o,t,a,n)),r._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(i).then((function(){}))}))},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,t,n,o){if(!(o instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var a=new Array;return o.metallic=null,o.roughness=null,n.diffuseFactor?(o.albedoColor=r.Color3.FromArray(n.diffuseFactor),o.alpha=n.diffuseFactor[3]):o.albedoColor=r.Color3.White(),o.reflectivityColor=n.specularFactor?r.Color3.FromArray(n.specularFactor):r.Color3.White(),o.microSurface=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync(e+"/diffuseTexture",n.diffuseTexture,(function(e){e.name=o.name+" (Diffuse)",o.albedoTexture=e}))),n.specularGlossinessTexture&&(n.specularGlossinessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(e+"/specularGlossinessTexture",n.specularGlossinessTexture,(function(e){e.name=o.name+" (Specular Glossiness)",o.reflectivityTexture=e}))),o.reflectivityTexture.hasAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(a).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_pbrSpecularGlossiness",(function(e){return new d(e)}));var f=function(){function e(e){this.name="KHR_materials_unlit",this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_unlit")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(){return r._loadUnlitPropertiesAsync(e,t,n)}))},e.prototype._loadUnlitPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;n.unlit=!0;var a=t.pbrMetallicRoughness;return a&&(a.baseColorFactor?(n.albedoColor=r.Color3.FromArray(a.baseColorFactor),n.alpha=a.baseColorFactor[3]):n.albedoColor=r.Color3.White(),a.baseColorTexture&&o.push(this._loader.loadTextureInfoAsync(e+"/baseColorTexture",a.baseColorTexture,(function(e){e.name=n.name+" (Base Color)",n.albedoTexture=e})))),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_unlit",(function(e){return new f(e)}));var h=function(){function e(e){this.name="KHR_materials_clearcoat",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_clearcoat")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadClearCoatPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;return n.clearCoat.isEnabled=!0,n.clearCoat.useRoughnessFromMainTexture=!1,n.clearCoat.remapF0OnInterfaceChange=!1,null!=t.clearcoatFactor?n.clearCoat.intensity=t.clearcoatFactor:n.clearCoat.intensity=0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync(e+"/clearcoatTexture",t.clearcoatTexture,(function(e){e.name=n.name+" (ClearCoat Intensity)",n.clearCoat.texture=e}))),null!=t.clearcoatRoughnessFactor?n.clearCoat.roughness=t.clearcoatRoughnessFactor:n.clearCoat.roughness=0,t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(e+"/clearcoatRoughnessTexture",t.clearcoatRoughnessTexture,(function(e){e.name=n.name+" (ClearCoat Roughness)",n.clearCoat.textureRoughness=e})))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(e+"/clearcoatNormalTexture",t.clearcoatNormalTexture,(function(e){e.name=n.name+" (ClearCoat Normal)",n.clearCoat.bumpTexture=e}))),n.invertNormalMapX=!n.getScene().useRightHandedSystem,n.invertNormalMapY=n.getScene().useRightHandedSystem,null!=t.clearcoatNormalTexture.scale&&(n.clearCoat.bumpTexture.level=t.clearcoatNormalTexture.scale)),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_clearcoat",(function(e){return new h(e)}));var p=function(){function e(e){this.name="KHR_materials_sheen",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_sheen")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadSheenPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadSheenPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;return n.sheen.isEnabled=!0,n.sheen.intensity=1,null!=t.sheenColorFactor?n.sheen.color=r.Color3.FromArray(t.sheenColorFactor):n.sheen.color=r.Color3.Black(),t.sheenColorTexture&&o.push(this._loader.loadTextureInfoAsync(e+"/sheenColorTexture",t.sheenColorTexture,(function(e){e.name=n.name+" (Sheen Color)",n.sheen.texture=e}))),void 0!==t.sheenRoughnessFactor?n.sheen.roughness=t.sheenRoughnessFactor:n.sheen.roughness=0,t.sheenRoughnessTexture&&(t.sheenRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(e+"/sheenRoughnessTexture",t.sheenRoughnessTexture,(function(e){e.name=n.name+" (Sheen Roughness)",n.sheen.textureRoughness=e})))),n.sheen.albedoScaling=!0,n.sheen.useRoughnessFromMainTexture=!1,Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_sheen",(function(e){return new p(e)}));var _=function(){function e(e){this.name="KHR_materials_specular",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_specular")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadSpecularPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadSpecularPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var o=new Array;return void 0!==t.specularFactor&&(n.metallicF0Factor=t.specularFactor),void 0!==t.specularColorFactor&&(n.metallicReflectanceColor=r.Color3.FromArray(t.specularColorFactor)),t.specularTexture&&(t.specularTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(e+"/specularTexture",t.specularTexture,(function(e){e.name=n.name+" (Specular F0 Color)",n.metallicReflectanceTexture=e})))),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_specular",(function(e){return new _(e)}));var m=function(){function e(e){this.name="KHR_materials_ior",this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_ior")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadIorPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadIorPropertiesAsync=function(t,n,o){if(!(o instanceof r.PBRMaterial))throw new Error(t+": Material type not supported");return void 0!==n.ior?o.indexOfRefraction=n.ior:o.indexOfRefraction=e._DEFAULT_IOR,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();o.b.RegisterExtension("KHR_materials_ior",(function(e){return new m(e)}));var y=function(){function e(e){this.name="KHR_materials_variants",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_variants")}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the KHR_materials_variants extension");var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++){r(a[o])}else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){return e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the KHR_materials_variants extension");for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){return e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the KHR_materials_variants extension");return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n.KHR_materials_variants)||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype._loadMeshPrimitiveAsync=function(e,t,n,a,i,s){var l=this;return o.b.LoadExtensionAsync(e,i,this.name,(function(u,c){var d=new Array;return d.push(l._loader._loadMeshPrimitiveAsync(e,t,n,a,i,(function(t){if(s(t),t instanceof r.Mesh){var n=o.b._GetDrawMode(e,i.mode),a=l._loader.rootBabylonMesh,f=a.metadata=a.metadata||{},h=f.gltf=f.gltf||{},p=h.KHR_materials_variants=h.KHR_materials_variants||{lastSelected:null,original:[],variants:{}};p.original.push({mesh:t,material:t.material});for(var _=p.variants,m=0,y=c.mappings;m<y.length;m++)for(var b=y[m],v=function(e){var r=o.a.Get(u+"/mapping/"+e,l._variants,e),a=o.a.Get("#/materials/",l._loader.gltf.materials,b.material);d.push(l._loader._loadMaterialAsync("#/materials/"+b.material,a,t,n,(function(e){_[r.name]=_[r.name]||[],_[r.name].push({mesh:t,material:e})})))},g=0,A=b.variants;g<A.length;g++){v(A[g])}}}))),Promise.all(d).then((function(e){return e[0]}))}))},e}();o.b.RegisterExtension("KHR_materials_variants",(function(e){return new y(e)}));var b=n(4),v=function(){function e(t,n){var o=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._options=Object(b.a)(Object(b.a)({},e._getDefaultOptions()),t),this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new r.Observable,this._scene.onDisposeObservable.addOnce((function(e){o.dispose()})),this._parseScene(),this._setupRenderTargets()}return e._getDefaultOptions=function(){return{renderSize:512}},e.prototype.updateOptions=function(e){var t=this;if(Object.keys(e).filter((function(n){return t._options[n]!==e[n]})).length){var n=Object(b.a)(Object(b.a)({},this._options),e),r=this._options;this._options=n,n.renderSize!==r.renderSize&&this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype.shouldRenderAsTransmission=function(e){return!!e&&!!(e instanceof r.PBRMaterial&&e.subSurface.isRefractionEnabled)},e.prototype._addMesh=function(e){e instanceof r.Mesh&&(e.onMaterialChangedObservable.add(this.onMeshMaterialChanged.bind(this)),this.shouldRenderAsTransmission(e.material)?this._transparentMeshesCache.push(e):this._opaqueMeshesCache.push(e))},e.prototype._removeMesh=function(e){if(e instanceof r.Mesh){e.onMaterialChangedObservable.remove(this.onMeshMaterialChanged.bind(this));var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1)}},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype.onMeshMaterialChanged=function(e){if(e instanceof r.Mesh){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);this.shouldRenderAsTransmission(e.material)?(e.material instanceof r.PBRMaterial&&(e.material.subSurface.refractionTexture=this._opaqueRenderTarget),-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e)):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)}},e.prototype._setupRenderTargets=function(){var e=this,t=-1;if(this._scene.layers&&this._opaqueRenderTarget)for(var n=0,o=this._scene.layers;n<o.length;n++){var a=(l=o[n]).renderTargetTextures.indexOf(this._opaqueRenderTarget);a>=0&&l.renderTargetTextures.splice(a,1)}if(this._opaqueRenderTarget&&(t=this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget),this._opaqueRenderTarget.dispose()),this._opaqueRenderTarget=new r.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,!0),this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.gammaSpace=!0,this._opaqueRenderTarget.lodGenerationScale=1,this._opaqueRenderTarget.lodGenerationOffset=-4,t>=0?this._scene.customRenderTargets.splice(t,0,this._opaqueRenderTarget):(t=this._scene.customRenderTargets.length,this._scene.customRenderTargets.push(this._opaqueRenderTarget)),this._scene.layers&&this._opaqueRenderTarget)for(var i=0,s=this._scene.layers;i<s.length;i++){var l;(l=s[i]).renderTargetTextures.push(this._opaqueRenderTarget)}this._transparentMeshesCache.forEach((function(t){e.shouldRenderAsTransmission(t.material)&&t.material instanceof r.PBRMaterial&&(t.material.refractionTexture=e._opaqueRenderTarget)}))},e.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]},e}(),g=function(){function e(e){this.name="KHR_materials_transmission",this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_transmission"),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadTransparentPropertiesAsync(o,t,n,a)),Promise.all(i).then((function(){}))}))},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,o){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var a=n;if(a.subSurface.isRefractionEnabled=!0,a.subSurface.volumeIndexOfRefraction=1,a.subSurface.useAlbedoToTintRefraction=!0,void 0===o.transmissionFactor)return a.subSurface.refractionIntensity=0,a.subSurface.isRefractionEnabled=!1,Promise.resolve();a.subSurface.refractionIntensity=o.transmissionFactor;var i=a.getScene();return a.subSurface.refractionIntensity&&!i._transmissionHelper&&new v({},a.getScene()),o.transmissionTexture?(o.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync(e+"/transmissionTexture",o.transmissionTexture,void 0).then((function(e){a.subSurface.thicknessTexture=e,a.subSurface.useMaskFromThicknessTextureGltf=!0}))):Promise.resolve()},e}();o.b.RegisterExtension("KHR_materials_transmission",(function(e){return new g(e)}));var A=function(){function e(e){this.name="KHR_materials_translucency",this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_translucency"),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadTranslucentPropertiesAsync(o,t,n,a)),Promise.all(i).then((function(){}))}))},e.prototype._loadTranslucentPropertiesAsync=function(e,t,n,o){if(!(n instanceof r.PBRMaterial))throw new Error(e+": Material type not supported");var a=n;return a.subSurface.isTranslucencyEnabled=!0,a.subSurface.volumeIndexOfRefraction=1,a.subSurface.minimumThickness=0,a.subSurface.maximumThickness=0,a.subSurface.useAlbedoToTintRefraction=!0,void 0===o.translucencyFactor?(a.subSurface.translucencyIntensity=0,a.subSurface.isTranslucencyEnabled=!1,Promise.resolve()):(a.subSurface.translucencyIntensity=o.translucencyFactor,o.translucencyTexture?this._loader.loadTextureInfoAsync(e+"/translucencyTexture",o.translucencyTexture).then((function(e){a.subSurface.thicknessTexture=e,a.subSurface.useMaskFromThicknessTextureGltf=!0})):Promise.resolve())},e}();o.b.RegisterExtension("KHR_materials_translucency",(function(e){return new A(e)}));var T=function(){function e(e){this.name="KHR_mesh_quantization",this.enabled=e.isExtensionUsed("KHR_mesh_quantization")}return e.prototype.dispose=function(){},e}();o.b.RegisterExtension("KHR_mesh_quantization",(function(e){return new T(e)}));var x=function(){function e(e){this.name="KHR_texture_basisu",this._loader=e,this.enabled=e.isExtensionUsed("KHR_texture_basisu")}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(a,i){var s=null==t.sampler?o.b.DefaultSampler:o.a.Get(e+"/sampler",r._loader.gltf.samplers,t.sampler),l=o.a.Get(a+"/source",r._loader.gltf.images,i.source);return r._loader._createTextureAsync(e,s,l,(function(e){n(e)}),t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0)}))},e}();o.b.RegisterExtension("KHR_texture_basisu",(function(e){return new x(e)}));var E=function(){function e(e){this.name="KHR_texture_transform",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_texture_transform")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,i){return a._loader.loadTextureInfoAsync(e,t,(function(e){if(!(e instanceof r.Texture))throw new Error(o+": Texture type not supported");i.offset&&(e.uOffset=i.offset[0],e.vOffset=i.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,i.rotation&&(e.wAng=-i.rotation),i.scale&&(e.uScale=i.scale[0],e.vScale=i.scale[1]),null!=i.texCoord&&(e.coordinatesIndex=i.texCoord),n(e)}))}))},e}();o.b.RegisterExtension("KHR_texture_transform",(function(e){return new E(e)}));var L=function(){function e(e){this.name="MSFT_audio_emitter",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_audio_emitter")}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,o.a.Assign(this._clips),o.a.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){var i=new Array;i.push(n._loader.loadSceneAsync(e,t));for(var s=0,l=a.emitters;s<l.length;s++){var u=l[s],c=o.a.Get(r+"/emitters",n._emitters,u);if(null!=c.refDistance||null!=c.maxDistance||null!=c.rolloffFactor||null!=c.distanceModel||null!=c.innerAngle||null!=c.outerAngle)throw new Error(r+": Direction or Distance properties are not allowed on emitters attached to a scene");i.push(n._loadEmitterAsync(r+"/emitters/"+c.index,c))}return Promise.all(i).then((function(){}))}))},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,i){var s=new Array;return a._loader.loadNodeAsync(e,t,(function(t){for(var l=function(n){var i=o.a.Get(e+"/emitters",a._emitters,n);s.push(a._loadEmitterAsync(e+"/emitters/"+i.index,i).then((function(){for(var e=0,n=i._babylonSounds;e<n.length;e++){var o=n[e];o.attachToMesh(t),null==i.innerAngle&&null==i.outerAngle||(o.setLocalDirectionToMesh(r.Vector3.Forward()),o.setDirectionalCone(2*r.Tools.ToDegrees(null==i.innerAngle?Math.PI:i.innerAngle),2*r.Tools.ToDegrees(null==i.outerAngle?Math.PI:i.outerAngle),0))}})))},u=0,c=i.emitters;u<c.length;u++){l(c[u])}n(t)})).then((function(e){return Promise.all(s).then((function(){return e}))}))}))},e.prototype.loadAnimationAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){return n._loader.loadAnimationAsync(e,t).then((function(i){var s=new Array;o.a.Assign(a.events);for(var l=0,u=a.events;l<u.length;l++){var c=u[l];s.push(n._loadAnimationEventAsync(r+"/events/"+c.index,e,t,c,i))}return Promise.all(s).then((function(){return i}))}))}))},e.prototype._loadClipAsync=function(e,t){if(t._objectURL)return t._objectURL;var n;if(t.uri)n=this._loader.loadUriAsync(e,t,t.uri);else{var r=o.a.Get(e+"/bufferView",this._loader.gltf.bufferViews,t.bufferView);n=this._loader.loadBufferViewAsync("/bufferViews/"+r.index,r)}return t._objectURL=n.then((function(e){return URL.createObjectURL(new Blob([e],{type:t.mimeType}))})),t._objectURL},e.prototype._loadEmitterAsync=function(e,t){var n=this;if(t._babylonSounds=t._babylonSounds||[],!t._babylonData){for(var a=new Array,i=t.name||"emitter"+t.index,s={loop:!1,autoplay:!1,volume:null==t.volume?1:t.volume},l=function(e){var l="/extensions/"+u.name+"/clips",c=o.a.Get(l,u._clips,t.clips[e].clip);a.push(u._loadClipAsync(l+"/"+t.clips[e].clip,c).then((function(o){var a=t._babylonSounds[e]=new r.Sound(i,o,n._loader.babylonScene,null,s);a.refDistance=t.refDistance||1,a.maxDistance=t.maxDistance||256,a.rolloffFactor=t.rolloffFactor||1,a.distanceModel=t.distanceModel||"exponential",a._positionInEmitterSpace=!0})))},u=this,c=0;c<t.clips.length;c++)l(c);var d=Promise.all(a).then((function(){var e=t.clips.map((function(e){return e.weight||1})),n=new r.WeightedSound(t.loop||!1,t._babylonSounds,e);t.innerAngle&&(n.directionalConeInnerAngle=2*r.Tools.ToDegrees(t.innerAngle)),t.outerAngle&&(n.directionalConeOuterAngle=2*r.Tools.ToDegrees(t.outerAngle)),t.volume&&(n.volume=t.volume),t._babylonData.sound=n}));t._babylonData={loaded:d}}return t._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(e){t.stop()};case"pause":return function(e){t.pause()};default:throw new Error(e+": Unsupported action "+n)}},e.prototype._loadAnimationEventAsync=function(e,t,n,a,i){var s=this;if(0==i.targetedAnimations.length)return Promise.resolve();var l=i.targetedAnimations[0],u=a.emitter,c=o.a.Get("/extensions/"+this.name+"/emitters",this._emitters,u);return this._loadEmitterAsync(e,c).then((function(){var t=c._babylonData.sound;if(t){var n=new r.AnimationEvent(a.time,s._getEventAction(e,t,a.action,a.time,a.startOffset));l.animation.addEvent(n),i.onAnimationGroupEndObservable.add((function(){t.stop()})),i.onAnimationGroupPauseObservable.add((function(){t.pause()}))}}))},e}();o.b.RegisterExtension("MSFT_audio_emitter",(function(e){return new L(e)}));var O=function(){function e(e){this.name="MSFT_lod",this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new r.Observable,this.onMaterialLODsLoadedObservable=new r.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_lod")}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._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._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())}));n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._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._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())}));a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,n){var o,i=a._getLODs(e,t,a._loader.gltf.nodes,n.ids);a._loader.logOpen(""+e);for(var s=function(e){var t=i[e];0!==e&&(a._nodeIndexLOD=e,a._nodeSignalLODs[e]=a._nodeSignalLODs[e]||new r.Deferred);var n=a._loader.loadNodeAsync("/nodes/"+t.index,t,(function(e){e.setEnabled(!1)})).then((function(t){if(0!==e){var n=i[e-1];n._babylonTransformNode&&(a._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t}));a._nodePromiseLODs[e]=a._nodePromiseLODs[e]||[],0===e?o=n:(a._nodeIndexLOD=null,a._nodePromiseLODs[e].push(n))},l=0;l<i.length;l++)s(l);return a._loader.logClose(),o}))},e.prototype._loadMaterialAsync=function(e,t,n,r,a){var i=this;return this._nodeIndexLOD?null:o.b.LoadExtensionAsync(e,t,this.name,(function(e,o){var s,l=i._getLODs(e,t,i._loader.gltf.materials,o.ids);i._loader.logOpen(""+e);for(var u=function(e){var t=l[e];0!==e&&(i._materialIndexLOD=e);var o=i._loader._loadMaterialAsync("/materials/"+t.index,t,n,r,(function(t){0===e&&a(t)})).then((function(t){if(0!==e){a(t);var n=l[e-1]._data;n[r]&&(i._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t}));i._materialPromiseLODs[e]=i._materialPromiseLODs[e]||[],0===e?s=o:(i._materialIndexLOD=null,i._materialPromiseLODs[e].push(o))},c=0;c<l.length;c++)u(c);return i._loader.logClose(),s}))},e.prototype._loadUriAsync=function(e,t,n){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new r.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then((function(){return o._loader.loadUriAsync(e,t,n)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");a=this._materialIndexLOD-1;return this._materialSignalLODs[a]=this._materialSignalLODs[a]||new r.Deferred,this._materialSignalLODs[a].promise.then((function(){return o._loader.loadUriAsync(e,t,n)}))}return null},e.prototype.loadBufferAsync=function(e,t,n,o){if(this._loader.parent.useRangeRequests&&!t.uri){if(!this._loader.bin)throw new Error(e+": Uri is missing or the binary glTF is missing its binary chunk");var a=function(e,t){var a=n,i=a+o-1,s=e[t];return s?(s.start=Math.min(s.start,a),s.end=Math.max(s.end,i)):(s={start:a,end:i,loaded:new r.Deferred},e[t]=s),s.loaded.promise.then((function(e){return new Uint8Array(e.buffer,e.byteOffset+n-s.start,o)}))};return this._loader.log("deferred"),null!==this._nodeIndexLOD?a(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?a(this._materialBufferLODs,this._materialIndexLOD):a(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range ["+n.start+"-"+n.end+"]"),this._loader.bin.readAsync(n.start,n.end-n.start+1).then((function(e){n.loaded.resolve(e)}),(function(e){n.loaded.reject(e)})))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var a=new Array,i=r.length-1;i>=0;i--)if(a.push(o.a.Get(e+"/ids/"+r[i],n,r[i])),a.length===this.maxLODsToLoad)return a;return a.push(t),a},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter((function(e){return t._loader.babylonScene.meshes.every((function(t){return t.material!=e}))}));this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(c=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}c.dispose()}for(var s in t)for(var l=0,u=this._loader.babylonScene.materials;l<u.length;l++){var c;(c=u[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();o.b.RegisterExtension("MSFT_lod",(function(e){return new O(e)}));var M=function(){function e(e){this.name="MSFT_minecraftMesh",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_minecraftMesh")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var a=this;return o.b.LoadExtraAsync(e,t,this.name,(function(o,i){if(i){if(!(n instanceof r.PBRMaterial))throw new Error(o+": Material type not supported");var s=a._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,s}return null}))},e}();o.b.RegisterExtension("MSFT_minecraftMesh",(function(e){return new M(e)}));var S=function(){function e(e){this.name="MSFT_sRGBFactors",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_sRGBFactors")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var a=this;return o.b.LoadExtraAsync(e,t,this.name,(function(o,i){if(i){if(!(n instanceof r.PBRMaterial))throw new Error(o+": Material type not supported");var s=a._loader.loadMaterialPropertiesAsync(e,t,n);return n.albedoTexture||n.albedoColor.toLinearSpaceToRef(n.albedoColor),n.reflectivityTexture||n.reflectivityColor.toLinearSpaceToRef(n.reflectivityColor),s}return null}))},e}();o.b.RegisterExtension("MSFT_sRGBFactors",(function(e){return new S(e)}));var w=function(){function e(e){this.name="ExtrasAsMetadata",this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();o.b.RegisterExtension("ExtrasAsMetadata",(function(e){return new w(e)}))},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFBinaryExtension",(function(){return k})),n.d(t,"GLTFLoaderBase",(function(){return D})),n.d(t,"GLTFLoader",(function(){return G})),n.d(t,"GLTFLoaderExtension",(function(){return U})),n.d(t,"EComponentType",(function(){return r})),n.d(t,"EShaderType",(function(){return o})),n.d(t,"EParameterType",(function(){return a})),n.d(t,"ETextureWrapMode",(function(){return i})),n.d(t,"ETextureFilterType",(function(){return s})),n.d(t,"ETextureFormat",(function(){return l})),n.d(t,"ECullingType",(function(){return u})),n.d(t,"EBlendingFunction",(function(){return c})),n.d(t,"GLTFUtils",(function(){return p})),n.d(t,"GLTFMaterialsCommonExtension",(function(){return H}));var r,o,a,i,s,l,u,c,d=n(4);!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"}(r||(r={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(o||(o={})),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"}(a||(a={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(i||(i={})),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"}(s||(s={})),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"}(l||(l={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(u||(u={})),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"}(c||(c={}));var f,h=n(0),p=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var i=null;if("MODEL"===n.semantic?i=t.getWorldMatrix():"PROJECTION"===n.semantic?i=e.getProjectionMatrix():"VIEW"===n.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?i=h.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?i=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(i=h.Matrix.Transpose(t.getWorldMatrix().invert())),i)switch(n.type){case a.FLOAT_MAT2:o.setMatrix2x2(r,h.Matrix.GetAsMatrix2x2(i));break;case a.FLOAT_MAT3:o.setMatrix3x3(r,h.Matrix.GetAsMatrix3x3(i));break;case a.FLOAT_MAT4:o.setMatrix(r,i)}},e.SetUniform=function(e,t,n,r){switch(r){case a.FLOAT:return e.setFloat(t,n),!0;case a.FLOAT_VEC2:return e.setVector2(t,h.Vector2.FromArray(n)),!0;case a.FLOAT_VEC3:return e.setVector3(t,h.Vector3.FromArray(n)),!0;case a.FLOAT_VEC4:return e.setVector4(t,h.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case i.CLAMP_TO_EDGE:return h.Texture.CLAMP_ADDRESSMODE;case i.MIRRORED_REPEAT:return h.Texture.MIRROR_ADDRESSMODE;case i.REPEAT:default:return h.Texture.WRAP_ADDRESSMODE}},e.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}},e.GetTextureFilterMode=function(e){switch(e){case s.LINEAR:case s.LINEAR_MIPMAP_NEAREST:case s.LINEAR_MIPMAP_LINEAR:return h.Texture.TRILINEAR_SAMPLINGMODE;case s.NEAREST:case s.NEAREST_MIPMAP_NEAREST:return h.Texture.NEAREST_SAMPLINGMODE;default:return h.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,o,a){n=t.byteOffset+n;var i=e.loadedBufferViews[t.buffer];if(n+o>i.byteLength)throw new Error("Buffer access is out of range");var s=i.buffer;switch(n+=i.byteOffset,a){case r.BYTE:return new Int8Array(s,n,o);case r.UNSIGNED_BYTE:return new Uint8Array(s,n,o);case r.SHORT:return new Int16Array(s,n,o);case r.UNSIGNED_SHORT:return new Uint16Array(s,n,o);default:return new Float32Array(s,n,o)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){h.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"),h.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new h.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new h.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),_=n(2);!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(f||(f={}));var m=function(){function e(e){this._pos=0,this.currentToken=f.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 f.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=f.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=f.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}(),y=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],b=["world","view","projection","worldView","worldViewProjection","mBones"],v=["translation","rotation","scale"],g=["position","rotationQuaternion","scaling"],A=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},T=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},x=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},E=function(e){var t=null;if(e.translation||e.rotation||e.scale){var n=h.Vector3.FromArray(e.scale||[1,1,1]),r=h.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=h.Vector3.FromArray(e.translation||[0,0,0]);t=h.Matrix.Compose(n,r,o)}else t=h.Matrix.FromArray(e.matrix);return t},L=function(e,t,n,r){for(var o=0;o<r.bones.length;o++)if(r.bones[o].name===n)return r.bones[o];var a=e.nodes;for(var i in a){var s=a[i];if(s.jointName){var l=s.children;for(o=0;o<l.length;o++){var u=e.nodes[l[o]];if(u.jointName&&u.jointName===n){var c=E(s),d=new h.Bone(s.name||"",r,L(e,t,s.jointName,r),c);return d.id=i,d}}}}return null},O=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++){if(r.node.children[o]===t)return r.bone}return null},M=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},S=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},w=function(e,t,n,r,o){if(r||(r=new h.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var a=[],i=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!S(n,a.jointName)){var s=E(a),l=new h.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var u=0;u<r.length;u++)for(var c=r[u],d=c.node.children,f=0;f<d.length;f++){for(var p=null,_=0;_<r.length;_++)if(r[_].id===d[f]){p=r[_];break}p&&(p.bone._parent=c.bone,c.bone.children.push(p.bone))}}(e,r,t,a),r.bones=[];for(var s=0;s<t.jointNames.length;s++){if(g=M(e,t.jointNames[s])){var l=g.node;if(l){o=g.id;var u=e.scene.getBoneByID(o);if(u)r.bones.push(u);else{for(var c=!1,d=null,f=0;f<s;f++){var p=M(e,t.jointNames[f]);if(p){var _=p.node;if(_){var m=_.children;if(m){c=!1;for(var y=0;y<m.length;y++)if(m[y]===o){d=L(e,t,t.jointNames[f],r),c=!0;break}if(c)break}}else h.Tools.Warn("Joint named "+t.jointNames[f]+" does not exist when looking for parent")}}var b=E(l);!d&&a.length>0&&(d=O(a,o))&&-1===i.indexOf(d)&&i.push(d),new h.Bone(l.jointName||"",r,d,b).id=o}}else h.Tools.Warn("Joint named "+t.jointNames[s]+" does not exist")}}var v=r.bones;r.bones=[];for(s=0;s<t.jointNames.length;s++){var g;if(g=M(e,t.jointNames[s]))for(f=0;f<v.length;f++)if(v[f].id===g.id){r.bones.push(v[f]);break}}r.prepare();for(s=0;s<i.length;s++)r.bones.push(i[s]);return r},R=function(e,t,n,r,o){if(o||(e.scene._blockEntityCollection=e.forAssetContainer,o=new h.Mesh(t.name||"",e.scene),e.scene._blockEntityCollection=!1,o.id=r),!t.babylonNode)return o;for(var a,i=[],s=null,l=new Array,u=new Array,c=new Array,d=new Array,f=0;f<n.length;f++){var m=n[f];if(N=e.meshes[m])for(var y=0;y<N.primitives.length;y++){var b=new h.VertexData,v=N.primitives[y];v.mode;var g=v.attributes,A=null,x=null;for(var E in g)if(A=e.accessors[g[E]],x=p.GetBufferFromAccessor(e,A),"NORMAL"===E)b.normals=new Float32Array(x.length),b.normals.set(x);else if("POSITION"===E){if(_.GLTFFileLoader.HomogeneousCoordinates){b.positions=new Float32Array(x.length-x.length/4);for(var L=0;L<x.length;L+=4)b.positions[L]=x[L],b.positions[L+1]=x[L+1],b.positions[L+2]=x[L+2]}else b.positions=new Float32Array(x.length),b.positions.set(x);u.push(b.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var O=Number(E.split("_")[1]),M=h.VertexBuffer.UVKind+(0===O?"":O+1),S=new Float32Array(x.length);S.set(x),T(S),b.set(S,M)}else"JOINT"===E?(b.matricesIndices=new Float32Array(x.length),b.matricesIndices.set(x)):"WEIGHT"===E?(b.matricesWeights=new Float32Array(x.length),b.matricesWeights.set(x)):"COLOR"===E&&(b.colors=new Float32Array(x.length),b.colors.set(x));if(A=e.accessors[v.indices])x=p.GetBufferFromAccessor(e,A),b.indices=new Int32Array(x.length),b.indices.set(x),d.push(b.indices.length);else{var w=[];for(L=0;L<b.positions.length/3;L++)w.push(L);b.indices=new Int32Array(w),d.push(b.indices.length)}s?s.merge(b):s=b;var R=e.scene.getMaterialByID(v.material);i.push(null===R?p.GetDefaultMaterial(e.scene):R),l.push(0===l.length?0:l[l.length-1]+u[u.length-2]),c.push(0===c.length?0:c[c.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=e.forAssetContainer,i.length>1?(a=new h.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new h.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),o.material||(o.material=a),new h.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var C=0;for(f=0;f<n.length;f++){var N;m=n[f];if(N=e.meshes[m])for(y=0;y<N.primitives.length;y++)N.primitives[y].mode,h.SubMesh.AddToMesh(C,l[C],u[C],c[C],d[C],o,o,!0),C++}return o},C=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},N=function(e,t,n,r){var o=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var a=e.skins[t.skin];(i=R(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonByID(t.skin),null===i.skeleton&&(i.skeleton=w(e,a,0,a.babylonSkeleton,t.skin),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(t.meshes){var i;o=i=R(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[t.camera];if(s){if(e.scene._blockEntityCollection=e.forAssetContainer,"orthographic"===s.type){var l=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);l.name=t.name||"",l.mode=h.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l}else if("perspective"===s.type){var u=s[s.type],c=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c}e.scene._blockEntityCollection=!1}}}else{var d=e.lights[t.light];if(d)if("ambient"===d.type){var f=d[d.type],p=new h.HemisphericLight(t.light,h.Vector3.Zero(),e.scene);p.name=t.name||"",f.color&&(p.diffuse=h.Color3.FromArray(f.color)),o=p}else if("directional"===d.type){var _=d[d.type],m=new h.DirectionalLight(t.light,h.Vector3.Zero(),e.scene);m.name=t.name||"",_.color&&(m.diffuse=h.Color3.FromArray(_.color)),o=m}else if("point"===d.type){var y=d[d.type],b=new h.PointLight(t.light,h.Vector3.Zero(),e.scene);b.name=t.name||"",y.color&&(b.diffuse=h.Color3.FromArray(y.color)),o=b}else if("spot"===d.type){var v=d[d.type],g=new h.SpotLight(t.light,h.Vector3.Zero(),h.Vector3.Zero(),0,0,e.scene);g.name=t.name||"",v.color&&(g.diffuse=h.Color3.FromArray(v.color)),v.fallOfAngle&&(g.angle=v.fallOfAngle),v.fallOffExponent&&(g.exponent=v.fallOffExponent),o=g}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===o){e.scene._blockEntityCollection=e.forAssetContainer;var A=new h.Mesh(t.name||"",e.scene);e.scene._blockEntityCollection=!1,t.babylonNode=A,o=A}}if(null!==o){if(t.matrix&&o instanceof h.Mesh)!function(e,t,n){if(t.matrix){var r=new h.Vector3(0,0,0),o=new h.Quaternion,a=new h.Vector3(0,0,0);h.Matrix.FromArray(t.matrix).decompose(a,o,r),C(e,r,o,a)}else t.translation&&t.rotation&&t.scale&&C(e,h.Vector3.FromArray(t.translation),h.Quaternion.FromArray(t.rotation),h.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(o,t);else{var T=t.translation||[0,0,0],x=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];C(o,h.Vector3.FromArray(T),h.Quaternion.FromArray(x),h.Vector3.FromArray(E))}o.updateCache(!0),t.babylonNode=o}return o},P=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&r&&null!==(a=N(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)P(e,o.children[i],a,r)},I=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)P(e,t.nodes[n],null);else for(var r in e.scenes){t=e.scenes[r];for(n=0;n<t.nodes.length;n++)P(e,t.nodes[n],null)}!function(e){for(var t in e.animations){var n=e.animations[t];if(n.channels&&n.samplers)for(var r=null,o=0;o<n.channels.length;o++){var a=n.channels[o],i=n.samplers[a.sampler];if(i){var s=null,l=null;n.parameters?(s=n.parameters[i.input],l=n.parameters[i.output]):(s=i.input,l=i.output);var u=p.GetBufferFromAccessor(e,e.accessors[s]),c=p.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,f=e.scene.getNodeByID(d);if(null===f&&(f=e.scene.getNodeByName(d)),null!==f){var _=f instanceof h.Bone,m=a.target.path,y=v.indexOf(m);-1!==y&&(m=g[y]);var b=h.Animation.ANIMATIONTYPE_MATRIX;_||("rotationQuaternion"===m?(b=h.Animation.ANIMATIONTYPE_QUATERNION,f.rotationQuaternion=new h.Quaternion):b=h.Animation.ANIMATIONTYPE_VECTOR3);var A=null,T=[],x=0,E=!1;_&&r&&r.getKeys().length===u.length&&(A=r,E=!0),E||(e.scene._blockEntityCollection=e.forAssetContainer,A=new h.Animation(t,_?"_matrix":m,1,b,h.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var L=0;L<u.length;L++){var O=null;if("rotationQuaternion"===m?(O=h.Quaternion.FromArray([c[x],c[x+1],c[x+2],c[x+3]]),x+=4):(O=h.Vector3.FromArray([c[x],c[x+1],c[x+2]]),x+=3),_){var M=f,S=h.Vector3.Zero(),w=new h.Quaternion,R=h.Vector3.Zero(),C=M.getBaseMatrix();E&&r&&(C=r.getKeys()[L].value),C.decompose(R,w,S),"position"===m?S=O:"rotationQuaternion"===m?w=O:R=O,O=h.Matrix.Compose(R,w,S)}E?r&&(r.getKeys()[L].value=O):T.push({frame:u[L],value:O})}!E&&A&&(A.setKeys(T),f.animations.push(A)),r=A,e.scene.stopAnimation(f),e.scene.beginAnimation(f,0,u[u.length-1],!0,1)}else h.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e);for(n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},F=function(e,t,n,r,o,i){return function(s){!function(e,t,n,r,o){var i=r.values||n.parameters,s=n.uniforms;for(var l in o){var u=o[l],c=u.type,d=i[s[l]];if(void 0===d&&(d=u.value),d){var f=function(e){return function(n){u.value&&e&&(t.setTexture(e,n),delete o[e])}};c===a.SAMPLER_2D?U.LoadTextureAsync(e,r.values?d:u.value,f(l),(function(){return f(null)})):u.value&&p.SetUniform(t,l,r.values?d:u.value,c)&&delete o[l]}}}(e,t,n,r,o),t.onBind=function(s){!function(e,t,n,r,o,i,s){var l=i.values||o.parameters;for(var u in n){var c=n[u],d=c.type;if(d===a.FLOAT_MAT2||d===a.FLOAT_MAT3||d===a.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var f=t.scene.getNodeByName(c.source||c.node||"");if(null===f&&(f=t.scene.getNodeByID(c.source||c.node||"")),null===f)continue;p.SetMatrix(t.scene,f,c,u,r.getEffect())}}else p.SetMatrix(t.scene,e,c,u,r.getEffect());else{var h=l[o.uniforms[u]];if(!h)continue;if(d===a.SAMPLER_2D){var _=t.textures[i.values?h:c.value].babylonTexture;if(null==_)continue;r.getEffect().setTexture(u,_)}else p.SetUniform(r.getEffect(),u,h,d)}}s(r)}(s,e,o,t,n,r,i)}}},B=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=y.indexOf(a.semantic);if(-1!==i)return delete n[r],b[i]}}return e.currentIdentifier},V=function(e){for(var t in e.materials)U.LoadMaterialAsync(e,t,(function(e){}),(function(){}))},D=function(){function e(){}return e.CreateRuntime=function(e,t,n){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:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],forAssetContainer:!1};return e.extensions&&A(e.extensions,"extensions",r),e.extensionsUsed&&A(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&A(e.bufferViews,"bufferViews",r),e.accessors&&A(e.accessors,"accessors",r),e.meshes&&A(e.meshes,"meshes",r),e.lights&&A(e.lights,"lights",r),e.cameras&&A(e.cameras,"cameras",r),e.nodes&&A(e.nodes,"nodes",r),e.images&&A(e.images,"images",r),e.textures&&A(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&A(e.programs,"programs",r),e.samplers&&A(e.samplers,"samplers",r),e.techniques&&A(e.techniques,"techniques",r),e.materials&&A(e.materials,"materials",r),e.animations&&A(e.animations,"animations",r),e.skins&&A(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,t,n,r,o){var a=e.buffers[t];h.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(h.Tools.DecodeBase64(a.uri)))})):h.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,n,r){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)n(null);else{var a=e.images[o.source];h.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(h.Tools.DecodeBase64(a.uri)))})):h.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))}else r("")},e.CreateTextureAsync=function(e,t,n,r,o){var a=e.textures[t];if(a.babylonTexture)r(a.babylonTexture);else{var i=e.samplers[a.sampler],l=i.minFilter===s.NEAREST_MIPMAP_NEAREST||i.minFilter===s.NEAREST_MIPMAP_LINEAR||i.minFilter===s.LINEAR_MIPMAP_NEAREST||i.minFilter===s.LINEAR_MIPMAP_LINEAR,u=h.Texture.BILINEAR_SAMPLINGMODE,c=null==n?new Blob:new Blob([n]),d=URL.createObjectURL(c),f=function(){return URL.revokeObjectURL(d)},_=new h.Texture(d,e.scene,!l,!0,u,f,f);void 0!==i.wrapS&&(_.wrapU=p.GetWrapMode(i.wrapS)),void 0!==i.wrapT&&(_.wrapV=p.GetWrapMode(i.wrapT)),_.name=t,a.babylonTexture=_,r(_)}},e.LoadShaderStringAsync=function(e,t,n,r){var o=e.shaders[t];if(h.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);n&&n(a)}else h.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,(function(e){e&&r&&r(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(o.technique){var i=e.techniques[o.technique];if(!i){e.scene._blockEntityCollection=e.forAssetContainer;var s=new h.StandardMaterial(t,e.scene);return e.scene._blockEntityCollection=!1,s.diffuseColor=new h.Color3(.5,.5,.5),s.sideOrientation=h.Material.CounterClockWiseSideOrientation,void n(s)}var l=e.programs[i.program],d=i.states,p=h.Effect.ShadersStore[l.vertexShader+"VertexShader"],_=h.Effect.ShadersStore[l.fragmentShader+"PixelShader"],v="",g="",A=new m(p),T=new m(_),E={},L=[],O=[],M=[];for(var S in i.uniforms){var w=i.uniforms[S],R=i.parameters[w];if(E[S]=R,!R.semantic||R.node||R.source)R.type===a.SAMPLER_2D?M.push(S):L.push(S);else{var C=y.indexOf(R.semantic);-1!==C?(L.push(b[C]),delete E[S]):L.push(S)}}for(var N in i.attributes){var P=i.attributes[N];if((D=i.parameters[P]).semantic){var I=x(D);I&&O.push(I)}}for(;!A.isEnd()&&A.getNextToken();){if(A.currentToken===f.IDENTIFIER){var V=!1;for(var N in i.attributes){P=i.attributes[N];var D=i.parameters[P];if(A.currentIdentifier===N&&D.semantic){v+=x(D),V=!0;break}}V||(v+=B(A,i,E))}else v+=A.currentString}for(;!T.isEnd()&&T.getNextToken();){T.currentToken===f.IDENTIFIER?g+=B(T,i,E):g+=T.currentString}var G={vertex:l.vertexShader+t,fragment:l.fragmentShader+t},U={attributes:O,uniforms:L,samplers:M,needAlphaBlending:d&&d.enable&&-1!==d.enable.indexOf(3042)};h.Effect.ShadersStore[l.vertexShader+t+"VertexShader"]=v,h.Effect.ShadersStore[l.fragmentShader+t+"PixelShader"]=g;var k=new h.ShaderMaterial(t,e.scene,G,U);if(k.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(l,k,r),k.onCompiled=F(e,k,i,o,E,n),k.sideOrientation=h.Material.CounterClockWiseSideOrientation,d&&d.functions){var H=d.functions;H.cullFace&&H.cullFace[0]!==u.BACK&&(k.backFaceCulling=!1);var K=H.blendFuncSeparate;K&&(K[0]===c.SRC_ALPHA&&K[1]===c.ONE_MINUS_SRC_ALPHA&&K[2]===c.ONE&&K[3]===c.ONE?k.alphaMode=h.Constants.ALPHA_COMBINE:K[0]===c.ONE&&K[1]===c.ONE&&K[2]===c.ZERO&&K[3]===c.ONE?k.alphaMode=h.Constants.ALPHA_ONEONE:K[0]===c.SRC_ALPHA&&K[1]===c.ONE&&K[2]===c.ZERO&&K[3]===c.ONE?k.alphaMode=h.Constants.ALPHA_ADD:K[0]===c.ZERO&&K[1]===c.ONE_MINUS_SRC_COLOR&&K[2]===c.ONE&&K[3]===c.ONE?k.alphaMode=h.Constants.ALPHA_SUBTRACT:K[0]===c.DST_COLOR&&K[1]===c.ZERO&&K[2]===c.ONE&&K[3]===c.ONE?k.alphaMode=h.Constants.ALPHA_MULTIPLY:K[0]===c.SRC_ALPHA&&K[1]===c.ONE_MINUS_SRC_COLOR&&K[2]===c.ONE&&K[3]===c.ONE&&(k.alphaMode=h.Constants.ALPHA_MAXIMIZED))}}else r&&r("No technique found.")},e}(),G=function(){function e(){this.state=null}return e.RegisterExtension=function(t){e.Extensions[t.name]?h.Tools.Error('Tool with the same name "'+t.name+'" already exists'):e.Extensions[t.name]=t},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,t,n,r,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,U.LoadRuntimeAsync(t,n,r,(function(t){t.forAssetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],h.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var n=new Array,r=new Array;for(var s in t.nodes){var u=t.nodes[s];u.babylonNode instanceof h.AbstractMesh&&n.push(u.babylonNode)}for(var c in t.skins){var d=t.skins[c];d.babylonSkeleton instanceof h.Skeleton&&r.push(d.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){V(t),I(t),!_.GLTFFileLoader.IncrementalLoading&&a&&a(n,r)}))}),i),_.GLTFFileLoader.IncrementalLoading&&a&&a(n,r)}),s),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,r,o,n,(function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[]})}),a,(function(e){l(new Error(e))}))}))},e.prototype._loadAsync=function(e,t,n,r,o,a,i){var s=this;e.useRightHandedSystem=!0,U.LoadRuntimeAsync(e,t,n,(function(e){U.LoadRuntimeExtensionsAsync(e,(function(){s._createNodes(e),s._loadBuffersAsync(e,(function(){s._loadShadersAsync(e,(function(){V(e),I(e),_.GLTFFileLoader.IncrementalLoading||o()}))})),_.GLTFFileLoader.IncrementalLoading&&o()}),i)}),i)},e.prototype.loadAsync=function(e,t,n,r){var o=this;return new Promise((function(a,i){o._loadAsync(e,t,n,!1,(function(){a()}),r,(function(e){i(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,t){var n=!1,r=function(n,r){U.LoadShaderStringAsync(e,n,(function(a){a instanceof ArrayBuffer||(e.loadedShaderCount++,a&&(h.Effect.ShadersStore[n+(r.type===o.VERTEX?"VertexShader":"PixelShader")]=a),e.loadedShaderCount===e.shaderscount&&t())}),(function(){h.Tools.Error("Error when loading shader program named "+n+" located at "+r.uri)}))};for(var a in e.shaders){n=!0;var i=e.shaders[a];i?r.bind(this,a,i)():h.Tools.Error("No shader named: "+a)}n||t()},e.prototype._loadBuffersAsync=function(e,t,n){var r=!1,o=function(n,r){U.LoadBufferAsync(e,n,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&h.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+r.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){h.Tools.Error("Error when loading buffer named "+n+" located at "+r.uri)}))};for(var a in e.buffers){r=!0;var i=e.buffers[a];i?o.bind(this,a,i)():h.Tools.Error("No buffer named: "+a)}r||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)P(e,t.nodes[n],null);else for(var r in e.scenes){t=e.scenes[r];for(n=0;n<t.nodes.length;n++)P(e,t.nodes[n],null)}},e.Extensions={},e}(),U=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,r,o,a)}),(function(){setTimeout((function(){o&&o(D.CreateRuntime(n.json,t,r))}))}))},e.LoadRuntimeExtensionsAsync=function(t,n,r){e.ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,n,r)}),(function(){setTimeout((function(){n()}))}))},e.LoadBufferAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.loadBufferAsync(t,n,r,o,a)}),(function(){D.LoadBufferAsync(t,n,r,o,a)}))},e.LoadTextureAsync=function(t,n,r,o){e.LoadTextureBufferAsync(t,n,(function(a){a&&e.CreateTextureAsync(t,n,a,r,o)}),o)},e.LoadShaderStringAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,r,o)}),(function(){D.LoadShaderStringAsync(t,n,r,o)}))},e.LoadMaterialAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,r,o)}),(function(){D.LoadMaterialAsync(t,n,r,o)}))},e.LoadTextureBufferAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,r,o)}),(function(){D.LoadTextureBufferAsync(t,n,r,o)}))},e.CreateTextureAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.createTextureAsync(t,n,r,o,a)}),(function(){D.CreateTextureAsync(t,n,r,o,a)}))},e.ApplyExtensions=function(e,t){for(var n in G.Extensions){if(e(G.Extensions[n]))return}t()},e}();_.GLTFFileLoader._CreateGLTF1Loader=function(){return new G};var k=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return Object(d.b)(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r,o){var a=t.json.extensionsUsed;return!(!a||-1===a.indexOf(this.name)||!t.bin)&&(this._bin=t.bin,r(D.CreateRuntime(t.json,e,n)),!0)},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,(function(e){return r(e.message)})),!0))},t.prototype.loadTextureBufferAsync=function(e,t,n,o){var a=e.textures[t],i=e.images[a.source];if(!i.extensions||!(this.name in i.extensions))return!1;var s=i.extensions[this.name],l=e.bufferViews[s.bufferView];return n(p.GetBufferFromBufferView(e,l,0,l.byteLength,r.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n,o){var a=e.shaders[t];if(!a.extensions||!(this.name in a.extensions))return!1;var i=a.extensions[this.name],s=e.bufferViews[i.bufferView],l=p.GetBufferFromBufferView(e,s,0,s.byteLength,r.UNSIGNED_BYTE);return setTimeout((function(){var e=p.DecodeBufferToText(l);n(e)})),!0},t}(U);G.RegisterExtension(new k);var H=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return Object(d.b)(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e,t,n){if(!e.extensions)return!1;var r=e.extensions[this.name];if(!r)return!1;var o=r.lights;if(o)for(var a in o){var i=o[a];switch(i.type){case"ambient":var s=new h.HemisphericLight(i.name,new h.Vector3(0,1,0),e.scene),l=i.ambient;l&&(s.diffuse=h.Color3.FromArray(l.color||[1,1,1]));break;case"point":var u=new h.PointLight(i.name,new h.Vector3(10,10,10),e.scene),c=i.point;c&&(u.diffuse=h.Color3.FromArray(c.color||[1,1,1]));break;case"directional":var d=new h.DirectionalLight(i.name,new h.Vector3(0,-1,0),e.scene),f=i.directional;f&&(d.diffuse=h.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var p=i.spot;if(p)new h.SpotLight(i.name,new h.Vector3(0,10,0),new h.Vector3(0,-1,0),p.fallOffAngle||Math.PI,p.fallOffExponent||0,e.scene).diffuse=h.Color3.FromArray(p.color||[1,1,1]);break;default:h.Tools.Warn('GLTF Material Common extension: light type "'+i.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new h.StandardMaterial(t,e.scene);return i.sideOrientation=h.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",r):i.ambientColor=h.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",r):i.diffuseColor=h.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",r):i.emissiveColor=h.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",r):i.specularColor=h.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,n,r,o){D.LoadTextureBufferAsync(e,t,(function(a){D.CreateTextureAsync(e,t,a,(function(e){return n[r]=e}),o)}),o)},t}(U);G.RegisterExtension(new H)},function(e,t,n){"use strict";n.r(t),n.d(t,"ArrayItem",(function(){return r.a})),n.d(t,"GLTFLoader",(function(){return r.b})),n.d(t,"EXT_lights_image_based",(function(){return o.EXT_lights_image_based})),n.d(t,"EXT_mesh_gpu_instancing",(function(){return o.EXT_mesh_gpu_instancing})),n.d(t,"EXT_texture_webp",(function(){return o.EXT_texture_webp})),n.d(t,"KHR_draco_mesh_compression",(function(){return o.KHR_draco_mesh_compression})),n.d(t,"KHR_lights",(function(){return o.KHR_lights})),n.d(t,"KHR_materials_pbrSpecularGlossiness",(function(){return o.KHR_materials_pbrSpecularGlossiness})),n.d(t,"KHR_materials_unlit",(function(){return o.KHR_materials_unlit})),n.d(t,"KHR_materials_clearcoat",(function(){return o.KHR_materials_clearcoat})),n.d(t,"KHR_materials_sheen",(function(){return o.KHR_materials_sheen})),n.d(t,"KHR_materials_specular",(function(){return o.KHR_materials_specular})),n.d(t,"KHR_materials_ior",(function(){return o.KHR_materials_ior})),n.d(t,"KHR_materials_variants",(function(){return o.KHR_materials_variants})),n.d(t,"KHR_materials_transmission",(function(){return o.KHR_materials_transmission})),n.d(t,"KHR_materials_translucency",(function(){return o.KHR_materials_translucency})),n.d(t,"KHR_mesh_quantization",(function(){return o.KHR_mesh_quantization})),n.d(t,"KHR_texture_basisu",(function(){return o.KHR_texture_basisu})),n.d(t,"KHR_texture_transform",(function(){return o.KHR_texture_transform})),n.d(t,"MSFT_audio_emitter",(function(){return o.MSFT_audio_emitter})),n.d(t,"MSFT_lod",(function(){return o.MSFT_lod})),n.d(t,"MSFT_minecraftMesh",(function(){return o.MSFT_minecraftMesh})),n.d(t,"MSFT_sRGBFactors",(function(){return o.MSFT_sRGBFactors})),n.d(t,"ExtrasAsMetadata",(function(){return o.ExtrasAsMetadata}));var r=n(1),o=(n(6),n(7))},function(e,t,n){"use strict";n.r(t),n.d(t,"MTLFileLoader",(function(){return o})),n.d(t,"OBJFileLoader",(function(){return a}));var r=n(0),o=function(){function e(){this.materials=[]}return e.prototype.parseMTL=function(t,n,o,a){if(!(n instanceof ArrayBuffer)){for(var i,s=n.split("\n"),l=/\s+/,u=null,c=0;c<s.length;c++){var d=s[c].trim();if(0!==d.length&&"#"!==d.charAt(0)){var f=d.indexOf(" "),h=f>=0?d.substring(0,f):d;h=h.toLowerCase();var p=f>=0?d.substring(f+1).trim():"";"newmtl"===h?(u&&this.materials.push(u),t._blockEntityCollection=a,u=new r.StandardMaterial(p,t),t._blockEntityCollection=!1):"kd"===h&&u?(i=p.split(l,3).map(parseFloat),u.diffuseColor=r.Color3.FromArray(i)):"ka"===h&&u?(i=p.split(l,3).map(parseFloat),u.ambientColor=r.Color3.FromArray(i)):"ks"===h&&u?(i=p.split(l,3).map(parseFloat),u.specularColor=r.Color3.FromArray(i)):"ke"===h&&u?(i=p.split(l,3).map(parseFloat),u.emissiveColor=r.Color3.FromArray(i)):"ns"===h&&u?u.specularPower=parseFloat(p):"d"===h&&u?u.alpha=parseFloat(p):"map_ka"===h&&u?u.ambientTexture=e._getTexture(o,p,t):"map_kd"===h&&u?u.diffuseTexture=e._getTexture(o,p,t):"map_ks"===h&&u?u.specularTexture=e._getTexture(o,p,t):"map_ns"===h||("map_bump"===h&&u?u.bumpTexture=e._getTexture(o,p,t):"map_d"===h&&u&&(u.opacityTexture=e._getTexture(o,p,t)))}}u&&this.materials.push(u)}},e._getTexture=function(t,n,o){if(!n)return null;var a=t;if("file:"===t){var i=n.lastIndexOf("\\");-1===i&&(i=n.lastIndexOf("/")),a+=i>-1?n.substr(i+1):n}else a+=n;return new r.Texture(a,o,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),a=function(){function e(t){this.name="obj",this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v(\s+[\d|\.|\+|\-|e|E]+){3,7}/,this.normalPattern=/vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt(\s+[\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,})+)/,this._forAssetContainer=!1,this._meshLoadOptions=t||e.currentMeshLoadOptions}return Object.defineProperty(e,"INVERT_TEXTURE_Y",{get:function(){return o.INVERT_TEXTURE_Y},set:function(e){o.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"currentMeshLoadOptions",{get:function(){return{ComputeNormals:e.COMPUTE_NORMALS,ImportVertexColors:e.IMPORT_VERTEX_COLORS,InvertY:e.INVERT_Y,InvertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,MaterialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,OptimizeWithUV:e.OPTIMIZE_WITH_UV,SkipMaterials:e.SKIP_MATERIALS}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,t,n,o){var a=r.Tools.BaseUrl+t+e;r.Tools.LoadFile(a,n,void 0,void 0,!1,(function(e,t){o(a,t)}))},e.prototype.createPlugin=function(){return new e(e.currentMeshLoadOptions)},e.prototype.canDirectLoad=function(e){return!1},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return this._parseSolid(e,t,n,r).then((function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}}))},e.prototype.loadAsync=function(e,t,n,r,o){return this.importMeshAsync(null,e,t,n,r).then((function(){}))},e.prototype.loadAssetContainerAsync=function(e,t,n,o,a){var i=this;return this._forAssetContainer=!0,this.importMeshAsync(null,e,t,n).then((function(t){var n=new r.AssetContainer(e);return t.meshes.forEach((function(e){return n.meshes.push(e)})),t.meshes.forEach((function(e){var t=e.material;t&&(-1==n.materials.indexOf(t)&&(n.materials.push(t),t.getActiveTextures().forEach((function(e){-1==n.textures.indexOf(e)&&n.textures.push(e)}))))})),i._forAssetContainer=!1,n})).catch((function(e){throw i._forAssetContainer=!1,e}))},e.prototype._parseSolid=function(t,n,a,i){for(var s,l=this,u=[],c=[],d=[],f=[],h=[],p=[],_=[],m=[],y=[],b=[],v=[],g=0,A=!1,T=[],x=[],E=[],L=[],O=[],M="",S="",w=new o,R=1,C=!0,N=new r.Color4(.5,.5,.5,1),P=function(e,t,n,r,o,a,i){var s;-1===(s=l._meshLoadOptions.OptimizeWithUV?function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1}(v,[e,n,t]):function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]}(v,[e,n]))?(p.push(_.length),_.push(r),m.push(o),b.push(a),void 0!==i&&y.push(i),v[e].normals.push(n),v[e].idx.push(g++),l._meshLoadOptions.OptimizeWithUV&&v[e].uv.push(t)):p.push(s)},I=function(){for(var e=0;e<_.length;e++)T.push(_[e].x,_[e].y,_[e].z),E.push(b[e].x,b[e].y,b[e].z),L.push(m[e].x,m[e].y),!0===l._meshLoadOptions.ImportVertexColors&&x.push(y[e].r,y[e].g,y[e].b,y[e].a);_=[],b=[],m=[],y=[],v=[],g=0},F=function(e,t){for(var n=t;n<e.length-1;n++)O.push(e[0],e[n],e[n+1])},B=function(e,t){F(e,t);for(var n=0;n<O.length;n++){var o=parseInt(O[n])-1;P(o,0,0,u[o],r.Vector2.Zero(),r.Vector3.Up(),!0===l._meshLoadOptions.ImportVertexColors?f[o]:void 0)}O=[]},V=function(e,t){F(e,t);for(var n=0;n<O.length;n++){var o=O[n].split("/"),a=parseInt(o[0])-1,i=parseInt(o[1])-1;P(a,i,0,u[a],d[i],r.Vector3.Up(),!0===l._meshLoadOptions.ImportVertexColors?f[a]:void 0)}O=[]},D=function(e,t){F(e,t);for(var n=0;n<O.length;n++){var r=O[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1,i=parseInt(r[2])-1;P(o,a,i,u[o],d[a],c[i])}O=[]},G=function(e,t){F(e,t);for(var n=0;n<O.length;n++){var o=O[n].split("//"),a=parseInt(o[0])-1,i=parseInt(o[1])-1;P(a,1,i,u[a],r.Vector2.Zero(),c[i],!0===l._meshLoadOptions.ImportVertexColors?f[a]:void 0)}O=[]},U=function(e,t){F(e,t);for(var n=0;n<O.length;n++){var r=O[n].split("/"),o=u.length+parseInt(r[0]),a=d.length+parseInt(r[1]),i=c.length+parseInt(r[2]);P(o,a,i,u[o],d[a],c[i],!0===l._meshLoadOptions.ImportVertexColors?f[o]:void 0)}O=[]},k=function(){h.length>0&&(s=h[h.length-1],I(),p.reverse(),s.indices=p.slice(),s.positions=T.slice(),s.normals=E.slice(),s.uvs=L.slice(),!0===l._meshLoadOptions.ImportVertexColors&&(s.colors=x.slice()),p=[],T=[],x=[],E=[],L=[])},H=a.split("\n"),K=0;K<H.length;K++){var j,W=H[K].trim().replace(/\s\s/g," ");if(0!==W.length&&"#"!==W.charAt(0))if(this.vertexPattern.test(W))j=W.match(/[^ ]+/g),u.push(new r.Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3]))),!0===this._meshLoadOptions.ImportVertexColors&&(j.length>=7?f.push(new r.Color4(parseFloat(j[4]),parseFloat(j[5]),parseFloat(j[6]),7===j.length||void 0===j[7]?1:parseFloat(j[7]))):f.push(N));else if(null!==(j=this.normalPattern.exec(W)))c.push(new r.Vector3(parseFloat(j[1]),parseFloat(j[2]),parseFloat(j[3])));else if(null!==(j=this.uvPattern.exec(W)))d.push(new r.Vector2(parseFloat(j[1])*e.UV_SCALING.x,parseFloat(j[2])*e.UV_SCALING.y));else if(null!==(j=this.facePattern3.exec(W)))D(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern4.exec(W)))G(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern5.exec(W)))U(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern2.exec(W)))V(j[1].trim().split(" "),1);else if(null!==(j=this.facePattern1.exec(W)))B(j[1].trim().split(" "),1);else if(this.group.test(W)||this.obj.test(W)){var q={name:W.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:""};k(),h.push(q),A=!0,C=!0,R=1}else if(this.usemtl.test(W)){if(M=W.substring(7).trim(),!C||!A){k();q={name:"mesh_mm"+R.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:M};R++,h.push(q),A=!0}A&&C&&(h[h.length-1].materialName=M,C=!1)}else this.mtllib.test(W)?S=W.substring(7).trim():this.smooth.test(W)||console.log("Unhandled expression at line : "+W)}A&&(s=h[h.length-1],p.reverse(),I(),s.indices=p,s.positions=T,s.normals=E,s.uvs=L,!0===this._meshLoadOptions.ImportVertexColors&&(s.colors=x)),A||(p.reverse(),I(),h.push({name:r.Geometry.RandomId(),indices:p,positions:T,colors:x,normals:E,uvs:L,materialName:M}));for(var Y=[],X=new Array,J=0;J<h.length;J++){if(t&&h[J].name)if(t instanceof Array){if(-1===t.indexOf(h[J].name))continue}else if(h[J].name!==t)continue;s=h[J],n._blockEntityCollection=this._forAssetContainer;var Q=new r.Mesh(h[J].name,n);n._blockEntityCollection=!1,X.push(h[J].materialName);var z=new r.VertexData;if(z.uvs=s.uvs,z.indices=s.indices,z.positions=s.positions,!0===this._meshLoadOptions.ComputeNormals){var Z=new Array;r.VertexData.ComputeNormals(s.positions,s.indices,Z),z.normals=Z}else z.normals=s.normals;!0===this._meshLoadOptions.ImportVertexColors&&(z.colors=s.colors),z.applyToMesh(Q),this._meshLoadOptions.InvertY&&(Q.scaling.y*=-1),Y.push(Q)}var $=[];return""!==S&&!1===this._meshLoadOptions.SkipMaterials&&$.push(new Promise((function(e,t){l._loadMTL(S,i,(function(o){try{w.parseMTL(n,o,i,l._forAssetContainer);for(var a=0;a<w.materials.length;a++){for(var s,u=0,c=[];(s=X.indexOf(w.materials[a].name,u))>-1;)c.push(s),u=s+1;if(-1===s&&0===c.length)w.materials[a].dispose();else for(var d=0;d<c.length;d++)Y[c[d]].material=w.materials[a]}e()}catch(n){r.Tools.Warn("Error processing MTL file: '"+S+"'"),l._meshLoadOptions.MaterialLoadingFailsSilently?e():t(n)}}),(function(n,o){r.Tools.Warn("Error downloading MTL file: '"+S+"'"),l._meshLoadOptions.MaterialLoadingFailsSilently?e():t(o)}))}))),Promise.all($).then((function(){return Y}))},e.OPTIMIZE_WITH_UV=!0,e.INVERT_Y=!1,e.IMPORT_VERTEX_COLORS=!1,e.COMPUTE_NORMALS=!1,e.UV_SCALING=new r.Vector2(1,1),e.SKIP_MATERIALS=!1,e.MATERIAL_LOADING_FAILS_SILENTLY=!0,e}();r.SceneLoader&&r.SceneLoader.RegisterPlugin(new a)},function(e,t,n){"use strict";n.r(t),n.d(t,"STLFileLoader",(function(){return o}));var r=n(0),o=function(){function e(){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 e.prototype.importMesh=function(e,t,n,o,a,i,s){var l;if("string"!=typeof n){if(this._isBinary(n)){var u=new r.Mesh("stlmesh",t);return this._parseBinary(u,n),a&&a.push(u),!0}for(var c=new Uint8Array(n),d="",f=0;f<n.byteLength;f++)d+=String.fromCharCode(c[f]);n=d}for(;l=this.solidPattern.exec(n);){var h=l[1];if(h!=l[3])return r.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&h)if(e instanceof Array){if(!e.indexOf(h))continue}else if(h!==e)continue;h=h||"stlmesh";u=new r.Mesh(h,t);this._parseASCII(u,l[2]),a&&a.push(u)}return!0},e.prototype.load=function(e,t,n){return this.importMesh(null,e,t,n,null,null,null)},e.prototype.loadAssetContainer=function(e,t,n,o){var a=new r.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,t,n,a.meshes,null,null),e._blockEntityCollection=!1,a},e.prototype._isBinary=function(e){var t;if(50,84+50*(t=new DataView(e)).getUint32(80,!0)===t.byteLength)return!0;for(var n=t.byteLength,r=0;r<n;r++)if(t.getUint8(r)>127)return!0;return!1},e.prototype._parseBinary=function(e,t){for(var n=new DataView(t),o=n.getUint32(80,!0),a=0,i=new Float32Array(3*o*3),s=new Float32Array(3*o*3),l=new Uint32Array(3*o),u=0,c=0;c<o;c++){for(var d=84+50*c,f=n.getFloat32(d,!0),h=n.getFloat32(d+4,!0),p=n.getFloat32(d+8,!0),_=1;_<=3;_++){var m=d+12*_;i[a]=n.getFloat32(m,!0),i[a+2]=n.getFloat32(m+4,!0),i[a+1]=n.getFloat32(m+8,!0),s[a]=f,s[a+2]=h,s[a+1]=p,a+=3}l[u]=u++,l[u]=u++,l[u]=u++}e.setVerticesData(r.VertexBuffer.PositionKind,i),e.setVerticesData(r.VertexBuffer.NormalKind,s),e.setIndices(l),e.computeWorldMatrix(!0)},e.prototype._parseASCII=function(e,t){for(var n,o=[],a=[],i=[],s=0;n=this.facetsPattern.exec(t);){var l=n[1],u=this.normalPattern.exec(l);if(this.normalPattern.lastIndex=0,u){for(var c,d=[Number(u[1]),Number(u[5]),Number(u[3])];c=this.vertexPattern.exec(l);)o.push(Number(c[1]),Number(c[5]),Number(c[3])),a.push(d[0],d[1],d[2]);i.push(s++,s++,s++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,e.setVerticesData(r.VertexBuffer.PositionKind,o),e.setVerticesData(r.VertexBuffer.NormalKind,a),e.setIndices(i),e.computeWorldMatrix(!0)},e}();r.SceneLoader&&r.SceneLoader.RegisterPlugin(new o)},function(e,t,n){"use strict";(function(e){var r=n(2),o=n(3);n.d(t,"a",(function(){return r.GLTFFileLoader})),n.d(t,"b",(function(){return r.GLTFLoaderAnimationStartMode})),n.d(t,"c",(function(){return r.GLTFLoaderCoordinateSystemMode})),n.d(t,"d",(function(){return r.GLTFLoaderState})),n.d(t,"e",(function(){return o.GLTFValidation}));var a=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==a){for(var i in a.BABYLON=a.BABYLON||{},r)a.BABYLON[i]=r[i];for(var i in o)a.BABYLON[i]=o[i]}}).call(this,n(5))},function(e,t,n){"use strict";(function(e){var r=n(8);n.d(t,"a",(function(){return r}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in o.BABYLON=o.BABYLON||{},o.BABYLON.GLTF1=o.BABYLON.GLTF1||{},r)o.BABYLON.GLTF1[a]=r[a]}).call(this,n(5))},function(e,t,n){"use strict";(function(e){var r=n(7),o=n(6),a=n(9);n.d(t,"a",(function(){return a}));var i=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==i){i.BABYLON=i.BABYLON||{};var s=i.BABYLON;s.GLTF2=s.GLTF2||{},s.GLTF2.Loader=s.GLTF2.Loader||{},s.GLTF2.Loader.Extensions=s.GLTF2.Loader.Extensions||{};var l=[];for(var u in r)s.GLTF2.Loader.Extensions[u]=r[u],l.push(u);for(var u in o)s.GLTF2.Loader[u]=o[u],l.push(u);for(var u in a)l.indexOf(u)>-1||(s.GLTF2[u]=a[u])}}).call(this,n(5))},function(e,t,n){"use strict";n.r(t),function(e){var r=n(10);n.d(t,"MTLFileLoader",(function(){return r.MTLFileLoader})),n.d(t,"OBJFileLoader",(function(){return r.OBJFileLoader}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},function(e,t,n){"use strict";n.r(t),function(e){var r=n(11);n.d(t,"STLFileLoader",(function(){return r.STLFileLoader}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in r)o.BABYLON[a]=r[a]}.call(this,n(5))},,,,function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFLoaderCoordinateSystemMode",(function(){return r.c})),n.d(t,"GLTFLoaderAnimationStartMode",(function(){return r.b})),n.d(t,"GLTFLoaderState",(function(){return r.d})),n.d(t,"GLTFFileLoader",(function(){return r.a})),n.d(t,"GLTFValidation",(function(){return r.e})),n.d(t,"GLTF1",(function(){return o.a})),n.d(t,"GLTF2",(function(){return a.a})),n.d(t,"MTLFileLoader",(function(){return i.MTLFileLoader})),n.d(t,"OBJFileLoader",(function(){return i.OBJFileLoader})),n.d(t,"STLFileLoader",(function(){return s.STLFileLoader}));n(2),n(3),n(8),n(9),n(10),n(11);var r=n(12),o=n(13),a=n(14),i=n(15),s=n(16)}])}));
17
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-materials"]=t(require("babylonjs")):e.MATERIALS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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 n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},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(t,i){t.exports=e},function(e,t,i){"use strict";i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return o}));
18
- /*! *****************************************************************************
19
- Copyright (c) Microsoft Corporation.
20
-
21
- Permission to use, copy, modify, and/or distribute this software for any
22
- purpose with or without fee is hereby granted.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
- PERFORMANCE OF THIS SOFTWARE.
31
- ***************************************************************************** */
32
- var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)};function r(e,t){function i(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}function o(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}Object.create;Object.create},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i},function(e,t,i){"use strict";i.r(t),i.d(t,"CellMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\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#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.cellPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\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#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.cellVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.POINTSIZE=!1,t.FOG=!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.NDOTL=!0,t.CUSTOMUSERLIGHTING=!0,t.CELLBASIC=!0,t.DEPTHPREPASS=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._computeHighLevel=!1,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.CELLBASIC=!this.computeHighLevel,r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],d=["diffuseSampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("cell",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this._maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._diffuseTexture===t},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.getClassName=function(){return"CellMaterial"},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.CellMaterial",e},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)("diffuse")],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)("computeHighLevel")],t.prototype,"_computeHighLevel",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"computeHighLevel",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.CellMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"FireMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\nuniform sampler2D distortionSampler;\nuniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{\nreturn vec4(2.0)*x-vec4(1.0);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\n\nfloat alpha=1.0;\n#ifdef DIFFUSE\n\nconst float distortionAmount0=0.092;\nconst float distortionAmount1=0.092;\nconst float distortionAmount2=0.092;\nvec2 heightAttenuation=vec2(0.3,0.39);\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\nbaseColor*=opacityColor;\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.firePixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n\nuniform float time;\nuniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n\n#ifdef DIFFUSE\nvDiffuseUV=uv;\nvDiffuseUV.y-=0.2;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\n\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\nvDistortionCoords1.x=uv.x;\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\nvDistortionCoords2.x=uv.x;\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\nvDistortionCoords3.x=uv.x;\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n}\n";r.Effect.ShadersStore.fireVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.UV1=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.BonesPerMesh=0,t.NUM_BONE_INFLUENCERS=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.speed=1,n._scaledDiffuse=new r.Color3,n._lastTime=0,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return!1},t.prototype.needAlphaTesting=function(){return!0},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.ALPHATEST=!!this._opacityTexture,n._areMiscDirty&&(n.POINTSIZE=this.pointsCloud||o.forcePointsCloud,n.FOG=o.fogEnabled&&e.applyFog&&o.fogMode!==r.Scene.FOGMODE_NONE&&this.fogEnabled),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.UV1&&l.push(r.VertexBuffer.UVKind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString();t.setEffect(o.getEngine().createEffect("fire",{attributes:l,uniformsNames:["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","time","speed"],uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene();if(i._materialDefines){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,o)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix()),this._activeEffect.setTexture("distortionSampler",this._distortionTexture),this._activeEffect.setTexture("opacitySampler",this._opacityTexture)),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(o,n)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*t.visibility),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._distortionTexture&&this._distortionTexture.animations&&this._distortionTexture.animations.length>0&&e.push(this._distortionTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._distortionTexture&&t.push(this._distortionTexture),this._opacityTexture&&t.push(this._opacityTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._distortionTexture===t||this._opacityTexture===t))},t.prototype.getClassName=function(){return"FireMaterial"},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.customType="BABYLON.FireMaterial",t.diffuseColor=this.diffuseColor.asArray(),t.speed=this.speed,this._diffuseTexture&&(t._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(t._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(t._opacityTexture=this._opacityTexture.serialize()),t},t.Parse=function(e,i,n){var o=new t(e.name,i);return o.diffuseColor=r.Color3.FromArray(e.diffuseColor),o.speed=e.speed,o.alpha=e.alpha,o.id=e.id,r.Tags.AddTagsTo(o,e.tags),o.backFaceCulling=e.backFaceCulling,o.wireframe=e.wireframe,e._diffuseTexture&&(o._diffuseTexture=r.Texture.Parse(e._diffuseTexture,i,n)),e._distortionTexture&&(o._distortionTexture=r.Texture.Parse(e._distortionTexture,i,n)),e._opacityTexture&&(o._opacityTexture=r.Texture.Parse(e._opacityTexture,i,n)),o},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)("distortionTexture")],t.prototype,"_distortionTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"distortionTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)("diffuse")],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"speed",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.FireMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"FurMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 furColor;\nuniform float furLength;\nvarying vec3 vPositionW;\nvarying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform float furOcclusion;\nuniform sampler2D furTexture;\nvarying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=furColor;\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\n\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));\nif (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {\ndiscard;\n}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);\nbaseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;\nvec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.furPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\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<bonesDeclaration>\n\nuniform float furLength;\nuniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform vec3 furGravity;\nuniform float furTime;\nuniform float furSpacing;\nuniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else\nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);\nvec3 tangent2=vec3(-normal.z,0,normal.x);\nr=Rand(tangent1*r);\nfloat J=(2.0+4.0*r);\nr=Rand(tangent2*r);\nfloat K=(2.0+2.0*r);\ntangent1=tangent1*J+tangent2*K;\ntangent1=normalize(tangent1);\nvec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\n\nvec3 forceDirection=vec3(0.0,0.0,0.0);\nforceDirection.x=sin(furTime+position.x*0.05)*0.2;\nforceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;\nforceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;\nvec3 displacement=vec3(0.0,0.0,0.0);\ndisplacement=furGravity+forceDirection;\nfloat displacementFactor=pow(furOffset,3.0);\nvec3 aNormal=normal;\naNormal.xyz+=displacement*displacementFactor;\nnewPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\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#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\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";r.Effect.ShadersStore.furVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.HEIGHTMAP=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!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.HIGHLEVEL=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.furLength=1,n.furAngle=0,n.furColor=new r.Color3(.44,.21,.02),n.furOffset=0,n.furSpacing=12,n.furGravity=new r.Vector3(0,0,0),n.furSpeed=100,n.furDensity=20,n.furOcclusion=0,n._disableLighting=!1,n._maxSimultaneousLights=4,n.highLevelFur=!0,n._furTime=0,n}return Object(n.b)(t,e),Object.defineProperty(t.prototype,"furTime",{get:function(){return this._furTime},set:function(e){this._furTime=e},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.updateFur=function(){for(var e=1;e<this._meshes.length;e++){var t=this._meshes[e].material;t.furLength=this.furLength,t.furAngle=this.furAngle,t.furGravity=this.furGravity,t.furSpacing=this.furSpacing,t.furSpeed=this.furSpeed,t.furColor=this.furColor,t.diffuseTexture=this.diffuseTexture,t.furTexture=this.furTexture,t.highLevelFur=this.highLevelFur,t.furTime=this.furTime,t.furDensity=this.furDensity}},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&o.texturesEnabled){if(this.diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(this.heightTexture&&a.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;n._needUVs=!0,n.HEIGHTMAP=!0}}if(this.highLevelFur!==n.HIGHLEVEL&&(n.HIGHLEVEL=!0,n.markAsUnprocessed()),r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity","furOcclusion"],d=["diffuseSampler","heightTexture","furTexture"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("fur",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),n.getCachedMaterial()!==this&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._heightTexture&&this._activeEffect.setTexture("heightTexture",this._heightTexture),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._activeEffect.setFloat("furLength",this.furLength),this._activeEffect.setFloat("furAngle",this.furAngle),this._activeEffect.setColor4("furColor",this.furColor,1),this.highLevelFur&&(this._activeEffect.setVector3("furGravity",this.furGravity),this._activeEffect.setFloat("furOffset",this.furOffset),this._activeEffect.setFloat("furSpacing",this.furSpacing),this._activeEffect.setFloat("furDensity",this.furDensity),this._activeEffect.setFloat("furOcclusion",this.furOcclusion),this._furTime+=this.getScene().getEngine().getDeltaTime()/this.furSpeed,this._activeEffect.setFloat("furTime",this._furTime),this._activeEffect.setTexture("furTexture",this.furTexture)),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.heightTexture&&this.heightTexture.animations&&this.heightTexture.animations.length>0&&e.push(this.heightTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._heightTexture&&t.push(this._heightTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this.diffuseTexture===t||this._heightTexture===t)},t.prototype.dispose=function(t){if(this.diffuseTexture&&this.diffuseTexture.dispose(),this._meshes)for(var i=1;i<this._meshes.length;i++){var n=this._meshes[i].material;n&&n.dispose(t),this._meshes[i].dispose()}e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.FurMaterial",this._meshes&&(e.sourceMeshName=this._meshes[0].name,e.quality=this._meshes.length),e},t.prototype.getClassName=function(){return"FurMaterial"},t.Parse=function(e,i,n){var o=r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n);return e.sourceMeshName&&o.highLevelFur&&i.executeWhenReady((function(){var n=i.getMeshByName(e.sourceMeshName);if(n){var r=t.GenerateTexture("Fur Texture",i);o.furTexture=r,t.FurifyMesh(n,e.quality)}})),o},t.GenerateTexture=function(e,t){for(var i=new r.DynamicTexture("FurTexture "+e,256,t,!0),n=i.getContext(),o=0;o<2e4;++o)n.fillStyle="rgba(255, "+Math.floor(255*Math.random())+", "+Math.floor(255*Math.random())+", 1)",n.fillRect(Math.random()*i.getSize().width,Math.random()*i.getSize().height,2,2);return i.update(!1),i.wrapU=r.Texture.WRAP_ADDRESSMODE,i.wrapV=r.Texture.WRAP_ADDRESSMODE,i},t.FurifyMesh=function(e,i){var n,o=[e],a=e.material;if(!(a instanceof t))throw"The material of the source mesh must be a Fur Material";for(n=1;n<i;n++){var s=new t(a.name+n,e.getScene());e.getScene().materials.pop(),r.Tags.EnableFor(s),r.Tags.AddTagsTo(s,"furShellMaterial"),s.furLength=a.furLength,s.furAngle=a.furAngle,s.furGravity=a.furGravity,s.furSpacing=a.furSpacing,s.furSpeed=a.furSpeed,s.furColor=a.furColor,s.diffuseTexture=a.diffuseTexture,s.furOffset=n/i,s.furTexture=a.furTexture,s.highLevelFur=a.highLevelFur,s.furTime=a.furTime,s.furDensity=a.furDensity;var f=e.clone(e.name+n);f.material=s,f.skeleton=e.skeleton,f.position=r.Vector3.Zero(),o.push(f)}for(n=1;n<o.length;n++)o[n].parent=e;return e.material._meshes=o,o},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)("heightTexture")],t.prototype,"_heightTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"heightTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furLength",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furAngle",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"furColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furOffset",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furSpacing",void 0),Object(n.a)([Object(r.serializeAsVector3)()],t.prototype,"furGravity",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furSpeed",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furDensity",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furOcclusion",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"highLevelFur",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"furTime",null),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.FurMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"GradientMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\n\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float scale;\nuniform float smoothness;\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\nfloat h=vPosition.y*scale+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\n\nvec3 diffuseColor=baseColor.rgb;\n\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\n#ifdef EMISSIVE\nvec3 diffuseBase=baseColor.rgb;\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);\n#endif\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";r.Effect.ShadersStore.gradientPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\nvPosition=position;\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.gradientVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.EMISSIVE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!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.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._maxSimultaneousLights=4,n.topColor=new r.Color3(1,0,0),n.topColorAlpha=1,n.bottomColor=new r.Color3(0,0,1),n.bottomColorAlpha=1,n.offset=0,n.scale=1,n.smoothness=1,n._disableLighting=!1,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},t.prototype.needAlphaTesting=function(){return!0},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),n.EMISSIVE=this._disableLighting,r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","topColor","bottomColor","offset","smoothness","scale"],d=[],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:4}),t.setEffect(o.getEngine().createEffect("gradient",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,a),this._mustRebind(n,a)&&(r.MaterialHelper.BindClipPlane(a,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._activeEffect.setColor4("topColor",this.topColor,this.topColorAlpha),this._activeEffect.setColor4("bottomColor",this.bottomColor,this.bottomColorAlpha),this._activeEffect.setFloat("offset",this.offset),this._activeEffect.setFloat("scale",this.scale),this._activeEffect.setFloat("smoothness",this.smoothness),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){return[]},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.GradientMaterial",e},t.prototype.getClassName=function(){return"GradientMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"topColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"topColorAlpha",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"bottomColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"bottomColorAlpha",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"offset",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"scale",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"smoothness",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.GradientMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"GridMaterial",(function(){return f}));var n=i(1),r=i(0),o="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\n\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\n\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\nfloat getVisibility(float position) {\n\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n}\nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5);\nfractionPartOfPosition/=differentialLength;\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI);\nreturn result;\n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2;\n\nfloat result=isPointOnLine(position,differentialLength);\n\nfloat visibility=getVisibility(position);\nresult*=visibility;\n\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\nvoid main(void) {\n\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\n\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\n\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n\nfloat grid=clamp(x+y+z,0.,1.);\n\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif\n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif\n\ngl_FragColor=vec4(color.rgb,opacity);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n#endif\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.gridPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#include<instancesDeclaration>\n\nuniform mat4 projection;\nuniform mat4 view;\n\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\nvoid main(void) {\n#include<instancesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<fogVertex>\nvec4 cameraSpacePosition=view*worldPos;\ngl_Position=projection*cameraSpacePosition;\n#ifdef OPACITY\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\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\nvPosition=position;\nvNormal=normal;\n}";r.Effect.ShadersStore.gridVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.OPACITY=!1,t.TRANSPARENT=!1,t.FOG=!1,t.PREMULTIPLYALPHA=!1,t.UV1=!1,t.UV2=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.mainColor=r.Color3.Black(),n.lineColor=r.Color3.Teal(),n.gridRatio=1,n.gridOffset=r.Vector3.Zero(),n.majorUnitFrequency=10,n.minorUnitVisibility=.33,n.opacity=1,n.preMultiplyAlpha=!1,n._gridControl=new r.Vector4(n.gridRatio,n.majorUnitFrequency,n.minorUnitVisibility,n.opacity),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.opacity<1||this._opacityTexture&&this._opacityTexture.isReady()},t.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(n.TRANSPARENT!==this.opacity<1&&(n.TRANSPARENT=!n.TRANSPARENT,n.markAsUnprocessed()),n.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(n.PREMULTIPLYALPHA=!n.PREMULTIPLYALPHA,n.markAsUnprocessed()),n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._opacityTexture&&r.MaterialFlags.OpacityTextureEnabled)){if(!this._opacityTexture.isReady())return!1;n._needUVs=!0,n.OPACITY=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,!1,this.fogEnabled,!1,n),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,o.getEngine(),n,!!i),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial(),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!1);var a=[r.VertexBuffer.PositionKind,r.VertexBuffer.NormalKind];n.UV1&&a.push(r.VertexBuffer.UVKind),n.UV2&&a.push(r.VertexBuffer.UV2Kind),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess,r.MaterialHelper.PrepareAttributesForInstances(a,n);var f=n.toString();t.setEffect(o.getEngine().createEffect("grid",a,["projection","mainColor","lineColor","gridControl","gridOffset","vFogInfos","vFogColor","world","view","opacityMatrix","vOpacityInfos"],["opacitySampler"],f,void 0,this.onCompiled,this.onError),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,o.INSTANCES&&!o.THIN_INSTANCE||this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("view",n.getViewMatrix()),this._activeEffect.setMatrix("projection",n.getProjectionMatrix()),this._mustRebind(n,a)&&(this._activeEffect.setColor3("mainColor",this.mainColor),this._activeEffect.setColor3("lineColor",this.lineColor),this._activeEffect.setVector3("gridOffset",this.gridOffset),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4("gridControl",this._gridControl),this._opacityTexture&&r.MaterialFlags.OpacityTextureEnabled&&(this._activeEffect.setTexture("opacitySampler",this._opacityTexture),this._activeEffect.setFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._activeEffect.setMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix()))),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.GridMaterial",e},t.prototype.getClassName=function(){return"GridMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"mainColor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"lineColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"gridRatio",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"gridOffset",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"majorUnitFrequency",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"minorUnitVisibility",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"opacity",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"preMultiplyAlpha",void 0),Object(n.a)([Object(r.serializeAsTexture)("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.GridMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"LavaMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n\nuniform float time;\nuniform float speed;\nuniform float movingSpeed;\nuniform vec3 fogColor;\nuniform sampler2D noiseTexture;\nuniform float fogDensity;\n\nvarying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\n}\nvoid main(void) {\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#ifdef DIFFUSE\n\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\nT1.x+=noiseTex.x*2.0;\nT1.y+=noiseTex.y*2.0;\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\nbaseColor=temp;\nfloat depth=gl_FragCoord.z*4.0;\nconst float LOG2=1.442695;\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\ndiffuseColor=baseColor.rgb;\n\n\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.lavaPixelShader=o;var a="precision highp float;\n\nuniform float time;\nuniform float lowFrequencySpeed;\n\nvarying float noise;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n\n\nvec3 mod289(vec3 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 mod289(vec4 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 permute(vec4 x)\n{\nreturn mod289(((x*34.0)+1.0)*x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\nreturn 1.79284291400159-0.85373472095314*r;\n}\nvec3 fade(vec3 t) {\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat pnoise(vec3 P,vec3 rep)\n{\nvec3 Pi0=mod(floor(P),rep);\nvec3 Pi1=mod(Pi0+vec3(1.0),rep);\nPi0=mod289(Pi0);\nPi1=mod289(Pi1);\nvec3 Pf0=fract(P);\nvec3 Pf1=Pf0-vec3(1.0);\nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\nvec4 iz0=Pi0.zzzz;\nvec4 iz1=Pi1.zzzz;\nvec4 ixy=permute(permute(ix)+iy);\nvec4 ixy0=permute(ixy+iz0);\nvec4 ixy1=permute(ixy+iz1);\nvec4 gx0=ixy0*(1.0/7.0);\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\ngx0=fract(gx0);\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\nvec4 sz0=step(gz0,vec4(0.0));\ngx0-=sz0*(step(0.0,gx0)-0.5);\ngy0-=sz0*(step(0.0,gy0)-0.5);\nvec4 gx1=ixy1*(1.0/7.0);\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\ngx1=fract(gx1);\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\nvec4 sz1=step(gz1,vec4(0.0));\ngx1-=sz1*(step(0.0,gx1)-0.5);\ngy1-=sz1*(step(0.0,gy1)-0.5);\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\ng000*=norm0.x;\ng010*=norm0.y;\ng100*=norm0.z;\ng110*=norm0.w;\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\ng001*=norm1.x;\ng011*=norm1.y;\ng101*=norm1.z;\ng111*=norm1.w;\nfloat n000=dot(g000,Pf0);\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\nfloat n111=dot(g111,Pf1);\nvec3 fade_xyz=fade(Pf0);\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\nreturn 2.2*n_xyz;\n}\n\nfloat turbulence( vec3 p ) {\nfloat w=100.0;\nfloat t=-.5;\nfor (float f=1.0 ; f<=10.0 ; f++ ){\nfloat power=pow( 2.0,f );\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\n}\nreturn t;\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef NORMAL\n\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\n\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\n\nfloat displacement =-1.5*noise+b;\n\nvec3 newPosition=position+normal*displacement;\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\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#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}";r.Effect.ShadersStore.lavaVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.LIGHT0=!1,t.LIGHT1=!1,t.LIGHT2=!1,t.LIGHT3=!1,t.SPOTLIGHT0=!1,t.SPOTLIGHT1=!1,t.SPOTLIGHT2=!1,t.SPOTLIGHT3=!1,t.HEMILIGHT0=!1,t.HEMILIGHT1=!1,t.HEMILIGHT2=!1,t.HEMILIGHT3=!1,t.DIRLIGHT0=!1,t.DIRLIGHT1=!1,t.DIRLIGHT2=!1,t.DIRLIGHT3=!1,t.POINTLIGHT0=!1,t.POINTLIGHT1=!1,t.POINTLIGHT2=!1,t.POINTLIGHT3=!1,t.SHADOW0=!1,t.SHADOW1=!1,t.SHADOW2=!1,t.SHADOW3=!1,t.SHADOWS=!1,t.SHADOWESM0=!1,t.SHADOWESM1=!1,t.SHADOWESM2=!1,t.SHADOWESM3=!1,t.SHADOWPOISSON0=!1,t.SHADOWPOISSON1=!1,t.SHADOWPOISSON2=!1,t.SHADOWPOISSON3=!1,t.SHADOWPCF0=!1,t.SHADOWPCF1=!1,t.SHADOWPCF2=!1,t.SHADOWPCF3=!1,t.SHADOWPCSS0=!1,t.SHADOWPCSS1=!1,t.SHADOWPCSS2=!1,t.SHADOWPCSS3=!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.UNLIT=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.speed=1,n.movingSpeed=1,n.lowFrequencySpeed=1,n.fogDensity=.15,n._lastTime=0,n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._unlit=!1,n._maxSimultaneousLights=4,n._scaledDiffuse=new r.Color3,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","time","speed","movingSpeed","fogColor","fogDensity","lowFrequencySpeed"],d=["diffuseSampler","noiseTexture"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("lava",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,o.UNLIT=this._unlit,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.noiseTexture&&this._activeEffect.setTexture("noiseTexture",this.noiseTexture),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime*this.speed/1e3),this.fogColor||(this.fogColor=r.Color3.Black()),this._activeEffect.setColor3("fogColor",this.fogColor),this._activeEffect.setFloat("fogDensity",this.fogDensity),this._activeEffect.setFloat("lowFrequencySpeed",this.lowFrequencySpeed),this._activeEffect.setFloat("movingSpeed",this.movingSpeed),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.noiseTexture&&this.noiseTexture.animations&&this.noiseTexture.animations.length>0&&e.push(this.noiseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this.diffuseTexture&&this.diffuseTexture.dispose(),this.noiseTexture&&this.noiseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.LavaMaterial",e},t.prototype.getClassName=function(){return"LavaMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)()],t.prototype,"noiseTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"fogColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"speed",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"movingSpeed",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"lowFrequencySpeed",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"fogDensity",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("unlit")],t.prototype,"_unlit",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"unlit",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.LavaMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"MixMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D mixMap1Sampler;\nuniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform sampler2D diffuse4Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\nuniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;\nuniform sampler2D diffuse6Sampler;\nuniform sampler2D diffuse7Sampler;\nuniform sampler2D diffuse8Sampler;\nuniform vec2 diffuse5Infos;\nuniform vec2 diffuse6Infos;\nuniform vec2 diffuse7Infos;\nuniform vec2 diffuse8Infos;\n#endif\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\ndiffuse1Color.rgb*=mixColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";r.Effect.ShadersStore.mixPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*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";r.Effect.ShadersStore.mixVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!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.MIXMAP2=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(o.texturesEnabled){if(!this._mixTexture1||!this._mixTexture1.isReady())return!1;if(n._needUVs=!0,r.MaterialFlags.DiffuseTextureEnabled){if(!this._diffuseTexture1||!this._diffuseTexture1.isReady())return!1;if(n.DIFFUSE=!0,!this._diffuseTexture2||!this._diffuseTexture2.isReady())return!1;if(!this._diffuseTexture3||!this._diffuseTexture3.isReady())return!1;if(!this._diffuseTexture4||!this._diffuseTexture4.isReady())return!1;if(this._mixTexture2){if(!this._mixTexture2.isReady())return!1;if(n.MIXMAP2=!0,!this._diffuseTexture5||!this._diffuseTexture5.isReady())return!1;if(!this._diffuseTexture6||!this._diffuseTexture6.isReady())return!1;if(!this._diffuseTexture7||!this._diffuseTexture7.isReady())return!1;if(!this._diffuseTexture8||!this._diffuseTexture8.isReady())return!1}}}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos","diffuse4Infos","diffuse5Infos","diffuse6Infos","diffuse7Infos","diffuse8Infos"],d=["mixMap1Sampler","mixMap2Sampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","diffuse4Sampler","diffuse5Sampler","diffuse6Sampler","diffuse7Sampler","diffuse8Sampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("mix",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._mixTexture1&&(this._activeEffect.setTexture("mixMap1Sampler",this._mixTexture1),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture1.coordinatesIndex,this._mixTexture1.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture1.getTextureMatrix()),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture("diffuse1Sampler",this._diffuseTexture1),this._activeEffect.setFloat2("diffuse1Infos",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture("diffuse2Sampler",this._diffuseTexture2),this._activeEffect.setFloat2("diffuse2Infos",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture("diffuse3Sampler",this._diffuseTexture3),this._activeEffect.setFloat2("diffuse3Infos",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale)),this._diffuseTexture4&&(this._activeEffect.setTexture("diffuse4Sampler",this._diffuseTexture4),this._activeEffect.setFloat2("diffuse4Infos",this._diffuseTexture4.uScale,this._diffuseTexture4.vScale)))),this._mixTexture2&&(this._activeEffect.setTexture("mixMap2Sampler",this._mixTexture2),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture5&&(this._activeEffect.setTexture("diffuse5Sampler",this._diffuseTexture5),this._activeEffect.setFloat2("diffuse5Infos",this._diffuseTexture5.uScale,this._diffuseTexture5.vScale)),this._diffuseTexture6&&(this._activeEffect.setTexture("diffuse6Sampler",this._diffuseTexture6),this._activeEffect.setFloat2("diffuse6Infos",this._diffuseTexture6.uScale,this._diffuseTexture6.vScale)),this._diffuseTexture7&&(this._activeEffect.setTexture("diffuse7Sampler",this._diffuseTexture7),this._activeEffect.setFloat2("diffuse7Infos",this._diffuseTexture7.uScale,this._diffuseTexture7.vScale)),this._diffuseTexture8&&(this._activeEffect.setTexture("diffuse8Sampler",this._diffuseTexture8),this._activeEffect.setFloat2("diffuse8Infos",this._diffuseTexture8.uScale,this._diffuseTexture8.vScale)))),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._mixTexture1&&this._mixTexture1.animations&&this._mixTexture1.animations.length>0&&e.push(this._mixTexture1),this._mixTexture2&&this._mixTexture2.animations&&this._mixTexture2.animations.length>0&&e.push(this._mixTexture2),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._mixTexture1&&t.push(this._mixTexture1),this._diffuseTexture1&&t.push(this._diffuseTexture1),this._diffuseTexture2&&t.push(this._diffuseTexture2),this._diffuseTexture3&&t.push(this._diffuseTexture3),this._diffuseTexture4&&t.push(this._diffuseTexture4),this._mixTexture2&&t.push(this._mixTexture2),this._diffuseTexture5&&t.push(this._diffuseTexture5),this._diffuseTexture6&&t.push(this._diffuseTexture6),this._diffuseTexture7&&t.push(this._diffuseTexture7),this._diffuseTexture8&&t.push(this._diffuseTexture8),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._mixTexture1===t||(this._diffuseTexture1===t||(this._diffuseTexture2===t||(this._diffuseTexture3===t||(this._diffuseTexture4===t||(this._mixTexture2===t||(this._diffuseTexture5===t||(this._diffuseTexture6===t||(this._diffuseTexture7===t||this._diffuseTexture8===t)))))))))},t.prototype.dispose=function(t){this._mixTexture1&&this._mixTexture1.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.MixMaterial",e},t.prototype.getClassName=function(){return"MixMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("mixTexture1")],t.prototype,"_mixTexture1",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"mixTexture1",void 0),Object(n.a)([Object(r.serializeAsTexture)("mixTexture2")],t.prototype,"_mixTexture2",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"mixTexture2",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture1")],t.prototype,"_diffuseTexture1",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture1",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture2")],t.prototype,"_diffuseTexture2",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture2",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture3")],t.prototype,"_diffuseTexture3",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture3",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture4")],t.prototype,"_diffuseTexture4",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture4",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture1")],t.prototype,"_diffuseTexture5",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture5",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture2")],t.prototype,"_diffuseTexture6",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture6",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture3")],t.prototype,"_diffuseTexture7",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture7",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture4")],t.prototype,"_diffuseTexture8",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture8",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"specularColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"specularPower",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.MixMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"NormalMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef LIGHTING\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\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#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef NORMAL\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\n#ifdef LIGHTING\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=baseColor.rgb;\n#endif\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.normalPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\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#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.normalVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.LIGHT0=!1,t.LIGHT1=!1,t.LIGHT2=!1,t.LIGHT3=!1,t.SPOTLIGHT0=!1,t.SPOTLIGHT1=!1,t.SPOTLIGHT2=!1,t.SPOTLIGHT3=!1,t.HEMILIGHT0=!1,t.HEMILIGHT1=!1,t.HEMILIGHT2=!1,t.HEMILIGHT3=!1,t.DIRLIGHT0=!1,t.DIRLIGHT1=!1,t.DIRLIGHT2=!1,t.DIRLIGHT3=!1,t.POINTLIGHT0=!1,t.POINTLIGHT1=!1,t.POINTLIGHT2=!1,t.POINTLIGHT3=!1,t.SHADOW0=!1,t.SHADOW1=!1,t.SHADOW2=!1,t.SHADOW3=!1,t.SHADOWS=!1,t.SHADOWESM0=!1,t.SHADOWESM1=!1,t.SHADOWESM2=!1,t.SHADOWESM3=!1,t.SHADOWPOISSON0=!1,t.SHADOWPOISSON1=!1,t.SHADOWPOISSON2=!1,t.SHADOWPOISSON3=!1,t.SHADOWPCF0=!1,t.SHADOWPCF1=!1,t.SHADOWPCF2=!1,t.SHADOWPCF3=!1,t.SHADOWPCSS0=!1,t.SHADOWPCSS1=!1,t.SHADOWPCSS2=!1,t.SHADOWPCSS3=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.LIGHTING=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),n.LIGHTING=!this._disableLighting,r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],d=["diffuseSampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:4}),t.setEffect(o.getEngine().createEffect("normal",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this.diffuseTexture&&this.diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.NormalMaterial",e},t.prototype.getClassName=function(){return"NormalMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.NormalMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"ShadowOnlyMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\n\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.shadowOnlyPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.shadowOnlyVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._needAlphaBlending=!0,n.shadowColor=r.Color3.Black(),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this._needAlphaBlending},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(t.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),t.prototype._getFirstShadowLightForMesh=function(e){for(var t=0,i=e.lightSources;t<i.length;t++){var n=i[t];if(n.shadowEnabled)return n}return null},t.prototype.isReadyForSubMesh=function(e,t,i){var n;if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var o=t._materialDefines,a=this.getScene();if(this._isReadyForSubMesh(t))return!0;var f=a.getEngine();if(this._activeLight)for(var l=0,u=e.lightSources;l<u.length;l++){var c=u[l];if(c.shadowEnabled){if(this._activeLight===c)break;var d=e.lightSources.indexOf(this._activeLight);-1!==d&&(e.lightSources.splice(d,1),e.lightSources.splice(0,0,this._activeLight));break}}r.MaterialHelper.PrepareDefinesForFrameBoundValues(a,f,o,!!i),r.MaterialHelper.PrepareDefinesForMisc(e,a,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),o._needNormals=r.MaterialHelper.PrepareDefinesForLights(a,e,o,!1,1);var p=null===(n=this._getFirstShadowLightForMesh(e))||void 0===n?void 0:n.getShadowGenerator();if(this._needAlphaBlending=!0,p&&p.getClassName&&"CascadedShadowGenerator"===p.getClassName()){var h=p;this._needAlphaBlending=!h.autoCalcDepthBounds}if(r.MaterialHelper.PrepareDefinesForAttributes(e,o,!1,!0),o.isDirty){o.markAsProcessed(),a.resetCachedMaterial();var v=new r.EffectFallbacks;o.FOG&&v.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(o,v,1),o.NUM_BONE_INFLUENCERS>0&&v.addCPUSkinningFallback(0,e),o.IMAGEPROCESSINGPOSTPROCESS=a.imageProcessingConfiguration.applyByPostProcess;var m=[r.VertexBuffer.PositionKind];o.NORMAL&&m.push(r.VertexBuffer.NormalKind),r.MaterialHelper.PrepareAttributesForBones(m,e,o,v),r.MaterialHelper.PrepareAttributesForInstances(m,o);var g=o.toString(),x=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6"],T=new Array,_=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:x,uniformBuffersNames:_,samplers:T,defines:o,maxSimultaneousLights:1}),t.setEffect(a.getEngine().createEffect("shadowOnly",{attributes:m,uniformsNames:x,uniformBuffersNames:_,samplers:T,defines:g,fallbacks:v,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},f),o)}return!(!t.effect||!t.effect.isReady())&&(o._renderId=a.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;if(a){if(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),r.MaterialHelper.BindEyePosition(a,n)),n.lightsEnabled){r.MaterialHelper.BindLights(n,t,this._activeEffect,o,1);var s=this._getFirstShadowLightForMesh(t);s&&(s._renderId=-1)}(n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE||o.SHADOWCSM0)&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect)}}},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.ShadowOnlyMaterial",e},t.prototype.getClassName=function(){return"ShadowOnlyMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.ShadowOnlyMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"SimpleMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\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#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}";r.Effect.ShadersStore.simplePixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\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#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.simpleVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!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.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled&&this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],d=["diffuseSampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("simple",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights-1}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this._diffuseTexture&&r.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.diffuseTexture===t},t.prototype.dispose=function(t){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.SimpleMaterial",e},t.prototype.getClassName=function(){return"SimpleMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)("diffuse")],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.SimpleMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"SkyMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\nuniform vec3 cameraPosition;\nuniform vec3 cameraOffset;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n\n#include<fogFragmentDeclaration>\n\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst vec3 up=vec3(0.0,1.0,0.0);\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{\nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\n\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0);\ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance;\nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled);\nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\n\n\n\nvec3 retColor=curr*whiteScale;\n\n\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";r.Effect.ShadersStore.skyPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nvoid main(void) {\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";r.Effect.ShadersStore.skyVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.luminance=1,n.turbidity=10,n.rayleigh=2,n.mieCoefficient=.005,n.mieDirectionalG=.8,n.distance=500,n.inclination=.49,n.azimuth=.25,n.sunPosition=new r.Vector3(0,100,0),n.useSunPosition=!1,n.cameraOffset=r.Vector3.Zero(),n._cameraPosition=r.Vector3.Zero(),n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,!1,n),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!1),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var a=new r.EffectFallbacks;n.FOG&&a.addFallback(1,"FOG"),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var f=[r.VertexBuffer.PositionKind];n.VERTEXCOLOR&&f.push(r.VertexBuffer.ColorKind);var l=n.toString();t.setEffect(o.getEngine().createEffect("sky",f,["world","viewProjection","view","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","luminance","turbidity","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","cameraPosition","cameraOffset"],[],l,a,this.onCompiled,this.onError),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene();if(i._materialDefines){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),this._mustRebind(n,o)&&(r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize)),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect);var a=n.activeCamera;if(a){var s=a.getWorldMatrix();this._cameraPosition.x=s.m[12],this._cameraPosition.y=s.m[13],this._cameraPosition.z=s.m[14],this._activeEffect.setVector3("cameraPosition",this._cameraPosition)}if(this._activeEffect.setVector3("cameraOffset",this.cameraOffset),this.luminance>0&&this._activeEffect.setFloat("luminance",this.luminance),this._activeEffect.setFloat("turbidity",this.turbidity),this._activeEffect.setFloat("rayleigh",this.rayleigh),this._activeEffect.setFloat("mieCoefficient",this.mieCoefficient),this._activeEffect.setFloat("mieDirectionalG",this.mieDirectionalG),!this.useSunPosition){var f=Math.PI*(this.inclination-.5),l=2*Math.PI*(this.azimuth-.5);this.sunPosition.x=this.distance*Math.cos(l),this.sunPosition.y=this.distance*Math.sin(l)*Math.sin(f),this.sunPosition.z=this.distance*Math.sin(l)*Math.cos(f)}this._activeEffect.setVector3("sunPosition",this.sunPosition),this._afterBind(t,this._activeEffect)}}},t.prototype.getAnimatables=function(){return[]},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.SkyMaterial",e},t.prototype.getClassName=function(){return"SkyMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serialize)()],t.prototype,"luminance",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"turbidity",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"rayleigh",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"mieCoefficient",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"mieDirectionalG",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"distance",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"inclination",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"azimuth",void 0),Object(n.a)([Object(r.serializeAsVector3)()],t.prototype,"sunPosition",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"useSunPosition",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"cameraOffset",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.SkyMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"TerrainMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\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 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{\nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";r.Effect.ShadersStore.terrainPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*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";r.Effect.ShadersStore.terrainVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.BUMP=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!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.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(o.texturesEnabled){if(!this.mixTexture||!this.mixTexture.isReady())return!1;if(n._needUVs=!0,r.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture1||!this.diffuseTexture1.isReady())return!1;if(!this.diffuseTexture2||!this.diffuseTexture2.isReady())return!1;if(!this.diffuseTexture3||!this.diffuseTexture3.isReady())return!1;n.DIFFUSE=!0}if(this.bumpTexture1&&this.bumpTexture2&&this.bumpTexture3&&r.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture1.isReady())return!1;if(!this.bumpTexture2.isReady())return!1;if(!this.bumpTexture3.isReady())return!1;n._needNormals=!0,n.BUMP=!0}}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var f=new r.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var l=[r.VertexBuffer.PositionKind];n.NORMAL&&l.push(r.VertexBuffer.NormalKind),n.UV1&&l.push(r.VertexBuffer.UVKind),n.UV2&&l.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(l,e,n,f),r.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),c=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos"],d=["textureSampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","bump1Sampler","bump2Sampler","bump3Sampler"],p=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("terrain",{attributes:l,uniformsNames:c,uniformBuffersNames:p,samplers:d,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.mixTexture&&(this._activeEffect.setTexture("textureSampler",this._mixTexture),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture.coordinatesIndex,this._mixTexture.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture.getTextureMatrix()),r.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture("diffuse1Sampler",this._diffuseTexture1),this._activeEffect.setFloat2("diffuse1Infos",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture("diffuse2Sampler",this._diffuseTexture2),this._activeEffect.setFloat2("diffuse2Infos",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture("diffuse3Sampler",this._diffuseTexture3),this._activeEffect.setFloat2("diffuse3Infos",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale))),r.MaterialFlags.BumpTextureEnabled&&n.getEngine().getCaps().standardDerivatives&&(this._bumpTexture1&&this._activeEffect.setTexture("bump1Sampler",this._bumpTexture1),this._bumpTexture2&&this._activeEffect.setTexture("bump2Sampler",this._bumpTexture2),this._bumpTexture3&&this._activeEffect.setTexture("bump3Sampler",this._bumpTexture3))),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._mixTexture&&t.push(this._mixTexture),this._diffuseTexture1&&t.push(this._diffuseTexture1),this._diffuseTexture2&&t.push(this._diffuseTexture2),this._diffuseTexture3&&t.push(this._diffuseTexture3),this._bumpTexture1&&t.push(this._bumpTexture1),this._bumpTexture2&&t.push(this._bumpTexture2),this._bumpTexture3&&t.push(this._bumpTexture3),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._mixTexture===t||(this._diffuseTexture1===t||(this._diffuseTexture2===t||(this._diffuseTexture3===t||(this._bumpTexture1===t||(this._bumpTexture2===t||this._bumpTexture3===t))))))},t.prototype.dispose=function(t){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.TerrainMaterial",e},t.prototype.getClassName=function(){return"TerrainMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)("mixTexture")],t.prototype,"_mixTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"mixTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture1")],t.prototype,"_diffuseTexture1",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture1",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture2")],t.prototype,"_diffuseTexture2",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture2",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexture3")],t.prototype,"_diffuseTexture3",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture3",void 0),Object(n.a)([Object(r.serializeAsTexture)("bumpTexture1")],t.prototype,"_bumpTexture1",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture1",void 0),Object(n.a)([Object(r.serializeAsTexture)("bumpTexture2")],t.prototype,"_bumpTexture2",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture2",void 0),Object(n.a)([Object(r.serializeAsTexture)("bumpTexture3")],t.prototype,"_bumpTexture3",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture3",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"specularColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"specularPower",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.TerrainMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"TriPlanarMaterial",(function(){return f}));var n=i(1),r=i(0),o="precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n}\n";r.Effect.ShadersStore.triplanarPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\nvec3 worldNormal=(world*vec4(normalize(normal),1.0)).xyz;\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\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";r.Effect.ShadersStore.triplanarVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSEX=!1,t.DIFFUSEY=!1,t.DIFFUSEZ=!1,t.BUMPX=!1,t.BUMPY=!1,t.BUMPZ=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.NORMAL=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.tileSize=1,n.diffuseColor=new r.Color3(1,1,1),n.specularColor=new r.Color3(.2,.2,.2),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return Object(n.b)(t,e),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&o.texturesEnabled){if(r.MaterialFlags.DiffuseTextureEnabled)for(var f=[this.diffuseTextureX,this.diffuseTextureY,this.diffuseTextureZ],l=["DIFFUSEX","DIFFUSEY","DIFFUSEZ"],u=0;u<f.length;u++)if(f[u]){if(!f[u].isReady())return!1;n[l[u]]=!0}if(r.MaterialFlags.BumpTextureEnabled)for(f=[this.normalTextureX,this.normalTextureY,this.normalTextureZ],l=["BUMPX","BUMPY","BUMPZ"],u=0;u<f.length;u++)if(f[u]){if(!f[u].isReady())return!1;n[l[u]]=!0}}if(r.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!1,this._maxSimultaneousLights,this._disableLighting),r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var c=new r.EffectFallbacks;n.FOG&&c.addFallback(1,"FOG"),r.MaterialHelper.HandleFallbacksForShadows(n,c,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var d=[r.VertexBuffer.PositionKind];n.NORMAL&&d.push(r.VertexBuffer.NormalKind),n.VERTEXCOLOR&&d.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(d,e,n,c),r.MaterialHelper.PrepareAttributesForInstances(d,n);var p=n.toString(),h=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","tileSize"],v=["diffuseSamplerX","diffuseSamplerY","diffuseSamplerZ","normalSamplerX","normalSamplerY","normalSamplerZ"],m=new Array;r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:m,samplers:v,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("triplanar",{attributes:d,uniformsNames:h,uniformBuffersNames:m,samplers:v,defines:p,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;a&&(this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._activeEffect.setFloat("tileSize",this.tileSize),n.getCachedMaterial()!==this&&(this.diffuseTextureX&&this._activeEffect.setTexture("diffuseSamplerX",this.diffuseTextureX),this.diffuseTextureY&&this._activeEffect.setTexture("diffuseSamplerY",this.diffuseTextureY),this.diffuseTextureZ&&this._activeEffect.setTexture("diffuseSamplerZ",this.diffuseTextureZ),this.normalTextureX&&this._activeEffect.setTexture("normalSamplerX",this.normalTextureX),this.normalTextureY&&this._activeEffect.setTexture("normalSamplerY",this.normalTextureY),this.normalTextureZ&&this._activeEffect.setTexture("normalSamplerZ",this.normalTextureZ),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),this._afterBind(t,this._activeEffect))}},t.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTextureX&&t.push(this._diffuseTextureX),this._diffuseTextureY&&t.push(this._diffuseTextureY),this._diffuseTextureZ&&t.push(this._diffuseTextureZ),this._normalTextureX&&t.push(this._normalTextureX),this._normalTextureY&&t.push(this._normalTextureY),this._normalTextureZ&&t.push(this._normalTextureZ),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTextureX===t||(this._diffuseTextureY===t||(this._diffuseTextureZ===t||(this._normalTextureX===t||(this._normalTextureY===t||this._normalTextureZ===t)))))},t.prototype.dispose=function(t){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);return e.customType="BABYLON.TriPlanarMaterial",e},t.prototype.getClassName=function(){return"TriPlanarMaterial"},t.Parse=function(e,i,n){return r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n)},Object(n.a)([Object(r.serializeAsTexture)()],t.prototype,"mixTexture",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTextureX")],t.prototype,"_diffuseTextureX",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTextureX",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTexturY")],t.prototype,"_diffuseTextureY",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTextureY",void 0),Object(n.a)([Object(r.serializeAsTexture)("diffuseTextureZ")],t.prototype,"_diffuseTextureZ",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTextureZ",void 0),Object(n.a)([Object(r.serializeAsTexture)("normalTextureX")],t.prototype,"_normalTextureX",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalTextureX",void 0),Object(n.a)([Object(r.serializeAsTexture)("normalTextureY")],t.prototype,"_normalTextureY",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalTextureY",void 0),Object(n.a)([Object(r.serializeAsTexture)("normalTextureZ")],t.prototype,"_normalTextureZ",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalTextureZ",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"tileSize",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"specularColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"specularPower",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.TriPlanarMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"WaterMaterial",(function(){return f}));var n=i(1),r=i(0),o="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef BUMP\nvarying vec2 vNormalUV;\nvarying vec2 vNormalUV2;\nuniform sampler2D normalSampler;\nuniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;\nuniform sampler2D reflectionSampler;\n\nconst float LOG2=1.442695;\nuniform vec3 cameraPosition;\nuniform vec4 waterColor;\nuniform float colorBlendFactor;\nuniform vec4 waterColor2;\nuniform float colorBlendFactor2;\nuniform float bumpHeight;\nuniform float time;\n\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvarying vec3 vPosition;\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\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#ifdef BUMP\n#ifdef BUMPSUPERIMPOSE\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\n#else\nbaseColor=texture2D(normalSampler,vNormalUV);\n#endif\nvec3 bumpColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vNormalInfos.y;\n#else\nvec3 bumpColor=vec3(1.0);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\n#ifdef BUMPAFFECTSREFLECTION\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\nif (normalW.y<0.0) {\nnormalW.y=-normalW.y;\n}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\n\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=clamp(abs(pow(dot(viewDirectionW,upVector),3.0)),0.05,0.65);\nfloat IfresnelTerm=1.0-fresnelTerm;\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\nbaseColor=combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#else\n#ifdef REFLECTION\n\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=max(dot(viewDirectionW,upVector),0.0);\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#elif defined(IMAGEPROCESSING)\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\ngl_FragColor=color;\n}\n";r.Effect.ShadersStore.waterPixelShader=o;var a="precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;\nuniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\n\nuniform mat4 worldReflectionViewProjection;\nuniform vec2 windDirection;\nuniform float waveLength;\nuniform float time;\nuniform float windForce;\nuniform float waveHeight;\nuniform float waveSpeed;\nuniform float waveCount;\n\nvarying vec3 vPosition;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,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 BUMP\nif (vNormalInfos.x == 0.)\n{\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\n#endif\n}\nelse\n{\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\n#endif\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\nfloat finalWaveCount=1.0/(waveCount*0.5);\nvec3 p=position;\nfloat newY=(sin(((p.x/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+(cos(((p.z/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.y*5.0);\np.y+=abs(newY);\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#ifdef REFLECTION\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\n\nvPosition=position;\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvRefractionMapTexCoord.z=worldPos.w;\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n}\n";r.Effect.ShadersStore.waterVertexShader=a;var s=function(e){function t(){var t=e.call(this)||this;return t.BUMP=!1,t.REFLECTION=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.POINTSIZE=!1,t.FOG=!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.SPECULARTERM=!1,t.LOGARITHMICDEPTH=!1,t.FRESNELSEPARATE=!1,t.BUMPSUPERIMPOSE=!1,t.BUMPAFFECTSREFLECTION=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.rebuild(),t}return Object(n.b)(t,e),t}(r.MaterialDefines),f=function(e){function t(t,i,n){void 0===n&&(n=new r.Vector2(512,512));var o=e.call(this,t,i)||this;return o.renderTargetSize=n,o.diffuseColor=new r.Color3(1,1,1),o.specularColor=new r.Color3(0,0,0),o.specularPower=64,o._disableLighting=!1,o._maxSimultaneousLights=4,o.windForce=6,o.windDirection=new r.Vector2(0,1),o.waveHeight=.4,o.bumpHeight=.4,o._bumpSuperimpose=!1,o._fresnelSeparate=!1,o._bumpAffectsReflection=!1,o.waterColor=new r.Color3(.1,.1,.6),o.colorBlendFactor=.2,o.waterColor2=new r.Color3(.1,.1,.6),o.colorBlendFactor2=.2,o.waveLength=.1,o.waveSpeed=1,o.waveCount=20,o.disableClipPlane=!1,o._renderTargets=new r.SmartArray(16),o._mesh=null,o._reflectionTransform=r.Matrix.Zero(),o._lastTime=0,o._lastDeltaTime=0,o._createRenderTargets(i,n),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),o._renderTargets.push(o._reflectionRTT),o._renderTargets.push(o._refractionRTT),o._renderTargets},o._imageProcessingConfiguration=o.getScene().imageProcessingConfiguration,o._imageProcessingConfiguration&&(o._imageProcessingObserver=o._imageProcessingConfiguration.onUpdateParameters.add((function(){o._markAllSubMeshesAsImageProcessingDirty()}))),o}return Object(n.b)(t,e),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),t.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},t.prototype.enableRenderTargets=function(e){var t=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=t),this._reflectionRTT&&(this._reflectionRTT.refreshRate=t)},t.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(t.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&0===this._refractionRTT.refreshRate)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.isReadyForSubMesh=function(e,t,i){if(this.isFrozen&&t.effect&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new s);var n=t._materialDefines,o=this.getScene();if(this._isReadyForSubMesh(t))return!0;var a=o.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,o.texturesEnabled)){if(this.bumpTexture&&r.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;n._needUVs=!0,n.BUMP=!0}r.MaterialFlags.ReflectionTextureEnabled&&(n.REFLECTION=!0)}if(r.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,n,!!i),r.MaterialHelper.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._areMiscDirty&&(this._fresnelSeparate&&(n.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(n.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(n.BUMPAFFECTSREFLECTION=!0)),n._needNormals=r.MaterialHelper.PrepareDefinesForLights(o,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n),n.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,n.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(r.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),this._mesh=e,this._waitingRenderList){for(var f=0;f<this._waitingRenderList.length;f++)this.addToRenderList(o.getNodeByID(this._waitingRenderList[f]));this._waitingRenderList=null}if(n.isDirty){n.markAsProcessed(),o.resetCachedMaterial();var l=new r.EffectFallbacks;n.FOG&&l.addFallback(1,"FOG"),n.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),r.MaterialHelper.HandleFallbacksForShadows(n,l,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&l.addCPUSkinningFallback(0,e);var u=[r.VertexBuffer.PositionKind];n.NORMAL&&u.push(r.VertexBuffer.NormalKind),n.UV1&&u.push(r.VertexBuffer.UVKind),n.UV2&&u.push(r.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&u.push(r.VertexBuffer.ColorKind),r.MaterialHelper.PrepareAttributesForBones(u,e,n,l),r.MaterialHelper.PrepareAttributesForInstances(u,n);var c=n.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],p=["normalSampler","refractionSampler","reflectionSampler"],h=new Array;r.ImageProcessingConfiguration&&(r.ImageProcessingConfiguration.PrepareUniforms(d,n),r.ImageProcessingConfiguration.PrepareSamplers(p,n)),r.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:h,samplers:p,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),t.setEffect(o.getEngine().createEffect("water",{attributes:u,uniformsNames:d,uniformBuffersNames:h,samplers:p,defines:c,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),n)}return!(!t.effect||!t.effect.isReady())&&(n._renderId=o.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;if(a&&this._mesh){this._activeEffect=a,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),r.MaterialHelper.BindBonesParameters(t,this._activeEffect),this._mustRebind(n,a)&&(this.bumpTexture&&r.MaterialFlags.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),r.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),r.MaterialHelper.BindEyePosition(a,n)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility),o.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&r.MaterialHelper.BindLights(n,t,this._activeEffect,o,this.maxSimultaneousLights),n.fogEnabled&&t.applyFog&&n.fogMode!==r.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),r.MaterialHelper.BindFogParameters(n,t,this._activeEffect),r.MaterialHelper.BindLogDepth(o,this._activeEffect,n),r.MaterialFlags.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var s=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(n.getProjectionMatrix()),f=n.getEngine().getDeltaTime();f!==this._lastDeltaTime&&(this._lastDeltaTime=f,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",s),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(t,this._activeEffect)}}},t.prototype._createRenderTargets=function(e,t){var i,n=this;this._refractionRTT=new r.RenderTargetTexture(name+"_refraction",{width:t.x,height:t.y},e,!1,!0),this._refractionRTT.wrapU=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new r.RenderTargetTexture(name+"_reflection",{width:t.x,height:t.y},e,!1,!0),this._reflectionRTT.wrapU=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=r.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var o,a=null,s=r.Matrix.Zero();this._refractionRTT.onBeforeRender=function(){if(n._mesh&&(i=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){a=e.clipPlane;var t=n._mesh?n._mesh.position.y:0;e.clipPlane=r.Plane.FromPositionAndNormal(new r.Vector3(0,t+.05,0),new r.Vector3(0,1,0))}},this._refractionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=i),n.disableClipPlane||(e.clipPlane=a)},this._reflectionRTT.onBeforeRender=function(){if(n._mesh&&(i=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){a=e.clipPlane;var t=n._mesh?n._mesh.position.y:0;e.clipPlane=r.Plane.FromPositionAndNormal(new r.Vector3(0,t-.05,0),new r.Vector3(0,-1,0)),r.Matrix.ReflectionToRef(e.clipPlane,s)}o=e.getViewMatrix(),s.multiplyToRef(o,n._reflectionTransform),e.setTransformMatrix(n._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=r.Vector3.TransformCoordinates(e.activeCamera.position,s)},this._reflectionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=i),e.clipPlane=a,e.setTransformMatrix(o,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!0,e._mirroredCameraPosition=null}},t.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._bumpTexture&&t.push(this._bumpTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this._bumpTexture===t},t.prototype.dispose=function(t){this.bumpTexture&&this.bumpTexture.dispose();var i=this.getScene().customRenderTargets.indexOf(this._refractionRTT);-1!=i&&this.getScene().customRenderTargets.splice(i,1),i=-1,-1!=(i=this.getScene().customRenderTargets.indexOf(this._reflectionRTT))&&this.getScene().customRenderTargets.splice(i,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return r.SerializationHelper.Clone((function(){return new t(e,i.getScene())}),this)},t.prototype.serialize=function(){var e=r.SerializationHelper.Serialize(this);if(e.customType="BABYLON.WaterMaterial",e.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var t=0;t<this._refractionRTT.renderList.length;t++)e.renderList.push(this._refractionRTT.renderList[t].id);return e},t.prototype.getClassName=function(){return"WaterMaterial"},t.Parse=function(e,i,n){var o=r.SerializationHelper.Parse((function(){return new t(e.name,i)}),e,i,n);return o._waitingRenderList=e.renderList,o},t.CreateDefaultMesh=function(e,t){return r.Mesh.CreateGround(e,512,512,32,t,!1)},Object(n.a)([Object(r.serializeAsTexture)("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"diffuseColor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"specularColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"specularPower",void 0),Object(n.a)([Object(r.serialize)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.a)([Object(r.serialize)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"windForce",void 0),Object(n.a)([Object(r.serializeAsVector2)()],t.prototype,"windDirection",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"waveHeight",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"bumpHeight",void 0),Object(n.a)([Object(r.serialize)("bumpSuperimpose")],t.prototype,"_bumpSuperimpose",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpSuperimpose",void 0),Object(n.a)([Object(r.serialize)("fresnelSeparate")],t.prototype,"_fresnelSeparate",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsMiscDirty")],t.prototype,"fresnelSeparate",void 0),Object(n.a)([Object(r.serialize)("bumpAffectsReflection")],t.prototype,"_bumpAffectsReflection",void 0),Object(n.a)([Object(r.expandToProperty)("_markAllSubMeshesAsMiscDirty")],t.prototype,"bumpAffectsReflection",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"waterColor",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"colorBlendFactor",void 0),Object(n.a)([Object(r.serializeAsColor3)()],t.prototype,"waterColor2",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"colorBlendFactor2",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"waveLength",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"waveSpeed",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"waveCount",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"disableClipPlane",void 0),Object(n.a)([Object(r.serialize)()],t.prototype,"useLogarithmicDepth",null),t}(r.PushMaterial);r._TypeStore.RegisteredTypes["BABYLON.WaterMaterial"]=f},function(e,t,i){"use strict";i.r(t),i.d(t,"CustomShaderStructure",(function(){return o})),i.d(t,"ShaderSpecialParts",(function(){return a})),i.d(t,"CustomMaterial",(function(){return s})),i.d(t,"ShaderAlebdoParts",(function(){return f})),i.d(t,"PBRCustomMaterial",(function(){return l}));var n=i(1),r=i(0),o=function(){},a=function(){},s=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.CustomParts=new a,n.customShaderNameResolve=n.Builder,n.FragmentShader=r.Effect.ShadersStore.defaultPixelShader,n.VertexShader=r.Effect.ShadersStore.defaultVertexShader,n}return Object(n.b)(t,e),t.prototype.AttachAfterBind=function(e,t){if(this._newUniformInstances)for(var i in this._newUniformInstances){"vec2"==(n=i.toString().split("-"))[0]?t.setVector2(n[1],this._newUniformInstances[i]):"vec3"==n[0]?t.setVector3(n[1],this._newUniformInstances[i]):"vec4"==n[0]?t.setVector4(n[1],this._newUniformInstances[i]):"mat4"==n[0]?t.setMatrix(n[1],this._newUniformInstances[i]):"float"==n[0]&&t.setFloat(n[1],this._newUniformInstances[i])}if(this._newSamplerInstances)for(var i in this._newSamplerInstances){var n;"sampler2D"==(n=i.toString().split("-"))[0]&&this._newSamplerInstances[i].isReady&&this._newSamplerInstances[i].isReady()&&t.setTexture(n[1],this._newSamplerInstances[i])}},t.prototype.ReviewUniform=function(e,t){if("uniform"==e&&this._newUniforms)for(var i=0;i<this._newUniforms.length;i++)-1==this._customUniform[i].indexOf("sampler")&&t.push(this._newUniforms[i]);if("sampler"==e&&this._newUniforms)for(i=0;i<this._newUniforms.length;i++)-1!=this._customUniform[i].indexOf("sampler")&&t.push(this._newUniforms[i]);return t},t.prototype.Builder=function(e,i,n,o,a,s){var f=this;if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",o),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,t.ShaderIndexer++;var l="custom_"+t.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){f.AttachAfterBind(e,t);try{u(e,t)}catch(t){}}},r.Effect.ShadersStore[l+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(r.Effect.ShadersStore[l+"VertexShader"]=r.Effect.ShadersStore[l+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),r.Effect.ShadersStore[l+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this.CustomParts.Fragment_Before_Fog&&(r.Effect.ShadersStore[l+"PixelShader"]=r.Effect.ShadersStore[l+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},t.prototype.AddUniform=function(e,t,i){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),i&&(-1!=t.indexOf("sampler")?this._newSamplerInstances[t+"-"+e]=i:this._newUniformInstances[t+"-"+e]=i),this._customUniform.push("uniform "+t+" "+e+";"),this._newUniforms.push(e),this},t.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},t.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},t.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},t.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},t.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace("result","diffuseColor"),this},t.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},t.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},t.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},t.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},t.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},t.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},t.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},t.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},t.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},t.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},t.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},t.ShaderIndexer=1,t}(r.StandardMaterial);r._TypeStore.RegisteredTypes["BABYLON.CustomMaterial"]=s;var f=function(){},l=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.CustomParts=new f,n.customShaderNameResolve=n.Builder,n.FragmentShader=r.Effect.ShadersStore.pbrPixelShader,n.VertexShader=r.Effect.ShadersStore.pbrVertexShader,n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,r.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,r.Effect.IncludesShadersStore.pbrBlockReflectivity),n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,r.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),n}return Object(n.b)(t,e),t.prototype.AttachAfterBind=function(e,t){if(this._newUniformInstances)for(var i in this._newUniformInstances){"vec2"==(n=i.toString().split("-"))[0]?t.setVector2(n[1],this._newUniformInstances[i]):"vec3"==n[0]?t.setVector3(n[1],this._newUniformInstances[i]):"vec4"==n[0]?t.setVector4(n[1],this._newUniformInstances[i]):"mat4"==n[0]?t.setMatrix(n[1],this._newUniformInstances[i]):"float"==n[0]&&t.setFloat(n[1],this._newUniformInstances[i])}if(this._newSamplerInstances)for(var i in this._newSamplerInstances){var n;"sampler2D"==(n=i.toString().split("-"))[0]&&this._newSamplerInstances[i].isReady&&this._newSamplerInstances[i].isReady()&&t.setTexture(n[1],this._newSamplerInstances[i])}},t.prototype.ReviewUniform=function(e,t){if("uniform"==e&&this._newUniforms)for(var i=0;i<this._newUniforms.length;i++)-1==this._customUniform[i].indexOf("sampler")&&t.push(this._newUniforms[i]);if("sampler"==e&&this._newUniforms)for(i=0;i<this._newUniforms.length;i++)-1!=this._customUniform[i].indexOf("sampler")&&t.push(this._newUniforms[i]);return t},t.prototype.Builder=function(e,i,n,o,a,s){var f=this;if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",i),this.ReviewUniform("sampler",o),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,t.ShaderIndexer++;var l="custom_"+t.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,t){if(t){f.AttachAfterBind(e,t);try{u(e,t)}catch(t){}}},r.Effect.ShadersStore[l+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(r.Effect.ShadersStore[l+"VertexShader"]=r.Effect.ShadersStore[l+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),r.Effect.ShadersStore[l+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_ALBEDO",this.CustomParts.Fragment_Custom_Albedo?this.CustomParts.Fragment_Custom_Albedo:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS",this.CustomParts.Fragment_Custom_MetallicRoughness?this.CustomParts.Fragment_Custom_MetallicRoughness:"").replace("#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE",this.CustomParts.Fragment_Custom_MicroSurface?this.CustomParts.Fragment_Custom_MicroSurface:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:""),this.CustomParts.Fragment_Before_Fog&&(r.Effect.ShadersStore[l+"PixelShader"]=r.Effect.ShadersStore[l+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},t.prototype.AddUniform=function(e,t,i){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),i&&(-1!=t.indexOf("sampler")?this._newSamplerInstances[t+"-"+e]=i:this._newUniformInstances[t+"-"+e]=i),this._customUniform.push("uniform "+t+" "+e+";"),this._newUniforms.push(e),this},t.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},t.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},t.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},t.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},t.prototype.Fragment_Custom_Albedo=function(e){return this.CustomParts.Fragment_Custom_Albedo=e.replace("result","surfaceAlbedo"),this},t.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},t.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},t.prototype.Fragment_Custom_MetallicRoughness=function(e){return this.CustomParts.Fragment_Custom_MetallicRoughness=e,this},t.prototype.Fragment_Custom_MicroSurface=function(e){return this.CustomParts.Fragment_Custom_MicroSurface=e,this},t.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},t.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},t.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},t.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},t.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},t.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},t.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},t.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},t.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},t.ShaderIndexer=1,t}(r.PBRMaterial);r._TypeStore.RegisteredTypes["BABYLON.PBRCustomMaterial"]=l},function(e,t,i){"use strict";i.r(t);var n=i(3);i.d(t,"CellMaterial",(function(){return n.CellMaterial}));var r=i(17);i.d(t,"CustomShaderStructure",(function(){return r.CustomShaderStructure})),i.d(t,"ShaderSpecialParts",(function(){return r.ShaderSpecialParts})),i.d(t,"CustomMaterial",(function(){return r.CustomMaterial})),i.d(t,"ShaderAlebdoParts",(function(){return r.ShaderAlebdoParts})),i.d(t,"PBRCustomMaterial",(function(){return r.PBRCustomMaterial}));var o=i(4);i.d(t,"FireMaterial",(function(){return o.FireMaterial}));var a=i(5);i.d(t,"FurMaterial",(function(){return a.FurMaterial}));var s=i(6);i.d(t,"GradientMaterial",(function(){return s.GradientMaterial}));var f=i(7);i.d(t,"GridMaterial",(function(){return f.GridMaterial}));var l=i(8);i.d(t,"LavaMaterial",(function(){return l.LavaMaterial}));var u=i(9);i.d(t,"MixMaterial",(function(){return u.MixMaterial}));var c=i(10);i.d(t,"NormalMaterial",(function(){return c.NormalMaterial}));var d=i(11);i.d(t,"ShadowOnlyMaterial",(function(){return d.ShadowOnlyMaterial}));var p=i(12);i.d(t,"SimpleMaterial",(function(){return p.SimpleMaterial}));var h=i(13);i.d(t,"SkyMaterial",(function(){return h.SkyMaterial}));var v=i(14);i.d(t,"TerrainMaterial",(function(){return v.TerrainMaterial}));var m=i(15);i.d(t,"TriPlanarMaterial",(function(){return m.TriPlanarMaterial}));var g=i(16);i.d(t,"WaterMaterial",(function(){return g.WaterMaterial}))},function(e,t,i){"use strict";i.r(t),function(e){var n=i(18);i.d(t,"CellMaterial",(function(){return n.CellMaterial})),i.d(t,"CustomShaderStructure",(function(){return n.CustomShaderStructure})),i.d(t,"ShaderSpecialParts",(function(){return n.ShaderSpecialParts})),i.d(t,"CustomMaterial",(function(){return n.CustomMaterial})),i.d(t,"ShaderAlebdoParts",(function(){return n.ShaderAlebdoParts})),i.d(t,"PBRCustomMaterial",(function(){return n.PBRCustomMaterial})),i.d(t,"FireMaterial",(function(){return n.FireMaterial})),i.d(t,"FurMaterial",(function(){return n.FurMaterial})),i.d(t,"GradientMaterial",(function(){return n.GradientMaterial})),i.d(t,"GridMaterial",(function(){return n.GridMaterial})),i.d(t,"LavaMaterial",(function(){return n.LavaMaterial})),i.d(t,"MixMaterial",(function(){return n.MixMaterial})),i.d(t,"NormalMaterial",(function(){return n.NormalMaterial})),i.d(t,"ShadowOnlyMaterial",(function(){return n.ShadowOnlyMaterial})),i.d(t,"SimpleMaterial",(function(){return n.SimpleMaterial})),i.d(t,"SkyMaterial",(function(){return n.SkyMaterial})),i.d(t,"TerrainMaterial",(function(){return n.TerrainMaterial})),i.d(t,"TriPlanarMaterial",(function(){return n.TriPlanarMaterial})),i.d(t,"WaterMaterial",(function(){return n.WaterMaterial}));var r=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var o in r.BABYLON=r.BABYLON||{},n)r.BABYLON[o]=n[o]}.call(this,i(2))}])}));
33
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),a=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var o={buffer:e,byteLength:r};return t&&(o.byteOffset=t),a&&(o.name=a),n&&(o.byteStride=n),o},e._CreateAccessor=function(e,t,r,n,a,o,i,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=i&&(u.min=i),null!=s&&(u.max=s),null!=o&&(u.byteOffset=o),u},e._CalculateMinMaxPositions=function(t,r,a,o){var i,s,u,l=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];if(a)for(var f=r,h=r+a;f<h;++f){i=3*f,s=n.Vector3.FromArray(t,i),o&&e._GetRightHandedPositionVector3FromRef(s),u=s.asArray();for(var p=0;p<3;++p){var d=u[p];d<l[p]&&(l[p]=d),d>c[p]&&(c[p]=d),++i}}return{min:l,max:c}},e._GetRightHandedPositionVector3=function(e){return new n.Vector3(e.x,e.y,-e.z)},e._GetRightHandedPositionVector3FromRef=function(e){e.z*=-1},e._GetRightHandedPositionArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedNormalVector3=function(e){return new n.Vector3(e.x,e.y,-e.z)},e._GetRightHandedNormalVector3FromRef=function(e){e.z*=-1},e._GetRightHandedNormalArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedVector4FromRef=function(e){e.z*=-1,e.w*=-1},e._GetRightHandedArray4FromRef=function(e){e[2]*=-1,e[3]*=-1},e._GetRightHandedQuaternionFromRef=function(e){e.x*=-1,e.y*=-1},e._GetRightHandedQuaternionArrayFromRef=function(e){e[0]*=-1,e[1]*=-1},e._NormalizeTangentFromRef=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)},e._GetRightHandedMatrixFromRef=function(e){var t=e.m;n.Matrix.FromValuesToRef(t[0],t[1],-t[2],t[3],t[4],t[5],-t[6],t[7],-t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15],e)},e._GetDataAccessorElementCount=function(e){switch(e){case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4}},e}()},function(e,t,r){"use strict";r.d(t,"b",(function(){return u})),r.d(t,"a",(function(){return l}));Object.create;Object.create;var n=r(0),a=r(10),o=r(1),i=r(3),s=r(7),u=function(){function e(e,t){this._includeCoordinateSystemConversionNodes=!1,this._extensions={},this._glTF={asset:{generator:"BabylonJS",version:"2.0"}},this._babylonScene=e,this._bufferViews=[],this._accessors=[],this._meshes=[],this._scenes=[],this._nodes=[],this._images=[],this._materials=[],this._materialMap=[],this._textures=[],this._samplers=[],this._skins=[],this._animations=[],this._imageData={},this._orderedImageData=[],this._options=t||{},this._animationSampleRate=t&&t.animationSampleRate?t.animationSampleRate:1/60,this._includeCoordinateSystemConversionNodes=!(!t||!t.includeCoordinateSystemConversionNodes),this._glTFMaterialExporter=new a.a(this),this._loadExtensions()}return e.prototype._applyExtension=function(e,t,r,n){var a=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a];n.push(this._extensions[i])}return this._applyExtension(t,n,0,r)},e.prototype._extensionsPreExportTextureAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.preExportTextureAsync&&t.preExportTextureAsync(e,n,r)}))},e.prototype._extensionsPostExportMeshPrimitiveAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportMeshPrimitiveAsync&&t.postExportMeshPrimitiveAsync(e,a,r,n)}))},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportNodeAsync&&t.postExportNodeAsync(e,a,r,n)}))},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)}))},e.prototype._extensionsPostExportMaterialAdditionalTextures=function(t,r,n){for(var a=[],o=0,i=e._ExtensionNames;o<i.length;o++){var s=i[o],u=this._extensions[s];u.postExportMaterialAdditionalTextures&&a.push.apply(a,u.postExportMaterialAdditionalTextures(t,r,n))}return a},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a],s=this._extensions[i];s.postExportTexture&&s.postExportTexture(t,r,n)}},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var a=n[r],o=this._extensions[a];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions((function(t){t.wasUsed&&(null==e._glTF.extensionsUsed&&(e._glTF.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&(null==e._glTF.extensionsRequired&&(e._glTF.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),null==e._glTF.extensions&&(e._glTF.extensions={}),t.onExporting&&t.onExporting())}))},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],a=e._ExtensionFactories[n](this);this._extensions[n]=a}},e.prototype.dispose=function(){for(var e in this._extensions){this._extensions[e].dispose()}},e.RegisterExtension=function(t,r){e.UnregisterExtension(t)&&n.Tools.Warn("Extension with the name "+t+" already exists"),e._ExtensionFactories[t]=r,e._ExtensionNames.push(t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._getLocalEngine=function(){if(!this._localEngine){var e=document.createElement("canvas");e.id="WriteCanvas",e.width=2048,e.height=2048,this._localEngine=new n.Engine(e,!0,{premultipliedAlpha:n.Tools.IsSafari(),preserveDrawingBuffer:!0}),this._localEngine.setViewport(new n.Viewport(0,0,1,1))}return this._localEngine},e.prototype.reorderIndicesBasedOnPrimitiveMode=function(e,t,r,a,o){switch(t){case n.Material.TriangleFillMode:a||(a=0);for(var i=e.indexStart,s=e.indexStart+e.indexCount;i<s;i+=3){var u=a+4*i,l=o.getUInt32(u+4),c=o.getUInt32(u+8);o.setUInt32(c,u+4),o.setUInt32(l,u+8)}break;case n.Material.TriangleFanDrawMode:i=e.indexStart+e.indexCount-1;for(var f=e.indexStart;i>=f;--i)o.setUInt32(r[i],a),a+=4;break;case n.Material.TriangleStripDrawMode:e.indexCount>=3&&(o.setUInt32(r[e.indexStart+2],a+4),o.setUInt32(r[e.indexStart+1],a+8))}},e.prototype.reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,a,o,i,s,u){if(u&&r===n.Material.ClockWiseSideOrientation)switch(t){case n.Material.TriangleFillMode:this.reorderTriangleFillMode(e,t,r,a,o,i,s,u);break;case n.Material.TriangleStripDrawMode:this.reorderTriangleStripDrawMode(e,t,r,a,o,i,s,u);break;case n.Material.TriangleFanDrawMode:this.reorderTriangleFanMode(e,t,r,a,o,i,s,u)}},e.prototype.reorderTriangleFillMode=function(e,t,r,a,o,i,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type);if(e.verticesCount%3!=0)n.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector3.FromArray(o,h)),f.push(n.Vector3.FromArray(o,h+2*c)),f.push(n.Vector3.FromArray(o,h+c));break;case n.VertexBuffer.TangentKind:for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector4.FromArray(o,h)),f.push(n.Vector4.FromArray(o,h+2*c)),f.push(n.Vector4.FromArray(o,h+c));break;case n.VertexBuffer.ColorKind:var d=l.getSize();for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=d)h=p*c,4===d?(f.push(n.Vector4.FromArray(o,h)),f.push(n.Vector4.FromArray(o,h+2*c)),f.push(n.Vector4.FromArray(o,h+c))):(f.push(n.Vector3.FromArray(o,h)),f.push(n.Vector3.FromArray(o,h+2*c)),f.push(n.Vector3.FromArray(o,h+c)));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector2.FromArray(o,h)),f.push(n.Vector2.FromArray(o,h+2*c)),f.push(n.Vector2.FromArray(o,h+c));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,i,a,o,s,u)}}else n.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind "+a+" not present!")},e.prototype.reorderTriangleStripDrawMode=function(e,t,r,a,o,i,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:h=e.verticesStart,f.push(n.Vector3.FromArray(o,h+2*c)),f.push(n.Vector3.FromArray(o,h+c));break;case n.VertexBuffer.TangentKind:for(var p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(o,h));break;case n.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,4===l.getSize()?f.push(n.Vector4.FromArray(o,h)):f.push(n.Vector3.FromArray(o,h));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector2.FromArray(o,h));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,i+12,a,o,s,u)}else n.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind "+a+" not present!")},e.prototype.reorderTriangleFanMode=function(e,t,r,a,o,i,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector3.FromArray(o,h));break;case n.VertexBuffer.TangentKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(o,h));break;case n.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(o,h)),4===l.getSize()?f.push(n.Vector4.FromArray(o,h)):f.push(n.Vector3.FromArray(o,h));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector2.FromArray(o,h));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,i,a,o,s,u)}else n.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind "+a+" not present!")},e.prototype.writeVertexAttributeData=function(e,t,r,a,i,s){for(var u=0,l=e;u<l.length;u++){var c=l[u];!s||r===n.VertexBuffer.ColorKind||c instanceof n.Vector2||(c instanceof n.Vector3?r===n.VertexBuffer.NormalKind?o.a._GetRightHandedNormalVector3FromRef(c):r===n.VertexBuffer.PositionKind?o.a._GetRightHandedPositionVector3FromRef(c):n.Tools.Error("Unsupported vertex attribute kind!"):o.a._GetRightHandedVector4FromRef(c)),r===n.VertexBuffer.NormalKind?c.normalize():r===n.VertexBuffer.TangentKind&&c instanceof n.Vector4&&o.a._NormalizeTangentFromRef(c);for(var f=0,h=c.asArray();f<h.length;f++){var p=h[f];i.setFloat32(p,t),t+=4}}},e.prototype.writeAttributeData=function(e,t,r,a,i,s,u){var l,c,f=[];switch(e){case n.VertexBuffer.PositionKind:for(var h=0,p=r.length/a;h<p;++h){l=h*a;var d=n.Vector3.FromArray(r,l);s&&o.a._GetRightHandedPositionVector3FromRef(d),f.push(d.asArray())}break;case n.VertexBuffer.NormalKind:h=0;for(var m=r.length/a;h<m;++h){l=h*a;d=n.Vector3.FromArray(r,l);s&&o.a._GetRightHandedNormalVector3FromRef(d),d.normalize(),f.push(d.asArray())}break;case n.VertexBuffer.TangentKind:h=0;for(var g=r.length/a;h<g;++h){l=h*a;d=n.Vector4.FromArray(r,l);s&&o.a._GetRightHandedVector4FromRef(d),o.a._NormalizeTangentFromRef(d),f.push(d.asArray())}break;case n.VertexBuffer.ColorKind:for(var _=u.material,x=!_||_ instanceof n.StandardMaterial,y=(d=3===a?new n.Color3:new n.Color4,h=0,r.length/a);h<y;++h)l=h*a,3===a?(n.Color3.FromArrayToRef(r,l,d),x&&d.toLinearSpaceToRef(d)):(n.Color4.FromArrayToRef(r,l,d),x&&d.toLinearSpaceToRef(d)),f.push(d.asArray());break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:h=0;for(var T=r.length/a;h<T;++h)l=h*a,f.push([r[l],r[l+1]]);break;case n.VertexBuffer.MatricesIndicesKind:case n.VertexBuffer.MatricesIndicesExtraKind:h=0;for(var v=r.length/a;h<v;++h){l=h*a;d=n.Vector4.FromArray(r,l);f.push(d.asArray())}break;case n.VertexBuffer.MatricesWeightsKind:case n.VertexBuffer.MatricesWeightsExtraKind:h=0;for(var b=r.length/a;h<b;++h){l=h*a;d=n.Vector4.FromArray(r,l);f.push(d.asArray())}break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+e),f=[]}switch(t){case 5121:c=i.setUInt8.bind(i);break;case 5123:c=i.setUInt16.bind(i);break;case 5125:c=i.setUInt32.bind(i);case 5126:c=i.setFloat32.bind(i);break;default:return void n.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var A=0,F=f;A<F.length;A++)for(var E=0,M=F[A];E<M.length;E++){c(M[E])}},e.prototype.writeMorphTargetAttributeData=function(e,t,r,a,i,s,u,l,c,f){var h,p,d=[],m=new n.Vector3,g=new n.Vector4(0,0,0,0);switch(e){case n.VertexBuffer.PositionKind:for(var _=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*u;var x=n.Vector3.FromArray(i,h);m=(y=n.Vector3.FromArray(s,h)).subtractToRef(x,m),c&&o.a._GetRightHandedPositionVector3FromRef(m),f&&(f.min.copyFromFloats(Math.min(m.x,f.min.x),Math.min(m.y,f.min.y),Math.min(m.z,f.min.z)),f.max.copyFromFloats(Math.max(m.x,f.max.x),Math.max(m.y,f.max.y),Math.max(m.z,f.max.z))),d.push(m.asArray())}break;case n.VertexBuffer.NormalKind:for(_=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*u,(x=n.Vector3.FromArray(i,h)).normalize(),(y=n.Vector3.FromArray(s,h)).normalize(),m=y.subtractToRef(x,m),c&&o.a._GetRightHandedNormalVector3FromRef(m),d.push(m.asArray())}break;case n.VertexBuffer.TangentKind:for(_=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*(u+1);x=n.Vector4.FromArray(i,h);o.a._NormalizeTangentFromRef(x);var y=n.Vector4.FromArray(s,h);o.a._NormalizeTangentFromRef(y),g=y.subtractToRef(x,g),c&&o.a._GetRightHandedVector4FromRef(g),d.push([g.x,g.y,g.z])}break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+e),d=[]}switch(t){case 5121:p=l.setUInt8.bind(l);break;case 5123:p=l.setUInt16.bind(l);break;case 5125:p=l.setUInt32.bind(l);case 5126:p=l.setFloat32.bind(l);break;default:return void n.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var T=0,v=d;T<v.length;T++)for(var b=0,A=v[T];b<A.length;b++){p(A[b])}},e.prototype.generateJSON=function(e,t,r){var n,a,i,s=this,u={byteLength:this._totalByteLength},l=this._totalByteLength;return u.byteLength&&(this._glTF.buffers=[u]),this._nodes&&this._nodes.length&&(this._glTF.nodes=this._nodes),this._meshes&&this._meshes.length&&(this._glTF.meshes=this._meshes),this._scenes&&this._scenes.length&&(this._glTF.scenes=this._scenes,this._glTF.scene=0),this._bufferViews&&this._bufferViews.length&&(this._glTF.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(this._glTF.accessors=this._accessors),this._animations&&this._animations.length&&(this._glTF.animations=this._animations),this._materials&&this._materials.length&&(this._glTF.materials=this._materials),this._textures&&this._textures.length&&(this._glTF.textures=this._textures),this._samplers&&this._samplers.length&&(this._glTF.samplers=this._samplers),this._skins&&this._skins.length&&(this._glTF.skins=this._skins),this._images&&this._images.length&&(e?(this._glTF.images=[],this._images.forEach((function(e){e.uri&&(a=s._imageData[e.uri],s._orderedImageData.push(a),n=e.uri.split(".")[0]+" image",i=o.a._CreateBufferView(0,l,a.data.length,void 0,n),l+=a.data.buffer.byteLength,s._bufferViews.push(i),e.bufferView=s._bufferViews.length-1,e.name=n,e.mimeType=a.mimeType,e.uri=void 0,s._glTF.images||(s._glTF.images=[]),s._glTF.images.push(e))})),u.byteLength=l):this._glTF.images=this._images),e||(u.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype._generateGLTFAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a=r.generateJSON(!1,e,!0),o=new Blob([n],{type:"application/octet-stream"}),s=e+".gltf",u=e+".bin",l=new i.GLTFData;if(l.glTFFiles[s]=a,l.glTFFiles[u]=o,r._imageData)for(var c in r._imageData)l.glTFFiles[c]=new Blob([r._imageData[c].data],{type:r._imageData[c].mimeType});return t&&r.dispose(),l}))},e.prototype._generateBinaryAsync=function(){var e=this,t=new l(4);return this.createSceneAsync(this._babylonScene,t).then((function(){return e._localEngine&&e._localEngine.dispose(),t.getArrayBuffer()}))},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype._generateGLBAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();for(var a=r.generateJSON(!0),o=e+".glb",s=a.length,u=0,l=0;l<r._orderedImageData.length;++l)u+=r._orderedImageData[l].data.byteLength;var c=r._getPadding(s),f=r._getPadding(n.byteLength),h=r._getPadding(u),p=28+s+c+n.byteLength+f+u+h,d=new ArrayBuffer(12),m=new DataView(d);m.setUint32(0,1179937895,!0),m.setUint32(4,2,!0),m.setUint32(8,p,!0);var g=new ArrayBuffer(8+s+c),_=new DataView(g);_.setUint32(0,s+c,!0),_.setUint32(4,1313821514,!0);var x=new Uint8Array(g,8);for(l=0;l<s;++l)x[l]=a.charCodeAt(l);var y=new Uint8Array(g,8+s);for(l=0;l<c;++l)y[l]=32;var T=new ArrayBuffer(8),v=new DataView(T);v.setUint32(0,n.byteLength+u+h,!0),v.setUint32(4,5130562,!0);var b=new ArrayBuffer(f),A=new Uint8Array(b);for(l=0;l<f;++l)A[l]=0;var F=new ArrayBuffer(h),E=new Uint8Array(F);for(l=0;l<h;++l)E[l]=0;var M=[d,g,T,n];for(l=0;l<r._orderedImageData.length;++l)M.push(r._orderedImageData[l].data.buffer);M.push(b),M.push(F);var R=new Blob(M,{type:"application/octet-stream"}),V=new i.GLTFData;return V.glTFFiles[o]=R,null!=r._localEngine&&r._localEngine.dispose(),t&&r.dispose(),V}))},e.prototype.setNodeTransformation=function(e,t,r){t.getPivotPoint().equalsToFloats(0,0,0)||n.Tools.Warn("Pivot points are not supported in the glTF serializer"),t.position.equalsToFloats(0,0,0)||(e.translation=r?o.a._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray()),t.scaling.equalsToFloats(1,1,1)||(e.scale=t.scaling.asArray());var a=n.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z);t.rotationQuaternion&&a.multiplyInPlace(t.rotationQuaternion),0===a.x&&0===a.y&&0===a.z&&1===a.w||(r&&o.a._GetRightHandedQuaternionFromRef(a),e.rotation=a.normalize().asArray())},e.prototype.getVertexBufferFromMesh=function(e,t){if(t.isVerticesDataPresent(e)){var r=t.getVertexBuffer(e);if(r)return r}return null},e.prototype.createBufferViewKind=function(e,t,r,a,i,s){var u=r instanceof n.Mesh?r:r instanceof n.InstancedMesh?r.sourceMesh:null;if(u){var l=u.getVertexBuffer(e),c=u.getVerticesData(e);if(l&&c){var f=n.VertexBuffer.GetTypeByteLength(t),h=c.length*f,p=o.a._CreateBufferView(0,a.getByteOffset(),h,i,e+" - "+u.name);this._bufferViews.push(p),this.writeAttributeData(e,t,c,i/f,a,s,r)}}},e.prototype.setMorphTargetAttributes=function(e,t,r,a,i){if(r){t.targets||(t.targets=[]);var s={};if(r.hasNormals){var u=e.getMesh().getVerticesData(n.VertexBuffer.NormalKind),l=r.getNormals(),c=(_=e.verticesCount)*(x=12),f=o.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_NORMAL");this._bufferViews.push(f);var h=this._bufferViews.length-1,p=o.a._CreateAccessor(h,r.name+" - NORMAL","VEC3",5126,_,0,null,null);this._accessors.push(p),s.NORMAL=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.NormalKind,5126,e,r,u,l,x/4,a,i)}if(r.hasPositions){var d=e.getMesh().getVerticesData(n.VertexBuffer.PositionKind),m=r.getPositions();c=(_=e.verticesCount)*(x=12),f=o.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_POSITION");this._bufferViews.push(f);h=this._bufferViews.length-1;var g={min:new n.Vector3(1/0,1/0,1/0),max:new n.Vector3(-1/0,-1/0,-1/0)};p=o.a._CreateAccessor(h,r.name+" - POSITION","VEC3",5126,_,0,null,null);this._accessors.push(p),s.POSITION=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.PositionKind,5126,e,r,d,m,x/4,a,i,g),p.min=g.min.asArray(),p.max=g.max.asArray()}if(r.hasTangents){var _,x,y=e.getMesh().getVerticesData(n.VertexBuffer.TangentKind),T=r.getTangents();c=(_=e.verticesCount)*(x=12),f=o.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_NORMAL");this._bufferViews.push(f);h=this._bufferViews.length-1,p=o.a._CreateAccessor(h,r.name+" - TANGENT","VEC3",5126,_,0,null,null);this._accessors.push(p),s.TANGENT=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.TangentKind,5126,e,r,y,T,x/4,a,i)}t.targets.push(s)}},e.prototype.getMeshPrimitiveMode=function(e){return e instanceof n.LinesMesh?n.Material.LineListDrawMode:e.material?e.material.fillMode:n.Material.TriangleFillMode},e.prototype.setPrimitiveMode=function(e,t){switch(t){case n.Material.TriangleFillMode:break;case n.Material.TriangleStripDrawMode:e.mode=5;break;case n.Material.TriangleFanDrawMode:e.mode=6;break;case n.Material.PointListDrawMode:e.mode=0;case n.Material.PointFillMode:e.mode=0;break;case n.Material.LineLoopDrawMode:e.mode=2;break;case n.Material.LineListDrawMode:e.mode=1;break;case n.Material.LineStripDrawMode:e.mode=3}},e.prototype.setAttributeKind=function(e,t){switch(t){case n.VertexBuffer.PositionKind:e.attributes.POSITION=this._accessors.length-1;break;case n.VertexBuffer.NormalKind:e.attributes.NORMAL=this._accessors.length-1;break;case n.VertexBuffer.ColorKind:e.attributes.COLOR_0=this._accessors.length-1;break;case n.VertexBuffer.TangentKind:e.attributes.TANGENT=this._accessors.length-1;break;case n.VertexBuffer.UVKind:e.attributes.TEXCOORD_0=this._accessors.length-1;break;case n.VertexBuffer.UV2Kind:e.attributes.TEXCOORD_1=this._accessors.length-1;break;case n.VertexBuffer.MatricesIndicesKind:e.attributes.JOINTS_0=this._accessors.length-1;break;case n.VertexBuffer.MatricesIndicesExtraKind:e.attributes.JOINTS_1=this._accessors.length-1;break;case n.VertexBuffer.MatricesWeightsKind:e.attributes.WEIGHTS_0=this._accessors.length-1;break;case n.VertexBuffer.MatricesWeightsExtraKind:e.attributes.WEIGHTS_1=this._accessors.length-1;break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+t)}},e.prototype.setPrimitiveAttributesAsync=function(e,t,r,a){var i,s,u,l=[],c=null;t instanceof n.Mesh?c=t:t instanceof n.InstancedMesh&&(c=t.sourceMesh);var f=[{kind:n.VertexBuffer.PositionKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:n.VertexBuffer.NormalKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:n.VertexBuffer.ColorKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.TangentKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.UVKind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:n.VertexBuffer.UV2Kind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:n.VertexBuffer.MatricesIndicesKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:n.VertexBuffer.MatricesIndicesExtraKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:n.VertexBuffer.MatricesWeightsKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.MatricesWeightsExtraKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16}];if(c){for(var h=null,p=this.getMeshPrimitiveMode(c),d={},m=c.morphTargetManager,g=0,_=f;g<_.length;g++){var x=(W=_[g]).kind,y=W.accessorComponentType;if(c.isVerticesDataPresent(x)){var T=this.getVertexBufferFromMesh(x,c);W.byteStride=T?T.getSize()*n.VertexBuffer.GetTypeByteLength(W.accessorComponentType):4*n.VertexBuffer.DeduceStride(x),12===W.byteStride&&(W.accessorType="VEC3"),this.createBufferViewKind(x,y,t,r,W.byteStride,a),W.bufferViewIndex=this._bufferViews.length-1,d[x]=W.bufferViewIndex}}if(c.getTotalIndices()){var v=c.getIndices();if(v){var b=4*v.length;s=o.a._CreateBufferView(0,r.getByteOffset(),b,void 0,"Indices - "+c.name),this._bufferViews.push(s),h=this._bufferViews.length-1;for(var A=0,F=v.length;A<F;++A)r.setUInt32(v[A])}}if(c.subMeshes)for(var E=0,M=c.subMeshes;E<M.length;E++){var R=M[E],V=R.getMaterial()||c.getScene().defaultMaterial,w=null;if(V)if(c instanceof n.LinesMesh){var S={name:c.name+" material"};(!c.color.equals(n.Color3.White())||c.alpha<1)&&(S.pbrMetallicRoughness={baseColorFactor:c.color.asArray().concat([c.alpha])}),this._materials.push(S),w=this._materials.length-1}else if(V instanceof n.MultiMaterial){var C=V.subMaterials[R.materialIndex];C&&(V=C,w=this._materialMap[V.uniqueId])}else w=this._materialMap[V.uniqueId];var B=null!=w?this._materials[w]:null,I={attributes:{}};this.setPrimitiveMode(I,p);for(var P=0,L=f;P<L.length;P++){if((x=(W=L[P]).kind)!==n.VertexBuffer.UVKind&&x!==n.VertexBuffer.UV2Kind||!B||this._glTFMaterialExporter._hasTexturesPresent(B))if(z=c.getVerticesData(x))if(T=this.getVertexBufferFromMesh(x,c)){var N=T.getSize(),O=W.bufferViewIndex;if(null!=O){u={min:null,max:null},x==n.VertexBuffer.PositionKind&&(u=o.a._CalculateMinMaxPositions(z,0,z.length/N,a));var G=o.a._CreateAccessor(O,x+" - "+t.name,W.accessorType,W.accessorComponentType,z.length/N,0,u.min,u.max);this._accessors.push(G),this.setAttributeKind(I,x)}}}if(h){G=o.a._CreateAccessor(h,"indices - "+t.name,"SCALAR",5125,R.indexCount,4*R.indexStart,null,null);this._accessors.push(G),I.indices=this._accessors.length-1}if(null!=w&&Object.keys(I.attributes).length>0){var k=null!==c.overrideMaterialSideOrientation?c.overrideMaterialSideOrientation:V.sideOrientation;if(k==n.Material.ClockWiseSideOrientation&&this._babylonScene.useRightHandedSystem||k==n.Material.ClockWiseSideOrientation&&a&&c.overrideMaterialSideOrientation!==(null===(i=c.material)||void 0===i?void 0:i.sideOrientation)){var K=null!=h?this._bufferViews[h].byteOffset:null;null==K&&(K=0);var D=null;if(null!=h&&(D=c.getIndices()),D)this.reorderIndicesBasedOnPrimitiveMode(R,p,D,K,r);else for(var U=0,H=f;U<H.length;U++){var z,W=H[U];if(z=c.getVerticesData(W.kind)){var q=this._bufferViews[d[W.kind]].byteOffset;q||(q=0),this.reorderVertexAttributeDataBasedOnPrimitiveMode(R,p,k,W.kind,z,q,r,a)}}}I.material=w}if(m)for(var Q=void 0,j=0;j<m.numTargets;++j)Q=m.getTarget(j),this.setMorphTargetAttributes(R,I,Q,r,a);e.primitives.push(I),this._extensionsPostExportMeshPrimitiveAsync("postExport",I,R,r)&&l.push()}}return Promise.all(l).then((function(){}))},e.prototype.isBabylonCoordinateSystemConvertingNode=function(e){if(e instanceof n.TransformNode){if("__root__"!==e.name)return!1;for(var t=e.getWorldMatrix(),r=n.Matrix.Compose(this._convertToRightHandedSystem?new n.Vector3(-1,1,1):n.Vector3.One(),n.Quaternion.Identity(),n.Vector3.Zero()),a=t.multiply(r),o=n.Matrix.IdentityReadOnly,i=0;i<16;i++)if(Math.abs(a.m[i]-o.m[i])>n.Epsilon)return!1;return!(e instanceof n.Mesh&&null!==e.geometry||e instanceof n.InstancedMesh&&null!==e.sourceMesh.geometry)&&!this._includeCoordinateSystemConversionNodes}return!1},e.prototype.createSceneAsync=function(e,t){var r,a,o,i=this,s={nodes:[]},u=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),a=0;for(t=0;t<r;t++)for(var o=arguments[t],i=0,s=o.length;i<s;i++,a++)n[a]=o[i];return n}(e.transformNodes,e.meshes,e.lights),l=[];return this._convertToRightHandedSystem=!e.useRightHandedSystem,this._convertToRightHandedSystemMap={},e.rootNodes.forEach((function(e){i._convertToRightHandedSystemMap[e.uniqueId]=i._convertToRightHandedSystem,e.getDescendants(!1).forEach((function(e){i._convertToRightHandedSystemMap[e.uniqueId]=i._convertToRightHandedSystem}))})),e.rootNodes.forEach((function(e){if(i.isBabylonCoordinateSystemConvertingNode(e)){l.push(e);var t=u.indexOf(e);-1!==t&&u.splice(t,1),e.getDescendants(!1).forEach((function(e){i._convertToRightHandedSystemMap[e.uniqueId]=!1}))}})),this._glTFMaterialExporter._convertMaterialsToGLTFAsync(e.materials,"image/png",!0).then((function(){return i.createNodeMapAndAnimationsAsync(e,u,t).then((function(c){return i.createSkinsAsync(e,c,t).then((function(e){if(i._nodeMap=c,i._totalByteLength=t.getByteOffset(),null==i._totalByteLength)throw new Error("undefined byte length!");for(var f=0,h=u;f<h.length;f++){var p=h[f];if(void 0!==(r=i._nodeMap[p.uniqueId])){if(a=i._nodes[r],p.metadata&&(i._options.metadataSelector?a.extras=i._options.metadataSelector(p.metadata):p.metadata.gltf&&(a.extras=p.metadata.gltf.extras)),!p.parent||-1!==l.indexOf(p.parent))if(i._options.shouldExportNode&&!i._options.shouldExportNode(p))n.Tools.Log("Omitting "+p.name+" from scene.");else i._convertToRightHandedSystemMap[p.uniqueId]&&(a.translation&&(a.translation[2]*=-1,a.translation[0]*=-1),a.rotation=a.rotation?n.Quaternion.FromArray([0,1,0,0]).multiply(n.Quaternion.FromArray(a.rotation)).asArray():n.Quaternion.FromArray([0,1,0,0]).asArray()),s.nodes.push(r);if(p instanceof n.Mesh){var d=p;d.skeleton&&(a.skin=e[d.skeleton.uniqueId])}if(o=p.getDescendants(!0),!a.children&&o&&o.length){for(var m=[],g=0,_=o;g<_.length;g++){var x=_[g];null!=i._nodeMap[x.uniqueId]&&m.push(i._nodeMap[x.uniqueId])}m.length&&(a.children=m)}}}s.nodes.length&&i._scenes.push(s)}))}))}))},e.prototype.createNodeMapAndAnimationsAsync=function(e,t,r){for(var a,o=this,i=Promise.resolve(),u={},l={name:"runtime animations",channels:[],samplers:[]},c=[],f=function(t){!h._options.shouldExportNode||h._options.shouldExportNode(t)?i=i.then((function(){var i=o._convertToRightHandedSystemMap[t.uniqueId];return o.createNodeAsync(t,r,i,u).then((function(f){var h=o._extensionsPostExportNodeAsync("createNodeAsync",f,t,u);return null==h?(n.Tools.Warn("Not exporting node "+t.name),Promise.resolve()):h.then((function(n){n&&(o._nodes.push(n),a=o._nodes.length-1,u[t.uniqueId]=a,e.animationGroups.length||(s.a._CreateMorphTargetAnimationFromMorphTargetAnimations(t,l,c,u,o._nodes,r,o._bufferViews,o._accessors,i,o._animationSampleRate),t.animations.length&&s.a._CreateNodeAnimationFromNodeAnimations(t,l,c,u,o._nodes,r,o._bufferViews,o._accessors,i,o._animationSampleRate)))}))}))})):t.name},h=this,p=0,d=t;p<d.length;p++){f(d[p])}return i.then((function(){return l.channels.length&&l.samplers.length&&o._animations.push(l),c.forEach((function(e){e.channels.length&&e.samplers.length&&o._animations.push(e)})),e.animationGroups.length&&s.a._CreateNodeAndMorphAnimationFromAnimationGroups(e,o._animations,u,o._nodes,r,o._bufferViews,o._accessors,o._convertToRightHandedSystemMap,o._animationSampleRate),u}))},e.prototype.createNodeAsync=function(e,t,r,a){var o=this;return Promise.resolve().then((function(){var a={},i={primitives:[]};if(e.name&&(a.name=e.name),e instanceof n.TransformNode){if(o.setNodeTransformation(a,e,r),e instanceof n.Mesh){var s=e.morphTargetManager;if(s&&s.numTargets>0){i.weights=[];for(var u=0;u<s.numTargets;++u)i.weights.push(s.getTarget(u).influence)}}return o.setPrimitiveAttributesAsync(i,e,t,r).then((function(){return i.primitives.length&&(o._meshes.push(i),a.mesh=o._meshes.length-1),a}))}return a}))},e.prototype.createSkinsAsync=function(e,t,r){for(var n=Promise.resolve(),a={},i=function(n){var i={joints:[]},u=[],l=e.meshes.find((function(e){e.skeleton}));i.skeleton=null===n.overrideMesh?l?t[l.uniqueId]:void 0:t[n.overrideMesh.uniqueId];for(var c={},f=-1,h=-1,p=0,d=n.bones;p<d.length;p++){(h=(g=d[p]).getIndex())>-1&&(c[h]=g),f=Math.max(f,h)}for(var m=0;m<=f;++m){var g,_=(g=c[m]).getTransformNode();if(_){var x=g.getInvertedAbsoluteTransform();s._convertToRightHandedSystem&&o.a._GetRightHandedMatrixFromRef(x),u.push(x),i.joints.push(t[_.uniqueId])}}var y=64*u.length,T=r.getByteOffset(),v=o.a._CreateBufferView(0,T,y,64,"InverseBindMatrices - "+n.name);s._bufferViews.push(v);var b=s._bufferViews.length-1,A=o.a._CreateAccessor(b,"InverseBindMatrices - "+n.name,"MAT4",5126,u.length,null,null,null),F=s._accessors.push(A)-1;i.inverseBindMatrices=F,s._skins.push(i),a[n.uniqueId]=s._skins.length-1,u.forEach((function(e){e.m.forEach((function(e){r.setFloat32(e)}))}))},s=this,u=0,l=e.skeletons;u<l.length;u++){i(l[u])}return n.then((function(){return a}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),l=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype.resizeBuffer=function(e){for(var t=new ArrayBuffer(e),r=new Uint8Array(this._arrayBuffer),n=new Uint8Array(t),a=0,o=n.byteLength;a<o;++a)n[a]=r[a];return this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this.resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint8(t,e):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+1>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint16(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+2>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(e<this._byteOffset)return this._dataView.getUint32(e,!0);throw n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")},e.prototype.getVector3Float32FromRef=function(e,t){t+8>this._byteOffset?n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&n.Tools.Error("Invalid data being written!"),null!=t&&(t<this._byteOffset?this._dataView.setFloat32(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),this._byteOffset+4>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint32(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+4>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"GLTFData",(function(){return n}));var n=function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"__IGLTFExporterExtension",(function(){return n}));var n=0},function(e,t,r){"use strict";r.r(t),r.d(t,"OBJExport",(function(){return a}));var n=r(0),a=function(){function e(){}return e.OBJ=function(e,t,r,a){var o=[],i=1;t&&(r||(r="mat"),o.push("mtllib "+r+".mtl"));for(var s=0;s<e.length;s++){o.push("g object"+s),o.push("o object_"+s);var u=null;if(a){var l=n.Matrix.Translation(e[s].position.x,e[s].position.y,e[s].position.z);u=n.Matrix.Translation(-e[s].position.x,-e[s].position.y,-e[s].position.z),e[s].bakeTransformIntoVertices(l)}if(t){var c=e[s].material;c&&o.push("usemtl "+c.id)}var f=e[s].geometry;if(f){var h=f.getVerticesData("position"),p=f.getVerticesData("normal"),d=f.getVerticesData("uv"),m=f.getIndices(),g=0;if(h&&m){for(var _=0;_<h.length;_+=3)e[0].getScene().useRightHandedSystem?o.push("v "+h[_]+" "+h[_+1]+" "+h[_+2]):o.push("v "+h[_]+" "+h[_+1]+" "+-h[_+2]),g++;if(null!=p)for(_=0;_<p.length;_+=3)o.push("vn "+p[_]+" "+p[_+1]+" "+p[_+2]);if(null!=d)for(_=0;_<d.length;_+=2)o.push("vt "+d[_]+" "+d[_+1]);for(_=0;_<m.length;_+=3){var x=[String(m[_+2]+i),String(m[_+1]+i),String(m[_]+i)],y=["","",""],T=x,v=null!=d?x:y,b=null!=p?x:y;o.push("f "+T[0]+"/"+v[0]+"/"+b[0]+" "+T[1]+"/"+v[1]+"/"+b[1]+" "+T[2]+"/"+v[2]+"/"+b[2])}a&&u&&e[s].bakeTransformIntoVertices(u),i+=g}else n.Tools.Warn("There are no position vertices or indices on the mesh!")}else n.Tools.Warn("No geometry is present on the mesh")}return o.join("\n")},e.MTL=function(e){var t=[],r=e.material;t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4));return r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"_GLTFAnimation",(function(){return n.a})),r.d(t,"GLTFData",(function(){return a.GLTFData})),r.d(t,"_Exporter",(function(){return o.b})),r.d(t,"_BinaryWriter",(function(){return o.a})),r.d(t,"__IGLTFExporterExtensionV2",(function(){return i})),r.d(t,"_GLTFMaterialExporter",(function(){return s.a})),r.d(t,"GLTF2Export",(function(){return u.GLTF2Export})),r.d(t,"_GLTFUtilities",(function(){return l.a})),r.d(t,"KHR_texture_transform",(function(){return c.KHR_texture_transform})),r.d(t,"KHR_lights_punctual",(function(){return c.KHR_lights_punctual})),r.d(t,"KHR_materials_sheen",(function(){return c.KHR_materials_sheen})),r.d(t,"KHR_materials_unlit",(function(){return c.KHR_materials_unlit}));var n=r(7),a=r(3),o=r(2),i=0,s=r(10),u=r(8),l=r(1),c=r(9)},function(e,t,r){"use strict";r.d(t,"a",(function(){return i}));var n,a=r(0),o=r(1);!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(n||(n={}));var i=function(){function e(){}return e._CreateNodeAnimation=function(t,r,n,o,i,s){var u=[],l=[],c=r.getKeys(),f=e.calculateMinMaxKeyFrames(c),h=e._DeduceInterpolation(c,n,i),p=f.max-f.min,d=h.interpolationType,m=h.shouldBakeAnimation;return m?e._CreateBakedAnimation(t,r,n,f.min,f.max,r.framePerSecond,s,u,l,f,o,i):"LINEAR"===d||"STEP"===d?e._CreateLinearOrStepAnimation(t,r,n,p,u,l,o,i):"CUBICSPLINE"===d?e._CreateCubicSplineAnimation(t,r,n,p,u,l,o,i):e._CreateBakedAnimation(t,r,n,f.min,f.max,r.framePerSecond,s,u,l,f,o,i),u.length&&l.length?{inputs:u,outputs:l,samplerInterpolation:d,inputsMin:m?f.min:a.Tools.FloatRound(f.min/r.framePerSecond),inputsMax:m?f.max:a.Tools.FloatRound(f.max/r.framePerSecond)}:null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,o=e.targetProperty.split(".");switch(o[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:a.Tools.Error("Unsupported animatable property "+o[0])}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(a.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,o,i,s,u,l,c,f){var h;if(t instanceof a.TransformNode&&t.animations)for(var p=0,d=t.animations;p<d.length;p++){var m=d[p],g=e._DeduceAnimationInfo(m);g&&(h={name:m.name,samplers:[],channels:[]},e.AddAnimation(""+m.name,m.hasRunningRuntimeAnimations?r:h,t,m,g.dataAccessorType,g.animationChannelTargetPath,o,s,u,l,c,g.useQuaternion,f),h.samplers.length&&h.channels.length&&n.push(h))}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,o,i,s,u,l,c,f){var h;if(t instanceof a.Mesh){var p=t.morphTargetManager;if(p)for(var d=0;d<p.numTargets;++d)for(var m=0,g=p.getTarget(d).animations;m<g.length;m++){for(var _=g[m],x=new a.Animation(""+_.name,"influence",_.framePerSecond,_.dataType,_.loopMode,_.enableBlending),y=[],T=_.getKeys(),v=0;v<T.length;++v)for(var b=T[v],A=0;A<p.numTargets;++A)A==d?y.push(b):y.push({frame:b.frame,value:0});x.setKeys(y);var F=e._DeduceAnimationInfo(x);F&&(h={name:x.name,samplers:[],channels:[]},e.AddAnimation(_.name,_.hasRunningRuntimeAnimations?r:h,t,x,F.dataAccessorType,F.animationChannelTargetPath,o,s,u,l,c,F.useQuaternion,f,p.numTargets),h.samplers.length&&h.channels.length&&n.push(h))}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,o,i,s,u,l,c){var f,h;if(t.animationGroups)for(var p=function(o){var p=new Map,d=new Map,m=new Set,g=o.to-o.from;h={name:o.name,channels:[],samplers:[]};for(var _=function(r){var g=o.targetedAnimations[r],_=g.target,x=g.animation;if(_ instanceof a.TransformNode||1===_.length&&_[0]instanceof a.TransformNode){if(v=e._DeduceAnimationInfo(g.animation)){var y=_ instanceof a.TransformNode?_:_[0],T=l[y.uniqueId];e.AddAnimation(""+x.name,h,y,x,v.dataAccessorType,v.animationChannelTargetPath,n,i,s,u,T,v.useQuaternion,c)}}else if(_ instanceof a.MorphTarget||1===_.length&&_[0]instanceof a.MorphTarget){var v;if(v=e._DeduceAnimationInfo(g.animation)){var b=_ instanceof a.MorphTarget?_:_[0];if(b){var A=t.morphTargetManagers.find((function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===b)return!0;return!1}));if(A){var F=t.meshes.find((function(e){return e.morphTargetManager===A}));F&&(p.has(F)||p.set(F,new Map),null===(f=p.get(F))||void 0===f||f.set(b,x),m.add(F),d.set(F,x))}}}}},x=0;x<o.targetedAnimations.length;++x)_(x);m.forEach((function(t){for(var r=t.morphTargetManager,l=null,f=[],m=d.get(t).getKeys(),_=m.length,x=0;x<_;++x)for(var y=0;y<r.numTargets;++y){var T=r.getTarget(y),v=p.get(t);if(v){var b=v.get(T);b?(l||(l=new a.Animation(o.name+"_"+t.name+"_MorphWeightAnimation","influence",b.framePerSecond,a.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),f.push(b.getKeys()[x])):f.push({frame:o.from+g/_*x,value:T.influence,inTangent:m[0].inTangent?0:void 0,outTangent:m[0].outTangent?0:void 0})}}l.setKeys(f);var A=e._DeduceAnimationInfo(l);A&&e.AddAnimation(o.name+"_"+t.name+"_MorphWeightAnimation",h,t,l,A.dataAccessorType,A.animationChannelTargetPath,n,i,s,u,!1,A.useQuaternion,c,null==r?void 0:r.numTargets)})),h.channels.length&&h.samplers.length&&r.push(h)},d=0,m=t.animationGroups;d<m.length;d++){p(m[d])}},e.AddAnimation=function(t,r,n,a,i,s,u,l,c,f,h,p,d,m){var g,_,x,y,T,v,b,A=e._CreateNodeAnimation(n,a,s,h,p,d);if(A){if(m){for(var F=0,E=0,M=[];A.inputs.length>0;)E=A.inputs.shift(),F%m==0&&M.push(E),F++;A.inputs=M}var R=u[n.uniqueId],V=4*A.inputs.length;g=o.a._CreateBufferView(0,l.getByteOffset(),V,void 0,t+" keyframe data view"),c.push(g),A.inputs.forEach((function(e){l.setFloat32(e)})),_=o.a._CreateAccessor(c.length-1,t+" keyframes","SCALAR",5126,A.inputs.length,null,[A.inputsMin],[A.inputsMax]),f.push(_),x=f.length-1,T=A.outputs.length,V=4*o.a._GetDataAccessorElementCount(i)*A.outputs.length,g=o.a._CreateBufferView(0,l.getByteOffset(),V,void 0,t+" data view"),c.push(g),A.outputs.forEach((function(e){e.forEach((function(e){l.setFloat32(e)}))})),_=o.a._CreateAccessor(c.length-1,t+" data",i,5126,T,null,null,null),f.push(_),y=f.length-1,v={interpolation:A.samplerInterpolation,input:x,output:y},r.samplers.push(v),b={sampler:r.samplers.length-1,target:{node:R,path:s}},r.channels.push(b)}},e._CreateBakedAnimation=function(t,r,n,o,i,s,u,l,c,f,h,p){var d,m,g=a.Quaternion.Identity(),_=null,x=null,y=null,T=null,v=null,b=null;f.min=a.Tools.FloatRound(o/s);for(var A=r.getKeys(),F=0,E=A.length;F<E;++F){if(b=null,y=A[F],F+1<E)if(T=A[F+1],y.value.equals&&y.value.equals(T.value)||y.value===T.value){if(0!==F)continue;b=y.frame}else b=T.frame;else{if(v=A[F-1],y.value.equals&&y.value.equals(v.value)||y.value===v.value)continue;b=i}if(b)for(var M=y.frame;M<=b;M+=u)if((m=a.Tools.FloatRound(M/s))!==_){_=m,x=m;var R={key:0,repeatCount:0,loopMode:r.loopMode};d=r._interpolate(M,R),e._SetInterpolatedValue(t,d,m,r,n,g,l,c,h,p)}}x&&(f.max=x)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,o,i,s,u){var l,c,f=null,h=e._GetBasePositionRotationOrScale(r,i,s,u);if(o===a.Animation.ANIMATIONTYPE_FLOAT)switch(c=(l=n.targetProperty.split("."))?l[1]:"",f=u?a.Quaternion.FromArray(h).normalize():a.Vector3.FromArray(h),c){case"x":case"y":f[c]=s&&u&&"scale"!==i?-t:t;break;case"z":f[c]=s&&!u&&"scale"!==i?-t:t;break;case"w":f.w=t;break;default:a.Tools.Error('glTFAnimation: Unsupported component type "'+c+'" for scale animation!')}return f},e._SetInterpolatedValue=function(e,t,r,n,i,s,u,l,c,f){var h,p=n.dataType;u.push(r),"number"==typeof t&&e instanceof a.TransformNode&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,p,i,c,f)),t&&("rotation"===i?(f?s=t:(h=t,a.Quaternion.RotationYawPitchRollToRef(h.y,h.x,h.z,s)),c&&(o.a._GetRightHandedQuaternionFromRef(s),e.parent||(s=a.Quaternion.FromArray([0,1,0,0]).multiply(s))),l.push(s.asArray())):"weights"===i?l.push([t]):(h=t,c&&"scale"!==i&&(o.a._GetRightHandedPositionVector3FromRef(h),e.parent||(h.x*=-1,h.z*=-1)),l.push(h.asArray())))},e._CreateLinearOrStepAnimation=function(t,r,n,a,o,i,s,u){for(var l=0,c=r.getKeys();l<c.length;l++){var f=c[l];o.push(f.frame/r.framePerSecond),e._AddKeyframeValue(f,r,i,n,t,s,u)}},e._CreateCubicSplineAnimation=function(t,r,a,o,i,s,u,l){r.getKeys().forEach((function(c){i.push(c.frame/r.framePerSecond),e.AddSplineTangent(t,n.INTANGENT,s,a,"CUBICSPLINE",c,o,l,u),e._AddKeyframeValue(c,r,s,a,t,u,l),e.AddSplineTangent(t,n.OUTTANGENT,s,a,"CUBICSPLINE",c,o,l,u)}))},e._GetBasePositionRotationOrScale=function(e,t,r,n){var i;return"rotation"===t?n?e.rotationQuaternion?(i=e.rotationQuaternion.asArray(),r&&(o.a._GetRightHandedQuaternionArrayFromRef(i),e.parent||(i=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(i)).asArray()))):i=a.Quaternion.Identity().asArray():(i=e.rotation.asArray(),o.a._GetRightHandedNormalArray3FromRef(i)):"translation"===t?(i=e.position.asArray(),r&&o.a._GetRightHandedPositionArray3FromRef(i)):i=e.scaling.asArray(),i},e._AddKeyframeValue=function(e,t,r,n,i,s,u){var l,c,f=t.dataType;if(f===a.Animation.ANIMATIONTYPE_VECTOR3){if(l=e.value.asArray(),"rotation"===n){var h=a.Vector3.FromArray(l),p=a.Quaternion.RotationYawPitchRoll(h.y,h.x,h.z);s&&(o.a._GetRightHandedQuaternionFromRef(p),i.parent||(p=a.Quaternion.FromArray([0,1,0,0]).multiply(p))),l=p.asArray()}else"translation"===n&&s&&(o.a._GetRightHandedNormalArray3FromRef(l),i.parent||(l[0]*=-1,l[2]*=-1));r.push(l)}else if(f===a.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(c=this._ConvertFactorToVector3OrQuaternion(e.value,i,t,f,n,s,u)){if("rotation"===n){var d=u?c:a.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).normalize();s&&(o.a._GetRightHandedQuaternionFromRef(d),i.parent||(d=a.Quaternion.FromArray([0,1,0,0]).multiply(d))),r.push(d.asArray())}else"translation"===n&&s&&(o.a._GetRightHandedNormalVector3FromRef(c),i.parent||(c.x*=-1,c.z*=-1));r.push(c.asArray())}}else f===a.Animation.ANIMATIONTYPE_QUATERNION?(l=e.value.normalize().asArray(),s&&(o.a._GetRightHandedQuaternionArrayFromRef(l),i.parent||(l=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(l)).asArray())),r.push(l)):a.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,o,i=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var s=0,u=e.length;s<u;++s)if((o=e[s]).inTangent||o.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",i=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||o.interpolation&&o.interpolation===a.AnimationKeyInterpolation.STEP&&"STEP"!==n){n="LINEAR",i=!0;break}}else n=o.interpolation&&o.interpolation===a.AnimationKeyInterpolation.STEP?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:i}},e.AddSplineTangent=function(e,t,r,i,s,u,l,c,f){var h,p=t===n.INTANGENT?u.inTangent:u.outTangent;if("CUBICSPLINE"===s){if("rotation"===i)if(p){if(c)h=p.asArray();else{var d=p;h=a.Quaternion.RotationYawPitchRoll(d.y,d.x,d.z).asArray()}f&&(o.a._GetRightHandedQuaternionArrayFromRef(h),e.parent||(h=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(h)).asArray()))}else h=[0,0,0,0];else"weights"===i?h=p?[p]:[0]:p?(h=p.asArray(),f&&"translation"===i&&(o.a._GetRightHandedPositionArray3FromRef(h),e.parent||(h[0]*=-1,h[2]*=-1))):h=[0,0,0];r.push(h)}},e.calculateMinMaxKeyFrames=function(e){var t=1/0,r=-1/0;return e.forEach((function(e){t=Math.min(t,e.frame),r=Math.max(r,e.frame)})),{min:t,max:r}},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"GLTF2Export",(function(){return a}));var n=r(2),a=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var a=t.replace(/\.[^/.]+$/,"");return new n.b(e,r)._generateGLTFAsync(a)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(e,t,r){var a=this;return this._PreExportAsync(e,r).then((function(){var o=t.replace(/\.[^/.]+$/,"");return new n.b(e,r)._generateGLBAsync(o).then((function(t){return a._PostExportAsync(e,t,r)}))}))},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"KHR_texture_transform",(function(){return s})),r.d(t,"KHR_lights_punctual",(function(){return l})),r.d(t,"KHR_materials_sheen",(function(){return c})),r.d(t,"KHR_materials_unlit",(function(){return f}));var n=r(0),a=r(2),o="precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 textureTransformMat;\nvoid main(void) {\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;\ngl_FragColor=texture2D(textureSampler,uvTransformed);\n}";n.Effect.ShadersStore.textureTransformPixelShader=o;var i="KHR_texture_transform",s=function(){function e(e){this._recordedTextures=[],this.name=i,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){for(var e=0,t=this._recordedTextures;e<t.length;e++){t[e].dispose()}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[i]=n}},e.prototype.preExportTextureAsync=function(e,t,r){var n=this;return new Promise((function(r,a){var o=t.getScene();if(o){var i=!1;if(0===t.uAng&&0===t.wAng&&0===t.vAng||0===t.uRotationCenter&&0===t.vRotationCenter||(i=!0),i)return n._textureTransformTextureAsync(t,o).then((function(e){r(e)})).catch((function(e){a(e)}));r(t)}else a(e+': "scene" is not defined for Babylon texture '+t.name+"!")}))},e.prototype._textureTransformTextureAsync=function(e,t){var r=this;return new Promise((function(a){var o=new n.ProceduralTexture(""+e.name,e.getSize(),"textureTransform",t);o||(n.Tools.Log("Cannot create procedural texture for "+e.name+"!"),a(e)),o.reservedDataStore={hidden:!0,source:e},r._recordedTextures.push(o),o.coordinatesIndex=e.coordinatesIndex,o.setTexture("textureSampler",e),o.setMatrix("textureTransformMat",e.getTextureMatrix()),o.isReady()?(o.render(),a(o)):o.getEffect().executeWhenCompiled((function(){o.render(),a(o)}))}))},e}();a.b.RegisterExtension(i,(function(e){return new s(e)}));var u=r(1),l=function(){function e(e){this.name="KHR_lights_punctual",this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions.KHR_lights_punctual=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,a){var o=this;return new Promise((function(i,s){if(t&&r instanceof n.ShadowLight){var l=r,c=void 0,f=l.getTypeID()==n.Light.LIGHTTYPEID_POINTLIGHT?"point":l.getTypeID()==n.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":l.getTypeID()==n.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==f)n.Logger.Warn(e+": Light "+l.name+" is not supported in KHR_lights_punctual");else{var h=l.position.clone(),p=o._exporter._convertToRightHandedSystemMap[r.uniqueId];if(h.equals(n.Vector3.Zero())||(p&&u.a._GetRightHandedPositionVector3FromRef(h),t.translation=h.asArray()),"point"!==f){var d=l.direction,m=-Math.atan2(d.z*(o._exporter._babylonScene.useRightHandedSystem?-1:1),d.x)+Math.PI/2,g=Math.sqrt(d.x*d.x+d.z*d.z),_=-Math.atan2(d.y,g),x=n.Quaternion.RotationYawPitchRoll(m,_,0);p&&u.a._GetRightHandedQuaternionFromRef(x),x.equals(n.Quaternion.Identity())||(t.rotation=x.asArray())}if(l.falloffType!==n.Light.FALLOFF_GLTF&&n.Logger.Warn(e+": Light falloff for "+l.name+" does not match the KHR_lights_punctual specification!"),c={type:f},l.diffuse.equals(n.Color3.White())||(c.color=l.diffuse.asArray()),1!==l.intensity&&(c.intensity=l.intensity),l.range!==Number.MAX_VALUE&&(c.range=l.range),"spot"===f){var y=l;y.angle!==Math.PI/2&&(null==c.spot&&(c.spot={}),c.spot.outerConeAngle=y.angle/2),0!==y.innerAngle&&(null==c.spot&&(c.spot={}),c.spot.innerConeAngle=y.innerAngle/2)}null==o._lights&&(o._lights={lights:[]}),o._lights.lights.push(c);var T={light:o._lights.lights.length-1},v=r.parent;if(v&&1==v.getChildren().length){var b=o._exporter._nodes[a[v.uniqueId]];if(b){var A=n.TmpVectors.Matrix[0],F=n.TmpVectors.Matrix[1],E=b.translation?new n.Vector3(b.translation[0],b.translation[1],b.translation[2]):n.Vector3.Zero(),M=b.rotation?new n.Quaternion(b.rotation[0],b.rotation[1],b.rotation[2],b.rotation[3]):n.Quaternion.Identity(),R=b.scale?new n.Vector3(b.scale[0],b.scale[1],b.scale[2]):n.Vector3.One();n.Matrix.ComposeToRef(R,M,E,A),A.invertToRef(F);var V=n.TmpVectors.Matrix[2],w=t.translation?new n.Vector3(t.translation[0],t.translation[1],t.translation[2]):n.Vector3.Zero();l instanceof n.DirectionalLight&&w.subtractInPlace(o._exporter._babylonScene.useRightHandedSystem?l.direction:u.a._GetRightHandedPositionVector3(l.direction));var S=o._exporter._babylonScene.useRightHandedSystem?n.Quaternion.Identity():new n.Quaternion(0,1,0,0);t.rotation&&S.multiplyInPlace(new n.Quaternion(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]));var C=t.scale?new n.Vector3(t.scale[0],t.scale[1],t.scale[2]):n.Vector3.One();n.Matrix.ComposeToRef(C,S,w,V),V.multiplyToRef(F,V);var B=n.TmpVectors.Vector3[0],I=n.TmpVectors.Quaternion[0],P=n.TmpVectors.Vector3[1];return V.decompose(B,I,P),b.scale=B.asArray(),b.rotation=I.asArray(),b.translation=P.asArray(),null==b.extensions&&(b.extensions={}),b.extensions.KHR_lights_punctual=T,void i(void 0)}}null==t.extensions&&(t.extensions={}),t.extensions.KHR_lights_punctual=T}}i(t)}))},e}();a.b.RegisterExtension("KHR_lights_punctual",(function(e){return new l(e)}));var c=function(){function e(e){this.name="KHR_materials_sheen",this.enabled=!0,this.required=!1,this._textureInfos=[],this._exportedTextures=[],this._wasUsed=!1}return e.prototype.dispose=function(){this._textureInfos=[],this._exportedTextures=[]},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._getTextureIndex=function(e){var t=this._exportedTextures.indexOf(e);return-1===t&&e.reservedDataStore&&(t=this._exportedTextures.indexOf(e.reservedDataStore.source)),t},e.prototype.postExportTexture=function(e,t,r){var n=this._getTextureIndex(r);n>-1&&(this._textureInfos[n]=t)},e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof n.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?(this._exportedTextures.push(r.sheen.texture),[r.sheen.texture]):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var a=this;return new Promise((function(e,o){var i;if(r instanceof n.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);a._wasUsed=!0,null==t.extensions&&(t.extensions={});var s={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(i=r.sheen.roughness)&&void 0!==i?i:0};if(r.sheen.texture)(u=a._getTextureIndex(r.sheen.texture))>-1&&(s.sheenColorTexture=a._textureInfos[u]);if(r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture)(u=a._getTextureIndex(r.sheen.textureRoughness))>-1&&(s.sheenRoughnessTexture=a._textureInfos[u]);else if(r.sheen.texture&&r.sheen.useRoughnessFromMainTexture){var u;(u=a._getTextureIndex(r.sheen.texture))>-1&&(s.sheenRoughnessTexture=a._textureInfos[u])}t.extensions.KHR_materials_sheen=s}e(t)}))},e}();a.b.RegisterExtension("KHR_materials_sheen",(function(e){return new c(e)}));var f=function(){function e(e){this.name="KHR_materials_unlit",this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var a=this;return new Promise((function(e,o){var i=!1;r instanceof n.PBRMaterial?i=r.unlit:r instanceof n.StandardMaterial&&(i=r.disableLighting),i&&(a._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions.KHR_materials_unlit={}),e(t)}))},e}();a.b.RegisterExtension("KHR_materials_unlit",(function(e){return new f(e)}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),a=function(){function e(e){this._textureMap={},this._textureMap={},this._exporter=e}return e.FuzzyEquals=function(e,t,r){return n.Scalar.WithinEpsilon(e.r,t.r,r)&&n.Scalar.WithinEpsilon(e.g,t.g,r)&&n.Scalar.WithinEpsilon(e.b,t.b,r)},e.prototype._convertMaterialsToGLTFAsync=function(e,t,r){for(var a=[],o=0,i=e;o<i.length;o++){var s=i[o];s instanceof n.StandardMaterial?a.push(this._convertStandardMaterialAsync(s,t,r)):s instanceof n.PBRMetallicRoughnessMaterial?a.push(this._convertPBRMetallicRoughnessMaterialAsync(s,t,r)):s instanceof n.PBRMaterial?a.push(this._convertPBRMaterialAsync(s,t,r)):n.Tools.Warn("Unsupported material type: "+s.name)}return Promise.all(a).then((function(){}))},e.prototype._stripTexturesFromMaterial=function(e){var t={};if(e){t.name=e.name,t.doubleSided=e.doubleSided,t.alphaMode=e.alphaMode,t.alphaCutoff=e.alphaCutoff,t.emissiveFactor=e.emissiveFactor;var r=e.pbrMetallicRoughness;r&&(t.pbrMetallicRoughness={},t.pbrMetallicRoughness.baseColorFactor=r.baseColorFactor,t.pbrMetallicRoughness.metallicFactor=r.metallicFactor,t.pbrMetallicRoughness.roughnessFactor=r.roughnessFactor)}return t},e.prototype._hasTexturesPresent=function(e){if(e.emissiveTexture||e.normalTexture||e.occlusionTexture)return!0;var t=e.pbrMetallicRoughness;return!(!t||!t.baseColorTexture&&!t.metallicRoughnessTexture)},e.prototype._convertToGLTFPBRMetallicRoughness=function(t){var r=new n.Vector2(0,1),a=new n.Vector2(0,.1),o=new n.Vector2(0,.1),i=new n.Vector2(1300,.1);var s=t.diffuseColor.toLinearSpace().scale(.5),u=t.alpha,l=function(e){return function(e,t,r,n,a){return(1-e)*(1-e)*(1-e)*t+3*(1-e)*(1-e)*e*r+3*(1-e)*e*e*n+e*e*e*a}(Math.pow(e/i.x,.333333),r.y,a.y,o.y,i.y)}(n.Scalar.Clamp(t.specularPower,0,e._MaxSpecularPower));return{baseColorFactor:[s.r,s.g,s.b,u],metallicFactor:0,roughnessFactor:l}},e._SolveMetallic=function(e,t,r){if(t<this._DielectricSpecular.r)return this._DielectricSpecular,0;var a=this._DielectricSpecular.r,o=e*r/(1-this._DielectricSpecular.r)+t-2*this._DielectricSpecular.r,i=o*o-4*a*(this._DielectricSpecular.r-t);return n.Scalar.Clamp((-o+Math.sqrt(i))/(2*a),0,1)},e._SetAlphaMode=function(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)},e.prototype._convertStandardMaterialAsync=function(t,r,a){var o=this._exporter._materialMap,i=this._exporter._materials,s=[],u=this._convertToGLTFPBRMetallicRoughness(t),l={name:t.name};return null==t.backFaceCulling||t.backFaceCulling||(t.twoSidedLighting||n.Tools.Warn(t.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),l.doubleSided=!0),a&&(t.diffuseTexture&&s.push(this._exportTextureAsync(t.diffuseTexture,r).then((function(e){e&&(u.baseColorTexture=e)}))),t.bumpTexture&&s.push(this._exportTextureAsync(t.bumpTexture,r).then((function(e){e&&(l.normalTexture=e,null!=t.bumpTexture&&1!==t.bumpTexture.level&&(l.normalTexture.scale=t.bumpTexture.level))}))),t.emissiveTexture&&(l.emissiveFactor=[1,1,1],s.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(l.emissiveTexture=e)})))),t.ambientTexture&&s.push(this._exportTextureAsync(t.ambientTexture,r).then((function(e){if(e){var t={index:e.index};l.occlusionTexture=t,t.strength=1}})))),(t.alpha<1||t.opacityTexture)&&(t.alphaMode===n.Constants.ALPHA_COMBINE?l.alphaMode="BLEND":n.Tools.Warn(t.name+": glTF 2.0 does not support alpha mode: "+t.alphaMode.toString())),t.emissiveColor&&!e.FuzzyEquals(t.emissiveColor,n.Color3.Black(),e._Epsilon)&&(l.emissiveFactor=t.emissiveColor.asArray()),l.pbrMetallicRoughness=u,e._SetAlphaMode(l,t),i.push(l),o[t.uniqueId]=i.length-1,this._finishMaterial(s,l,t,r)},e.prototype._finishMaterial=function(e,t,r,n){var a=this;return Promise.all(e).then((function(){for(var e=null,o=0,i=a._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial",t,r);o<i.length;o++){var s=i[o];e||(e=[]),e.push(a._exportTextureAsync(s,n))}return e||(e=[Promise.resolve(null)]),Promise.all(e).then((function(){var e=a._exporter._extensionsPostExportMaterialAsync("exportMaterial",t,r);return e?e.then((function(){return t})):t}))}))},e.prototype._convertPBRMetallicRoughnessMaterialAsync=function(t,r,a){var o=this._exporter._materialMap,i=this._exporter._materials,s=[],u={};t.baseColor&&(u.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,t.alpha]),null!=t.metallic&&1!==t.metallic&&(u.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(u.roughnessFactor=t.roughness);var l={name:t.name};return t.doubleSided&&(l.doubleSided=t.doubleSided),e._SetAlphaMode(l,t),a&&(null!=t.baseTexture&&s.push(this._exportTextureAsync(t.baseTexture,r).then((function(e){e&&(u.baseColorTexture=e)}))),t.normalTexture&&s.push(this._exportTextureAsync(t.normalTexture,r).then((function(e){e&&(l.normalTexture=e,1!==t.normalTexture.level&&(l.normalTexture.scale=t.normalTexture.level))}))),t.occlusionTexture&&s.push(this._exportTextureAsync(t.occlusionTexture,r).then((function(e){e&&(l.occlusionTexture=e,null!=t.occlusionStrength&&(l.occlusionTexture.strength=t.occlusionStrength))}))),t.emissiveTexture&&s.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(l.emissiveTexture=e)})))),e.FuzzyEquals(t.emissiveColor,n.Color3.Black(),e._Epsilon)&&(l.emissiveFactor=t.emissiveColor.asArray()),l.pbrMetallicRoughness=u,i.push(l),o[t.uniqueId]=i.length-1,this._finishMaterial(s,l,t,r)},e.prototype._createBase64FromCanvasAsync=function(e,t,r,a){var o=this;return new Promise((function(i,s){var u,l=n.Constants.TEXTURETYPE_UNSIGNED_INT,c=o._exporter._getLocalEngine();u=new n.Scene(c);var f=c.createRawTexture(e,t,r,n.Constants.TEXTUREFORMAT_RGBA,!1,!0,n.Texture.NEAREST_SAMPLINGMODE,null,l),h=new n.PostProcess("pass","pass",null,null,1,null,n.Texture.NEAREST_SAMPLINGMODE,c,!1,void 0,n.Constants.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);h.getEffect().executeWhenCompiled((function(){var e,o;h.onApply=function(e){e._bindTexture("textureSampler",f)},c.setSize(t,r),u.postProcessManager.directRender([h],null),h.dispose(),f.dispose();var l=c.getRenderingCanvas(),p=document.createElement("canvas");if(p.width=null!==(e=null==l?void 0:l.width)&&void 0!==e?e:0,p.height=null!==(o=null==l?void 0:l.height)&&void 0!==o?o:0,p.getContext("2d").drawImage(l,0,0),p)if(p.toBlob)n.Tools.ToBlob(p,(function(e){if(p=null,e){var t=new FileReader;t.onload=function(e){var t=e.target.result;u.dispose(),i(t)},t.readAsDataURL(e)}else s("gltfMaterialExporter: Failed to get blob from image canvas!")}),a);else{var d=p.toDataURL();i(d)}else s("Engine is missing a canvas!")}))}))},e.prototype._createWhiteTexture=function(e,t,r){for(var a=new Uint8Array(e*t*4),o=0;o<a.length;o+=4)a[o]=a[o+1]=a[o+2]=a[o+3]=255;return n.RawTexture.CreateRGBATexture(a,e,t,r)},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var a,o,i=e?e.getSize():{width:0,height:0},s=t?t.getSize():{width:0,height:0};return i.width<s.width?(a=e&&e instanceof n.Texture?n.TextureTools.CreateResizedCopy(e,s.width,s.height,!0):this._createWhiteTexture(s.width,s.height,r),o=t):i.width>s.width?(o=t&&t instanceof n.Texture?n.TextureTools.CreateResizedCopy(t,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),a=e):(a=e,o=t),{texture1:a,texture2:o}},e.prototype._convertPixelArrayToFloat32=function(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;n<t;++n)r[n]=e[n]/255;return r}if(e instanceof Float32Array)return e;throw new Error("Unsupported pixel format!")},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(t,r,a,o){var i=[];if(!t&&!r)return Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!");var s=t?t.getScene():r?r.getScene():null;if(s){var u=this._resizeTexturesToSameDimensions(t,r,s),l=u.texture1.getSize(),c=void 0,f=void 0,h=l.width,p=l.height,d=u.texture1.readPixels(),m=u.texture2.readPixels();if(!d)return Promise.reject("Failed to retrieve pixels from diffuse texture!");if(c=this._convertPixelArrayToFloat32(d),!m)return Promise.reject("Failed to retrieve pixels from specular glossiness texture!");for(var g=(f=this._convertPixelArrayToFloat32(m)).byteLength,_=new Uint8Array(g),x=new Uint8Array(g),y=n.Color3.Black(),T=0,v=0,b=0;b<p;++b)for(var A=0;A<h;++A){var F=4*(h*b+A),E={diffuseColor:new n.Color3(c[F],c[F+1],c[F+2]).toLinearSpace().multiply(a.diffuseColor),specularColor:new n.Color3(f[F],f[F+1],f[F+2]).toLinearSpace().multiply(a.specularColor),glossiness:f[F+3]*a.glossiness},M=this._convertSpecularGlossinessToMetallicRoughness(E);y.r=Math.max(y.r,M.baseColor.r),y.g=Math.max(y.g,M.baseColor.g),y.b=Math.max(y.b,M.baseColor.b),T=Math.max(T,M.metallic),v=Math.max(v,M.roughness),x[F]=255*M.baseColor.r,x[F+1]=255*M.baseColor.g,x[F+2]=255*M.baseColor.b,x[F+3]=u.texture1.hasAlpha?255*c[F+3]:255,_[F]=0,_[F+1]=255*M.roughness,_[F+2]=255*M.metallic,_[F+3]=255}var R={baseColor:y,metallic:T,roughness:v},V=!1,w=!1;for(b=0;b<p;++b)for(A=0;A<h;++A){var S=4*(h*b+A);x[S]/=R.baseColor.r>e._Epsilon?R.baseColor.r:1,x[S+1]/=R.baseColor.g>e._Epsilon?R.baseColor.g:1,x[S+2]/=R.baseColor.b>e._Epsilon?R.baseColor.b:1;var C=n.Color3.FromInts(x[S],x[S+1],x[S+2]).toGammaSpace();x[S]=255*C.r,x[S+1]=255*C.g,x[S+2]=255*C.b,e.FuzzyEquals(C,n.Color3.White(),e._Epsilon)||(w=!0),_[S+1]/=R.roughness>e._Epsilon?R.roughness:1,_[S+2]/=R.metallic>e._Epsilon?R.metallic:1;var B=n.Color3.FromInts(255,_[S+1],_[S+2]);e.FuzzyEquals(B,n.Color3.White(),e._Epsilon)||(V=!0)}if(V){var I=this._createBase64FromCanvasAsync(_,h,p,o).then((function(e){R.metallicRoughnessTextureBase64=e}));i.push(I)}if(w){I=this._createBase64FromCanvasAsync(x,h,p,o).then((function(e){R.baseColorTextureBase64=e}));i.push(I)}return Promise.all(i).then((function(){return R}))}return Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),a=this._getPerceivedBrightness(t.specularColor),o=1-this._getMaxComponent(t.specularColor),i=e._SolveMetallic(r,a,o),s=t.diffuseColor.scale(o/(1-e._DielectricSpecular.r)/Math.max(1-i,e._Epsilon)),u=t.specularColor.subtract(e._DielectricSpecular.scale(1-i)).scale(1/Math.max(i,e._Epsilon)),l=n.Color3.Lerp(s,u,i*i);return{baseColor:l=l.clampToRef(0,1,l),metallic:i,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],o={baseColor:e.albedoColor,metallic:e.metallic,roughness:e.roughness};return n&&(e.albedoTexture&&a.push(this._exportTextureAsync(e.albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)}))),e.metallicTexture&&a.push(this._exportTextureAsync(e.metallicTexture,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))),Promise.all(a).then((function(){return o}))},e.prototype._getGLTFTextureSampler=function(e){var t=this._getGLTFTextureWrapModesSampler(e),r=e instanceof n.Texture?e.samplingMode:null;if(null!=r)switch(r){case n.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case n.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case n.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case n.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case n.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case n.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case n.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case n.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case n.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case n.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case n.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case n.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case n.Texture.WRAP_ADDRESSMODE:return 10497;case n.Texture.CLAMP_ADDRESSMODE:return 33071;case n.Texture.MIRROR_ADDRESSMODE:return 33648;default:return n.Tools.Error("Unsupported Texture Wrap Mode "+e+"!"),10497}},e.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof n.Texture?e.wrapU:n.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof n.Texture?e.wrapV:n.Texture.WRAP_ADDRESSMODE);return 10497===t&&10497===r?{}:{wrapS:t,wrapT:r}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,a){var o=this;return Promise.resolve().then((function(){var i=o._exporter._samplers,s=o._exporter._textures,u={diffuseColor:e.albedoColor||n.Color3.White(),specularColor:e.reflectivityColor||n.Color3.White(),glossiness:e.microSurface||1},l=null,c=o._getGLTFTextureSampler(e.albedoTexture);return null!=c.magFilter&&null!=c.minFilter&&null!=c.wrapS&&null!=c.wrapT&&(i.push(c),l=i.length-1),e.reflectivityTexture&&!e.useMicroSurfaceFromReflectivityMapAlpha?Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"):(e.albedoTexture||e.reflectivityTexture)&&a?o._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(e.albedoTexture,e.reflectivityTexture,u,t).then((function(n){if(n.baseColorTextureBase64){var a=o._getTextureInfoFromBase64(n.baseColorTextureBase64,"bjsBaseColorTexture_"+s.length+".png",t,e.albedoTexture?e.albedoTexture.coordinatesIndex:null,l);a&&(r.baseColorTexture=a)}if(n.metallicRoughnessTextureBase64){var i=o._getTextureInfoFromBase64(n.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+s.length+".png",t,e.reflectivityTexture?e.reflectivityTexture.coordinatesIndex:null,l);i&&(r.metallicRoughnessTexture=i)}return n})):o._convertSpecularGlossinessToMetallicRoughness(u)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},o={name:e.name};return e.isMetallicWorkflow()?(e.albedoColor&&(a.baseColorFactor=[e.albedoColor.r,e.albedoColor.g,e.albedoColor.b,e.alpha]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n.setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))):this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n.setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))},e.prototype.setMetallicRoughnessPbrMaterial=function(t,r,a,o,i,s){var u=this._exporter._materialMap,l=this._exporter._materials,c=[];if(t){if(e._SetAlphaMode(a,r),e.FuzzyEquals(t.baseColor,n.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(o.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(o.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(o.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r.twoSidedLighting||n.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),a.doubleSided=!0),s){if(r.bumpTexture){var f=this._exportTextureAsync(r.bumpTexture,i).then((function(e){e&&(a.normalTexture=e,1!==r.bumpTexture.level&&(a.normalTexture.scale=r.bumpTexture.level))}));c.push(f)}if(r.ambientTexture){f=this._exportTextureAsync(r.ambientTexture,i).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord};a.occlusionTexture=t,r.ambientTextureStrength&&(t.strength=r.ambientTextureStrength)}}));c.push(f)}if(r.emissiveTexture){f=this._exportTextureAsync(r.emissiveTexture,i).then((function(e){e&&(a.emissiveTexture=e)}));c.push(f)}}e.FuzzyEquals(r.emissiveColor,n.Color3.Black(),e._Epsilon)||(a.emissiveFactor=r.emissiveColor.asArray()),a.pbrMetallicRoughness=o,l.push(a),u[r.uniqueId]=l.length-1}return this._finishMaterial(c,a,r,i)},e.prototype.getPixelsFromTexture=function(e){return e.textureType,n.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){var r=this;return Promise.resolve().then((function(){var n=e.uid;if(n in r._textureMap)return r._textureMap[n];var a=r.getPixelsFromTexture(e);if(!a)return null;for(var o=r._exporter._samplers,i=r._getGLTFTextureSampler(e),s=null,u=null,l=0;l<o.length;++l){var c=o[l];if(c.minFilter===i.minFilter&&c.magFilter===i.magFilter&&c.wrapS===i.wrapS&&c.wrapT===i.wrapT){u=l;break}}null==u?(o.push(i),s=o.length-1):s=u;var f=e.getSize();if(e.mimeType)switch(e.mimeType){case"image/jpeg":t="image/jpeg";break;case"image/png":t="image/png"}return r._createBase64FromCanvasAsync(a,f.width,f.height,t).then((function(a){var o=r._getTextureInfoFromBase64(a,e.name.replace(/\.\/|\/|\.\\|\\/g,"_"),t,e.coordinatesIndex,s);return o&&(r._textureMap[n]=o,r._exporter._extensionsPostExportTextures("linkTextureInfo",o,e)),o}))}))},e.prototype._getTextureInfoFromBase64=function(e,t,r,a,o){var i=this._exporter._textures,s=this._exporter._images,u=this._exporter._imageData,l=null,c={source:s.length,name:t};null!=o&&(c.sampler=o);for(var f=atob(e.split(",")[1]),h=new ArrayBuffer(f.length),p=new Uint8Array(h),d=0,m=f.length;d<m;++d)p[d]=f.charCodeAt(d);var g={data:p,mimeType:r},_="image/jpeg"===r?".jpeg":".png",x=t+_,y=x;if(x in u&&(x=t+"_"+n.Tools.RandomId()+_),u[x]=g,"image/jpeg"===r||"image/png"===r){var T={name:t,uri:x},v=null;for(d=0;d<s.length;++d)if(s[d].uri===y){v=d;break}null==v?(s.push(T),c.source=s.length-1):c.source=v,i.push(c),l={index:i.length-1},null!=a&&(l.texCoord=a)}else n.Tools.Error("Unsupported texture mime type "+r);return l},e._DielectricSpecular=new n.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}()},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";r.r(t),r.d(t,"STLExport",(function(){return a}));var n=r(0),a=function(){function e(){}return e.CreateSTL=function(e,t,r,a,o,i){void 0===t&&(t=!0),void 0===r&&(r="stlmesh"),void 0===a&&(a=!1),void 0===o&&(o=!0),void 0===i&&(i=!1);var s,u=function(e,t,r){var a=[3*e[r],3*e[r+1],3*e[r+2]],o=[new n.Vector3(t[a[0]],t[a[0]+2],t[a[0]+1]),new n.Vector3(t[a[1]],t[a[1]+2],t[a[1]+1]),new n.Vector3(t[a[2]],t[a[2]+2],t[a[2]+1])],i=o[0].subtract(o[1]),s=o[2].subtract(o[1]);return{v:o,n:n.Vector3.Cross(s,i).normalize()}},l=function(e,t,r,n){return t=c(e,t,r.x,n),t=c(e,t,r.y,n),c(e,t,r.z,n)},c=function(e,t,r,n){return e.setFloat32(t,r,n),t+4},f=0,h=0;if(a){for(var p=0;p<e.length;p++){f+=(_=(m=e[p]).getIndices())?_.length/3:0}var d=new ArrayBuffer(84+50*f);h+=80,(s=new DataView(d)).setUint32(h,f,o),h+=4}else s="solid stlmesh\r\n";for(p=0;p<e.length;p++){var m=e[p];i||m.bakeCurrentTransformIntoVertices();for(var g=m.getVerticesData(n.VertexBuffer.PositionKind)||[],_=m.getIndices()||[],x=0;x<_.length;x+=3){var y=u(_,g,x);a?(h=l(s,h,y.n,o),h=l(s,h,y.v[0],o),h=l(s,h,y.v[1],o),h=l(s,h,y.v[2],o),h+=2):(s+="facet normal "+y.n.x+" "+y.n.y+" "+y.n.z+"\r\n",s+="\touter loop\r\n",s+="\t\tvertex "+y.v[0].x+" "+y.v[0].y+" "+y.v[0].z+"\r\n",s+="\t\tvertex "+y.v[1].x+" "+y.v[1].y+" "+y.v[1].z+"\r\n",s+="\t\tvertex "+y.v[2].x+" "+y.v[2].y+" "+y.v[2].z+"\r\n",s+="\tendloop\r\n",s+="endfacet\r\n")}}if(a||(s+="endsolid stlmesh"),t){var T=document.createElement("a"),v=new Blob([s],{type:"application/octet-stream"});T.href=window.URL.createObjectURL(v),T.download=r+".stl",T.click()}return s},e}()},function(e,t,r){"use strict";r.r(t),function(e){var n=r(4),a=r(3),o=r(8),i=r(9),s=r(6);r.d(t,"__IGLTFExporterExtension",(function(){return n.__IGLTFExporterExtension})),r.d(t,"_GLTFAnimation",(function(){return s._GLTFAnimation})),r.d(t,"GLTFData",(function(){return s.GLTFData})),r.d(t,"_Exporter",(function(){return s._Exporter})),r.d(t,"_BinaryWriter",(function(){return s._BinaryWriter})),r.d(t,"__IGLTFExporterExtensionV2",(function(){return s.__IGLTFExporterExtensionV2})),r.d(t,"_GLTFMaterialExporter",(function(){return s._GLTFMaterialExporter})),r.d(t,"GLTF2Export",(function(){return s.GLTF2Export})),r.d(t,"_GLTFUtilities",(function(){return s._GLTFUtilities})),r.d(t,"KHR_texture_transform",(function(){return s.KHR_texture_transform})),r.d(t,"KHR_lights_punctual",(function(){return s.KHR_lights_punctual})),r.d(t,"KHR_materials_sheen",(function(){return s.KHR_materials_sheen})),r.d(t,"KHR_materials_unlit",(function(){return s.KHR_materials_unlit}));var u=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==u){u.BABYLON=u.BABYLON||{};var l=u.BABYLON;l.GLTF2=l.GLTF2||{},l.GLTF2.Exporter=l.GLTF2.Exporter||{},l.GLTF2.Exporter.Extensions=l.GLTF2.Exporter.Extensions||{};var c=[];for(var f in n)l[f]=n[f],c.push(f);for(var f in a)l[f]=a[f],c.push(f);for(var f in o)l[f]=o[f],c.push(f);for(var f in i)l.GLTF2.Exporter.Extensions[f]=i[f],c.push(f);for(var f in s)c.indexOf(f)>-1||(l.GLTF2.Exporter[f]=s[f])}}.call(this,r(11))},function(e,t,r){"use strict";r.r(t),function(e){var n=r(5);r.d(t,"OBJExport",(function(){return n.OBJExport}));var a=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==a)for(var o in n)a.BABYLON[o]=n[o]}.call(this,r(11))},function(e,t,r){"use strict";(function(e){var n=r(12);r.d(t,"a",(function(){return n.STLExport}));var a=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==a)for(var o in n)a.BABYLON[o]=n[o]}).call(this,r(11))},function(e,t,r){"use strict";r.r(t),r.d(t,"__IGLTFExporterExtension",(function(){return n.__IGLTFExporterExtension})),r.d(t,"_GLTFAnimation",(function(){return n._GLTFAnimation})),r.d(t,"GLTFData",(function(){return n.GLTFData})),r.d(t,"_Exporter",(function(){return n._Exporter})),r.d(t,"_BinaryWriter",(function(){return n._BinaryWriter})),r.d(t,"__IGLTFExporterExtensionV2",(function(){return n.__IGLTFExporterExtensionV2})),r.d(t,"_GLTFMaterialExporter",(function(){return n._GLTFMaterialExporter})),r.d(t,"GLTF2Export",(function(){return n.GLTF2Export})),r.d(t,"_GLTFUtilities",(function(){return n._GLTFUtilities})),r.d(t,"KHR_texture_transform",(function(){return n.KHR_texture_transform})),r.d(t,"KHR_lights_punctual",(function(){return n.KHR_lights_punctual})),r.d(t,"KHR_materials_sheen",(function(){return n.KHR_materials_sheen})),r.d(t,"KHR_materials_unlit",(function(){return n.KHR_materials_unlit})),r.d(t,"OBJExport",(function(){return a.OBJExport})),r.d(t,"STLExport",(function(){return o.a}));r(5),r(4),r(6),r(12);var n=r(13),a=r(14),o=r(15)}])}));
34
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-gui",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-gui"]=e(require("babylonjs")):(t.BABYLON=t.BABYLON||{},t.BABYLON.GUI=e(t.BABYLON))}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(t){return function(t){var e={};function i(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return t[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,r){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(r,n,function(e){return t[e]}.bind(null,n));return r},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=2)}([function(e,i){e.exports=t},function(t,e,i){"use strict";i.r(e),i.d(e,"Button",(function(){return O})),i.d(e,"Checkbox",(function(){return T})),i.d(e,"ColorPicker",(function(){return M})),i.d(e,"Container",(function(){return g})),i.d(e,"Control",(function(){return f})),i.d(e,"Ellipse",(function(){return I})),i.d(e,"Grid",(function(){return P})),i.d(e,"Image",(function(){return v})),i.d(e,"InputText",(function(){return x})),i.d(e,"InputPassword",(function(){return k})),i.d(e,"Line",(function(){return A})),i.d(e,"MultiLine",(function(){return E})),i.d(e,"RadioButton",(function(){return D})),i.d(e,"StackPanel",(function(){return C})),i.d(e,"SelectorGroup",(function(){return B})),i.d(e,"CheckboxGroup",(function(){return N})),i.d(e,"RadioGroup",(function(){return H})),i.d(e,"SliderGroup",(function(){return V})),i.d(e,"SelectionPanel",(function(){return W})),i.d(e,"ScrollViewer",(function(){return G})),i.d(e,"TextWrapping",(function(){return m})),i.d(e,"TextBlock",(function(){return y})),i.d(e,"TextWrapper",(function(){return w})),i.d(e,"KeyPropertySet",(function(){return X})),i.d(e,"VirtualKeyboard",(function(){return U})),i.d(e,"Rectangle",(function(){return b})),i.d(e,"DisplayGrid",(function(){return Y})),i.d(e,"BaseSlider",(function(){return L})),i.d(e,"Slider",(function(){return R})),i.d(e,"ImageBasedSlider",(function(){return q})),i.d(e,"ScrollBar",(function(){return j})),i.d(e,"ImageScrollBar",(function(){return z})),i.d(e,"name",(function(){return K})),i.d(e,"AdvancedDynamicTexture",(function(){return J})),i.d(e,"AdvancedDynamicTextureInstrumentation",(function(){return Q})),i.d(e,"Vector2WithInfo",(function(){return d})),i.d(e,"Matrix2D",(function(){return p})),i.d(e,"Measure",(function(){return _})),i.d(e,"MultiLinePoint",(function(){return S})),i.d(e,"Style",(function(){return Z})),i.d(e,"ValueAndUnit",(function(){return a})),i.d(e,"XmlLoader",(function(){return $})),i.d(e,"AbstractButton3D",(function(){return it})),i.d(e,"Button3D",(function(){return rt})),i.d(e,"Container3D",(function(){return nt})),i.d(e,"Control3D",(function(){return et})),i.d(e,"CylinderPanel",(function(){return st})),i.d(e,"HolographicButton",(function(){return ct})),i.d(e,"MeshButton3D",(function(){return _t})),i.d(e,"PlanePanel",(function(){return dt})),i.d(e,"ScatterPanel",(function(){return pt})),i.d(e,"SpherePanel",(function(){return ft})),i.d(e,"StackPanel3D",(function(){return gt})),i.d(e,"VolumeBasedPanel",(function(){return ot})),i.d(e,"FluentMaterialDefines",(function(){return lt})),i.d(e,"FluentMaterial",(function(){return ut})),i.d(e,"GUI3DManager",(function(){return mt})),i.d(e,"Vector3WithInfo",(function(){return tt}));
35
- /*! *****************************************************************************
36
- Copyright (c) Microsoft Corporation.
37
-
38
- Permission to use, copy, modify, and/or distribute this software for any
39
- purpose with or without fee is hereby granted.
40
-
41
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
42
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
43
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
44
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
45
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47
- PERFORMANCE OF THIS SOFTWARE.
48
- ***************************************************************************** */
49
- var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function n(t,e){function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}function o(t,e,i,r){var n,o=arguments.length,s=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(o<3?n(s):o>3?n(e,i,s):n(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s}Object.create;Object.create;var s=i(0),a=function(){function t(e,i,r){void 0===i&&(i=t.UNITMODE_PIXEL),void 0===r&&(r=!0),this.unit=i,this.negativeValueAllowed=r,this._value=1,this.ignoreAdaptiveScaling=!1,this._value=e,this._originalUnit=i}return Object.defineProperty(t.prototype,"isPercentage",{get:function(){return this.unit===t.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPixel",{get:function(){return this.unit===t.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),t.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},t.prototype.updateInPlace=function(e,i){return void 0===i&&(i=t.UNITMODE_PIXEL),this._value=e,this.unit=i,this},t.prototype.getValue=function(e){if(e&&!this.ignoreAdaptiveScaling&&this.unit!==t.UNITMODE_PERCENTAGE){var i=0,r=0;if(e.idealWidth&&(i=this._value*e.getSize().width/e.idealWidth),e.idealHeight&&(r=this._value*e.getSize().height/e.idealHeight),e.useSmallestIdeal&&e.idealWidth&&e.idealHeight)return window.innerWidth<window.innerHeight?i:r;if(e.idealWidth)return i;if(e.idealHeight)return r}return this._value},t.prototype.toString=function(e,i){switch(this.unit){case t.UNITMODE_PERCENTAGE:var r=100*this.getValue(e);return(i?r.toFixed(i):r)+"%";case t.UNITMODE_PIXEL:var n=this.getValue(e);return(i?n.toFixed(i):n)+"px"}return this.unit.toString()},t.prototype.fromString=function(e){var i=t._Regex.exec(e.toString());if(!i||0===i.length)return!1;var r=parseFloat(i[1]),n=this._originalUnit;if(this.negativeValueAllowed||r<0&&(r=0),4===i.length)switch(i[3]){case"px":n=t.UNITMODE_PIXEL;break;case"%":n=t.UNITMODE_PERCENTAGE,r/=100}return(r!==this._value||n!==this.unit)&&(this._value=r,this.unit=n,!0)},Object.defineProperty(t,"UNITMODE_PERCENTAGE",{get:function(){return t._UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"UNITMODE_PIXEL",{get:function(){return t._UNITMODE_PIXEL},enumerable:!1,configurable:!0}),t._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,t._UNITMODE_PERCENTAGE=0,t._UNITMODE_PIXEL=1,t}(),h=[new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0)],l=[new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0)],u=new s.Vector2(0,0),c=new s.Vector2(0,0),_=function(){function t(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r}return t.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},t.prototype.copyFromFloats=function(t,e,i,r){this.left=t,this.top=e,this.width=i,this.height=r},t.CombineToRef=function(t,e,i){var r=Math.min(t.left,e.left),n=Math.min(t.top,e.top),o=Math.max(t.left+t.width,e.left+e.width),s=Math.max(t.top+t.height,e.top+e.height);i.left=r,i.top=n,i.width=o-r,i.height=s-n},t.prototype.addAndTransformToRef=function(t,e,i,r,n,o){var s=this.left+e,a=this.top+i,_=this.width+r,d=this.height+n;h[0].copyFromFloats(s,a),h[1].copyFromFloats(s+_,a),h[2].copyFromFloats(s+_,a+d),h[3].copyFromFloats(s,a+d),u.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE),c.copyFromFloats(0,0);for(var p=0;p<4;p++)t.transformCoordinates(h[p].x,h[p].y,l[p]),u.x=Math.floor(Math.min(u.x,l[p].x)),u.y=Math.floor(Math.min(u.y,l[p].y)),c.x=Math.ceil(Math.max(c.x,l[p].x)),c.y=Math.ceil(Math.max(c.y,l[p].y));o.left=u.x,o.top=u.y,o.width=c.x-u.x,o.height=c.y-u.y},t.prototype.transformToRef=function(t,e){this.addAndTransformToRef(t,0,0,0,0,e)},t.prototype.isEqualsTo=function(t){return this.left===t.left&&(this.top===t.top&&(this.width===t.width&&this.height===t.height))},t.Empty=function(){return new t(0,0,0,0)},t}(),d=function(t){function e(e,i){void 0===i&&(i=0);var r=t.call(this,e.x,e.y)||this;return r.buttonIndex=i,r}return n(e,t),e}(s.Vector2),p=function(){function t(t,e,i,r,n,o){this.m=new Float32Array(6),this.fromValues(t,e,i,r,n,o)}return t.prototype.fromValues=function(t,e,i,r,n,o){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=r,this.m[4]=n,this.m[5]=o,this},t.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},t.prototype.invertToRef=function(t){var e=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],a=this.m[5],h=this.determinant();if(h<s.Epsilon*s.Epsilon)return t.m[0]=0,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[5]=0,this;var l=1/h,u=r*a-n*o,c=i*o-e*a;return t.m[0]=n*l,t.m[1]=-i*l,t.m[2]=-r*l,t.m[3]=e*l,t.m[4]=u*l,t.m[5]=c*l,this},t.prototype.multiplyToRef=function(t,e){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],s=this.m[4],a=this.m[5],h=t.m[0],l=t.m[1],u=t.m[2],c=t.m[3],_=t.m[4],d=t.m[5];return e.m[0]=i*h+r*u,e.m[1]=i*l+r*c,e.m[2]=n*h+o*u,e.m[3]=n*l+o*c,e.m[4]=s*h+a*u+_,e.m[5]=s*l+a*c+d,this},t.prototype.transformCoordinates=function(t,e,i){return i.x=t*this.m[0]+e*this.m[2]+this.m[4],i.y=t*this.m[1]+e*this.m[3]+this.m[5],this},t.Identity=function(){return new t(1,0,0,1,0,0)},t.TranslationToRef=function(t,e,i){i.fromValues(1,0,0,1,t,e)},t.ScalingToRef=function(t,e,i){i.fromValues(t,0,0,e,0,0)},t.RotationToRef=function(t,e){var i=Math.sin(t),r=Math.cos(t);e.fromValues(r,i,-i,r,0,0)},t.ComposeToRef=function(e,i,r,n,o,s,a){t.TranslationToRef(e,i,t._TempPreTranslationMatrix),t.ScalingToRef(n,o,t._TempScalingMatrix),t.RotationToRef(r,t._TempRotationMatrix),t.TranslationToRef(-e,-i,t._TempPostTranslationMatrix),t._TempPreTranslationMatrix.multiplyToRef(t._TempScalingMatrix,t._TempCompose0),t._TempCompose0.multiplyToRef(t._TempRotationMatrix,t._TempCompose1),s?(t._TempCompose1.multiplyToRef(t._TempPostTranslationMatrix,t._TempCompose2),t._TempCompose2.multiplyToRef(s,a)):t._TempCompose1.multiplyToRef(t._TempPostTranslationMatrix,a)},t._TempPreTranslationMatrix=t.Identity(),t._TempPostTranslationMatrix=t.Identity(),t._TempRotationMatrix=t.Identity(),t._TempScalingMatrix=t.Identity(),t._TempCompose0=t.Identity(),t._TempCompose1=t.Identity(),t._TempCompose2=t.Identity(),t}(),f=function(){function t(e){this.name=e,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=_.Empty(),this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new a(18,a.UNITMODE_PIXEL,!1),this._width=new a(1,a.UNITMODE_PERCENTAGE,!1),this._height=new a(1,a.UNITMODE_PERCENTAGE,!1),this._color="",this._style=null,this._horizontalAlignment=t.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=t.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._wasDirty=!1,this._tempParentMeasure=_.Empty(),this._prevCurrentMeasureTransformedIntoGlobalSpace=_.Empty(),this._cachedParentMeasure=_.Empty(),this._paddingLeft=new a(0),this._paddingRight=new a(0),this._paddingTop=new a(0),this._paddingBottom=new a(0),this._left=new a(0),this._top=new a(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=p.Identity(),this._invertTransformMatrix=p.Identity(),this._transformedPosition=s.Vector2.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._isHighlighted=!1,this._fontSet=!1,this._dummyVector2=s.Vector2.Zero(),this._downCount=0,this._enterCount=-1,this._doNotRender=!1,this._downPointerIds={},this._isEnabled=!0,this._disabledColor="#9a9a9a",this._disabledColorItem="#6a6a6a",this._rebuildLayout=!1,this._customData={},this._isClipped=!1,this._automaticSize=!1,this.metadata=null,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this.isFocusInvisible=!1,this.clipChildren=!0,this.clipContent=!0,this.useBitmapCache=!1,this._shadowOffsetX=0,this._shadowOffsetY=0,this._shadowBlur=0,this._shadowColor="black",this.hoverCursor="",this._linkOffsetX=new a(0),this._linkOffsetY=new a(0),this.onWheelObservable=new s.Observable,this.onPointerMoveObservable=new s.Observable,this.onPointerOutObservable=new s.Observable,this.onPointerDownObservable=new s.Observable,this.onPointerUpObservable=new s.Observable,this.onPointerClickObservable=new s.Observable,this.onPointerEnterObservable=new s.Observable,this.onDirtyObservable=new s.Observable,this.onBeforeDrawObservable=new s.Observable,this.onAfterDrawObservable=new s.Observable,this.onDisposeObservable=new s.Observable,this.fixedRatio=0,this._fixedRatioMasterIsWidth=!0,this._tmpMeasureA=new _(0,0,0,0)}return Object.defineProperty(t.prototype,"shadowOffsetX",{get:function(){return this._shadowOffsetX},set:function(t){this._shadowOffsetX!==t&&(this._shadowOffsetX=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOffsetY",{get:function(){return this._shadowOffsetY},set:function(t){this._shadowOffsetY!==t&&(this._shadowOffsetY=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowBlur",{get:function(){return this._shadowBlur},set:function(t){this._shadowBlur!==t&&(this._shadowBlur=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(t){this._shadowColor!==t&&(this._shadowColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return this._getTypeName()},Object.defineProperty(t.prototype,"host",{get:function(){return this._host},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontOffset",{get:function(){return this._fontOffset},set:function(t){this._fontOffset=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alphaSet=!0,this._alpha=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHighlighted",{get:function(){return this._isHighlighted},set:function(t){this._isHighlighted!==t&&(this._isHighlighted=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this._scaleX!==t&&(this._scaleX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this._scaleY!==t&&(this._scaleY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(t){this._transformCenterY!==t&&(this._transformCenterY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(t){this._transformCenterX!==t&&(this._transformCenterX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(t){this._horizontalAlignment!==t&&(this._horizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(t){this._verticalAlignment!==t&&(this._verticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!0,this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"widthInPixels",{get:function(){return this._width.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!0,this.width=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!1,this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"heightInPixels",{get:function(){return this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!1,this.height=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontFamily",{get:function(){return this._fontSet?this._fontFamily:""},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"style",{get:function(){return this._style},set:function(t){var e=this;this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._style=t,this._style&&(this._styleObserver=this._style.onChangedObservable.add((function(){e._markAsDirty(),e._resetFontCache()}))),this._markAsDirty(),this._resetFontCache()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFontSizeInPercentage",{get:function(){return this._fontSize.isPercentage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontSizeInPixels",{get:function(){var t=this._style?this._style._fontSize:this._fontSize;return t.isPixel?t.getValue(this._host):t.getValueInPixel(this._host,this._tempParentMeasure.height||this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.fontSize=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&(this._markAsDirty(),this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(t){this._color!==t&&(this._color=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this.zIndex!==t&&(this._zIndex=t,this.parent&&this.parent._reOrderControl(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"notRenderable",{get:function(){return this._doNotRender},set:function(t){this._doNotRender!==t&&(this._doNotRender=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!==t&&(this._isVisible=t,this._markAsDirty(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkedMesh",{get:function(){return this._linkedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(t){this._paddingLeft.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingLeftInPixels",{get:function(){return this._paddingLeft.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingLeft=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(t){this._paddingRight.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingRightInPixels",{get:function(){return this._paddingRight.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingRight=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(t){this._paddingTop.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingTopInPixels",{get:function(){return this._paddingTop.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingTop=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(t){this._paddingBottom.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingBottomInPixels",{get:function(){return this._paddingBottom.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingBottom=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(t){this._left.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftInPixels",{get:function(){return this._left.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.left=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(t){this._top.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"topInPixels",{get:function(){return this._top.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.top=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(t){this._linkOffsetX.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetXInPixels",{get:function(){return this._linkOffsetX.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.linkOffsetX=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(t){this._linkOffsetY.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetYInPixels",{get:function(){return this._linkOffsetY.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.linkOffsetY=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){this._isEnabled!==t&&(this._isEnabled=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disabledColor",{get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disabledColorItem",{get:function(){return this._disabledColorItem},set:function(t){this._disabledColorItem!==t&&(this._disabledColorItem=t,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Control"},t.prototype.getAscendantOfClass=function(t){return this.parent?this.parent.getClassName()===t?this.parent:this.parent.getAscendantOfClass(t):null},t.prototype._resetFontCache=function(){this._fontSet=!0,this._markAsDirty()},t.prototype.isAscendant=function(t){return!!this.parent&&(this.parent===t||this.parent.isAscendant(t))},t.prototype.getLocalCoordinates=function(t){var e=s.Vector2.Zero();return this.getLocalCoordinatesToRef(t,e),e},t.prototype.getLocalCoordinatesToRef=function(t,e){return e.x=t.x-this._currentMeasure.left,e.y=t.y-this._currentMeasure.top,this},t.prototype.getParentLocalCoordinates=function(t){var e=s.Vector2.Zero();return e.x=t.x-this._cachedParentMeasure.left,e.y=t.y-this._cachedParentMeasure.top,e},t.prototype.moveToVector3=function(e,i){if(this._host&&this.parent===this._host._rootContainer){this.horizontalAlignment=t.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.VERTICAL_ALIGNMENT_TOP;var r=this._host._getGlobalViewport(i),n=s.Vector3.Project(e,s.Matrix.Identity(),i.getTransformMatrix(),r);this._moveToProjectedPosition(n),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},t.prototype.getDescendantsToRef=function(t,e,i){void 0===e&&(e=!1)},t.prototype.getDescendants=function(t,e){var i=new Array;return this.getDescendantsToRef(i,t,e),i},t.prototype.linkWithMesh=function(e){if(!this._host||this.parent&&this.parent!==this._host._rootContainer)e&&s.Tools.Error("Cannot link a control to a mesh if the control is not at root level");else{var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=e,void(e||this._host._linkedControls.splice(i,1));e&&(this.horizontalAlignment=t.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this))}},t.prototype._moveToProjectedPosition=function(t){var e=this._left.getValue(this._host),i=this._top.getValue(this._host),r=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,n=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-e)<.5&&(r=e),Math.abs(n-i)<.5&&(n=i)),this.left=r+"px",this.top=n+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},t.prototype._offsetLeft=function(t){this._isDirty=!0,this._currentMeasure.left+=t},t.prototype._offsetTop=function(t){this._isDirty=!0,this._currentMeasure.top+=t},t.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},t.prototype._flagDescendantsAsMatrixDirty=function(){},t.prototype._intersectsRect=function(t){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=t.left+t.width)&&(!(this._tmpMeasureA.top>=t.top+t.height)&&(!(this._tmpMeasureA.left+this._tmpMeasureA.width<=t.left)&&!(this._tmpMeasureA.top+this._tmpMeasureA.height<=t.top)))},t.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),_.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var t=this.shadowOffsetX,e=this.shadowOffsetY,i=this.shadowBlur,r=Math.min(Math.min(t,0)-2*i,0),n=Math.max(Math.max(t,0)+2*i,0),o=Math.min(Math.min(e,0)-2*i,0),s=Math.max(Math.max(e,0)+2*i,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+r),Math.floor(this._tmpMeasureA.top+o),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+n),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+s))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},t.prototype._markAsDirty=function(t){void 0===t&&(t=!1),(this._isVisible||t)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},t.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},t.prototype._link=function(t){this._host=t,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},t.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var e=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t&&(t.translate(e,i),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-e,-i)),(this._isMatrixDirty||this._cachedOffsetX!==e||this._cachedOffsetY!==i)&&(this._cachedOffsetX=e,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),p.ComposeToRef(-e,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},t.prototype._renderHighlight=function(t){this.isHighlighted&&(t.save(),t.strokeStyle="#4affff",t.lineWidth=2,this._renderHighlightSpecific(t),t.restore())},t.prototype._renderHighlightSpecific=function(t){t.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},t.prototype._applyStates=function(e){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(e.font=this._font),this._color&&(e.fillStyle=this._color),t.AllowAlphaInheritance?e.globalAlpha*=this._alpha:this._alphaSet&&(e.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},t.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(t)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,0|-this.paddingLeftInPixels,0|-this.paddingTopInPixels,0|this.paddingRightInPixels,0|this.paddingBottomInPixels,this._prevCurrentMeasureTransformedIntoGlobalSpace),e.save(),this._applyStates(e);var i=0;do{this._rebuildLayout=!1,this._processMeasures(t,e),i++}while(this._rebuildLayout&&i<3);i>=3&&s.Logger.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this.invalidateRect(),this._evaluateClippingState(t)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},t.prototype._processMeasures=function(t,e){this._currentMeasure.copyFrom(t),this._preMeasure(t,e),this._measure(),this._computeAlignment(t,e),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(t,e),this._cachedParentMeasure.copyFrom(t),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},t.prototype._evaluateClippingState=function(t){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>t.left+t.width)return void(this._isClipped=!0);if(this._currentMeasure.left+this._currentMeasure.width<t.left)return void(this._isClipped=!0);if(this._currentMeasure.top>t.top+t.height)return void(this._isClipped=!0);if(this._currentMeasure.top+this._currentMeasure.height<t.top)return void(this._isClipped=!0)}this._isClipped=!1},t.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host),0!==this.fixedRatio&&(this._fixedRatioMasterIsWidth?this._currentMeasure.height=this._currentMeasure.width*this.fixedRatio:this._currentMeasure.width=this._currentMeasure.height*this.fixedRatio)},t.prototype._computeAlignment=function(e,i){var r=this._currentMeasure.width,n=this._currentMeasure.height,o=e.width,s=e.height,a=0,h=0;switch(this.horizontalAlignment){case t.HORIZONTAL_ALIGNMENT_LEFT:a=0;break;case t.HORIZONTAL_ALIGNMENT_RIGHT:a=o-r;break;case t.HORIZONTAL_ALIGNMENT_CENTER:a=(o-r)/2}switch(this.verticalAlignment){case t.VERTICAL_ALIGNMENT_TOP:h=0;break;case t.VERTICAL_ALIGNMENT_BOTTOM:h=s-n;break;case t.VERTICAL_ALIGNMENT_CENTER:h=(s-n)/2}this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=o*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=o*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=o*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=s*this._paddingTop.getValue(this._host),this._currentMeasure.height-=s*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=s*this._paddingBottom.getValue(this._host),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=o*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=s*this._top.getValue(this._host),this._currentMeasure.left+=a,this._currentMeasure.top+=h},t.prototype._preMeasure=function(t,e){},t.prototype._additionalProcessing=function(t,e){},t.prototype._clipForChildren=function(t){},t.prototype._clip=function(e,i){if(e.beginPath(),t._ClipMeasure.copyFrom(this._currentMeasure),i){i.transformToRef(this._invertTransformMatrix,this._tmpMeasureA);var r=new _(0,0,0,0);r.left=Math.max(this._tmpMeasureA.left,this._currentMeasure.left),r.top=Math.max(this._tmpMeasureA.top,this._currentMeasure.top),r.width=Math.min(this._tmpMeasureA.left+this._tmpMeasureA.width,this._currentMeasure.left+this._currentMeasure.width)-r.left,r.height=Math.min(this._tmpMeasureA.top+this._tmpMeasureA.height,this._currentMeasure.top+this._currentMeasure.height)-r.top,t._ClipMeasure.copyFrom(r)}if(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var n=this.shadowOffsetX,o=this.shadowOffsetY,s=this.shadowBlur,a=Math.min(Math.min(n,0)-2*s,0),h=Math.max(Math.max(n,0)+2*s,0),l=Math.min(Math.min(o,0)-2*s,0),u=Math.max(Math.max(o,0)+2*s,0);e.rect(t._ClipMeasure.left+a,t._ClipMeasure.top+l,t._ClipMeasure.width+h-a,t._ClipMeasure.height+u-l)}else e.rect(t._ClipMeasure.left,t._ClipMeasure.top,t._ClipMeasure.width,t._ClipMeasure.height);e.clip()},t.prototype._render=function(t,e){return!this.isVisible||this.notRenderable||this._isClipped?(this._isDirty=!1,!1):(this.host._numRenderCalls++,t.save(),this._applyStates(t),this._transform(t),this.clipContent&&this._clip(t,e),this.onBeforeDrawObservable.hasObservers()&&this.onBeforeDrawObservable.notifyObservers(this),this.useBitmapCache&&!this._wasDirty&&this._cacheData?t.putImageData(this._cacheData,this._currentMeasure.left,this._currentMeasure.top):this._draw(t,e),this.useBitmapCache&&this._wasDirty&&(this._cacheData=t.getImageData(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._renderHighlight(t),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this),t.restore(),!0)},t.prototype._draw=function(t,e){},t.prototype.contains=function(t,e){return this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y,!(t<this._currentMeasure.left)&&(!(t>this._currentMeasure.left+this._currentMeasure.width)&&(!(e<this._currentMeasure.top)&&(!(e>this._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},t.prototype._processPicking=function(t,e,i,r,n,o,s,a){return!!this._isEnabled&&(!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(t,e)&&(this._processObservables(r,t,e,i,n,o,s,a),!0)))},t.prototype._onPointerMove=function(t,e,i,r){this.onPointerMoveObservable.notifyObservers(e,-1,t,this,r)&&null!=this.parent&&this.parent._onPointerMove(t,e,i,r)},t.prototype._onPointerEnter=function(t,e){return!!this._isEnabled&&(!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this,e)&&null!=this.parent&&this.parent._onPointerEnter(t,e),!0))},t.prototype._onPointerOut=function(t,e,i){if(void 0===i&&(i=!1),i||this._isEnabled&&t!==this){this._enterCount=0;var r=!0;t.isAscendant(this)||(r=this.onPointerOutObservable.notifyObservers(this,-1,t,this,e)),r&&null!=this.parent&&this.parent._onPointerOut(t,e,i)}},t.prototype._onPointerDown=function(t,e,i,r,n){return this._onPointerEnter(this,n),0===this._downCount&&(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new d(e,r),-1,t,this,n)&&null!=this.parent&&this.parent._onPointerDown(t,e,i,r,n),!0)},t.prototype._onPointerUp=function(t,e,i,r,n,o){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var s=n;n&&(this._enterCount>0||-1===this._enterCount)&&(s=this.onPointerClickObservable.notifyObservers(new d(e,r),-1,t,this,o)),this.onPointerUpObservable.notifyObservers(new d(e,r),-1,t,this,o)&&null!=this.parent&&this.parent._onPointerUp(t,e,i,r,s,o)}},t.prototype._forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector2.Zero(),t,0,!0);else for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector2.Zero(),+e,0,!0)},t.prototype._onWheelScroll=function(t,e){this._isEnabled&&(this.onWheelObservable.notifyObservers(new s.Vector2(t,e))&&null!=this.parent&&this.parent._onWheelScroll(t,e))},t.prototype._onCanvasBlur=function(){},t.prototype._processObservables=function(t,e,i,r,n,o,a,h){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(e,i),t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,n,r);var l=this._host._lastControlOver[n];return l&&l!==this&&l._onPointerOut(this,r),l!==this&&this._onPointerEnter(this,r),this._host._lastControlOver[n]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,n,o,r),this._host._registerLastControlDown(this,n),this._host._lastPickedControl=this,!0):t===s.PointerEventTypes.POINTERUP?(this._host._lastControlDown[n]&&this._host._lastControlDown[n]._onPointerUp(this,this._dummyVector2,n,o,!0,r),delete this._host._lastControlDown[n],!0):!(t!==s.PointerEventTypes.POINTERWHEEL||!this._host._lastControlOver[n])&&(this._host._lastControlOver[n]._onWheelScroll(a,h),!0)},t.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=t._GetFontOffset(this._font))},t.prototype.dispose=function(){(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host)&&(this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null));this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return t._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return t._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return t._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_TOP",{get:function(){return t._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return t._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return t._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),t._GetFontOffset=function(e){if(t._FontHeightSizes[e])return t._FontHeightSizes[e];var i=document.createElement("span");i.innerHTML="Hg",i.style.font=e;var r=document.createElement("div");r.style.display="inline-block",r.style.width="1px",r.style.height="0px",r.style.verticalAlign="bottom";var n=document.createElement("div");n.style.whiteSpace="nowrap",n.appendChild(i),n.appendChild(r),document.body.appendChild(n);var o=0,s=0;try{s=r.getBoundingClientRect().top-i.getBoundingClientRect().top,r.style.verticalAlign="baseline",o=r.getBoundingClientRect().top-i.getBoundingClientRect().top}finally{document.body.removeChild(n)}var a={ascent:o,height:s,descent:s-o};return t._FontHeightSizes[e]=a,a},t.drawEllipse=function(t,e,i,r,n){n.translate(t,e),n.scale(i,r),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/r),n.translate(-t,-e)},t.AllowAlphaInheritance=!1,t._ClipMeasure=new _(0,0,0,0),t._HORIZONTAL_ALIGNMENT_LEFT=0,t._HORIZONTAL_ALIGNMENT_RIGHT=1,t._HORIZONTAL_ALIGNMENT_CENTER=2,t._VERTICAL_ALIGNMENT_TOP=0,t._VERTICAL_ALIGNMENT_BOTTOM=1,t._VERTICAL_ALIGNMENT_CENTER=2,t._FontHeightSizes={},t.AddHeader=function(){},t}();s._TypeStore.RegisteredTypes["BABYLON.GUI.Control"]=f;var g=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._children=new Array,i._measureForChildren=_.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return n(e,t),Object.defineProperty(e.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(t){this._adaptHeightToChildren!==t&&(this._adaptHeightToChildren=t,t&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(t){this._adaptWidthToChildren!==t&&(this._adaptWidthToChildren=t,t&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Container"},e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this.children;t<e.length;t++){e[t]._markMatrixAsDirty()}},e.prototype.getChildByName=function(t){for(var e=0,i=this.children;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},e.prototype.getChildByType=function(t,e){for(var i=0,r=this.children;i<r.length;i++){var n=r[i];if(n.typeName===e)return n}return null},e.prototype.containsControl=function(t){return-1!==this.children.indexOf(t)},e.prototype.addControl=function(t){return t?(-1!==this._children.indexOf(t)||(t._link(this._host),t._markAllAsDirty(),this._reOrderControl(t),this._markAsDirty()),this):this},e.prototype.clearControls=function(){for(var t=0,e=this.children.slice();t<e.length;t++){var i=e[t];this.removeControl(i)}return this},e.prototype.removeControl=function(t){var e=this._children.indexOf(t);return-1!==e&&(this._children.splice(e,1),t.parent=null),t.linkWithMesh(null),this._host&&this._host._cleanControlAfterRemoval(t),this._markAsDirty(),this},e.prototype._reOrderControl=function(t){this.removeControl(t);for(var e=!1,i=0;i<this._children.length;i++)if(this._children[i].zIndex>t.zIndex){this._children.splice(i,0,t),e=!0;break}e||this._children.push(t),t.parent=this,this._markAsDirty()},e.prototype._offsetLeft=function(e){t.prototype._offsetLeft.call(this,e);for(var i=0,r=this._children;i<r.length;i++){r[i]._offsetLeft(e)}},e.prototype._offsetTop=function(e){t.prototype._offsetTop.call(this,e);for(var i=0,r=this._children;i<r.length;i++){r[i]._offsetTop(e)}},e.prototype._markAllAsDirty=function(){t.prototype._markAllAsDirty.call(this);for(var e=0;e<this._children.length;e++)this._children[e]._markAllAsDirty()},e.prototype._localDraw=function(t){this._background&&(t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),t.restore())},e.prototype._link=function(e){t.prototype._link.call(this,e);for(var i=0,r=this._children;i<r.length;i++){r[i]._link(e)}},e.prototype._beforeLayout=function(){},e.prototype._processMeasures=function(e,i){!this._isDirty&&this._cachedParentMeasure.isEqualsTo(e)||(t.prototype._processMeasures.call(this,e,i),this._evaluateClippingState(e))},e.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;this.host._numLayoutCalls++,this._isDirty&&this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace);var i=0;e.save(),this._applyStates(e),this._beforeLayout();do{var r=-1,n=-1;if(this._rebuildLayout=!1,this._processMeasures(t,e),!this._isClipped){for(var o=0,a=this._children;o<a.length;o++){var h=a[o];h._tempParentMeasure.copyFrom(this._measureForChildren),h._layout(this._measureForChildren,e)&&(this.adaptWidthToChildren&&h._width.isPixel&&(r=Math.max(r,h._currentMeasure.width+h.paddingLeftInPixels+h.paddingRightInPixels)),this.adaptHeightToChildren&&h._height.isPixel&&(n=Math.max(n,h._currentMeasure.height+h.paddingTopInPixels+h.paddingBottomInPixels)))}this.adaptWidthToChildren&&r>=0&&(r+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==r+"px"&&(this.width=r+"px",this._rebuildLayout=!0)),this.adaptHeightToChildren&&n>=0&&(n+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==n+"px"&&(this.height=n+"px",this._rebuildLayout=!0)),this._postMeasure()}i++}while(this._rebuildLayout&&i<this.maxLayoutCycle);return i>=3&&this.logLayoutCycleErrors&&s.Logger.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),e.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},e.prototype._postMeasure=function(){},e.prototype._draw=function(t,e){this._localDraw(t),this.clipChildren&&this._clipForChildren(t);for(var i=0,r=this._children;i<r.length;i++){var n=r[i];e&&!n._intersectsRect(e)||n._render(t,e)}},e.prototype.getDescendantsToRef=function(t,e,i){if(void 0===e&&(e=!1),this.children)for(var r=0;r<this.children.length;r++){var n=this.children[r];i&&!i(n)||t.push(n),e||n.getDescendantsToRef(t,!1,i)}},e.prototype._processPicking=function(e,i,r,n,o,s,a,h){if(!this._isEnabled||!this.isVisible||this.notRenderable)return!1;if(!t.prototype.contains.call(this,e,i))return!1;for(var l=this._children.length-1;l>=0;l--){var u=this._children[l];if(u._processPicking(e,i,r,n,o,s,a,h))return u.hoverCursor&&this._host._changeCursor(u.hoverCursor),!0}return!!this.isHitTestVisible&&this._processObservables(n,e,i,r,o,s,a,h)},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(this._currentMeasure)},e.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=this.children.length-1;e>=0;e--)this.children[e].dispose()},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Container"]=g;var m,b=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(t){t<0&&(t=0),this._cornerRadius!==t&&(this._cornerRadius=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Rectangle"},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._background&&(t.fillStyle=this._background,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.fill()):t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.stroke()):t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._drawRoundedRect=function(t,e){void 0===e&&(e=0);var i=this._currentMeasure.left+e,r=this._currentMeasure.top+e,n=this._currentMeasure.width-2*e,o=this._currentMeasure.height-2*e,s=Math.min(o/2-2,Math.min(n/2-2,this._cornerRadius));t.beginPath(),t.moveTo(i+s,r),t.lineTo(i+n-s,r),t.quadraticCurveTo(i+n,r,i+n,r+s),t.lineTo(i+n,r+o-s),t.quadraticCurveTo(i+n,r+o,i+n-s,r+o),t.lineTo(i+s,r+o),t.quadraticCurveTo(i,r+o,i,r+o-s),t.lineTo(i,r+s),t.quadraticCurveTo(i,r,i+s,r),t.closePath()},e.prototype._clipForChildren=function(t){this._cornerRadius&&(this._drawRoundedRect(t,this._thickness),t.clip())},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.Rectangle"]=b,function(t){t[t.Clip=0]="Clip",t[t.WordWrap=1]="WordWrap",t[t.Ellipsis=2]="Ellipsis"}(m||(m={}));var y=function(t){function e(e,i){void 0===i&&(i="");var r=t.call(this,e)||this;return r.name=e,r._text="",r._textWrapping=m.Clip,r._textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,r._textVerticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,r._resizeToFit=!1,r._lineSpacing=new a(0),r._outlineWidth=0,r._outlineColor="white",r._underline=!1,r._lineThrough=!1,r.onTextChangedObservable=new s.Observable,r.onLinesReadyObservable=new s.Observable,r.text=i,r}return n(e,t),Object.defineProperty(e.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(t){this._resizeToFit!==t&&(this._resizeToFit=t,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(t){this._textWrapping!==t&&(this._textWrapping=+t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(t){this._textHorizontalAlignment!==t&&(this._textHorizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(t){this._textVerticalAlignment!==t&&(this._textVerticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(t){this._lineSpacing.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"underline",{get:function(){return this._underline},set:function(t){this._underline!==t&&(this._underline=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(t){this._lineThrough!==t&&(this._lineThrough=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(t){this._outlineColor!==t&&(this._outlineColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"TextBlock"},e.prototype._processMeasures=function(e,i){this._fontOffset||(this._fontOffset=f._GetFontOffset(i.font)),t.prototype._processMeasures.call(this,e,i),this._lines=this._breakLines(this._currentMeasure.width,i),this.onLinesReadyObservable.notifyObservers(this);for(var r=0,n=0;n<this._lines.length;n++){var o=this._lines[n];o.width>r&&(r=o.width)}if(this._resizeToFit){if(this._textWrapping===m.Clip){var s=this.paddingLeftInPixels+this.paddingRightInPixels+r|0;s!==this._width.internalValue&&(this._width.updateInPlace(s,a.UNITMODE_PIXEL),this._rebuildLayout=!0)}var h=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&0!==this._lineSpacing.internalValue){var l=0;l=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),h+=(this._lines.length-1)*l}h!==this._height.internalValue&&(this._height.updateInPlace(h,a.UNITMODE_PIXEL),this._rebuildLayout=!0)}},e.prototype._drawText=function(t,e,i,r){var n=this._currentMeasure.width,o=0;switch(this._textHorizontalAlignment){case f.HORIZONTAL_ALIGNMENT_LEFT:o=0;break;case f.HORIZONTAL_ALIGNMENT_RIGHT:o=n-e;break;case f.HORIZONTAL_ALIGNMENT_CENTER:o=(n-e)/2}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&r.strokeText(t,this._currentMeasure.left+o,i),r.fillText(t,this._currentMeasure.left+o,i),this._underline&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i+3),r.lineTo(this._currentMeasure.left+o+e,i+3),r.stroke(),r.closePath()),this._lineThrough&&(r.beginPath(),r.lineWidth=Math.round(.05*this.fontSizeInPixels),r.moveTo(this._currentMeasure.left+o,i-this.fontSizeInPixels/3),r.lineTo(this._currentMeasure.left+o+e,i-this.fontSizeInPixels/3),r.stroke(),r.closePath())},e.prototype._draw=function(t,e){t.save(),this._applyStates(t),this._renderLines(t),t.restore()},e.prototype._applyStates=function(e){t.prototype._applyStates.call(this,e),this.outlineWidth&&(e.lineWidth=this.outlineWidth,e.strokeStyle=this.outlineColor,e.lineJoin="miter",e.miterLimit=2)},e.prototype._breakLines=function(t,e){var i=[],r=this.text.split("\n");if(this._textWrapping===m.Ellipsis)for(var n=0,o=r;n<o.length;n++){var s=o[n];i.push(this._parseLineEllipsis(s,t,e))}else if(this._textWrapping===m.WordWrap)for(var a=0,h=r;a<h.length;a++){s=h[a];i.push.apply(i,this._parseLineWordWrap(s,t,e))}else for(var l=0,u=r;l<u.length;l++){s=u[l];i.push(this._parseLine(s,e))}return i},e.prototype._parseLine=function(t,e){return void 0===t&&(t=""),{text:t,width:e.measureText(t).width}},e.prototype._parseLineEllipsis=function(t,e,i){void 0===t&&(t="");var r=i.measureText(t).width;r>e&&(t+="…");var n=Array.from&&Array.from(t);if(n)for(;n.length&&r>e;)n.pop(),t=n.join("")+"...",r=i.measureText(t).width;else for(;t.length>2&&r>e;)t=t.slice(0,-2)+"…",r=i.measureText(t).width;return{text:t,width:r}},e.prototype._parseLineWordWrap=function(t,e,i){void 0===t&&(t="");for(var r=[],n=this.wordSplittingFunction?this.wordSplittingFunction(t):t.split(" "),o=0,s=0;s<n.length;s++){var a=s>0?t+" "+n[s]:n[0],h=i.measureText(a).width;h>e&&s>0?(r.push({text:t,width:o}),t=n[s],o=i.measureText(t).width):(o=h,t=a)}return r.push({text:t,width:o}),r},e.prototype._renderLines=function(t){var e=this._currentMeasure.height,i=0;switch(this._textVerticalAlignment){case f.VERTICAL_ALIGNMENT_TOP:i=this._fontOffset.ascent;break;case f.VERTICAL_ALIGNMENT_BOTTOM:i=e-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case f.VERTICAL_ALIGNMENT_CENTER:i=this._fontOffset.ascent+(e-this._fontOffset.height*this._lines.length)/2}i+=this._currentMeasure.top;for(var r=0;r<this._lines.length;r++){var n=this._lines[r];0!==r&&0!==this._lineSpacing.internalValue&&(this._lineSpacing.isPixel?i+=this._lineSpacing.getValue(this._host):i+=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)),this._drawText(n.text,n.width,i,t),i+=this._fontOffset.height}},e.prototype.computeExpectedHeight=function(){if(this.text&&this.widthInPixels){var t=document.createElement("canvas").getContext("2d");if(t){this._applyStates(t),this._fontOffset||(this._fontOffset=f._GetFontOffset(t.font));var e=this._lines?this._lines:this._breakLines(this.widthInPixels-this.paddingLeftInPixels-this.paddingRightInPixels,t),i=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*e.length;if(e.length>0&&0!==this._lineSpacing.internalValue){var r=0;r=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),i+=(e.length-1)*r}return i}}return 0},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onTextChangedObservable.clear()},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.TextBlock"]=y;var v=function(t){function e(i,r){void 0===r&&(r=null);var n=t.call(this,i)||this;return n.name=i,n._workingCanvas=null,n._loaded=!1,n._stretch=e.STRETCH_FILL,n._autoScale=!1,n._sourceLeft=0,n._sourceTop=0,n._sourceWidth=0,n._sourceHeight=0,n._svgAttributesComputationCompleted=!1,n._isSVG=!1,n._cellWidth=0,n._cellHeight=0,n._cellId=-1,n._populateNinePatchSlicesFromImage=!1,n._imageDataCache={data:null,key:""},n.onImageLoadedObservable=new s.Observable,n.onSVGAttributesComputedObservable=new s.Observable,n.source=r,n}return n(e,t),Object.defineProperty(e.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(t){this._populateNinePatchSlicesFromImage!==t&&(this._populateNinePatchSlicesFromImage=t,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(t){this._detectPointerOnOpaqueOnly!==t&&(this._detectPointerOnOpaqueOnly=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(t){this._sliceLeft!==t&&(this._sliceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(t){this._sliceRight!==t&&(this._sliceRight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(t){this._sliceTop!==t&&(this._sliceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(t){this._sliceBottom!==t&&(this._sliceBottom=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(t){this._sourceLeft!==t&&(this._sourceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(t){this._sourceTop!==t&&(this._sourceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(t){this._sourceWidth!==t&&(this._sourceWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(t){this._sourceHeight!==t&&(this._sourceHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSVG",{get:function(){return this._isSVG},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"svgAttributesComputationCompleted",{get:function(){return this._svgAttributesComputationCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoScale",{get:function(){return this._autoScale},set:function(t){this._autoScale!==t&&(this._autoScale=t,t&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stretch",{get:function(){return this._stretch},set:function(t){this._stretch!==t&&(this._stretch=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._rotate90=function(t,i){void 0===i&&(i=!1);var r=document.createElement("canvas"),n=r.getContext("2d"),o=this._domImage.width,s=this._domImage.height;r.width=s,r.height=o,n.translate(r.width/2,r.height/2),n.rotate(t*Math.PI/2),n.drawImage(this._domImage,0,0,o,s,-o/2,-s/2,o,s);var a=r.toDataURL("image/jpg"),h=new e(this.name+"rotated",a);return i&&(h._stretch=this._stretch,h._autoScale=this._autoScale,h._cellId=this._cellId,h._cellWidth=t%1?this._cellHeight:this._cellWidth,h._cellHeight=t%1?this._cellWidth:this._cellHeight),this._handleRotationForSVGImage(this,h,t),this._imageDataCache.data=null,h},e.prototype._handleRotationForSVGImage=function(t,e,i){var r=this;t._isSVG&&(t._svgAttributesComputationCompleted?(this._rotate90SourceProperties(t,e,i),this._markAsDirty()):t.onSVGAttributesComputedObservable.addOnce((function(){r._rotate90SourceProperties(t,e,i),r._markAsDirty()})))},e.prototype._rotate90SourceProperties=function(t,e,i){var r,n,o=t.sourceLeft,s=t.sourceTop,a=t.domImage.width,h=t.domImage.height,l=o,u=s,c=t.sourceWidth,_=t.sourceHeight;if(0!=i){var d=i<0?-1:1;i%=4;for(var p=0;p<Math.abs(i);++p)l=-(s-h/2)*d+h/2,u=(o-a/2)*d+a/2,c=(r=[_,c])[0],_=r[1],i<0?u-=_:l-=c,o=l,s=u,a=(n=[h,a])[0],h=n[1]}e.sourceLeft=l,e.sourceTop=u,e.sourceWidth=c,e.sourceHeight=_},Object.defineProperty(e.prototype,"domImage",{get:function(){return this._domImage},set:function(t){var e=this;this._domImage=t,this._loaded=!1,this._imageDataCache.data=null,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){e._onImageLoaded()}},enumerable:!1,configurable:!0}),e.prototype._onImageLoaded=function(){this._imageDataCache.data=null,this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._populateNinePatchSlicesFromImage&&this._extractNinePatchSliceDataFromImage(),this._autoScale&&this.synchronizeSizeWithContent(),this.onImageLoadedObservable.notifyObservers(this),this._markAsDirty()},e.prototype._extractNinePatchSliceDataFromImage=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var t=this._workingCanvas,e=t.getContext("2d"),i=this._domImage.width,r=this._domImage.height;t.width=i,t.height=r,e.drawImage(this._domImage,0,0,i,r);var n=e.getImageData(0,0,i,r);this._sliceLeft=-1,this._sliceRight=-1;for(var o=0;o<i;o++){if((a=n.data[4*o+3])>127&&-1===this._sliceLeft)this._sliceLeft=o;else if(a<127&&this._sliceLeft>-1){this._sliceRight=o;break}}this._sliceTop=-1,this._sliceBottom=-1;for(var s=0;s<r;s++){var a;if((a=n.data[s*i*4+3])>127&&-1===this._sliceTop)this._sliceTop=s;else if(a<127&&this._sliceTop>-1){this._sliceBottom=s;break}}},Object.defineProperty(e.prototype,"source",{set:function(t){var e=this;this._source!==t&&(this._loaded=!1,this._source=t,this._imageDataCache.data=null,t&&(t=this._svgCheck(t)),this._domImage=document.createElement("img"),this._domImage.onload=function(){e._onImageLoaded()},t&&(s.Tools.SetCorsBehavior(t,this._domImage),this._domImage.src=t))},enumerable:!1,configurable:!0}),e.prototype._svgCheck=function(t){var e=this;if(window.SVGSVGElement&&-1!==t.search(/.svg#/gi)&&t.indexOf("#")===t.lastIndexOf("#")){this._isSVG=!0;var i=t.split("#")[0],r=t.split("#")[1],n=document.body.querySelector('object[data="'+i+'"]');if(n){var o=n.contentDocument;if(o&&o.documentElement){var s=o.documentElement.getAttribute("viewBox"),a=Number(o.documentElement.getAttribute("width")),h=Number(o.documentElement.getAttribute("height"));if(o.getElementById(r)&&s&&a&&h)return this._getSVGAttribs(n,r),t}n.addEventListener("load",(function(){e._getSVGAttribs(n,r)}))}else{var l=document.createElement("object");l.data=i,l.type="image/svg+xml",l.width="0%",l.height="0%",document.body.appendChild(l),l.onload=function(){var t=document.body.querySelector('object[data="'+i+'"]');t&&e._getSVGAttribs(t,r)}}return i}return t},e.prototype._getSVGAttribs=function(t,e){var i=t.contentDocument;if(i&&i.documentElement){var r=i.documentElement.getAttribute("viewBox"),n=Number(i.documentElement.getAttribute("width")),o=Number(i.documentElement.getAttribute("height")),s=i.getElementById(e);if(r&&n&&o&&s){var a=Number(r.split(" ")[2]),h=Number(r.split(" ")[3]),l=s.getBBox(),u=1,c=1,_=0,d=0;s.transform&&s.transform.baseVal.consolidate()&&(u=s.transform.baseVal.consolidate().matrix.a,c=s.transform.baseVal.consolidate().matrix.d,_=s.transform.baseVal.consolidate().matrix.e,d=s.transform.baseVal.consolidate().matrix.f),this.sourceLeft=(u*l.x+_)*n/a,this.sourceTop=(c*l.y+d)*o/h,this.sourceWidth=l.width*u*(n/a),this.sourceHeight=l.height*c*(o/h),this._svgAttributesComputationCompleted=!0,this.onSVGAttributesComputedObservable.notifyObservers(this)}}},Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth!==t&&(this._cellWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight!==t&&(this._cellHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellId",{get:function(){return this._cellId},set:function(t){this._cellId!==t&&(this._cellId=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.contains=function(e,i){if(!t.prototype.contains.call(this,e,i))return!1;if(!this._detectPointerOnOpaqueOnly||!this._workingCanvas)return!0;var r=0|this._currentMeasure.width,n=0|this._currentMeasure.height,o=r+"_"+n,s=this._imageDataCache.data;if(!s||this._imageDataCache.key!==o){var a=this._workingCanvas.getContext("2d");this._imageDataCache.data=s=a.getImageData(0,0,r,n).data,this._imageDataCache.key=o}return s[4*((e=e-this._currentMeasure.left|0)+(i=i-this._currentMeasure.top|0)*r)+3]>0},e.prototype._getTypeName=function(){return"Image"},e.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},e.prototype._processMeasures=function(i,r){if(this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:case e.STRETCH_UNIFORM:case e.STRETCH_NINE_PATCH:break;case e.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0)}t.prototype._processMeasures.call(this,i,r)},e.prototype._prepareWorkingCanvasForOpaqueDetection=function(){if(this._detectPointerOnOpaqueOnly){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"));var t=this._workingCanvas,e=this._currentMeasure.width,i=this._currentMeasure.height,r=t.getContext("2d");t.width=e,t.height=i,r.clearRect(0,0,e,i)}},e.prototype._drawImage=function(t,e,i,r,n,o,s,a,h){(t.drawImage(this._domImage,e,i,r,n,o,s,a,h),this._detectPointerOnOpaqueOnly)&&(t=this._workingCanvas.getContext("2d")).drawImage(this._domImage,e,i,r,n,o-this._currentMeasure.left,s-this._currentMeasure.top,a,h)},e.prototype._draw=function(t){var i,r,n,o;if(t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),-1==this.cellId)i=this._sourceLeft,r=this._sourceTop,n=this._sourceWidth?this._sourceWidth:this._imageWidth,o=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var s=this._domImage.naturalWidth/this.cellWidth,a=this.cellId/s>>0,h=this.cellId%s;i=this.cellWidth*h,r=this.cellHeight*a,n=this.cellWidth,o=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(t),this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:this._drawImage(t,i,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_UNIFORM:var l=this._currentMeasure.width/n,u=this._currentMeasure.height/o,c=Math.min(l,u),_=(this._currentMeasure.width-n*c)/2,d=(this._currentMeasure.height-o*c)/2;this._drawImage(t,i,r,n,o,this._currentMeasure.left+_,this._currentMeasure.top+d,n*c,o*c);break;case e.STRETCH_EXTEND:this._drawImage(t,i,r,n,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_NINE_PATCH:this._renderNinePatch(t)}t.restore()},e.prototype._renderCornerPatch=function(t,e,i,r,n,o,s){this._drawImage(t,e,i,r,n,this._currentMeasure.left+o,this._currentMeasure.top+s,r,n)},e.prototype._renderNinePatch=function(t){var e=this._imageHeight,i=this._sliceLeft,r=this._sliceTop,n=this._imageHeight-this._sliceBottom,o=this._imageWidth-this._sliceRight,s=0,a=0;this._populateNinePatchSlicesFromImage&&(s=1,a=1,e-=2,i-=1,r-=1,n-=1,o-=1);var h=this._sliceRight-this._sliceLeft,l=this._currentMeasure.width-o-this.sliceLeft,u=this._currentMeasure.height-e+this._sliceBottom;this._renderCornerPatch(t,s,a,i,r,0,0),this._renderCornerPatch(t,s,this._sliceBottom,i,e-this._sliceBottom,0,u),this._renderCornerPatch(t,this._sliceRight,a,o,r,this._currentMeasure.width-o,0),this._renderCornerPatch(t,this._sliceRight,this._sliceBottom,o,e-this._sliceBottom,this._currentMeasure.width-o,u),this._drawImage(t,this._sliceLeft,this._sliceTop,h,this._sliceBottom-this._sliceTop,this._currentMeasure.left+i,this._currentMeasure.top+r,l,u-r),this._drawImage(t,s,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left,this._currentMeasure.top+r,i,u-r),this._drawImage(t,this._sliceRight,this._sliceTop,i,this._sliceBottom-this._sliceTop,this._currentMeasure.left+this._currentMeasure.width-o,this._currentMeasure.top+r,i,u-r),this._drawImage(t,this._sliceLeft,a,h,r,this._currentMeasure.left+i,this._currentMeasure.top,l,r),this._drawImage(t,this._sliceLeft,this._sliceBottom,h,n,this._currentMeasure.left+i,this._currentMeasure.top+u,l,n)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onImageLoadedObservable.clear(),this.onSVGAttributesComputedObservable.clear()},e.STRETCH_NONE=0,e.STRETCH_FILL=1,e.STRETCH_UNIFORM=2,e.STRETCH_EXTEND=3,e.STRETCH_NINE_PATCH=4,e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Image"]=v;var O=function(t){function e(e){var i=t.call(this,e)||this;i.name=e,i.delegatePickingToChildren=!1,i.thickness=1,i.isPointerBlocker=!0;var r=null;return i.pointerEnterAnimation=function(){r=i.alpha,i.alpha-=.1},i.pointerOutAnimation=function(){null!==r&&(i.alpha=r)},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return n(e,t),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textBlock",{get:function(){return this._textBlock},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Button"},e.prototype._processPicking=function(e,i,r,n,o,s,a,h){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable)return!1;if(!t.prototype.contains.call(this,e,i))return!1;if(this.delegatePickingToChildren){for(var l=!1,u=this._children.length-1;u>=0;u--){var c=this._children[u];if(c.isEnabled&&c.isHitTestVisible&&c.isVisible&&!c.notRenderable&&c.contains(e,i)){l=!0;break}}if(!l)return!1}return this._processObservables(n,e,i,r,o,s,a,h),!0},e.prototype._onPointerEnter=function(e,i){return!!t.prototype._onPointerEnter.call(this,e,i)&&(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},e.prototype._onPointerOut=function(e,i,r){void 0===r&&(r=!1),this.pointerOutAnimation&&this.pointerOutAnimation(),t.prototype._onPointerOut.call(this,e,i,r)},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},e.prototype._onPointerUp=function(e,i,r,n,o,s){this.pointerUpAnimation&&this.pointerUpAnimation(),t.prototype._onPointerUp.call(this,e,i,r,n,o,s)},e.CreateImageButton=function(t,i,r){var n=new e(t),o=new y(t+"_button",i);o.textWrapping=!0,o.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,o.paddingLeft="20%",n.addControl(o);var s=new v(t+"_icon",r);return s.width="20%",s.stretch=v.STRETCH_UNIFORM,s.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.addControl(s),n._image=s,n._textBlock=o,n},e.CreateImageOnlyButton=function(t,i){var r=new e(t),n=new v(t+"_icon",i);return n.stretch=v.STRETCH_FILL,n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r.addControl(n),r._image=n,r},e.CreateSimpleButton=function(t,i){var r=new e(t),n=new y(t+"_button",i);return n.textWrapping=!0,n.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,r.addControl(n),r._textBlock=n,r},e.CreateImageWithCenterTextButton=function(t,i,r){var n=new e(t),o=new v(t+"_icon",r);o.stretch=v.STRETCH_FILL,n.addControl(o);var s=new y(t+"_button",i);return s.textWrapping=!0,s.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,n.addControl(s),n._image=o,n._textBlock=s,n},e}(b);s._TypeStore.RegisteredTypes["BABYLON.GUI.Button"]=O;var C=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isVertical=!0,i._manualWidth=!1,i._manualHeight=!1,i._doNotTrackManualChanges=!1,i.ignoreLayoutWarnings=!1,i}return n(e,t),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"StackPanel"},e.prototype._preMeasure=function(e,i){for(var r=0,n=this._children;r<n.length;r++){var o=n[r];this._isVertical?o.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP:o.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT}t.prototype._preMeasure.call(this,e,i)},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(e),this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this.isVertical&&!this._manualWidth||(this._measureForChildren.width=this._currentMeasure.width),(this.isVertical||this._manualHeight)&&(this._measureForChildren.height=this._currentMeasure.height)},e.prototype._postMeasure=function(){for(var e=0,i=0,r=0,n=this._children;r<n.length;r++){var o=n[r];o.isVisible&&!o.notRenderable&&(this._isVertical?(o.top!==i+"px"&&(o.top=i+"px",this._rebuildLayout=!0,o._top.ignoreAdaptiveScaling=!0),o._height.isPercentage&&!o._automaticSize?this.ignoreLayoutWarnings||s.Tools.Warn("Control (Name:"+o.name+", UniqueId:"+o.uniqueId+") is using height in percentage mode inside a vertical StackPanel"):i+=o._currentMeasure.height+o.paddingTopInPixels+o.paddingBottomInPixels):(o.left!==e+"px"&&(o.left=e+"px",this._rebuildLayout=!0,o._left.ignoreAdaptiveScaling=!0),o._width.isPercentage&&!o._automaticSize?this.ignoreLayoutWarnings||s.Tools.Warn("Control (Name:"+o.name+", UniqueId:"+o.uniqueId+") is using width in percentage mode inside a horizontal StackPanel"):e+=o._currentMeasure.width+o.paddingLeftInPixels+o.paddingRightInPixels))}e+=this.paddingLeftInPixels+this.paddingRightInPixels,i+=this.paddingTopInPixels+this.paddingBottomInPixels,this._doNotTrackManualChanges=!0;var a=!1,h=!1;if(!this._manualHeight&&this._isVertical){var l=this.height;this.height=i+"px",h=l!==this.height||!this._height.ignoreAdaptiveScaling}if(!this._manualWidth&&!this._isVertical){var u=this.width;this.width=e+"px",a=u!==this.width||!this._width.ignoreAdaptiveScaling}h&&(this._height.ignoreAdaptiveScaling=!0),a&&(this._width.ignoreAdaptiveScaling=!0),this._doNotTrackManualChanges=!1,(a||h)&&(this._rebuildLayout=!0),t.prototype._postMeasure.call(this)},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.StackPanel"]=C;var T=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.onIsCheckedChangedObservable=new s.Observable,i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){return this._isChecked},set:function(t){this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Checkbox"},e.prototype._draw=function(t,e){t.save(),this._applyStates(t);var i=this._currentMeasure.width-this._thickness,r=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fillRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._isChecked){t.fillStyle=this._isEnabled?this.color:this._disabledColorItem;var n=i*this._checkSizeRatio,o=r*this._checkSizeRatio;t.fillRect(this._currentMeasure.left+this._thickness/2+(i-n)/2,this._currentMeasure.top+this._thickness/2+(r-o)/2,n,o)}t.strokeStyle=this.color,t.lineWidth=this._thickness,t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r),t.restore()},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this.isChecked=!this.isChecked,!0)},e.AddCheckBoxWithHeader=function(t,i){var r=new C;r.isVertical=!1,r.height="30px";var n=new e;n.width="20px",n.height="20px",n.isChecked=!0,n.color="green",n.onIsCheckedChangedObservable.add(i),r.addControl(n);var o=new y;return o.text=t,o.width="180px",o.paddingLeft="5px",o.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,o.color="white",r.addControl(o),r},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Checkbox"]=T;var w=function(){function t(){}return Object.defineProperty(t.prototype,"text",{get:function(){return this._characters?this._characters.join(""):this._text},set:function(t){this._text=t,this._characters=Array.from&&Array.from(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._characters?this._characters.length:this._text.length},enumerable:!1,configurable:!0}),t.prototype.removePart=function(t,e,i){var r;if(this._text=this._text.slice(0,t)+(i||"")+this._text.slice(e),this._characters){var n=i?Array.from(i):[];(r=this._characters).splice.apply(r,function(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var r=Array(t),n=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,n++)r[n]=o[s];return r}([t,e-t],n))}},t.prototype.charAt=function(t){return this._characters?this._characters[t]:this._text.charAt(t)},t.prototype.substr=function(t,e){if(this._characters){t=isNaN(t)?0:t>=0?Math.min(t,this._characters.length):this._characters.length+Math.max(t,-this._characters.length),void 0===e?e=this._characters.length-t:(isNaN(e)||e<0)&&(e=0);for(var i=[];--e>=0;)i[e]=this._characters[t+e];return i.join("")}return this._text.substr(t,e)},t.prototype.substring=function(t,e){if(this._characters){isNaN(t)?t=0:t>this._characters.length?t=this._characters.length:t<0&&(t=0),void 0===e?e=this._characters.length:isNaN(e)?e=0:e>this._characters.length?e=this._characters.length:e<0&&(e=0);for(var i=[],r=0;t<e;)i[r++]=this._characters[t++];return i.join("")}return this._text.substring(t,e)},t.prototype.isWord=function(t){var e=/\w/g;return this._characters?-1!==this._characters[t].search(e):-1!==this._text.search(e)},t}(),x=function(t){function e(e,i){void 0===i&&(i="");var r=t.call(this,e)||this;return r.name=e,r._placeholderText="",r._background="#222222",r._focusedBackground="#000000",r._focusedColor="white",r._placeholderColor="gray",r._thickness=1,r._margin=new a(10,a.UNITMODE_PIXEL),r._autoStretchWidth=!0,r._maxWidth=new a(1,a.UNITMODE_PERCENTAGE,!1),r._isFocused=!1,r._blinkIsEven=!1,r._cursorOffset=0,r._deadKey=!1,r._addKey=!0,r._currentKey="",r._isTextHighlightOn=!1,r._textHighlightColor="#d5e0ff",r._highligherOpacity=.4,r._highlightedText="",r._startHighlightIndex=0,r._endHighlightIndex=0,r._cursorIndex=-1,r._onFocusSelectAll=!1,r._isPointerDown=!1,r.promptMessage="Please enter text:",r.disableMobilePrompt=!1,r.onTextChangedObservable=new s.Observable,r.onBeforeKeyAddObservable=new s.Observable,r.onFocusObservable=new s.Observable,r.onBlurObservable=new s.Observable,r.onTextHighlightObservable=new s.Observable,r.onTextCopyObservable=new s.Observable,r.onTextCutObservable=new s.Observable,r.onTextPasteObservable=new s.Observable,r.onKeyboardEventProcessedObservable=new s.Observable,r.text=i,r.isPointerBlocker=!0,r}return n(e,t),Object.defineProperty(e.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(t){this._maxWidth.toString(this._host)!==t&&this._maxWidth.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxWidthInPixels",{get:function(){return this._maxWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highligherOpacity",{get:function(){return this._highligherOpacity},set:function(t){this._highligherOpacity!==t&&(this._highligherOpacity=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onFocusSelectAll",{get:function(){return this._onFocusSelectAll},set:function(t){this._onFocusSelectAll!==t&&(this._onFocusSelectAll=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textHighlightColor",{get:function(){return this._textHighlightColor},set:function(t){this._textHighlightColor!==t&&(this._textHighlightColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(t){this._margin.toString(this._host)!==t&&this._margin.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"marginInPixels",{get:function(){return this._margin.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(t){this._autoStretchWidth!==t&&(this._autoStretchWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"focusedBackground",{get:function(){return this._focusedBackground},set:function(t){this._focusedBackground!==t&&(this._focusedBackground=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"focusedColor",{get:function(){return this._focusedColor},set:function(t){this._focusedColor!==t&&(this._focusedColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"placeholderColor",{get:function(){return this._placeholderColor},set:function(t){this._placeholderColor!==t&&(this._placeholderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"placeholderText",{get:function(){return this._placeholderText},set:function(t){this._placeholderText!==t&&(this._placeholderText=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deadKey",{get:function(){return this._deadKey},set:function(t){this._deadKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedText",{get:function(){return this._highlightedText},set:function(t){this._highlightedText!==t&&(this._highlightedText=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"addKey",{get:function(){return this._addKey},set:function(t){this._addKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentKey",{get:function(){return this._currentKey},set:function(t){this._currentKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._textWrapper.text},set:function(t){var e=t.toString();this._textWrapper||(this._textWrapper=new w),this._textWrapper.text!==e&&(this._textWrapper.text=e,this._textHasChanged())},enumerable:!1,configurable:!0}),e.prototype._textHasChanged=function(){this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this)},Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._width.toString(this._host)!==t&&(this._width.fromString(t)&&this._markAsDirty(),this.autoStretchWidth=!1)},enumerable:!1,configurable:!0}),e.prototype.onBlur=function(){this._isFocused=!1,this._scrollLeft=null,this._cursorOffset=0,clearTimeout(this._blinkTimeout),this._markAsDirty(),this.onBlurObservable.notifyObservers(this),this._host.unRegisterClipboardEvents(),this._onClipboardObserver&&this._host.onClipboardObservable.remove(this._onClipboardObserver);var t=this._host.getScene();this._onPointerDblTapObserver&&t&&t.onPointerObservable.remove(this._onPointerDblTapObserver)},e.prototype.onFocus=function(){var t=this;if(this._isEnabled){if(this._scrollLeft=null,this._isFocused=!0,this._blinkIsEven=!1,this._cursorOffset=0,this._markAsDirty(),this.onFocusObservable.notifyObservers(this),-1!==navigator.userAgent.indexOf("Mobile")&&!this.disableMobilePrompt){var e=prompt(this.promptMessage);return null!==e&&(this.text=e),void(this._host.focusedControl=null)}this._host.registerClipboardEvents(),this._onClipboardObserver=this._host.onClipboardObservable.add((function(e){switch(e.type){case s.ClipboardEventTypes.COPY:t._onCopyText(e.event),t.onTextCopyObservable.notifyObservers(t);break;case s.ClipboardEventTypes.CUT:t._onCutText(e.event),t.onTextCutObservable.notifyObservers(t);break;case s.ClipboardEventTypes.PASTE:t._onPasteText(e.event),t.onTextPasteObservable.notifyObservers(t);break;default:return}}));var i=this._host.getScene();i&&(this._onPointerDblTapObserver=i.onPointerObservable.add((function(e){t._isFocused&&e.type===s.PointerEventTypes.POINTERDOUBLETAP&&t._processDblClick(e)}))),this._onFocusSelectAll&&this._selectAllText()}},e.prototype._getTypeName=function(){return"InputText"},e.prototype.keepsFocusWith=function(){return this._connectedVirtualKeyboard?[this._connectedVirtualKeyboard]:null},e.prototype.processKey=function(t,e,i){if(!i||!i.ctrlKey&&!i.metaKey||67!==t&&86!==t&&88!==t){if(i&&(i.ctrlKey||i.metaKey)&&65===t)return this._selectAllText(),void i.preventDefault();switch(t){case 32:e=" ";break;case 191:i&&i.preventDefault();break;case 8:if(this._textWrapper.text&&this._textWrapper.length>0){if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._blinkIsEven=!1,void(i&&i.preventDefault());if(0===this._cursorOffset)this.text=this._textWrapper.substr(0,this._textWrapper.length-1);else(r=this._textWrapper.length-this._cursorOffset)>0&&(this._textWrapper.removePart(r-1,r),this._textHasChanged())}return void(i&&i.preventDefault());case 46:if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,void(i&&i.preventDefault());if(this._textWrapper.text&&this._textWrapper.length>0&&this._cursorOffset>0){var r=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(r,r+1),this._textHasChanged(),this._cursorOffset--}return void(i&&i.preventDefault());case 13:return this._host.focusedControl=null,void(this._isTextHighlightOn=!1);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._textWrapper.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 37:if(this._cursorOffset++,this._cursorOffset>this._textWrapper.length&&(this._cursorOffset=this._textWrapper.length),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(this._textWrapper.length===this._cursorOffset)return;this._endHighlightIndex=this._textWrapper.length-this._cursorOffset+1}return this._startHighlightIndex=0,this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._textWrapper.length,this._isTextHighlightOn=!0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=0===this._startHighlightIndex?this._textWrapper.length:this._textWrapper.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._textWrapper.length?this._textWrapper.length:this._cursorOffset-1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=this._textWrapper.length,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(0===this._cursorOffset)return;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset-1}return this._endHighlightIndex=this._textWrapper.length,this._isTextHighlightOn=!0,this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=this._textWrapper.length===this._endHighlightIndex?0:this._textWrapper.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._endHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=0,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 222:i&&i.preventDefault(),this._cursorIndex=-1,this.deadKey=!0}if(e&&(-1===t||32===t||t>47&&t<64||t>64&&t<91||t>159&&t<193||t>218&&t<223||t>95&&t<112)&&(this._currentKey=e,this.onBeforeKeyAddObservable.notifyObservers(this),e=this._currentKey,this._addKey))if(this._isTextHighlightOn)this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex,e),this._textHasChanged(),this._cursorOffset=this._textWrapper.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(0===this._cursorOffset)this.text+=e;else{var n=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(n,n,e),this._textHasChanged()}}},e.prototype._updateValueFromCursorIndex=function(t){if(this._blinkIsEven=!1,-1===this._cursorIndex)this._cursorIndex=t;else if(this._cursorIndex<this._cursorOffset)this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset;else{if(!(this._cursorIndex>this._cursorOffset))return this._isTextHighlightOn=!1,void this._markAsDirty();this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex}this._isTextHighlightOn=!0,this._markAsDirty()},e.prototype._processDblClick=function(t){var e,i;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;do{i=this._endHighlightIndex<this._textWrapper.length&&this._textWrapper.isWord(this._endHighlightIndex)?++this._endHighlightIndex:0,e=this._startHighlightIndex>0&&this._textWrapper.isWord(this._startHighlightIndex-1)?--this._startHighlightIndex:0}while(e||i);this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},e.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._textWrapper.length,this._cursorOffset=this._textWrapper.length,this._cursorIndex=-1,this._markAsDirty()},e.prototype.processKeyboard=function(t){this.processKey(t.keyCode,t.key,t),this.onKeyboardEventProcessedObservable.notifyObservers(t)},e.prototype._onCopyText=function(t){this._isTextHighlightOn=!1;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText},e.prototype._onCutText=function(t){if(this._highlightedText){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},e.prototype._onPasteText=function(t){var e="";e=t.clipboardData&&-1!==t.clipboardData.types.indexOf("text/plain")?t.clipboardData.getData("text/plain"):this._host.clipboardData;var i=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(i,i,e),this._textHasChanged()},e.prototype._draw=function(t,e){var i=this;t.save(),this._applyStates(t),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(t.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._fontOffset||(this._fontOffset=f._GetFontOffset(t.font));var r=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(t.fillStyle=this.color);var n=this._beforeRenderText(this._textWrapper);this._isFocused||this._textWrapper.text||!this._placeholderText||((n=new w).text=this._placeholderText,this._placeholderColor&&(t.fillStyle=this._placeholderColor)),this._textWidth=t.measureText(n.text).width;var o=2*this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+o)+"px");var s=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,a=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-o;if(t.save(),t.beginPath(),t.rect(r,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,a+2,this._currentMeasure.height),t.clip(),this._isFocused&&this._textWidth>a){var h=r-this._textWidth+a;this._scrollLeft||(this._scrollLeft=h)}else this._scrollLeft=r;if(t.fillText(n.text,this._scrollLeft,this._currentMeasure.top+s),this._isFocused){if(this._clickedCoordinate){var l=this._scrollLeft+this._textWidth-this._clickedCoordinate,u=0;this._cursorOffset=0;var c=0;do{this._cursorOffset&&(c=Math.abs(l-u)),this._cursorOffset++,u=t.measureText(n.substr(n.length-this._cursorOffset,this._cursorOffset)).width}while(u<l&&n.length>=this._cursorOffset);Math.abs(l-u)>c&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var _=n.substr(n.length-this._cursorOffset),d=t.measureText(_).width,p=this._scrollLeft+this._textWidth-d;p<r?(this._scrollLeft+=r-p,p=r,this._markAsDirty()):p>r+a&&(this._scrollLeft+=r+a-p,p=r+a,this._markAsDirty()),this._isTextHighlightOn||t.fillRect(p,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){i._blinkIsEven=!i._blinkIsEven,i._markAsDirty()}),500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var g=t.measureText(n.substring(this._startHighlightIndex)).width,m=this._scrollLeft+this._textWidth-g;this._highlightedText=n.substring(this._startHighlightIndex,this._endHighlightIndex);var b=t.measureText(n.substring(this._startHighlightIndex,this._endHighlightIndex)).width;m<r&&((b-=r-m)||(b=t.measureText(n.charAt(n.length-this._cursorOffset)).width),m=r),t.globalAlpha=this._highligherOpacity,t.fillStyle=this._textHighlightColor,t.fillRect(m,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,b,this._fontOffset.height),t.globalAlpha=1}}t.restore(),this._thickness&&(this._isFocused?this.focusedColor&&(t.strokeStyle=this.focusedColor):this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),t.restore()},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this._clickedCoordinate=i.x,this._isTextHighlightOn=!1,this._highlightedText="",this._cursorIndex=-1,this._isPointerDown=!0,this._host._capturingControl[r]=this,this._host.focusedControl===this?(clearTimeout(this._blinkTimeout),this._markAsDirty(),!0):!!this._isEnabled&&(this._host.focusedControl=this,!0))},e.prototype._onPointerMove=function(e,i,r,n){this._host.focusedControl===this&&this._isPointerDown&&(this._clickedCoordinate=i.x,this._markAsDirty(),this._updateValueFromCursorIndex(this._cursorOffset)),t.prototype._onPointerMove.call(this,e,i,r,n)},e.prototype._onPointerUp=function(e,i,r,n,o){this._isPointerDown=!1,delete this._host._capturingControl[r],t.prototype._onPointerUp.call(this,e,i,r,n,o)},e.prototype._beforeRenderText=function(t){return t},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onTextChangedObservable.clear(),this.onTextCopyObservable.clear(),this.onTextCutObservable.clear(),this.onTextPasteObservable.clear(),this.onTextHighlightObservable.clear(),this.onKeyboardEventProcessedObservable.clear()},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.InputText"]=x;var P=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._rowDefinitions=new Array,i._columnDefinitions=new Array,i._cells={},i._childControls=new Array,i}return n(e,t),Object.defineProperty(e.prototype,"columnCount",{get:function(){return this._columnDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rowCount",{get:function(){return this._rowDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._childControls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cells",{get:function(){return this._cells},enumerable:!1,configurable:!0}),e.prototype.getRowDefinition=function(t){return t<0||t>=this._rowDefinitions.length?null:this._rowDefinitions[t]},e.prototype.getColumnDefinition=function(t){return t<0||t>=this._columnDefinitions.length?null:this._columnDefinitions[t]},e.prototype.addRowDefinition=function(t,e){return void 0===e&&(e=!1),this._rowDefinitions.push(new a(t,e?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},e.prototype.addColumnDefinition=function(t,e){return void 0===e&&(e=!1),this._columnDefinitions.push(new a(t,e?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},e.prototype.setRowDefinition=function(t,e,i){if(void 0===i&&(i=!1),t<0||t>=this._rowDefinitions.length)return this;var r=this._rowDefinitions[t];return r&&r.isPixel===i&&r.internalValue===e||(this._rowDefinitions[t]=new a(e,i?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE),this._markAsDirty()),this},e.prototype.setColumnDefinition=function(t,e,i){if(void 0===i&&(i=!1),t<0||t>=this._columnDefinitions.length)return this;var r=this._columnDefinitions[t];return r&&r.isPixel===i&&r.internalValue===e||(this._columnDefinitions[t]=new a(e,i?a.UNITMODE_PIXEL:a.UNITMODE_PERCENTAGE),this._markAsDirty()),this},e.prototype.getChildrenAt=function(t,e){var i=this._cells[t+":"+e];return i?i.children:null},e.prototype.getChildCellInfo=function(t){return t._tag},e.prototype._removeCell=function(e,i){if(e){t.prototype.removeControl.call(this,e);for(var r=0,n=e.children;r<n.length;r++){var o=n[r],s=this._childControls.indexOf(o);-1!==s&&this._childControls.splice(s,1)}delete this._cells[i]}},e.prototype._offsetCell=function(t,e){if(this._cells[e]){this._cells[t]=this._cells[e];for(var i=0,r=this._cells[t].children;i<r.length;i++){r[i]._tag=t}delete this._cells[e]}},e.prototype.removeColumnDefinition=function(t){if(t<0||t>=this._columnDefinitions.length)return this;for(var e=0;e<this._rowDefinitions.length;e++){var i=e+":"+t,r=this._cells[i];this._removeCell(r,i)}for(e=0;e<this._rowDefinitions.length;e++)for(var n=t+1;n<this._columnDefinitions.length;n++){var o=e+":"+(n-1);i=e+":"+n;this._offsetCell(o,i)}return this._columnDefinitions.splice(t,1),this._markAsDirty(),this},e.prototype.removeRowDefinition=function(t){if(t<0||t>=this._rowDefinitions.length)return this;for(var e=0;e<this._columnDefinitions.length;e++){var i=t+":"+e,r=this._cells[i];this._removeCell(r,i)}for(e=0;e<this._columnDefinitions.length;e++)for(var n=t+1;n<this._rowDefinitions.length;n++){var o=n-1+":"+e;i=n+":"+e;this._offsetCell(o,i)}return this._rowDefinitions.splice(t,1),this._markAsDirty(),this},e.prototype.addControl=function(e,i,r){if(void 0===i&&(i=0),void 0===r&&(r=0),0===this._rowDefinitions.length&&this.addRowDefinition(1,!1),0===this._columnDefinitions.length&&this.addColumnDefinition(1,!1),-1!==this._childControls.indexOf(e))return s.Tools.Warn("Control (Name:"+e.name+", UniqueId:"+e.uniqueId+") is already associated with this grid. You must remove it before reattaching it"),this;var n=Math.min(i,this._rowDefinitions.length-1)+":"+Math.min(r,this._columnDefinitions.length-1),o=this._cells[n];return o||(o=new g(n),this._cells[n]=o,o.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,o.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,t.prototype.addControl.call(this,o)),o.addControl(e),this._childControls.push(e),e._tag=n,e.parent=this,this._markAsDirty(),this},e.prototype.removeControl=function(t){var e=this._childControls.indexOf(t);-1!==e&&this._childControls.splice(e,1);var i=this._cells[t._tag];return i&&(i.removeControl(t),t._tag=null),this._markAsDirty(),this},e.prototype._getTypeName=function(){return"Grid"},e.prototype._getGridDefinitions=function(t){for(var e=[],i=[],r=[],n=[],o=this._currentMeasure.width,s=0,a=this._currentMeasure.height,h=0,l=0,u=0,c=this._rowDefinitions;u<c.length;u++){if((g=c[u]).isPixel)a-=f=g.getValue(this._host),i[l]=f;else h+=g.internalValue;l++}var _=0;l=0;for(var d=0,p=this._rowDefinitions;d<p.length;d++){var f,g=p[d];if(n.push(_),g.isPixel)_+=g.getValue(this._host);else _+=f=g.internalValue/h*a,i[l]=f;l++}l=0;for(var m=0,b=this._columnDefinitions;m<b.length;m++){if((g=b[m]).isPixel)o-=C=g.getValue(this._host),e[l]=C;else s+=g.internalValue;l++}var y=0;l=0;for(var v=0,O=this._columnDefinitions;v<O.length;v++){var C;g=O[v];if(r.push(y),g.isPixel)y+=g.getValue(this._host);else y+=C=g.internalValue/s*o,e[l]=C;l++}t(r,n,e,i)},e.prototype._additionalProcessing=function(e,i){var r=this;this._getGridDefinitions((function(t,e,i,n){for(var o in r._cells)if(r._cells.hasOwnProperty(o)){var s=o.split(":"),a=parseInt(s[0]),h=parseInt(s[1]),l=r._cells[o];l.left=t[h]+"px",l.top=e[a]+"px",l.width=i[h]+"px",l.height=n[a]+"px",l._left.ignoreAdaptiveScaling=!0,l._top.ignoreAdaptiveScaling=!0,l._width.ignoreAdaptiveScaling=!0,l._height.ignoreAdaptiveScaling=!0}})),t.prototype._additionalProcessing.call(this,e,i)},e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t in this._cells){if(this._cells.hasOwnProperty(t))this._cells[t]._markMatrixAsDirty()}},e.prototype._renderHighlightSpecific=function(e){var i=this;t.prototype._renderHighlightSpecific.call(this,e),this._getGridDefinitions((function(t,r,n,o){for(var s=0;s<t.length;s++){var a=i._currentMeasure.left+t[s]+n[s];e.beginPath(),e.moveTo(a,i._currentMeasure.top),e.lineTo(a,i._currentMeasure.top+i._currentMeasure.height),e.stroke()}for(s=0;s<r.length;s++){var h=i._currentMeasure.top+r[s]+o[s];e.beginPath(),e.moveTo(i._currentMeasure.left,h),e.lineTo(i._currentMeasure.left+i._currentMeasure.width,h),e.stroke()}})),e.restore()},e.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=0,i=this._childControls;e<i.length;e++){i[e].dispose()}this._childControls=[]},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.Grid"]=P;var M=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._value=s.Color3.Red(),i._tmpColor=new s.Color3,i._pointerStartedOnSquare=!1,i._pointerStartedOnWheel=!1,i._squareLeft=0,i._squareTop=0,i._squareSize=0,i._h=360,i._s=1,i._v=1,i._lastPointerDownID=-1,i.onValueChangedObservable=new s.Observable,i._pointerIsDown=!1,i.value=new s.Color3(.88,.1,.1),i.size="200px",i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){this._value.equals(t)||(this._value.copyFrom(t),this._value.toHSVToRef(this._tmpColor),this._h=this._tmpColor.r,this._s=Math.max(this._tmpColor.g,1e-5),this._v=Math.max(this._tmpColor.b,1e-5),this._markAsDirty(),this._value.r<=e._Epsilon&&(this._value.r=0),this._value.g<=e._Epsilon&&(this._value.g=0),this._value.b<=e._Epsilon&&(this._value.b=0),this._value.r>=1-e._Epsilon&&(this._value.r=1),this._value.g>=1-e._Epsilon&&(this._value.g=1),this._value.b>=1-e._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._width.toString(this._host)!==t&&this._width.fromString(t)&&(this._height.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._height.toString(this._host)!==t&&this._height.fromString(t)&&(this._width.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(t){this.width=t},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ColorPicker"},e.prototype._preMeasure=function(t,e){t.width<t.height?this._currentMeasure.height=t.width:this._currentMeasure.width=t.height},e.prototype._updateSquareProps=function(){var t=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),e=2*(t-.2*t)/Math.sqrt(2),i=t-.5*e;this._squareLeft=this._currentMeasure.left+i,this._squareTop=this._currentMeasure.top+i,this._squareSize=e},e.prototype._drawGradientSquare=function(t,e,i,r,n,o){var s=o.createLinearGradient(e,i,r+e,i);s.addColorStop(0,"#fff"),s.addColorStop(1,"hsl("+t+", 100%, 50%)"),o.fillStyle=s,o.fillRect(e,i,r,n);var a=o.createLinearGradient(e,i,e,n+i);a.addColorStop(0,"rgba(0,0,0,0)"),a.addColorStop(1,"#000"),o.fillStyle=a,o.fillRect(e,i,r,n)},e.prototype._drawCircle=function(t,e,i,r){r.beginPath(),r.arc(t,e,i+1,0,2*Math.PI,!1),r.lineWidth=3,r.strokeStyle="#333333",r.stroke(),r.beginPath(),r.arc(t,e,i,0,2*Math.PI,!1),r.lineWidth=3,r.strokeStyle="#ffffff",r.stroke()},e.prototype._createColorWheelCanvas=function(t,e){var i=document.createElement("canvas");i.width=2*t,i.height=2*t;for(var r=i.getContext("2d"),n=r.getImageData(0,0,2*t,2*t),o=n.data,a=this._tmpColor,h=t*t,l=t-e,u=l*l,c=-t;c<t;c++)for(var _=-t;_<t;_++){var d=c*c+_*_;if(!(d>h||d<u)){var p=Math.sqrt(d),f=Math.atan2(_,c);s.Color3.HSVtoRGBToRef(180*f/Math.PI+180,p/t,1,a);var g=4*(c+t+2*(_+t)*t);o[g]=255*a.r,o[g+1]=255*a.g,o[g+2]=255*a.b;var m=.2;m=t<50?.2:t>150?.04:-.16*(t-50)/100+.2;var b=(p-l)/(t-l);o[g+3]=b<m?b/m*255:b>1-m?255*(1-(b-(1-m))/m):255}}return r.putImageData(n,0,0),i},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=.2*e,r=this._currentMeasure.left,n=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*e||(this._colorWheelCanvas=this._createColorWheelCanvas(e,i)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),t.drawImage(this._colorWheelCanvas,r,n),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,t);var o=this._squareLeft+this._squareSize*this._s,s=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(o,s,.04*e,t);var a=e-.5*i;o=r+e+Math.cos((this._h-180)*Math.PI/180)*a,s=n+e+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(o,s,.35*i,t),t.restore()},e.prototype._updateValueFromPointer=function(t,i){if(this._pointerStartedOnWheel){var r=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),n=r+this._currentMeasure.left,o=r+this._currentMeasure.top;this._h=180*Math.atan2(i-o,t-n)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(i-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,e._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,e._Epsilon));s.Color3.HSVtoRGBToRef(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},e.prototype._isPointOnSquare=function(t,e){this._updateSquareProps();var i=this._squareLeft,r=this._squareTop,n=this._squareSize;return t>=i&&t<=i+n&&e>=r&&e<=r+n},e.prototype._isPointOnWheel=function(t,e){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i-.2*i,n=t-(i+this._currentMeasure.left),o=e-(i+this._currentMeasure.top),s=n*n+o*o;return s<=i*i&&s>=r*r},e.prototype._onPointerDown=function(e,i,r,n,o){if(!t.prototype._onPointerDown.call(this,e,i,r,n,o))return!1;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var s=this._transformedPosition.x,a=this._transformedPosition.y;return this._isPointOnSquare(s,a)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(s,a)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(s,a),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0},e.prototype._onPointerMove=function(e,i,r,n){if(r==this._lastPointerDownID){this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var o=this._transformedPosition.x,s=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(o,s),t.prototype._onPointerMove.call(this,e,i,r,n)}},e.prototype._onPointerUp=function(e,i,r,n,o,s){this._pointerIsDown=!1,delete this._host._capturingControl[r],t.prototype._onPointerUp.call(this,e,i,r,n,o,s)},e.prototype._onCanvasBlur=function(){this._forcePointerUp(),t.prototype._onCanvasBlur.call(this)},e.ShowPickerDialogAsync=function(t,i){return new Promise((function(r,n){i.pickerWidth=i.pickerWidth||"640px",i.pickerHeight=i.pickerHeight||"400px",i.headerHeight=i.headerHeight||"35px",i.lastColor=i.lastColor||"#000000",i.swatchLimit=i.swatchLimit||20,i.numSwatchesPerLine=i.numSwatchesPerLine||10;var o,a,h,l,u,c,_,d,p,g,m,v,C,T,w,M,I,k,A,S=i.swatchLimit/i.numSwatchesPerLine,E=parseFloat(i.pickerWidth)/i.numSwatchesPerLine,D=Math.floor(.25*E),L=D*(i.numSwatchesPerLine+1),R=Math.floor((parseFloat(i.pickerWidth)-L)/i.numSwatchesPerLine),B=R*S+D*(S+1),N=(parseInt(i.pickerHeight)+B+Math.floor(.25*R)).toString()+"px",H=s.Color3.FromHexString("#dddddd"),V=H.r+H.g+H.b,W=["R","G","B"],F=!1;function j(t,e){A=e;var i=t.toHexString();if(I.background=i,g.name!=A&&(g.text=Math.floor(255*t.r).toString()),m.name!=A&&(m.text=Math.floor(255*t.g).toString()),v.name!=A&&(v.text=Math.floor(255*t.b).toString()),C.name!=A&&(C.text=t.r.toString()),T.name!=A&&(T.text=t.g.toString()),w.name!=A&&(w.text=t.b.toString()),M.name!=A){var r=i.split("#");M.text=r[1]}p.name!=A&&(p.value=t)}function z(t,e){var i=t.text;if(/[^0-9]/g.test(i))t.text=k;else if(""!=i&&(Math.floor(parseInt(i))<0?i="0":Math.floor(parseInt(i))>255?i="255":isNaN(parseInt(i))&&(i="0")),A==t.name&&(k=i),""!=i){i=parseInt(i).toString(),t.text=i;var r=s.Color3.FromHexString(I.background);A==t.name&&j("r"==e?new s.Color3(parseInt(i)/255,r.g,r.b):"g"==e?new s.Color3(r.r,parseInt(i)/255,r.b):new s.Color3(r.r,r.g,parseInt(i)/255),t.name)}}function G(t,e){var i=t.text;if(/[^0-9\.]/g.test(i))t.text=k;else{""!=i&&"."!=i&&0!=parseFloat(i)&&(parseFloat(i)<0?i="0.0":parseFloat(i)>1?i="1.0":isNaN(parseFloat(i))&&(i="0.0")),A==t.name&&(k=i),""!=i&&"."!=i&&0!=parseFloat(i)?(i=parseFloat(i).toString(),t.text=i):i="0.0";var r=s.Color3.FromHexString(I.background);A==t.name&&j("r"==e?new s.Color3(parseFloat(i),r.g,r.b):"g"==e?new s.Color3(r.r,parseFloat(i),r.b):new s.Color3(r.r,r.g,parseFloat(i)),t.name)}}function X(){if(i.savedColors&&i.savedColors[_]){if(F)var t="b";else t="";var e=O.CreateSimpleButton("Swatch_"+_,t);e.fontFamily="BabylonJSglyphs";var r=s.Color3.FromHexString(i.savedColors[_]),n=r.r+r.g+r.b;e.color=n>V?"#aaaaaa":"#ffffff",e.fontSize=Math.floor(.7*R),e.textBlock.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,e.height=e.width=R.toString()+"px",e.background=i.savedColors[_],e.thickness=2;var o=_;return e.pointerDownAnimation=function(){e.thickness=4},e.pointerUpAnimation=function(){e.thickness=3},e.pointerEnterAnimation=function(){e.thickness=3},e.pointerOutAnimation=function(){e.thickness=2},e.onPointerClickObservable.add((function(){var t;F?(t=o,i.savedColors&&i.savedColors.splice(t,1),i.savedColors&&0==i.savedColors.length&&(q(!1),F=!1),Y("",It)):i.savedColors&&j(s.Color3.FromHexString(i.savedColors[o]),e.name)})),e}return null}function U(t){if(void 0!==t&&(F=t),F){for(var e=0;e<d.children.length;e++){d.children[e].textBlock.text="b"}void 0!==h&&(h.textBlock.text="Done")}else{for(e=0;e<d.children.length;e++){d.children[e].textBlock.text=""}void 0!==h&&(h.textBlock.text="Edit")}}function Y(t,e){if(i.savedColors){""!=t&&i.savedColors.push(t),_=0,d.clearControls();var r=Math.ceil(i.savedColors.length/i.numSwatchesPerLine);if(0==r)var n=0;else n=r+1;if(d.rowCount!=r+n){for(var o=d.rowCount,s=0;s<o;s++)d.removeRowDefinition(0);for(s=0;s<r+n;s++)s%2?d.addRowDefinition(R,!0):d.addRowDefinition(D,!0)}d.height=(R*r+n*D).toString()+"px";for(var a=1,h=1;a<r+n;a+=2,h++){if(i.savedColors.length>h*i.numSwatchesPerLine)var l=i.numSwatchesPerLine;else l=i.savedColors.length-(h-1)*i.numSwatchesPerLine;for(var u=Math.min(Math.max(l,0),i.numSwatchesPerLine),c=0,p=1;c<u;c++)if(!(c>i.numSwatchesPerLine)){var f=X();null!=f&&(d.addControl(f,a,p),p+=2,_++)}}i.savedColors.length>=i.swatchLimit?K(e,!0):K(e,!1)}}function q(t){t?((h=O.CreateSimpleButton("butEdit","Edit")).width=l,h.height=u,h.left=Math.floor(.1*parseInt(l)).toString()+"px",h.top=(-1*parseFloat(h.left)).toString()+"px",h.verticalAlignment=f.VERTICAL_ALIGNMENT_BOTTOM,h.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,h.thickness=2,h.color="#c0c0c0",h.fontSize=a,h.background="#535353",h.onPointerEnterObservable.add((function(){h.background="#414141"})),h.onPointerOutObservable.add((function(){h.background="#535353"})),h.pointerDownAnimation=function(){h.background="515151"},h.pointerUpAnimation=function(){h.background="#414141"},h.onPointerClickObservable.add((function(){F=!F,U()})),ut.addControl(h,1,0)):ut.removeControl(h)}function K(t,e){e?(t.color="#555555",t.background="#454545"):(t.color="#c0c0c0",t.background="#535353")}function Z(e){i.savedColors&&i.savedColors.length>0?r({savedColors:i.savedColors,pickedColor:e}):r({pickedColor:e}),t.removeControl(J)}var J=new P;if(J.name="Dialog Container",J.width=i.pickerWidth,i.savedColors){J.height=N;var Q=parseInt(i.pickerHeight)/parseInt(N);J.addRowDefinition(Q,!1),J.addRowDefinition(1-Q,!1)}else J.height=i.pickerHeight,J.addRowDefinition(1,!1);if(t.addControl(J),i.savedColors){(d=new P).name="Swatch Drawer",d.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,d.background="#535353",d.width=i.pickerWidth;var $=i.savedColors.length/i.numSwatchesPerLine;if(0==$)var tt=0;else tt=$+1;d.height=(R*$+tt*D).toString()+"px",d.top=Math.floor(.25*R).toString()+"px";for(var et=0;et<2*Math.ceil(i.savedColors.length/i.numSwatchesPerLine)+1;et++)et%2!=0?d.addRowDefinition(R,!0):d.addRowDefinition(D,!0);for(et=0;et<2*i.numSwatchesPerLine+1;et++)et%2!=0?d.addColumnDefinition(R,!0):d.addColumnDefinition(D,!0);J.addControl(d,1,0)}var it=new P;it.name="Picker Panel",it.height=i.pickerHeight;var rt=parseInt(i.headerHeight)/parseInt(i.pickerHeight),nt=[rt,1-rt];it.addRowDefinition(nt[0],!1),it.addRowDefinition(nt[1],!1),J.addControl(it,0,0);var ot=new b;ot.name="Dialogue Header Bar",ot.background="#cccccc",ot.thickness=0,it.addControl(ot,0,0);var st=O.CreateSimpleButton("closeButton","a");st.fontFamily="BabylonJSglyphs";var at=s.Color3.FromHexString(ot.background);o=new s.Color3(1-at.r,1-at.g,1-at.b),st.color=o.toHexString(),st.fontSize=Math.floor(.6*parseInt(i.headerHeight)),st.textBlock.textVerticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,st.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_RIGHT,st.height=st.width=i.headerHeight,st.background=ot.background,st.thickness=0,st.pointerDownAnimation=function(){},st.pointerUpAnimation=function(){st.background=ot.background},st.pointerEnterAnimation=function(){st.color=ot.background,st.background="red"},st.pointerOutAnimation=function(){st.color=o.toHexString(),st.background=ot.background},st.onPointerClickObservable.add((function(){Z(Ct.background)})),it.addControl(st,0,0);var ht=new P;ht.name="Dialogue Body",ht.background="#535353";var lt=[.4375,.5625];ht.addRowDefinition(1,!1),ht.addColumnDefinition(lt[0],!1),ht.addColumnDefinition(lt[1],!1),it.addControl(ht,1,0);var ut=new P;ut.name="Picker Grid",ut.addRowDefinition(.85,!1),ut.addRowDefinition(.15,!1),ht.addControl(ut,0,0),(p=new e).name="GUI Color Picker",i.pickerHeight<i.pickerWidth?p.width=.89:p.height=.89,p.value=s.Color3.FromHexString(i.lastColor),p.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,p.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,p.onPointerDownObservable.add((function(){A=p.name,k="",U(!1)})),p.onValueChangedObservable.add((function(t){A==p.name&&j(t,p.name)})),ut.addControl(p,0,0);var ct=new P;ct.name="Dialogue Right Half",ct.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT;var _t=[.514,.486];ct.addRowDefinition(_t[0],!1),ct.addRowDefinition(_t[1],!1),ht.addControl(ct,1,1);var dt=new P;dt.name="Swatches and Buttons";var pt=[.417,.583];dt.addRowDefinition(1,!1),dt.addColumnDefinition(pt[0],!1),dt.addColumnDefinition(pt[1],!1),ct.addControl(dt,0,0);var ft=new P;ft.name="New and Current Swatches";var gt=[.04,.16,.64,.16];ft.addRowDefinition(gt[0],!1),ft.addRowDefinition(gt[1],!1),ft.addRowDefinition(gt[2],!1),ft.addRowDefinition(gt[3],!1),dt.addControl(ft,0,0);var mt=new P;mt.name="Active Swatches",mt.width=.67,mt.addRowDefinition(.5,!1),mt.addRowDefinition(.5,!1),ft.addControl(mt,2,0);var bt=Math.floor(parseInt(i.pickerWidth)*lt[1]*pt[0]*.11),yt=Math.floor(parseInt(i.pickerHeight)*nt[1]*_t[0]*gt[1]*.5);if(i.pickerWidth>i.pickerHeight)var vt=yt;else vt=bt;var Ot=new y;Ot.text="new",Ot.name="New Color Label",Ot.color="#c0c0c0",Ot.fontSize=vt,ft.addControl(Ot,1,0),(I=new b).name="New Color Swatch",I.background=i.lastColor,I.thickness=0,mt.addControl(I,0,0);var Ct=O.CreateSimpleButton("currentSwatch","");Ct.background=i.lastColor,Ct.thickness=0,Ct.onPointerClickObservable.add((function(){j(s.Color3.FromHexString(Ct.background),Ct.name),U(!1)})),Ct.pointerDownAnimation=function(){},Ct.pointerUpAnimation=function(){},Ct.pointerEnterAnimation=function(){},Ct.pointerOutAnimation=function(){},mt.addControl(Ct,1,0);var Tt=new b;Tt.name="Swatch Outline",Tt.width=.67,Tt.thickness=2,Tt.color="#404040",Tt.isHitTestVisible=!1,ft.addControl(Tt,2,0);var wt=new y;wt.name="Current Color Label",wt.text="current",wt.color="#c0c0c0",wt.fontSize=vt,ft.addControl(wt,3,0);var xt=new P;xt.name="Button Grid",xt.height=.8;xt.addRowDefinition(1/3,!1),xt.addRowDefinition(1/3,!1),xt.addRowDefinition(1/3,!1),dt.addControl(xt,0,1),l=Math.floor(parseInt(i.pickerWidth)*lt[1]*pt[1]*.67).toString()+"px",u=Math.floor(parseInt(i.pickerHeight)*nt[1]*_t[0]*(parseFloat(xt.height.toString())/100)*(1/3)*.7).toString()+"px",a=parseFloat(l)>parseFloat(u)?Math.floor(.45*parseFloat(u)):Math.floor(.11*parseFloat(l));var Pt=O.CreateSimpleButton("butOK","OK");Pt.width=l,Pt.height=u,Pt.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,Pt.thickness=2,Pt.color="#c0c0c0",Pt.fontSize=a,Pt.background="#535353",Pt.onPointerEnterObservable.add((function(){Pt.background="#414141"})),Pt.onPointerOutObservable.add((function(){Pt.background="#535353"})),Pt.pointerDownAnimation=function(){Pt.background="515151"},Pt.pointerUpAnimation=function(){Pt.background="#414141"},Pt.onPointerClickObservable.add((function(){U(!1),Z(I.background)})),xt.addControl(Pt,0,0);var Mt=O.CreateSimpleButton("butCancel","Cancel");if(Mt.width=l,Mt.height=u,Mt.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,Mt.thickness=2,Mt.color="#c0c0c0",Mt.fontSize=a,Mt.background="#535353",Mt.onPointerEnterObservable.add((function(){Mt.background="#414141"})),Mt.onPointerOutObservable.add((function(){Mt.background="#535353"})),Mt.pointerDownAnimation=function(){Mt.background="515151"},Mt.pointerUpAnimation=function(){Mt.background="#414141"},Mt.onPointerClickObservable.add((function(){U(!1),Z(Ct.background)})),xt.addControl(Mt,1,0),i.savedColors){var It=O.CreateSimpleButton("butSave","Save");It.width=l,It.height=u,It.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,It.thickness=2,It.fontSize=a,i.savedColors.length<i.swatchLimit?(It.color="#c0c0c0",It.background="#535353"):K(It,!0),It.onPointerEnterObservable.add((function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(It.background="#414141")})),It.onPointerOutObservable.add((function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(It.background="#535353")})),It.pointerDownAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(It.background="515151")},It.pointerUpAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(It.background="#414141")},It.onPointerClickObservable.add((function(){i.savedColors&&(0==i.savedColors.length&&q(!0),i.savedColors.length<i.swatchLimit&&Y(I.background,It),U(!1))})),i.savedColors.length>0&&q(!0),xt.addControl(It,2,0)}var kt=new P;kt.name="Dialog Lower Right",kt.addRowDefinition(.02,!1),kt.addRowDefinition(.63,!1),kt.addRowDefinition(.21,!1),kt.addRowDefinition(.14,!1),ct.addControl(kt,1,0),c=s.Color3.FromHexString(i.lastColor);var At=new P;At.name="RGB Values",At.width=.82,At.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,At.addRowDefinition(1/3,!1),At.addRowDefinition(1/3,!1),At.addRowDefinition(1/3,!1),At.addColumnDefinition(.1,!1),At.addColumnDefinition(.2,!1),At.addColumnDefinition(.7,!1),kt.addControl(At,1,0);for(et=0;et<W.length;et++){(St=new y).text=W[et],St.color="#c0c0c0",St.fontSize=a,At.addControl(St,et,0)}(g=new x).width=.83,g.height=.72,g.name="rIntField",g.fontSize=a,g.text=(255*c.r).toString(),g.color="#f0f0f0",g.background="#454545",g.onFocusObservable.add((function(){A=g.name,k=g.text,U(!1)})),g.onBlurObservable.add((function(){""==g.text&&(g.text="0"),z(g,"r"),A==g.name&&(A="")})),g.onTextChangedObservable.add((function(){A==g.name&&z(g,"r")})),At.addControl(g,0,1),(m=new x).width=.83,m.height=.72,m.name="gIntField",m.fontSize=a,m.text=(255*c.g).toString(),m.color="#f0f0f0",m.background="#454545",m.onFocusObservable.add((function(){A=m.name,k=m.text,U(!1)})),m.onBlurObservable.add((function(){""==m.text&&(m.text="0"),z(m,"g"),A==m.name&&(A="")})),m.onTextChangedObservable.add((function(){A==m.name&&z(m,"g")})),At.addControl(m,1,1),(v=new x).width=.83,v.height=.72,v.name="bIntField",v.fontSize=a,v.text=(255*c.b).toString(),v.color="#f0f0f0",v.background="#454545",v.onFocusObservable.add((function(){A=v.name,k=v.text,U(!1)})),v.onBlurObservable.add((function(){""==v.text&&(v.text="0"),z(v,"b"),A==v.name&&(A="")})),v.onTextChangedObservable.add((function(){A==v.name&&z(v,"b")})),At.addControl(v,2,1),(C=new x).width=.95,C.height=.72,C.name="rDecField",C.fontSize=a,C.text=c.r.toString(),C.color="#f0f0f0",C.background="#454545",C.onFocusObservable.add((function(){A=C.name,k=C.text,U(!1)})),C.onBlurObservable.add((function(){0!=parseFloat(C.text)&&""!=C.text||(C.text="0",G(C,"r")),A==C.name&&(A="")})),C.onTextChangedObservable.add((function(){A==C.name&&G(C,"r")})),At.addControl(C,0,2),(T=new x).width=.95,T.height=.72,T.name="gDecField",T.fontSize=a,T.text=c.g.toString(),T.color="#f0f0f0",T.background="#454545",T.onFocusObservable.add((function(){A=T.name,k=T.text,U(!1)})),T.onBlurObservable.add((function(){0!=parseFloat(T.text)&&""!=T.text||(T.text="0",G(T,"g")),A==T.name&&(A="")})),T.onTextChangedObservable.add((function(){A==T.name&&G(T,"g")})),At.addControl(T,1,2),(w=new x).width=.95,w.height=.72,w.name="bDecField",w.fontSize=a,w.text=c.b.toString(),w.color="#f0f0f0",w.background="#454545",w.onFocusObservable.add((function(){A=w.name,k=w.text,U(!1)})),w.onBlurObservable.add((function(){0!=parseFloat(w.text)&&""!=w.text||(w.text="0",G(w,"b")),A==w.name&&(A="")})),w.onTextChangedObservable.add((function(){A==w.name&&G(w,"b")})),At.addControl(w,2,2);var St,Et=new P;Et.name="Hex Value",Et.width=.82,Et.addRowDefinition(1,!1),Et.addColumnDefinition(.1,!1),Et.addColumnDefinition(.9,!1),kt.addControl(Et,2,0),(St=new y).text="#",St.color="#c0c0c0",St.fontSize=a,Et.addControl(St,0,0),(M=new x).width=.96,M.height=.72,M.name="hexField",M.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,M.fontSize=a;var Dt=i.lastColor.split("#");M.text=Dt[1],M.color="#f0f0f0",M.background="#454545",M.onFocusObservable.add((function(){A=M.name,k=M.text,U(!1)})),M.onBlurObservable.add((function(){if(3==M.text.length){var t=M.text.split("");M.text=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]}""==M.text&&(M.text="000000",j(s.Color3.FromHexString(M.text),"b")),A==M.name&&(A="")})),M.onTextChangedObservable.add((function(){var t=M.text,e=/[^0-9A-F]/i.test(t);if((M.text.length>6||e)&&A==M.name)M.text=k;else{if(M.text.length<6)for(var i=6-M.text.length,r=0;r<i;r++)t="0"+t;if(3==M.text.length){var n=M.text.split("");t=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]}t="#"+t,A==M.name&&(k=M.text,j(s.Color3.FromHexString(t),M.name))}})),Et.addControl(M,0,1),i.savedColors&&i.savedColors.length>0&&Y("",It)}))},e._Epsilon=1e-6,e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.ColorPicker"]=M;var I=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Ellipse"},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),this._background&&(t.fillStyle=this._background,t.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._thickness&&(this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,t.stroke()),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._clipForChildren=function(t){f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,t),t.clip()},e}(g);s._TypeStore.RegisteredTypes["BABYLON.GUI.Ellipse"]=I;var k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._beforeRenderText=function(t){for(var e=new w,i="",r=0;r<t.length;r++)i+="•";return e.text=i,e},e}(x);s._TypeStore.RegisteredTypes["BABYLON.GUI.InputPassword"]=k;var A=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._lineWidth=1,i._x1=new a(0),i._y1=new a(0),i._x2=new a(0),i._y2=new a(0),i._dash=new Array,i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,i}return n(e,t),Object.defineProperty(e.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectedControl",{get:function(){return this._connectedControl},set:function(t){var e=this;this._connectedControl!==t&&(this._connectedControlDirtyObserver&&this._connectedControl&&(this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver),this._connectedControlDirtyObserver=null),t&&(this._connectedControlDirtyObserver=t.onDirtyObservable.add((function(){return e._markAsDirty()}))),this._connectedControl=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._x1.toString(this._host)},set:function(t){this._x1.toString(this._host)!==t&&this._x1.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._y1.toString(this._host)},set:function(t){this._y1.toString(this._host)!==t&&this._y1.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this._x2.toString(this._host)},set:function(t){this._x2.toString(this._host)!==t&&this._x2.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this._y2.toString(this._host)},set:function(t){this._y2.toString(this._host)!==t&&this._y2.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Line"},e.prototype._draw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._applyStates(t),t.strokeStyle=this.color,t.lineWidth=this._lineWidth,t.setLineDash(this._dash),t.beginPath(),t.moveTo(this._cachedParentMeasure.left+this._x1.getValue(this._host),this._cachedParentMeasure.top+this._y1.getValue(this._host)),t.lineTo(this._cachedParentMeasure.left+this._effectiveX2,this._cachedParentMeasure.top+this._effectiveY2),t.stroke(),t.restore()},e.prototype._measure=function(){this._currentMeasure.width=Math.abs(this._x1.getValue(this._host)-this._effectiveX2)+this._lineWidth,this._currentMeasure.height=Math.abs(this._y1.getValue(this._host)-this._effectiveY2)+this._lineWidth},e.prototype._computeAlignment=function(t,e){this._currentMeasure.left=t.left+Math.min(this._x1.getValue(this._host),this._effectiveX2)-this._lineWidth/2,this._currentMeasure.top=t.top+Math.min(this._y1.getValue(this._host),this._effectiveY2)-this._lineWidth/2},e.prototype.moveToVector3=function(t,e,i){if(void 0===i&&(i=!1),this._host&&this.parent===this._host._rootContainer){var r=this._host._getGlobalViewport(e),n=s.Vector3.Project(t,s.Matrix.Identity(),e.getTransformMatrix(),r);this._moveToProjectedPosition(n,i),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},e.prototype._moveToProjectedPosition=function(t,e){void 0===e&&(e=!1);var i=t.x+this._linkOffsetX.getValue(this._host)+"px",r=t.y+this._linkOffsetY.getValue(this._host)+"px";e?(this.x2=i,this.y2=r,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=i,this.y1=r,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.Line"]=A;var S=function(){function t(t){this._multiLine=t,this._x=new a(0),this._y=new a(0),this._point=new s.Vector3(0,0,0)}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(t){this._x.toString(this._multiLine._host)!==t&&this._x.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(t){this._y.toString(this._multiLine._host)!==t&&this._y.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"control",{get:function(){return this._control},set:function(t){this._control!==t&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=t,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=t,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype.resetLinks=function(){this.control=null,this.mesh=null},t.prototype.translate=function(){return this._point=this._translatePoint(),this._point},t.prototype._translatePoint=function(){if(null!=this._mesh)return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(null!=this._control)return new s.Vector3(this._control.centerX,this._control.centerY,1-s.Epsilon);var t=this._multiLine._host,e=this._x.getValueInPixel(t,Number(t._canvas.width)),i=this._y.getValueInPixel(t,Number(t._canvas.height));return new s.Vector3(e,i,1-s.Epsilon)},t.prototype.dispose=function(){this.resetLinks()},t}(),E=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return n(e,t),Object.defineProperty(e.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.getAt=function(t){return this._points[t]||(this._points[t]=new S(this)),this._points[t]},e.prototype.add=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return t.push(e)}))},e.prototype.push=function(t){var e=this.getAt(this._points.length);return null==t||(t instanceof s.AbstractMesh?e.mesh=t:t instanceof f?e.control=t:null!=t.x&&null!=t.y&&(e.x=t.x,e.y=t.y)),e},e.prototype.remove=function(t){var e;if(t instanceof S){if(-1===(e=this._points.indexOf(t)))return}else e=t;var i=this._points[e];i&&(i.dispose(),this._points.splice(e,1))},e.prototype.reset=function(){for(;this._points.length>0;)this.remove(this._points.length-1)},e.prototype.resetLinks=function(){this._points.forEach((function(t){null!=t&&t.resetLinks()}))},Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"MultiLine"},e.prototype._draw=function(t,e){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._applyStates(t),t.strokeStyle=this.color,t.lineWidth=this._lineWidth,t.setLineDash(this._dash),t.beginPath();var i,r=!0;this._points.forEach((function(e){e&&(r?(t.moveTo(e._point.x,e._point.y),r=!1):e._point.z<1&&i.z<1?t.lineTo(e._point.x,e._point.y):t.moveTo(e._point.x,e._point.y),i=e._point)})),t.stroke(),t.restore()},e.prototype._additionalProcessing=function(t,e){var i=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach((function(t,e){t&&(t.translate(),(null==i._minX||t._point.x<i._minX)&&(i._minX=t._point.x),(null==i._minY||t._point.y<i._minY)&&(i._minY=t._point.y),(null==i._maxX||t._point.x>i._maxX)&&(i._maxX=t._point.x),(null==i._maxY||t._point.y>i._maxY)&&(i._maxY=t._point.y))})),null==this._minX&&(this._minX=0),null==this._minY&&(this._minY=0),null==this._maxX&&(this._maxX=0),null==this._maxY&&(this._maxY=0)},e.prototype._measure=function(){null!=this._minX&&null!=this._maxX&&null!=this._minY&&null!=this._maxY&&(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},e.prototype._computeAlignment=function(t,e){null!=this._minX&&null!=this._minY&&(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},e.prototype.dispose=function(){this.reset(),t.prototype.dispose.call(this)},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.MultiLine"]=E;var D=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.group="",i.onIsCheckedChangedObservable=new s.Observable,i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){return this._isChecked},set:function(t){var e=this;this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t),this._isChecked&&this._host&&this._host.executeOnAllControls((function(t){if(t!==e&&void 0!==t.group){var i=t;i.group===e.group&&(i.isChecked=!1)}})))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"RadioButton"},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=this._currentMeasure.width-this._thickness,i=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this.color,t.lineWidth=this._thickness,t.stroke(),this._isChecked){t.fillStyle=this._isEnabled?this.color:this._disabledColor;var r=e*this._checkSizeRatio,n=i*this._checkSizeRatio;f.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,r/2-this._thickness/2,n/2-this._thickness/2,t),t.fill()}t.restore()},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this.isChecked||(this.isChecked=!0),!0)},e.AddRadioButtonWithHeader=function(t,i,r,n){var o=new C;o.isVertical=!1,o.height="30px";var s=new e;s.width="20px",s.height="20px",s.isChecked=r,s.color="green",s.group=i,s.onIsCheckedChangedObservable.add((function(t){return n(s,t)})),o.addControl(s);var a=new y;return a.text=t,a.width="180px",a.paddingLeft="5px",a.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,a.color="white",o.addControl(a),o},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.RadioButton"]=D;var L=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbWidth=new a(20,a.UNITMODE_PIXEL,!1),i._minimum=0,i._maximum=100,i._value=50,i._isVertical=!1,i._barOffset=new a(5,a.UNITMODE_PIXEL,!1),i._isThumbClamped=!1,i._displayThumb=!0,i._step=0,i._lastPointerDownID=-1,i._effectiveBarOffset=0,i.onValueChangedObservable=new s.Observable,i._pointerIsDown=!1,i.isPointerBlocker=!0,i}return n(e,t),Object.defineProperty(e.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(t){this._displayThumb!==t&&(this._displayThumb=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"step",{get:function(){return this._step},set:function(t){this._step!==t&&(this._step=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(t){this._barOffset.toString(this._host)!==t&&this._barOffset.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(t){this._thumbWidth.toString(this._host)!==t&&this._thumbWidth.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimum",{get:function(){return this._minimum},set:function(t){this._minimum!==t&&(this._minimum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this._maximum},set:function(t){this._maximum!==t&&(this._maximum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){t=Math.max(Math.min(t,this._maximum),this._minimum),this._value!==t&&(this._value=t,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(t){this._isThumbClamped!==t&&(this._isThumbClamped=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"BaseSlider"},e.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},e.prototype._getThumbThickness=function(t){var e=0;switch(t){case"circle":e=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":e=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return e},e.prototype._prepareRenderingData=function(t){this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(t),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height<this._currentMeasure.width?console.error("Height should be greater than width"):(this._barOffset.isPixel?this._effectiveBarOffset=Math.min(this._barOffset.getValue(this._host),this._backgroundBoxThickness):this._effectiveBarOffset=this._backgroundBoxThickness*this._barOffset.getValue(this._host),this._backgroundBoxThickness-=2*this._effectiveBarOffset,this.isVertical?(this._renderLeft+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderTop+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxLength,this._renderWidth=this._backgroundBoxThickness):(this._renderTop+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderLeft+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxThickness,this._renderWidth=this._backgroundBoxLength))},e.prototype._updateValueFromPointer=function(t,e){var i;0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),i=this._isVertical?this._minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this._maximum-this._minimum):this._minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this._maximum-this._minimum);var r=1/this._step|0;this.value=this._step?(i*r|0)/r:i},e.prototype._onPointerDown=function(e,i,r,n,o){return!!t.prototype._onPointerDown.call(this,e,i,r,n,o)&&(this._pointerIsDown=!0,this._updateValueFromPointer(i.x,i.y),this._host._capturingControl[r]=this,this._lastPointerDownID=r,!0)},e.prototype._onPointerMove=function(e,i,r,n){r==this._lastPointerDownID&&(this._pointerIsDown&&this._updateValueFromPointer(i.x,i.y),t.prototype._onPointerMove.call(this,e,i,r,n))},e.prototype._onPointerUp=function(e,i,r,n,o){this._pointerIsDown=!1,delete this._host._capturingControl[r],t.prototype._onPointerUp.call(this,e,i,r,n,o)},e.prototype._onCanvasBlur=function(){this._forcePointerUp(),t.prototype._onCanvasBlur.call(this)},e}(f),R=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._thumbColor="",i._isThumbCircle=!1,i._displayValueBar=!0,i}return n(e,t),Object.defineProperty(e.prototype,"displayValueBar",{get:function(){return this._displayValueBar},set:function(t){this._displayValueBar!==t&&(this._displayValueBar=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbColor",{get:function(){return this._thumbColor},set:function(t){this._thumbColor!==t&&(this._thumbColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isThumbCircle",{get:function(){return this._isThumbCircle},set:function(t){this._isThumbCircle!==t&&(this._isThumbCircle=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Slider"},e.prototype._draw=function(t,e){t.save(),this._applyStates(t),this._prepareRenderingData(this.isThumbCircle?"circle":"rectangle");var i=this._renderLeft,r=this._renderTop,n=this._renderWidth,o=this._renderHeight,s=0;this.isThumbClamped&&this.isThumbCircle?(this.isVertical?r+=this._effectiveThumbThickness/2:i+=this._effectiveThumbThickness/2,s=this._backgroundBoxThickness/2):s=(this._effectiveThumbThickness-this._effectiveBarOffset)/2,(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY);var a=this._getThumbPosition();t.fillStyle=this._background,this.isVertical?this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(i+this._backgroundBoxThickness/2,r,s,Math.PI,2*Math.PI),t.fill(),t.fillRect(i,r,n,o)):t.fillRect(i,r,n,o+this._effectiveThumbThickness):t.fillRect(i,r,n,o):this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(i+this._backgroundBoxLength,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),t.fill(),t.fillRect(i,r,n,o)):t.fillRect(i,r,n+this._effectiveThumbThickness,o):t.fillRect(i,r,n,o),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillStyle=this.color,this._displayValueBar&&(this.isVertical?this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(i+this._backgroundBoxThickness/2,r+this._backgroundBoxLength,s,0,2*Math.PI),t.fill(),t.fillRect(i,r+a,n,o-a)):t.fillRect(i,r+a,n,o-a+this._effectiveThumbThickness):t.fillRect(i,r+a,n,o-a):this.isThumbClamped&&this.isThumbCircle?(t.beginPath(),t.arc(i,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),t.fill(),t.fillRect(i,r,a,o)):t.fillRect(i,r,a,o)),t.fillStyle=this._thumbColor||this.color,this.displayThumb&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._isThumbCircle?(t.beginPath(),this.isVertical?t.arc(i+this._backgroundBoxThickness/2,r+a,s,0,2*Math.PI):t.arc(i+a,r+this._backgroundBoxThickness/2,s,0,2*Math.PI),t.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this._borderColor,t.stroke()):(this.isVertical?t.fillRect(i-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):t.fillRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this._borderColor,this.isVertical?t.strokeRect(i-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):t.strokeRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height))),t.restore()},e}(L);s._TypeStore.RegisteredTypes["BABYLON.GUI.Slider"]=R;var B=function(){function t(t){this.name=t,this._groupPanel=new C,this._selectors=new Array,this._groupPanel.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,this._groupPanel.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,this._groupHeader=this._addGroupHeader(t)}return Object.defineProperty(t.prototype,"groupPanel",{get:function(){return this._groupPanel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectors",{get:function(){return this._selectors},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"header",{get:function(){return this._groupHeader.text},set:function(t){"label"!==this._groupHeader.text&&(this._groupHeader.text=t)},enumerable:!1,configurable:!0}),t.prototype._addGroupHeader=function(t){var e=new y("groupHead",t);return e.width=.9,e.height="30px",e.textWrapping=!0,e.color="black",e.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,e.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,e.left="2px",this._groupPanel.addControl(e),e},t.prototype._getSelector=function(t){if(!(t<0||t>=this._selectors.length))return this._selectors[t]},t.prototype.removeSelector=function(t){t<0||t>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[t]),this._selectors.splice(t,1))},t}(),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.addCheckbox=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1);i=i||!1;var r=new T;r.width="20px",r.height="20px",r.color="#364249",r.background="#CCCCCC",r.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r.onIsCheckedChangedObservable.add((function(t){e(t)}));var n=f.AddHeader(r,t,"200px",{isHorizontal:!0,controlFirst:!0});n.height="30px",n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.left="4px",this.groupPanel.addControl(n),this.selectors.push(n),r.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(r.color=this.groupPanel.parent.parent.buttonColor,r.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(B),H=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._selectNb=0,e}return n(e,t),e.prototype.addRadio=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1);var r=this._selectNb++,n=new D;n.name=t,n.width="20px",n.height="20px",n.color="#364249",n.background="#CCCCCC",n.group=this.name,n.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,n.onIsCheckedChangedObservable.add((function(t){t&&e(r)}));var o=f.AddHeader(n,t,"200px",{isHorizontal:!0,controlFirst:!0});o.height="30px",o.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,o.left="4px",this.groupPanel.addControl(o),this.selectors.push(o),n.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(n.color=this.groupPanel.parent.parent.buttonColor,n.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(B),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.addSlider=function(t,e,i,r,n,o,s){void 0===e&&(e=function(t){}),void 0===i&&(i="Units"),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=function(t){return 0|t});var a=new R;a.name=i,a.value=o,a.minimum=r,a.maximum=n,a.width=.9,a.height="20px",a.color="#364249",a.background="#CCCCCC",a.borderColor="black",a.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,a.left="4px",a.paddingBottom="4px",a.onValueChangedObservable.add((function(t){a.parent.children[0].text=a.parent.children[0].name+": "+s(t)+" "+a.name,e(t)}));var h=f.AddHeader(a,t+": "+s(o)+" "+i,"30px",{isHorizontal:!1,controlFirst:!1});h.height="60px",h.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,h.left="4px",h.children[0].name=t,this.groupPanel.addControl(h),this.selectors.push(h),this.groupPanel.parent&&this.groupPanel.parent.parent&&(a.color=this.groupPanel.parent.parent.buttonColor,a.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[0].name=e,this.selectors[t].children[0].text=e+": "+this.selectors[t].children[1].value+" "+this.selectors[t].children[1].name},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[1].background=e},e}(B),W=function(t){function e(e,i){void 0===i&&(i=[]);var r=t.call(this,e)||this;if(r.name=e,r.groups=i,r._buttonColor="#364249",r._buttonBackground="#CCCCCC",r._headerColor="black",r._barColor="white",r._barHeight="2px",r._spacerHeight="20px",r._bars=new Array,r._groups=i,r.thickness=2,r._panel=new C,r._panel.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._panel.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._panel.top=5,r._panel.left=5,r._panel.width=.95,i.length>0){for(var n=0;n<i.length-1;n++)r._panel.addControl(i[n].groupPanel),r._addSpacer();r._panel.addControl(i[i.length-1].groupPanel)}return r.addControl(r._panel),r}return n(e,t),e.prototype._getTypeName=function(){return"SelectionPanel"},Object.defineProperty(e.prototype,"panel",{get:function(){return this._panel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headerColor",{get:function(){return this._headerColor},set:function(t){this._headerColor!==t&&(this._headerColor=t,this._setHeaderColor())},enumerable:!1,configurable:!0}),e.prototype._setHeaderColor=function(){for(var t=0;t<this._groups.length;t++)this._groups[t].groupPanel.children[0].color=this._headerColor},Object.defineProperty(e.prototype,"buttonColor",{get:function(){return this._buttonColor},set:function(t){this._buttonColor!==t&&(this._buttonColor=t,this._setbuttonColor())},enumerable:!1,configurable:!0}),e.prototype._setbuttonColor=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorButtonColor(e,this._buttonColor)},Object.defineProperty(e.prototype,"labelColor",{get:function(){return this._labelColor},set:function(t){this._labelColor!==t&&(this._labelColor=t,this._setLabelColor())},enumerable:!1,configurable:!0}),e.prototype._setLabelColor=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorLabelColor(e,this._labelColor)},Object.defineProperty(e.prototype,"buttonBackground",{get:function(){return this._buttonBackground},set:function(t){this._buttonBackground!==t&&(this._buttonBackground=t,this._setButtonBackground())},enumerable:!1,configurable:!0}),e.prototype._setButtonBackground=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorButtonBackground(e,this._buttonBackground)},Object.defineProperty(e.prototype,"barColor",{get:function(){return this._barColor},set:function(t){this._barColor!==t&&(this._barColor=t,this._setBarColor())},enumerable:!1,configurable:!0}),e.prototype._setBarColor=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].children[0].background=this._barColor},Object.defineProperty(e.prototype,"barHeight",{get:function(){return this._barHeight},set:function(t){this._barHeight!==t&&(this._barHeight=t,this._setBarHeight())},enumerable:!1,configurable:!0}),e.prototype._setBarHeight=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].children[0].height=this._barHeight},Object.defineProperty(e.prototype,"spacerHeight",{get:function(){return this._spacerHeight},set:function(t){this._spacerHeight!==t&&(this._spacerHeight=t,this._setSpacerHeight())},enumerable:!1,configurable:!0}),e.prototype._setSpacerHeight=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].height=this._spacerHeight},e.prototype._addSpacer=function(){var t=new g;t.width=1,t.height=this._spacerHeight,t.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT;var e=new b;e.width=1,e.height=this._barHeight,e.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,e.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,e.background=this._barColor,e.color="transparent",t.addControl(e),this._panel.addControl(t),this._bars.push(t)},e.prototype.addGroup=function(t){this._groups.length>0&&this._addSpacer(),this._panel.addControl(t.groupPanel),this._groups.push(t),t.groupPanel.children[0].color=this._headerColor;for(var e=0;e<t.selectors.length;e++)t._setSelectorButtonColor(e,this._buttonColor),t._setSelectorButtonBackground(e,this._buttonBackground)},e.prototype.removeGroup=function(t){if(!(t<0||t>=this._groups.length)){var e=this._groups[t];this._panel.removeControl(e.groupPanel),this._groups.splice(t,1),t<this._bars.length&&(this._panel.removeControl(this._bars[t]),this._bars.splice(t,1))}},e.prototype.setHeaderName=function(t,e){e<0||e>=this._groups.length||(this._groups[e].groupPanel.children[0].text=t)},e.prototype.relabel=function(t,e,i){if(!(e<0||e>=this._groups.length)){var r=this._groups[e];i<0||i>=r.selectors.length||r._setSelectorLabel(i,t)}},e.prototype.removeFromGroupSelector=function(t,e){if(!(t<0||t>=this._groups.length)){var i=this._groups[t];e<0||e>=i.selectors.length||i.removeSelector(e)}},e.prototype.addToGroupCheckbox=function(t,e,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),t<0||t>=this._groups.length)||this._groups[t].addCheckbox(e,i,r)},e.prototype.addToGroupRadio=function(t,e,i,r){(void 0===i&&(i=function(){}),void 0===r&&(r=!1),t<0||t>=this._groups.length)||this._groups[t].addRadio(e,i,r)},e.prototype.addToGroupSlider=function(t,e,i,r,n,o,s,a){(void 0===i&&(i=function(){}),void 0===r&&(r="Units"),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=function(t){return 0|t}),t<0||t>=this._groups.length)||this._groups[t].addSlider(e,i,r,n,o,s,a)},e}(b),F=function(t){function e(e){var i=t.call(this,e)||this;return i._freezeControls=!1,i._bucketWidth=0,i._bucketHeight=0,i._buckets={},i}return n(e,t),Object.defineProperty(e.prototype,"freezeControls",{get:function(){return this._freezeControls},set:function(t){if(this._freezeControls!==t){t||this._restoreMeasures(),this._freezeControls=!1;var e=this.host.getSize(),i=e.width,r=e.height,n=this.host.getContext(),o=new _(0,0,i,r);this.host._numLayoutCalls=0,this.host._rootContainer._layout(o,n),t&&(this._updateMeasures(),this._useBuckets()&&this._makeBuckets()),this._freezeControls=t,this.host.markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketWidth",{get:function(){return this._bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketHeight",{get:function(){return this._bucketHeight},enumerable:!1,configurable:!0}),e.prototype.setBucketSizes=function(t,e){this._bucketWidth=t,this._bucketHeight=e,this._useBuckets()?this._freezeControls&&this._makeBuckets():this._buckets={}},e.prototype._useBuckets=function(){return this._bucketWidth>0&&this._bucketHeight>0},e.prototype._makeBuckets=function(){this._buckets={},this._bucketLen=Math.ceil(this.widthInPixels/this._bucketWidth),this._dispatchInBuckets(this._children),this._oldLeft=null,this._oldTop=null},e.prototype._dispatchInBuckets=function(t){for(var e=0;e<t.length;++e){for(var i=t[e],r=Math.max(0,Math.floor((i._customData._origLeft-this._customData.origLeft)/this._bucketWidth)),n=Math.floor((i._customData._origLeft-this._customData.origLeft+i._currentMeasure.width-1)/this._bucketWidth),o=Math.max(0,Math.floor((i._customData._origTop-this._customData.origTop)/this._bucketHeight)),s=Math.floor((i._customData._origTop-this._customData.origTop+i._currentMeasure.height-1)/this._bucketHeight);o<=s;){for(var a=r;a<=n;++a){var h=o*this._bucketLen+a,l=this._buckets[h];l||(l=[],this._buckets[h]=l),l.push(i)}o++}i instanceof g&&i._children.length>0&&this._dispatchInBuckets(i._children)}},e.prototype._updateMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left-=t,this._measureForChildren.top-=e,this._currentMeasure.left-=t,this._currentMeasure.top-=e,this._customData.origLeftForChildren=this._measureForChildren.left,this._customData.origTopForChildren=this._measureForChildren.top,this._customData.origLeft=this._currentMeasure.left,this._customData.origTop=this._currentMeasure.top,this._updateChildrenMeasures(this._children,t,e)},e.prototype._updateChildrenMeasures=function(t,e,i){for(var r=0;r<t.length;++r){var n=t[r];n._currentMeasure.left-=e,n._currentMeasure.top-=i,n._customData._origLeft=n._currentMeasure.left,n._customData._origTop=n._currentMeasure.top,n instanceof g&&n._children.length>0&&this._updateChildrenMeasures(n._children,e,i)}},e.prototype._restoreMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left=this._customData.origLeftForChildren+t,this._measureForChildren.top=this._customData.origTopForChildren+e,this._currentMeasure.left=this._customData.origLeft+t,this._currentMeasure.top=this._customData.origTop+e},e.prototype._getTypeName=function(){return"ScrollViewerWindow"},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._parentMeasure=e,this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=e.width,this._measureForChildren.height=e.height},e.prototype._layout=function(e,i){return this._freezeControls?(this.invalidateRect(),!1):t.prototype._layout.call(this,e,i)},e.prototype._scrollChildren=function(t,e,i){for(var r=0;r<t.length;++r){var n=t[r];n._currentMeasure.left=n._customData._origLeft+e,n._currentMeasure.top=n._customData._origTop+i,n._isClipped=!1,n instanceof g&&n._children.length>0&&this._scrollChildren(n._children,e,i)}},e.prototype._scrollChildrenWithBuckets=function(t,e,i,r){for(var n=Math.max(0,Math.floor(-t/this._bucketWidth)),o=Math.floor((-t+this._parentMeasure.width-1)/this._bucketWidth),s=Math.max(0,Math.floor(-e/this._bucketHeight)),a=Math.floor((-e+this._parentMeasure.height-1)/this._bucketHeight);s<=a;){for(var h=n;h<=o;++h){var l=s*this._bucketLen+h,u=this._buckets[l];if(u)for(var c=0;c<u.length;++c){var _=u[c];_._currentMeasure.left=_._customData._origLeft+i,_._currentMeasure.top=_._customData._origTop+r,_._isClipped=!1}}s++}},e.prototype._draw=function(e,i){if(this._freezeControls){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);var r=0|this.leftInPixels,n=0|this.topInPixels;this._useBuckets()&&null!==this._oldLeft&&null!==this._oldTop?(this._scrollChildrenWithBuckets(this._oldLeft,this._oldTop,r,n),this._scrollChildrenWithBuckets(r,n,r,n)):this._scrollChildren(this._children,r,n),this._oldLeft=r,this._oldTop=n;for(var o=0,s=this._children;o<s.length;o++){var a=s[o];a._intersectsRect(this._parentMeasure)&&a._render(e,this._parentMeasure)}}else t.prototype._draw.call(this,e,i)},e.prototype._postMeasure=function(){if(this._freezeControls)t.prototype._postMeasure.call(this);else{for(var e=this.parentClientWidth,i=this.parentClientHeight,r=0,n=this.children;r<n.length;r++){var o=n[r];o.isVisible&&!o.notRenderable&&(o.horizontalAlignment===f.HORIZONTAL_ALIGNMENT_CENTER&&o._offsetLeft(this._currentMeasure.left-o._currentMeasure.left),o.verticalAlignment===f.VERTICAL_ALIGNMENT_CENTER&&o._offsetTop(this._currentMeasure.top-o._currentMeasure.top),e=Math.max(e,o._currentMeasure.left-this._currentMeasure.left+o._currentMeasure.width+o.paddingRightInPixels),i=Math.max(i,o._currentMeasure.top-this._currentMeasure.top+o._currentMeasure.height+o.paddingBottomInPixels))}this._currentMeasure.width!==e&&(this._width.updateInPlace(e,a.UNITMODE_PIXEL),this._currentMeasure.width=e,this._rebuildLayout=!0,this._isDirty=!0),this._currentMeasure.height!==i&&(this._height.updateInPlace(i,a.UNITMODE_PIXEL),this._currentMeasure.height=i,this._rebuildLayout=!0,this._isDirty=!0),t.prototype._postMeasure.call(this)}},e}(g),j=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._tempMeasure=new _(0,0,0,0),i}return n(e,t),Object.defineProperty(e.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Scrollbar"},e.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._renderLeft,i=this._getThumbPosition();t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),t.fillStyle=this.color,this.isVertical?(this._tempMeasure.left=e-this._effectiveBarOffset,this._tempMeasure.top=this._currentMeasure.top+i,this._tempMeasure.width=this._currentMeasure.width,this._tempMeasure.height=this._effectiveThumbThickness):(this._tempMeasure.left=this._currentMeasure.left+i,this._tempMeasure.top=this._currentMeasure.top,this._tempMeasure.width=this._effectiveThumbThickness,this._tempMeasure.height=this._currentMeasure.height),t.fillRect(this._tempMeasure.left,this._tempMeasure.top,this._tempMeasure.width,this._tempMeasure.height),t.restore()},e.prototype._updateValueFromPointer=function(t,e){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=t,this._originY=e,(t<this._tempMeasure.left||t>this._tempMeasure.left+this._tempMeasure.width||e<this._tempMeasure.top||e>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,r,n,o){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,r,n,o)},e}(L),z=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbLength=.5,i._thumbHeight=1,i._barImageHeight=1,i._tempMeasure=new _(0,0,0,0),i.num90RotationInVerticalMode=1,i}return n(e,t),Object.defineProperty(e.prototype,"backgroundImage",{get:function(){return this._backgroundBaseImage},set:function(t){var e=this;this._backgroundBaseImage!==t&&(this._backgroundBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._backgroundImage=t._rotate90(this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(e.num90RotationInVerticalMode,!0);e._backgroundImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._backgroundImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._thumbBaseImage},set:function(t){var e=this;this._thumbBaseImage!==t&&(this._thumbBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._thumbImage=t._rotate90(-this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(-e.num90RotationInVerticalMode,!0);e._thumbImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._thumbImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){this._thumbLength!==t&&(this._thumbLength=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){this._thumbLength!==t&&(this._thumbHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){this._barImageHeight!==t&&(this._barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ImageScrollBar"},e.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._getThumbPosition(),i=this._renderLeft,r=this._renderTop,n=this._renderWidth,o=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(i,r,n,o),this.isVertical?(this._tempMeasure.copyFromFloats(i+n*(1-this._barImageHeight)*.5,this._currentMeasure.top,n*this._barImageHeight,o),this._tempMeasure.height+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)):(this._tempMeasure.copyFromFloats(this._currentMeasure.left,r+o*(1-this._barImageHeight)*.5,n,o*this._barImageHeight),this._tempMeasure.width+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)),this._backgroundImage._draw(t)),this.isVertical?this._tempMeasure.copyFromFloats(i-this._effectiveBarOffset+this._currentMeasure.width*(1-this._thumbHeight)*.5,this._currentMeasure.top+e,this._currentMeasure.width*this._thumbHeight,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+e,this._currentMeasure.top+this._currentMeasure.height*(1-this._thumbHeight)*.5,this._effectiveThumbThickness,this._currentMeasure.height*this._thumbHeight),this._thumbImage&&(this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(t)),t.restore()},e.prototype._updateValueFromPointer=function(t,e){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=t,this._originY=e,(t<this._tempMeasure.left||t>this._tempMeasure.left+this._tempMeasure.width||e<this._tempMeasure.top||e>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i=0;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,r,n,o){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,r,n,o)},e}(L),G=function(t){function e(e,i){var r=t.call(this,e)||this;return r._barSize=20,r._pointerIsOver=!1,r._wheelPrecision=.05,r._thumbLength=.5,r._thumbHeight=1,r._barImageHeight=1,r._horizontalBarImageHeight=1,r._verticalBarImageHeight=1,r._oldWindowContentsWidth=0,r._oldWindowContentsHeight=0,r._forceHorizontalBar=!1,r._forceVerticalBar=!1,r._useImageBar=i||!1,r.onDirtyObservable.add((function(){r._horizontalBarSpace.color=r.color,r._verticalBarSpace.color=r.color,r._dragSpace.color=r.color})),r.onPointerEnterObservable.add((function(){r._pointerIsOver=!0})),r.onPointerOutObservable.add((function(){r._pointerIsOver=!1})),r._grid=new P,r._useImageBar?(r._horizontalBar=new z,r._verticalBar=new z):(r._horizontalBar=new j,r._verticalBar=new j),r._window=new F("scrollViewer_window"),r._window.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._window.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._grid.addColumnDefinition(1),r._grid.addColumnDefinition(0,!0),r._grid.addRowDefinition(1),r._grid.addRowDefinition(0,!0),t.prototype.addControl.call(r,r._grid),r._grid.addControl(r._window,0,0),r._verticalBarSpace=new b,r._verticalBarSpace.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._verticalBarSpace.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._verticalBarSpace.thickness=1,r._grid.addControl(r._verticalBarSpace,0,1),r._addBar(r._verticalBar,r._verticalBarSpace,!0,Math.PI),r._horizontalBarSpace=new b,r._horizontalBarSpace.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,r._horizontalBarSpace.verticalAlignment=f.VERTICAL_ALIGNMENT_TOP,r._horizontalBarSpace.thickness=1,r._grid.addControl(r._horizontalBarSpace,1,0),r._addBar(r._horizontalBar,r._horizontalBarSpace,!1,0),r._dragSpace=new b,r._dragSpace.thickness=1,r._grid.addControl(r._dragSpace,1,1),r._useImageBar||(r.barColor="grey",r.barBackground="transparent"),r}return n(e,t),Object.defineProperty(e.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!1,configurable:!0}),e.prototype.addControl=function(t){return t?(this._window.addControl(t),this):this},e.prototype.removeControl=function(t){return this._window.removeControl(t),this},Object.defineProperty(e.prototype,"children",{get:function(){return this._window.children},enumerable:!1,configurable:!0}),e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this._children;t<e.length;t++){e[t]._markMatrixAsDirty()}},Object.defineProperty(e.prototype,"freezeControls",{get:function(){return this._window.freezeControls},set:function(t){this._window.freezeControls=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketWidth",{get:function(){return this._window.bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketHeight",{get:function(){return this._window.bucketHeight},enumerable:!1,configurable:!0}),e.prototype.setBucketSizes=function(t,e){this._window.setBucketSizes(t,e)},Object.defineProperty(e.prototype,"forceHorizontalBar",{get:function(){return this._forceHorizontalBar},set:function(t){this._grid.setRowDefinition(1,t?this._barSize:0,!0),this._horizontalBar.isVisible=t,this._forceHorizontalBar=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forceVerticalBar",{get:function(){return this._forceVerticalBar},set:function(t){this._grid.setColumnDefinition(1,t?this._barSize:0,!0),this._verticalBar.isVisible=t,this._forceVerticalBar=t},enumerable:!1,configurable:!0}),e.prototype.resetWindow=function(){this._window.width="100%",this._window.height="100%"},e.prototype._getTypeName=function(){return"ScrollViewer"},e.prototype._buildClientSizes=function(){var t=this.host.idealRatio;this._window.parentClientWidth=this._currentMeasure.width-(this._verticalBar.isVisible||this.forceVerticalBar?this._barSize*t:0)-2*this.thickness,this._window.parentClientHeight=this._currentMeasure.height-(this._horizontalBar.isVisible||this.forceHorizontalBar?this._barSize*t:0)-2*this.thickness,this._clientWidth=this._window.parentClientWidth,this._clientHeight=this._window.parentClientHeight},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._buildClientSizes()},e.prototype._postMeasure=function(){t.prototype._postMeasure.call(this),this._updateScroller(),this._setWindowPosition(!1)},Object.defineProperty(e.prototype,"wheelPrecision",{get:function(){return this._wheelPrecision},set:function(t){this._wheelPrecision!==t&&(t<0&&(t=0),t>1&&(t=1),this._wheelPrecision=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollBackground",{get:function(){return this._horizontalBarSpace.background},set:function(t){this._horizontalBarSpace.background!==t&&(this._horizontalBarSpace.background=t,this._verticalBarSpace.background=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barColor",{get:function(){return this._barColor},set:function(t){this._barColor!==t&&(this._barColor=t,this._horizontalBar.color=t,this._verticalBar.color=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._barImage},set:function(t){if(this._barImage!==t){this._barImage=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbImage=t,i.thumbImage=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalThumbImage",{get:function(){return this._horizontalBarImage},set:function(t){this._horizontalBarImage!==t&&(this._horizontalBarImage=t,this._horizontalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalThumbImage",{get:function(){return this._verticalBarImage},set:function(t){this._verticalBarImage!==t&&(this._verticalBarImage=t,this._verticalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barSize",{get:function(){return this._barSize},set:function(t){this._barSize!==t&&(this._barSize=t,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){if(this._thumbLength!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbLength=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbLength=t,i.thumbLength=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){if(this._thumbHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbHeight=t,i.thumbHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){if(this._barImageHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._barImageHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.barImageHeight=t,i.barImageHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImageHeight",{get:function(){return this._horizontalBarImageHeight},set:function(t){this._horizontalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._horizontalBarImageHeight=t,this._horizontalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImageHeight",{get:function(){return this._verticalBarImageHeight},set:function(t){this._verticalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._verticalBarImageHeight=t,this._verticalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barBackground",{get:function(){return this._barBackground},set:function(t){if(this._barBackground!==t){this._barBackground=t;var e=this._horizontalBar,i=this._verticalBar;e.background=t,i.background=t,this._dragSpace.background=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImage",{get:function(){return this._barBackgroundImage},set:function(t){this._barBackgroundImage,this._barBackgroundImage=t;var e=this._horizontalBar,i=this._verticalBar;e.backgroundImage=t,i.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImage",{get:function(){return this._horizontalBarBackgroundImage},set:function(t){this._horizontalBarBackgroundImage,this._horizontalBarBackgroundImage=t,this._horizontalBar.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImage",{get:function(){return this._verticalBarBackgroundImage},set:function(t){this._verticalBarBackgroundImage,this._verticalBarBackgroundImage=t,this._verticalBar.backgroundImage=t},enumerable:!1,configurable:!0}),e.prototype._setWindowPosition=function(t){void 0===t&&(t=!0);var e=this.host.idealRatio,i=this._window._currentMeasure.width,r=this._window._currentMeasure.height;if(t||this._oldWindowContentsWidth!==i||this._oldWindowContentsHeight!==r){this._oldWindowContentsWidth=i,this._oldWindowContentsHeight=r;var n=this._clientWidth-i,o=this._clientHeight-r,s=this._horizontalBar.value/e*n+"px",a=this._verticalBar.value/e*o+"px";s!==this._window.left&&(this._window.left=s,this.freezeControls||(this._rebuildLayout=!0)),a!==this._window.top&&(this._window.top=a,this.freezeControls||(this._rebuildLayout=!0))}},e.prototype._updateScroller=function(){var t=this._window._currentMeasure.width,e=this._window._currentMeasure.height;this._horizontalBar.isVisible&&t<=this._clientWidth&&!this.forceHorizontalBar?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&(t>this._clientWidth||this.forceHorizontalBar)&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&e<=this._clientHeight&&!this.forceVerticalBar?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&(e>this._clientHeight||this.forceVerticalBar)&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes();var i=this.host.idealRatio;this._horizontalBar.thumbWidth=.9*this._thumbLength*(this._clientWidth/i)+"px",this._verticalBar.thumbWidth=.9*this._thumbLength*(this._clientHeight/i)+"px"},e.prototype._link=function(e){t.prototype._link.call(this,e),this._attachWheel()},e.prototype._addBar=function(t,e,i,r){var n=this;t.paddingLeft=0,t.width="100%",t.height="100%",t.barOffset=0,t.value=0,t.maximum=1,t.horizontalAlignment=f.HORIZONTAL_ALIGNMENT_CENTER,t.verticalAlignment=f.VERTICAL_ALIGNMENT_CENTER,t.isVertical=i,t.rotation=r,t.isVisible=!1,e.addControl(t),t.onValueChangedObservable.add((function(t){n._setWindowPosition()}))},e.prototype._attachWheel=function(){var t=this;this._host&&!this._onWheelObserver&&(this._onWheelObserver=this.onWheelObservable.add((function(e){t._pointerIsOver&&(1==t._verticalBar.isVisible&&(e.y<0&&t._verticalBar.value>0?t._verticalBar.value-=t._wheelPrecision:e.y>0&&t._verticalBar.value<t._verticalBar.maximum&&(t._verticalBar.value+=t._wheelPrecision)),1==t._horizontalBar.isVisible&&(e.x<0&&t._horizontalBar.value<t._horizontalBar.maximum?t._horizontalBar.value+=t._wheelPrecision:e.x>0&&t._horizontalBar.value>0&&(t._horizontalBar.value-=t._wheelPrecision)))})))},e.prototype._renderHighlightSpecific=function(e){this.isHighlighted&&(t.prototype._renderHighlightSpecific.call(this,e),this._grid._renderHighlightSpecific(e),e.restore())},e.prototype.dispose=function(){this.onWheelObservable.remove(this._onWheelObserver),this._onWheelObserver=null,t.prototype.dispose.call(this)},e}(b);s._TypeStore.RegisteredTypes["BABYLON.GUI.ScrollViewer"]=G;var X=function(){},U=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onKeyPressObservable=new s.Observable,e.defaultButtonWidth="40px",e.defaultButtonHeight="40px",e.defaultButtonPaddingLeft="2px",e.defaultButtonPaddingRight="2px",e.defaultButtonPaddingTop="2px",e.defaultButtonPaddingBottom="2px",e.defaultButtonColor="#DDD",e.defaultButtonBackground="#070707",e.shiftButtonColor="#7799FF",e.selectedShiftThickness=1,e.shiftState=0,e._currentlyConnectedInputText=null,e._connectedInputTexts=[],e._onKeyPressObserver=null,e}return n(e,t),e.prototype._getTypeName=function(){return"VirtualKeyboard"},e.prototype._createKey=function(t,e){var i=this,r=O.CreateSimpleButton(t,t);return r.width=e&&e.width?e.width:this.defaultButtonWidth,r.height=e&&e.height?e.height:this.defaultButtonHeight,r.color=e&&e.color?e.color:this.defaultButtonColor,r.background=e&&e.background?e.background:this.defaultButtonBackground,r.paddingLeft=e&&e.paddingLeft?e.paddingLeft:this.defaultButtonPaddingLeft,r.paddingRight=e&&e.paddingRight?e.paddingRight:this.defaultButtonPaddingRight,r.paddingTop=e&&e.paddingTop?e.paddingTop:this.defaultButtonPaddingTop,r.paddingBottom=e&&e.paddingBottom?e.paddingBottom:this.defaultButtonPaddingBottom,r.thickness=0,r.isFocusInvisible=!0,r.shadowColor=this.shadowColor,r.shadowBlur=this.shadowBlur,r.shadowOffsetX=this.shadowOffsetX,r.shadowOffsetY=this.shadowOffsetY,r.onPointerUpObservable.add((function(){i.onKeyPressObservable.notifyObservers(t)})),r},e.prototype.addKeysRow=function(t,e){var i=new C;i.isVertical=!1,i.isFocusInvisible=!0;for(var r=null,n=0;n<t.length;n++){var o=null;e&&e.length===t.length&&(o=e[n]);var s=this._createKey(t[n],o);(!r||s.heightInPixels>r.heightInPixels)&&(r=s),i.addControl(s)}i.height=r?r.height:this.defaultButtonHeight,this.addControl(i)},e.prototype.applyShiftState=function(t){if(this.children)for(var e=0;e<this.children.length;e++){var i=this.children[e];if(i&&i.children)for(var r=i,n=0;n<r.children.length;n++){var o=r.children[n];if(o&&o.children[0]){var s=o.children[0];"⇧"===s.text&&(o.color=t?this.shiftButtonColor:this.defaultButtonColor,o.thickness=t>1?this.selectedShiftThickness:0),s.text=t>0?s.text.toUpperCase():s.text.toLowerCase()}}}},Object.defineProperty(e.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!1,configurable:!0}),e.prototype.connect=function(t){var e=this;if(!this._connectedInputTexts.some((function(e){return e.input===t}))){null===this._onKeyPressObserver&&(this._onKeyPressObserver=this.onKeyPressObservable.add((function(t){if(e._currentlyConnectedInputText){switch(e._currentlyConnectedInputText._host.focusedControl=e._currentlyConnectedInputText,t){case"⇧":return e.shiftState++,e.shiftState>2&&(e.shiftState=0),void e.applyShiftState(e.shiftState);case"←":return void e._currentlyConnectedInputText.processKey(8);case"↵":return void e._currentlyConnectedInputText.processKey(13)}e._currentlyConnectedInputText.processKey(-1,e.shiftState?t.toUpperCase():t),1===e.shiftState&&(e.shiftState=0,e.applyShiftState(e.shiftState))}}))),this.isVisible=!1,this._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=this;var i=t.onFocusObservable.add((function(){e._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=e,e.isVisible=!0})),r=t.onBlurObservable.add((function(){t._connectedVirtualKeyboard=null,e._currentlyConnectedInputText=null,e.isVisible=!1}));this._connectedInputTexts.push({input:t,onBlurObserver:r,onFocusObserver:i})}},e.prototype.disconnect=function(t){var e=this;if(t){var i=this._connectedInputTexts.filter((function(e){return e.input===t}));1===i.length&&(this._removeConnectedInputObservables(i[0]),this._connectedInputTexts=this._connectedInputTexts.filter((function(e){return e.input!==t})),this._currentlyConnectedInputText===t&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach((function(t){e._removeConnectedInputObservables(t)})),this._connectedInputTexts=[];0===this._connectedInputTexts.length&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},e.prototype._removeConnectedInputObservables=function(t){t.input._connectedVirtualKeyboard=null,t.input.onFocusObservable.remove(t.onFocusObserver),t.input.onBlurObservable.remove(t.onBlurObserver)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disconnect()},e.CreateDefaultLayout=function(t){var i=new e(t);return i.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),i.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),i.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),i.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),i.addKeysRow([" "],[{width:"200px"}]),i},e}(C);s._TypeStore.RegisteredTypes["BABYLON.GUI.VirtualKeyboard"]=U;var Y=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._cellWidth=20,i._cellHeight=20,i._minorLineTickness=1,i._minorLineColor="DarkGray",i._majorLineTickness=2,i._majorLineColor="White",i._majorLineFrequency=5,i._background="Black",i._displayMajorLines=!0,i._displayMinorLines=!0,i}return n(e,t),Object.defineProperty(e.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(t){this._displayMinorLines!==t&&(this._displayMinorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(t){this._displayMajorLines!==t&&(this._displayMajorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(t){this._minorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(t){this._minorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(t){this._majorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(t){this._majorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(t){this._majorLineFrequency=t,this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._draw=function(t,e){if(t.save(),this._applyStates(t),this._isEnabled){this._background&&(t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var i=this._currentMeasure.width/this._cellWidth,r=this._currentMeasure.height/this._cellHeight,n=this._currentMeasure.left+this._currentMeasure.width/2,o=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){t.strokeStyle=this._minorLineColor,t.lineWidth=this._minorLineTickness;for(var s=-i/2;s<i/2;s++){var a=n+s*this.cellWidth;t.beginPath(),t.moveTo(a,this._currentMeasure.top),t.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),t.stroke()}for(var h=-r/2;h<r/2;h++){var l=o+h*this.cellHeight;t.beginPath(),t.moveTo(this._currentMeasure.left,l),t.lineTo(this._currentMeasure.left+this._currentMeasure.width,l),t.stroke()}}if(this._displayMajorLines){t.strokeStyle=this._majorLineColor,t.lineWidth=this._majorLineTickness;for(s=-i/2+this._majorLineFrequency;s<i/2;s+=this._majorLineFrequency){a=n+s*this.cellWidth;t.beginPath(),t.moveTo(a,this._currentMeasure.top),t.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),t.stroke()}for(h=-r/2+this._majorLineFrequency;h<r/2;h+=this._majorLineFrequency){l=o+h*this.cellHeight;t.moveTo(this._currentMeasure.left,l),t.lineTo(this._currentMeasure.left+this._currentMeasure.width,l),t.closePath(),t.stroke()}}}t.restore()},e.prototype._getTypeName=function(){return"DisplayGrid"},e}(f);s._TypeStore.RegisteredTypes["BABYLON.GUI.DisplayGrid"]=Y;var q=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._tempMeasure=new _(0,0,0,0),i}return n(e,t),Object.defineProperty(e.prototype,"displayThumb",{get:function(){return this._displayThumb&&null!=this.thumbImage},set:function(t){this._displayThumb!==t&&(this._displayThumb=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backgroundImage",{get:function(){return this._backgroundImage},set:function(t){var e=this;this._backgroundImage!==t&&(this._backgroundImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueBarImage",{get:function(){return this._valueBarImage},set:function(t){var e=this;this._valueBarImage!==t&&(this._valueBarImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._thumbImage},set:function(t){var e=this;this._thumbImage!==t&&(this._thumbImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ImageBasedSlider"},e.prototype._draw=function(t,e){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var i=this._getThumbPosition(),r=this._renderLeft,n=this._renderTop,o=this._renderWidth,s=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(r,n,o,s),this.isThumbClamped&&this.displayThumb&&(this.isVertical?this._tempMeasure.height+=this._effectiveThumbThickness:this._tempMeasure.width+=this._effectiveThumbThickness),this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure),this._backgroundImage._draw(t)),this._valueBarImage&&(this.isVertical?this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(r,n+i,o,s-i+this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(r,n+i,o,s-i):this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(r,n,i+this._effectiveThumbThickness/2,s):this._tempMeasure.copyFromFloats(r,n,i,s),this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure),this._valueBarImage._draw(t)),this.displayThumb&&(this.isVertical?this._tempMeasure.copyFromFloats(r-this._effectiveBarOffset,this._currentMeasure.top+i,this._currentMeasure.width,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+i,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(t)),t.restore()},e}(L);s._TypeStore.RegisteredTypes["BABYLON.GUI.ImageBasedSlider"]=q;var K="Statics";f.AddHeader=function(t,e,i,r){var n=new C("panel"),o=!r||r.isHorizontal,s=!r||r.controlFirst;n.isVertical=!o;var a=new y("header");return a.text=e,a.textHorizontalAlignment=f.HORIZONTAL_ALIGNMENT_LEFT,o?a.width=i:a.height=i,s?(n.addControl(t),n.addControl(a),a.paddingLeft="5px"):(n.addControl(a),n.addControl(t),a.paddingRight="5px"),a.shadowBlur=t.shadowBlur,a.shadowColor=t.shadowColor,a.shadowOffsetX=t.shadowOffsetX,a.shadowOffsetY=t.shadowOffsetY,n};var Z=function(){function t(t){this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new a(18,a.UNITMODE_PIXEL,!1),this.onChangedObservable=new s.Observable,this._host=t}return Object.defineProperty(t.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&this.onChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onChangedObservable.clear()},t}(),J=function(t){function e(e,i,r,n,o,a,h){void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=!1),void 0===a&&(a=s.Texture.NEAREST_SAMPLINGMODE);var l=t.call(this,e,{width:i,height:r},n,o,a,s.Constants.TEXTUREFORMAT_RGBA,h)||this;return l._isDirty=!1,l._rootContainer=new g("root"),l._lastControlOver={},l._lastControlDown={},l._capturingControl={},l._linkedControls=new Array,l._isFullscreen=!1,l._fullscreenViewport=new s.Viewport(0,0,1,1),l._idealWidth=0,l._idealHeight=0,l._useSmallestIdeal=!1,l._renderAtIdealSize=!1,l._blockNextFocusCheck=!1,l._renderScale=1,l._cursorChanged=!1,l._defaultMousePointerId=0,l._numLayoutCalls=0,l._numRenderCalls=0,l._clipboardData="",l.onClipboardObservable=new s.Observable,l.onControlPickedObservable=new s.Observable,l.onBeginLayoutObservable=new s.Observable,l.onEndLayoutObservable=new s.Observable,l.onBeginRenderObservable=new s.Observable,l.onEndRenderObservable=new s.Observable,l.premulAlpha=!1,l.applyYInversionOnUpdate=!0,l._useInvalidateRectOptimization=!0,l._invalidatedRectangle=null,l._clearMeasure=new _(0,0,0,0),l.onClipboardCopy=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.COPY,e);l.onClipboardObservable.notifyObservers(i),e.preventDefault()},l.onClipboardCut=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.CUT,e);l.onClipboardObservable.notifyObservers(i),e.preventDefault()},l.onClipboardPaste=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.PASTE,e);l.onClipboardObservable.notifyObservers(i),e.preventDefault()},(n=l.getScene())&&l._texture?(l._rootElement=n.getEngine().getInputElement(),l._renderObserver=n.onBeforeCameraRenderObservable.add((function(t){return l._checkUpdate(t)})),l._preKeyboardObserver=n.onPreKeyboardObservable.add((function(t){l._focusedControl&&(t.type===s.KeyboardEventTypes.KEYDOWN&&l._focusedControl.processKeyboard(t.event),t.skipOnPointerObservable=!0)})),l._rootContainer._link(l),l.hasAlpha=!0,i&&r||(l._resizeObserver=n.getEngine().onResizeObservable.add((function(){return l._onResize()})),l._onResize()),l._texture.isReady=!0,l):l}return n(e,t),Object.defineProperty(e.prototype,"numLayoutCalls",{get:function(){return this._numLayoutCalls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRenderCalls",{get:function(){return this._numRenderCalls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderScale",{get:function(){return this._renderScale},set:function(t){t!==this._renderScale&&(this._renderScale=t,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this.markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(t){this._idealWidth!==t&&(this._idealWidth=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(t){this._idealHeight!==t&&(this._idealHeight=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useSmallestIdeal",{get:function(){return this._useSmallestIdeal},set:function(t){this._useSmallestIdeal!==t&&(this._useSmallestIdeal=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(t){this._renderAtIdealSize!==t&&(this._renderAtIdealSize=t,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealRatio",{get:function(){var t=0,e=0;return this._idealWidth&&(t=this.getSize().width/this._idealWidth),this._idealHeight&&(e=this.getSize().height/this._idealHeight),this._useSmallestIdeal&&this._idealWidth&&this._idealHeight?window.innerWidth<window.innerHeight?t:e:this._idealWidth?t:this._idealHeight?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),e.prototype.getChildren=function(){return[this._rootContainer]},e.prototype.getDescendants=function(t,e){return this._rootContainer.getDescendants(t,e)},Object.defineProperty(e.prototype,"focusedControl",{get:function(){return this._focusedControl},set:function(t){this._focusedControl!=t&&(this._focusedControl&&this._focusedControl.onBlur(),t&&t.onFocus(),this._focusedControl=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isForeground",{get:function(){return!this.layer||!this.layer.isBackground},set:function(t){this.layer&&this.layer.isBackground!==!t&&(this.layer.isBackground=!t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clipboardData",{get:function(){return this._clipboardData},set:function(t){this._clipboardData=t},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"AdvancedDynamicTexture"},e.prototype.executeOnAllControls=function(t,e){e||(e=this._rootContainer),t(e);for(var i=0,r=e.children;i<r.length;i++){var n=r[i];n.children?this.executeOnAllControls(t,n):t(n)}},Object.defineProperty(e.prototype,"useInvalidateRectOptimization",{get:function(){return this._useInvalidateRectOptimization},set:function(t){this._useInvalidateRectOptimization=t},enumerable:!1,configurable:!0}),e.prototype.invalidateRect=function(t,e,i,r){if(this._useInvalidateRectOptimization)if(this._invalidatedRectangle){var n=Math.ceil(Math.max(this._invalidatedRectangle.left+this._invalidatedRectangle.width-1,i)),o=Math.ceil(Math.max(this._invalidatedRectangle.top+this._invalidatedRectangle.height-1,r));this._invalidatedRectangle.left=Math.floor(Math.min(this._invalidatedRectangle.left,t)),this._invalidatedRectangle.top=Math.floor(Math.min(this._invalidatedRectangle.top,e)),this._invalidatedRectangle.width=n-this._invalidatedRectangle.left+1,this._invalidatedRectangle.height=o-this._invalidatedRectangle.top+1}else this._invalidatedRectangle=new _(t,e,i-t+1,r-e+1)},e.prototype.markAsDirty=function(){this._isDirty=!0},e.prototype.createStyle=function(){return new Z(this)},e.prototype.addControl=function(t){return this._rootContainer.addControl(t),this},e.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),this},e.prototype.dispose=function(){var e=this.getScene();e&&(this._rootElement=null,e.onBeforeCameraRenderObservable.remove(this._renderObserver),this._resizeObserver&&e.getEngine().onResizeObservable.remove(this._resizeObserver),this._pointerMoveObserver&&e.onPrePointerObservable.remove(this._pointerMoveObserver),this._pointerObserver&&e.onPointerObservable.remove(this._pointerObserver),this._preKeyboardObserver&&e.onPreKeyboardObservable.remove(this._preKeyboardObserver),this._canvasPointerOutObserver&&e.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver),this._canvasBlurObserver&&e.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver),this._layerToDispose&&(this._layerToDispose.texture=null,this._layerToDispose.dispose(),this._layerToDispose=null),this._rootContainer.dispose(),this.onClipboardObservable.clear(),this.onControlPickedObservable.clear(),this.onBeginRenderObservable.clear(),this.onEndRenderObservable.clear(),this.onBeginLayoutObservable.clear(),this.onEndLayoutObservable.clear(),t.prototype.dispose.call(this))},e.prototype._onResize=function(){var t=this.getScene();if(t){var e=t.getEngine(),i=this.getSize(),r=e.getRenderWidth()*this._renderScale,n=e.getRenderHeight()*this._renderScale;this._renderAtIdealSize&&(this._idealWidth?(n=n*this._idealWidth/r,r=this._idealWidth):this._idealHeight&&(r=r*this._idealHeight/n,n=this._idealHeight)),i.width===r&&i.height===n||(this.scaleTo(r,n),this.markAsDirty(),(this._idealWidth||this._idealHeight)&&this._rootContainer._markAllAsDirty()),this.invalidateRect(0,0,i.width-1,i.height-1)}},e.prototype._getGlobalViewport=function(t){var e=t.getEngine();return this._fullscreenViewport.toGlobal(e.getRenderWidth(),e.getRenderHeight())},e.prototype.getProjectedPosition=function(t,e){var i=this.getScene();if(!i)return s.Vector2.Zero();var r=this._getGlobalViewport(i),n=s.Vector3.Project(t,e,i.getTransformMatrix(),r);return n.scaleInPlace(this.renderScale),new s.Vector2(n.x,n.y)},e.prototype.getProjectedPositionWithZ=function(t,e){var i=this.getScene();if(!i)return s.Vector3.Zero();var r=this._getGlobalViewport(i),n=s.Vector3.Project(t,e,i.getTransformMatrix(),r);return n.scaleInPlace(this.renderScale),new s.Vector3(n.x,n.y,n.z)},e.prototype._checkUpdate=function(t){if(!this._layerToDispose||0!=(t.layerMask&this._layerToDispose.layerMask)){if(this._isFullscreen&&this._linkedControls.length){var e=this.getScene();if(!e)return;for(var i=this._getGlobalViewport(e),r=function(t){if(!t.isVisible)return"continue";var r=t._linkedMesh;if(!r||r.isDisposed())return s.Tools.SetImmediate((function(){t.linkWithMesh(null)})),"continue";var o=r.getBoundingInfo?r.getBoundingInfo().boundingSphere.center:s.Vector3.ZeroReadOnly,a=s.Vector3.Project(o,r.getWorldMatrix(),e.getTransformMatrix(),i);if(a.z<0||a.z>1)return t.notRenderable=!0,"continue";t.notRenderable=!1,a.scaleInPlace(n.renderScale),t._moveToProjectedPosition(a)},n=this,o=0,a=this._linkedControls;o<a.length;o++){r(a[o])}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update(this.applyYInversionOnUpdate,this.premulAlpha))}},e.prototype._render=function(){var t=this.getSize(),e=t.width,i=t.height,r=this.getContext();r.font="18px Arial",r.strokeStyle="white",this.onBeginLayoutObservable.notifyObservers(this);var n=new _(0,0,e,i);this._numLayoutCalls=0,this._rootContainer._layout(n,r),this.onEndLayoutObservable.notifyObservers(this),this._isDirty=!1,this._invalidatedRectangle?this._clearMeasure.copyFrom(this._invalidatedRectangle):this._clearMeasure.copyFromFloats(0,0,e,i),r.clearRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),this._background&&(r.save(),r.fillStyle=this._background,r.fillRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),r.restore()),this.onBeginRenderObservable.notifyObservers(this),this._numRenderCalls=0,this._rootContainer._render(r,this._invalidatedRectangle),this.onEndRenderObservable.notifyObservers(this),this._invalidatedRectangle=null},e.prototype._changeCursor=function(t){this._rootElement&&(this._rootElement.style.cursor=t,this._cursorChanged=!0)},e.prototype._registerLastControlDown=function(t,e){this._lastControlDown[e]=t,this.onControlPickedObservable.notifyObservers(t)},e.prototype._doPicking=function(t,e,i,r,n,o,a,h){var l=this.getScene();if(l){var u=l.getEngine(),c=this.getSize();if(this._isFullscreen){var _=(l.cameraToUseForPointers||l.activeCamera).viewport;t*=c.width/(u.getRenderWidth()*_.width),e*=c.height/(u.getRenderHeight()*_.height)}this._capturingControl[n]?this._capturingControl[n]._processObservables(r,t,e,i,n,o):(this._cursorChanged=!1,this._rootContainer._processPicking(t,e,i,r,n,o,a,h)||(this._changeCursor(""),r===s.PointerEventTypes.POINTERMOVE&&this._lastControlOver[n]&&(this._lastControlOver[n]._onPointerOut(this._lastControlOver[n],i),delete this._lastControlOver[n])),this._cursorChanged||this._changeCursor(""),this._manageFocus())}},e.prototype._cleanControlAfterRemovalFromList=function(t,e){for(var i in t){if(t.hasOwnProperty(i))t[i]===e&&delete t[i]}},e.prototype._cleanControlAfterRemoval=function(t){this._cleanControlAfterRemovalFromList(this._lastControlDown,t),this._cleanControlAfterRemovalFromList(this._lastControlOver,t)},e.prototype.attach=function(){var t=this,e=this.getScene();if(e){var i=new s.Viewport(0,0,0,0);this._pointerMoveObserver=e.onPrePointerObservable.add((function(r,n){if(!e.isPointerCaptured(r.event.pointerId)&&(r.type===s.PointerEventTypes.POINTERMOVE||r.type===s.PointerEventTypes.POINTERUP||r.type===s.PointerEventTypes.POINTERDOWN||r.type===s.PointerEventTypes.POINTERWHEEL)&&e){r.type===s.PointerEventTypes.POINTERMOVE&&r.event.pointerId&&(t._defaultMousePointerId=r.event.pointerId);var o=e.cameraToUseForPointers||e.activeCamera,a=e.getEngine();o?o.viewport.toGlobalToRef(a.getRenderWidth(),a.getRenderHeight(),i):(i.x=0,i.y=0,i.width=a.getRenderWidth(),i.height=a.getRenderHeight());var h=e.pointerX/a.getHardwareScalingLevel()-i.x,l=e.pointerY/a.getHardwareScalingLevel()-(a.getRenderHeight()-i.y-i.height);t._shouldBlockPointer=!1;var u=r.event.pointerId||t._defaultMousePointerId;t._doPicking(h,l,r,r.type,u,r.event.button,r.event.deltaX,r.event.deltaY),t._shouldBlockPointer&&(r.skipOnPointerObservable=t._shouldBlockPointer)}})),this._attachToOnPointerOut(e),this._attachToOnBlur(e)}},e.prototype.registerClipboardEvents=function(){self.addEventListener("copy",this.onClipboardCopy,!1),self.addEventListener("cut",this.onClipboardCut,!1),self.addEventListener("paste",this.onClipboardPaste,!1)},e.prototype.unRegisterClipboardEvents=function(){self.removeEventListener("copy",this.onClipboardCopy),self.removeEventListener("cut",this.onClipboardCut),self.removeEventListener("paste",this.onClipboardPaste)},e.prototype.attachToMesh=function(t,e){var i=this;void 0===e&&(e=!0);var r=this.getScene();r&&(this._pointerObserver=r.onPointerObservable.add((function(e,r){if(e.type===s.PointerEventTypes.POINTERMOVE||e.type===s.PointerEventTypes.POINTERUP||e.type===s.PointerEventTypes.POINTERDOWN){var n=e.event.pointerId||i._defaultMousePointerId;if(e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh===t){var o=e.pickInfo.getTextureCoordinates();if(o){var a=i.getSize();i._doPicking(o.x*a.width,(i.applyYInversionOnUpdate?1-o.y:o.y)*a.height,e,e.type,n,e.event.button)}}else if(e.type===s.PointerEventTypes.POINTERUP){if(i._lastControlDown[n]&&i._lastControlDown[n]._forcePointerUp(n),delete i._lastControlDown[n],i.focusedControl){var h=i.focusedControl.keepsFocusWith(),l=!0;if(h)for(var u=0,c=h;u<c.length;u++){var _=c[u];if(i!==_._host){var d=_._host;if(d._lastControlOver[n]&&d._lastControlOver[n].isAscendant(_)){l=!1;break}}}l&&(i.focusedControl=null)}}else e.type===s.PointerEventTypes.POINTERMOVE&&(i._lastControlOver[n]&&i._lastControlOver[n]._onPointerOut(i._lastControlOver[n],e,!0),delete i._lastControlOver[n])}})),t.enablePointerMoveEvents=e,this._attachToOnPointerOut(r),this._attachToOnBlur(r))},e.prototype.moveFocusToControl=function(t){this.focusedControl=t,this._lastPickedControl=t,this._blockNextFocusCheck=!0},e.prototype._manageFocus=function(){if(this._blockNextFocusCheck)return this._blockNextFocusCheck=!1,void(this._lastPickedControl=this._focusedControl);if(this._focusedControl&&this._focusedControl!==this._lastPickedControl){if(this._lastPickedControl.isFocusInvisible)return;this.focusedControl=null}},e.prototype._attachToOnPointerOut=function(t){var e=this;this._canvasPointerOutObserver=t.getEngine().onCanvasPointerOutObservable.add((function(t){e._lastControlOver[t.pointerId]&&e._lastControlOver[t.pointerId]._onPointerOut(e._lastControlOver[t.pointerId],null),delete e._lastControlOver[t.pointerId],e._lastControlDown[t.pointerId]&&e._lastControlDown[t.pointerId]!==e._capturingControl[t.pointerId]&&(e._lastControlDown[t.pointerId]._forcePointerUp(),delete e._lastControlDown[t.pointerId])}))},e.prototype._attachToOnBlur=function(t){var e=this;this._canvasBlurObserver=t.getEngine().onCanvasBlurObservable.add((function(t){Object.entries(e._lastControlDown).forEach((function(t){t[0];t[1]._onCanvasBlur()})),e._lastControlDown={}}))},e.CreateForMesh=function(t,i,r,n,o,a){void 0===i&&(i=1024),void 0===r&&(r=1024),void 0===n&&(n=!0),void 0===o&&(o=!1);var h=new e(t.name+" AdvancedDynamicTexture",i,r,t.getScene(),!0,s.Texture.TRILINEAR_SAMPLINGMODE,a),l=new s.StandardMaterial("AdvancedDynamicTextureMaterial",t.getScene());return l.backFaceCulling=!1,l.diffuseColor=s.Color3.Black(),l.specularColor=s.Color3.Black(),o?(l.diffuseTexture=h,l.emissiveTexture=h,h.hasAlpha=!0):(l.emissiveTexture=h,l.opacityTexture=h),t.material=l,h.attachToMesh(t,n),h},e.CreateForMeshTexture=function(t,i,r,n,o){void 0===i&&(i=1024),void 0===r&&(r=1024),void 0===n&&(n=!0);var a=new e(t.name+" AdvancedDynamicTexture",i,r,t.getScene(),!0,s.Texture.TRILINEAR_SAMPLINGMODE,o);return a.attachToMesh(t,n),a},e.CreateFullscreenUI=function(t,i,r,n){void 0===i&&(i=!0),void 0===r&&(r=null),void 0===n&&(n=s.Texture.BILINEAR_SAMPLINGMODE);var o=new e(t,0,0,r,!1,n),a=new s.Layer(t+"_layer",null,r,!i);return a.texture=o,o._layerToDispose=a,o._isFullscreen=!0,o.attach(),o},e}(s.DynamicTexture),Q=function(){function t(t){this.texture=t,this._captureRenderTime=!1,this._renderTime=new s.PerfCounter,this._captureLayoutTime=!1,this._layoutTime=new s.PerfCounter,this._onBeginRenderObserver=null,this._onEndRenderObserver=null,this._onBeginLayoutObserver=null,this._onEndLayoutObserver=null}return Object.defineProperty(t.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layoutTimeCounter",{get:function(){return this._layoutTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var e=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeginRenderObserver=this.texture.onBeginRenderObservable.add((function(){e._renderTime.beginMonitoring()})),this._onEndRenderObserver=this.texture.onEndRenderObservable.add((function(){e._renderTime.endMonitoring(!0)}))):(this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureLayoutTime",{get:function(){return this._captureLayoutTime},set:function(t){var e=this;t!==this._captureLayoutTime&&(this._captureLayoutTime=t,t?(this._onBeginLayoutObserver=this.texture.onBeginLayoutObservable.add((function(){e._layoutTime.beginMonitoring()})),this._onEndLayoutObserver=this.texture.onEndLayoutObservable.add((function(){e._layoutTime.endMonitoring(!0)}))):(this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null))},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null,this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null,this.texture=null},t}(),$=function(){function t(t){void 0===t&&(t=null),this._nodes={},this._nodeTypes={element:1,attribute:2,text:3},this._isLoaded=!1,this._objectAttributes={textHorizontalAlignment:1,textVerticalAlignment:2,horizontalAlignment:3,verticalAlignment:4,stretch:5},t&&(this._parentClass=t)}return t.prototype._getChainElement=function(t){var e=window;this._parentClass&&(e=this._parentClass);var i=t;i=i.split(".");for(var r=0;r<i.length;r++)e=e[i[r]];return e},t.prototype._getClassAttribute=function(t){var e=t.split(".");return s._TypeStore.GetClass("BABYLON.GUI."+e[0])[e[1]]},t.prototype._createGuiElement=function(t,e,i){void 0===i&&(i=!0);try{var r=new(s._TypeStore.GetClass("BABYLON.GUI."+t.nodeName));e&&i&&e.addControl(r);for(var n=0;n<t.attributes.length;n++)if(!t.attributes[n].name.toLowerCase().includes("datasource"))if(t.attributes[n].name.toLowerCase().includes("observable")){var o=this._getChainElement(t.attributes[n].value);r[t.attributes[n].name].add(o)}else if("linkWithMesh"==t.attributes[n].name)this._parentClass?r.linkWithMesh(this._parentClass[t.attributes[n].value]):r.linkWithMesh(window[t.attributes[n].value]);else if(t.attributes[n].value.startsWith("{{")&&t.attributes[n].value.endsWith("}}")){o=this._getChainElement(t.attributes[n].value.substring(2,t.attributes[n].value.length-2));r[t.attributes[n].name]=o}else this._objectAttributes[t.attributes[n].name]?r[t.attributes[n].name]=this._getClassAttribute(t.attributes[n].value):"true"==t.attributes[n].value||"false"==t.attributes[n].value?r[t.attributes[n].name]="true"==t.attributes[n].value:r[t.attributes[n].name]=isNaN(Number(t.attributes[n].value))?t.attributes[n].value:Number(t.attributes[n].value);if(!t.attributes.getNamedItem("id"))return this._nodes[t.nodeName+Object.keys(this._nodes).length+"_gen"]=r,r;var a=t.attributes.getNamedItem("id").value;if(a.startsWith("{{")&&a.endsWith("}}")&&(a=this._getChainElement(a.substring(2,a.length-2))),this._nodes[a])throw"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";return this._nodes[a]=r,r}catch(e){throw"XmlLoader Exception : Error parsing Control "+t.nodeName+","+e+"."}},t.prototype._parseGrid=function(t,e,i){for(var r,n,o,s,a,h=t.children,l=!1,u=-1,c=-1,_=0,d=0;d<h.length;d++)if(h[d].nodeType==this._nodeTypes.element){if("Row"!=h[d].nodeName)throw"XmlLoader Exception : Expecting Row node, received "+h[d].nodeName;if(u+=1,o=h[d].children,!h[d].attributes.getNamedItem("height"))throw"XmlLoader Exception : Height must be defined for grid rows";n=Number(h[d].attributes.getNamedItem("height").nodeValue),l=!!h[d].attributes.getNamedItem("isPixel")&&JSON.parse(h[d].attributes.getNamedItem("isPixel").nodeValue),e.addRowDefinition(n,l);for(var p=0;p<o.length;p++)if(o[p].nodeType==this._nodeTypes.element){if("Column"!=o[p].nodeName)throw"XmlLoader Exception : Expecting Column node, received "+o[p].nodeName;if(c+=1,u>0&&c>_)throw"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";if(0==u){if(!o[p].attributes.getNamedItem("width"))throw"XmlLoader Exception : Width must be defined for all the grid columns in the first row";r=Number(o[p].attributes.getNamedItem("width").nodeValue),l=!!o[p].attributes.getNamedItem("isPixel")&&JSON.parse(o[p].attributes.getNamedItem("isPixel").nodeValue),e.addColumnDefinition(r,l)}s=o[p].children;for(var f=0;f<s.length;f++)s[f].nodeType==this._nodeTypes.element&&(a=this._createGuiElement(s[f],e,!1),e.addControl(a,u,c),s[f].firstChild&&this._parseXml(s[f].firstChild,a))}0==u&&(_=c),c=-1}t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._parseElement=function(t,e,i){t.firstChild&&this._parseXml(t.firstChild,e),t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._prepareSourceElement=function(t,e,i,r,n){this._parentClass?this._parentClass[i]=r[n]:window[i]=r[n],t.firstChild&&this._parseXml(t.firstChild,e,!0)},t.prototype._parseElementsFromSource=function(t,e,i){var r=t.attributes.getNamedItem("dataSource").value;if(!r.includes(" in "))throw"XmlLoader Exception : Malformed XML, Data Source must include an in";var n=!0,o=r.split(" in ");if(o.length<2)throw"XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";var s=o[1];if(s.startsWith("{")&&s.endsWith("}")&&(n=!1),(!n||s.startsWith("[")&&s.endsWith("]"))&&(s=s.substring(1,s.length-1)),s=this._parentClass?this._parentClass[s]:window[s],n)for(var a=0;a<s.length;a++)this._prepareSourceElement(t,e,o[0],s,a);else for(var a in s)this._prepareSourceElement(t,e,o[0],s,a);t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._parseXml=function(t,e,i){if(void 0===i&&(i=!1),t.nodeType==this._nodeTypes.element){i&&t.setAttribute("id",e.id+(e._children.length+1));var r=this._createGuiElement(t,e);"Grid"==t.nodeName?this._parseGrid(t,r,e):t.attributes.getNamedItem("dataSource")?this._parseElementsFromSource(t,r,e):this._parseElement(t,r,e)}else t.nextSibling&&this._parseXml(t.nextSibling,e,i)},t.prototype.isLoaded=function(){return this._isLoaded},t.prototype.getNodeById=function(t){return this._nodes[t]},t.prototype.getNodes=function(){return this._nodes},t.prototype.loadLayout=function(t,e,i){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4==r.readyState&&200==r.status){if(!r.responseXML)throw"XmlLoader Exception : XML file is malformed or corrupted.";var t=r.responseXML.documentElement;this._parseXml(t.firstChild,e),this._isLoaded=!0,i&&i()}}.bind(this),r.open("GET",t,!0),r.send()},t}(),tt=function(t){function e(e,i){void 0===i&&(i=0);var r=t.call(this,e.x,e.y,e.z)||this;return r.buttonIndex=i,r}return n(e,t),e}(s.Vector3),et=function(){function t(t){this.name=t,this._downCount=0,this._enterCount=-1,this._downPointerIds={},this._isVisible=!0,this.onPointerMoveObservable=new s.Observable,this.onPointerOutObservable=new s.Observable,this.onPointerDownObservable=new s.Observable,this.onPointerUpObservable=new s.Observable,this.onPointerClickObservable=new s.Observable,this.onPointerEnterObservable=new s.Observable,this._behaviors=new Array}return Object.defineProperty(t.prototype,"position",{get:function(){return this._node?this._node.position:s.Vector3.Zero()},set:function(t){this._node&&(this._node.position=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._node?this._node.scaling:new s.Vector3(1,1,1)},set:function(t){this._node&&(this._node.scaling=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),t.prototype.addBehavior=function(t){var e=this;if(-1!==this._behaviors.indexOf(t))return this;t.init();var i=this._host.scene;return i.isLoading?i.onDataLoadedObservable.addOnce((function(){t.attach(e)})):t.attach(this),this._behaviors.push(t),this},t.prototype.removeBehavior=function(t){var e=this._behaviors.indexOf(t);return-1===e||(this._behaviors[e].detach(),this._behaviors.splice(e,1)),this},t.prototype.getBehaviorByName=function(t){for(var e=0,i=this._behaviors;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},Object.defineProperty(t.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){if(this._isVisible!==t){this._isVisible=t;var e=this.mesh;e&&e.setEnabled(t)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return this._getTypeName()},t.prototype._getTypeName=function(){return"Control3D"},Object.defineProperty(t.prototype,"node",{get:function(){return this._node},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._node instanceof s.AbstractMesh?this._node:null},enumerable:!1,configurable:!0}),t.prototype.linkToTransformNode=function(t){return this._node&&(this._node.parent=t),this},t.prototype._prepareNode=function(t){if(!this._node){if(this._node=this._createNode(t),!this.node)return;this._node.metadata=this,this._node.position=this.position,this._node.scaling=this.scaling;var e=this.mesh;e&&(e.isPickable=!0,this._affectMaterial(e))}},t.prototype._createNode=function(t){return null},t.prototype._affectMaterial=function(t){t.material=null},t.prototype._onPointerMove=function(t,e){this.onPointerMoveObservable.notifyObservers(e,-1,t,this)},t.prototype._onPointerEnter=function(t){return!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this),this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},t.prototype._onPointerOut=function(t){this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this),this.pointerOutAnimation&&this.pointerOutAnimation()},t.prototype._onPointerDown=function(t,e,i,r){return 0!==this._downCount?(this._downCount++,!1):(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new tt(e,r),-1,t,this),this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},t.prototype._onPointerUp=function(t,e,i,r,n){this._downCount--,delete this._downPointerIds[i],this._downCount<0?this._downCount=0:0==this._downCount&&(n&&(this._enterCount>0||-1===this._enterCount)&&this.onPointerClickObservable.notifyObservers(new tt(e,r),-1,t,this),this.onPointerUpObservable.notifyObservers(new tt(e,r),-1,t,this),this.pointerUpAnimation&&this.pointerUpAnimation())},t.prototype.forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector3.Zero(),t,0,!0);else{for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector3.Zero(),+e,0,!0);this._downCount>0&&(this._downCount=1,this._onPointerUp(this,s.Vector3.Zero(),0,0,!0))}},t.prototype._processObservables=function(t,e,i,r){if(t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,e);var n=this._host._lastControlOver[i];return n&&n!==this&&n._onPointerOut(this),n!==this&&this._onPointerEnter(this),this._host._lastControlOver[i]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,e,i,r),this._host._lastControlDown[i]=this,this._host._lastPickedControl=this,!0):(t===s.PointerEventTypes.POINTERUP||t===s.PointerEventTypes.POINTERDOUBLETAP)&&(this._host._lastControlDown[i]&&this._host._lastControlDown[i]._onPointerUp(this,e,i,r,!0),delete this._host._lastControlDown[i],!0)},t.prototype._disposeNode=function(){this._node&&(this._node.dispose(),this._node=null)},t.prototype.dispose=function(){this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._disposeNode();for(var t=0,e=this._behaviors;t<e.length;t++){e[t].detach()}},t}(),it=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e.prototype._getTypeName=function(){return"AbstractButton3D"},e.prototype._createNode=function(t){return new s.TransformNode("button"+this.name)},e}(et),rt=function(t){function e(e){var i=t.call(this,e)||this;return i._contentResolution=512,i._contentScaleRatio=2,i.pointerEnterAnimation=function(){i.mesh&&(i._currentMaterial.emissiveColor=s.Color3.Red())},i.pointerOutAnimation=function(){i._currentMaterial.emissiveColor=s.Color3.Black()},i.pointerDownAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(.95)},i.pointerUpAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(1/.95)},i}return n(e,t),Object.defineProperty(e.prototype,"contentResolution",{get:function(){return this._contentResolution},set:function(t){this._contentResolution!==t&&(this._contentResolution=t,this._resetContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contentScaleRatio",{get:function(){return this._contentScaleRatio},set:function(t){this._contentScaleRatio!==t&&(this._contentScaleRatio=t,this._resetContent())},enumerable:!1,configurable:!0}),e.prototype._disposeFacadeTexture=function(){this._facadeTexture&&(this._facadeTexture.dispose(),this._facadeTexture=null)},e.prototype._resetContent=function(){this._disposeFacadeTexture(),this.content=this._content},Object.defineProperty(e.prototype,"content",{get:function(){return this._content},set:function(t){this._content=t,this._host&&this._host.utilityLayer&&(this._facadeTexture?this._facadeTexture.rootContainer.clearControls():(this._facadeTexture=new J("Facade",this._contentResolution,this._contentResolution,this._host.utilityLayer.utilityLayerScene,!0,s.Texture.TRILINEAR_SAMPLINGMODE),this._facadeTexture.rootContainer.scaleX=this._contentScaleRatio,this._facadeTexture.rootContainer.scaleY=this._contentScaleRatio,this._facadeTexture.premulAlpha=!0),this._facadeTexture.addControl(t),this._applyFacade(this._facadeTexture))},enumerable:!1,configurable:!0}),e.prototype._applyFacade=function(t){this._currentMaterial.emissiveTexture=t},e.prototype._getTypeName=function(){return"Button3D"},e.prototype._createNode=function(t){for(var e=new Array(6),i=0;i<6;i++)e[i]=new s.Vector4(0,0,0,0);return e[1]=new s.Vector4(0,0,1,1),s.BoxBuilder.CreateBox(this.name+"_rootMesh",{width:1,height:1,depth:.08,faceUV:e},t)},e.prototype._affectMaterial=function(t){var e=new s.StandardMaterial(this.name+"Material",t.getScene());e.specularColor=s.Color3.Black(),t.material=e,this._currentMaterial=e,this._resetContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeFacadeTexture(),this._currentMaterial&&this._currentMaterial.dispose()},e}(it),nt=function(t){function e(e){var i=t.call(this,e)||this;return i._blockLayout=!1,i._children=new Array,i}return n(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blockLayout",{get:function(){return this._blockLayout},set:function(t){this._blockLayout!==t&&(this._blockLayout=t,this._blockLayout||this._arrangeChildren())},enumerable:!1,configurable:!0}),e.prototype.updateLayout=function(){return this._arrangeChildren(),this},e.prototype.containsControl=function(t){return-1!==this._children.indexOf(t)},e.prototype.addControl=function(t){return-1!==this._children.indexOf(t)||(t.parent=this,t._host=this._host,this._children.push(t),this._host.utilityLayer&&(t._prepareNode(this._host.utilityLayer.utilityLayerScene),t.node&&(t.node.parent=this.node),this.blockLayout||this._arrangeChildren())),this},e.prototype._arrangeChildren=function(){},e.prototype._createNode=function(t){return new s.TransformNode("ContainerNode",t)},e.prototype.removeControl=function(t){var e=this._children.indexOf(t);return-1!==e&&(this._children.splice(e,1),t.parent=null,t._disposeNode()),this},e.prototype._getTypeName=function(){return"Container3D"},e.prototype.dispose=function(){for(var e=0,i=this._children;e<i.length;e++){i[e].dispose()}this._children=[],t.prototype.dispose.call(this)},e.UNSET_ORIENTATION=0,e.FACEORIGIN_ORIENTATION=1,e.FACEORIGINREVERSED_ORIENTATION=2,e.FACEFORWARD_ORIENTATION=3,e.FACEFORWARDREVERSED_ORIENTATION=4,e}(et),ot=function(t){function e(){var e=t.call(this)||this;return e._columns=10,e._rows=0,e._rowThenColum=!0,e._orientation=nt.FACEORIGIN_ORIENTATION,e.margin=0,e}return n(e,t),Object.defineProperty(e.prototype,"orientation",{get:function(){return this._orientation},set:function(t){var e=this;this._orientation!==t&&(this._orientation=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._columns},set:function(t){var e=this;this._columns!==t&&(this._columns=t,this._rowThenColum=!0,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},set:function(t){var e=this;this._rows!==t&&(this._rows=t,this._rowThenColum=!1,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._arrangeChildren=function(){this._cellWidth=0,this._cellHeight=0;for(var t=0,e=0,i=0,r=s.Matrix.Invert(this.node.computeWorldMatrix(!0)),n=0,o=this._children;n<o.length;n++){if((b=o[n]).mesh){i++,b.mesh.computeWorldMatrix(!0);var a=b.mesh.getHierarchyBoundingVectors(),h=s.TmpVectors.Vector3[0],l=s.TmpVectors.Vector3[1];a.max.subtractToRef(a.min,l),l.scaleInPlace(.5),s.Vector3.TransformNormalToRef(l,r,h),this._cellWidth=Math.max(this._cellWidth,2*h.x),this._cellHeight=Math.max(this._cellHeight,2*h.y)}}this._cellWidth+=2*this.margin,this._cellHeight+=2*this.margin,this._rowThenColum?(e=this._columns,t=Math.ceil(i/this._columns)):(t=this._rows,e=Math.ceil(i/this._rows));var u=.5*e*this._cellWidth,c=.5*t*this._cellHeight,_=[],d=0;if(this._rowThenColum)for(var p=0;p<t;p++)for(var f=0;f<e&&(_.push(new s.Vector3(f*this._cellWidth-u+this._cellWidth/2,p*this._cellHeight-c+this._cellHeight/2,0)),!(++d>i));f++);else for(f=0;f<e;f++)for(p=0;p<t&&(_.push(new s.Vector3(f*this._cellWidth-u+this._cellWidth/2,p*this._cellHeight-c+this._cellHeight/2,0)),!(++d>i));p++);d=0;for(var g=0,m=this._children;g<m.length;g++){var b;(b=m[g]).mesh&&(this._mapGridNode(b,_[d]),d++)}this._finalProcessing()},e.prototype._finalProcessing=function(){},e}(nt),st=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._radius=5,e}return n(e,t),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){var e=this;this._radius!==t&&(this._radius=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){var r=this._cylindricalMapping(e);switch(t.position=r,this.orientation){case nt.FACEORIGIN_ORIENTATION:i.lookAt(new s.Vector3(2*r.x,r.y,2*r.z));break;case nt.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(-r.x,r.y,-r.z));break;case nt.FACEFORWARD_ORIENTATION:break;case nt.FACEFORWARDREVERSED_ORIENTATION:i.rotate(s.Axis.Y,Math.PI,s.Space.LOCAL)}}},e.prototype._cylindricalMapping=function(t){var e=new s.Vector3(0,t.y,this._radius),i=t.x/this._radius;return s.Matrix.RotationYawPitchRollToRef(i,0,0,s.TmpVectors.Matrix[0]),s.Vector3.TransformNormal(e,s.TmpVectors.Matrix[0])},e}(ot),at="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";s.Effect.ShadersStore.fluentVertexShader=at;var ht="precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";s.Effect.ShadersStore.fluentPixelShader=ht;var lt=function(t){function e(){var e=t.call(this)||this;return e.INNERGLOW=!1,e.BORDER=!1,e.HOVERLIGHT=!1,e.TEXTURE=!1,e.rebuild(),e}return n(e,t),e}(s.MaterialDefines),ut=function(t){function e(e,i){var r=t.call(this,e,i)||this;return r.innerGlowColorIntensity=.5,r.innerGlowColor=new s.Color3(1,1,1),r.albedoColor=new s.Color3(.3,.35,.4),r.renderBorders=!1,r.borderWidth=.5,r.edgeSmoothingValue=.02,r.borderMinValue=.1,r.renderHoverLight=!1,r.hoverRadius=1,r.hoverColor=new s.Color4(.3,.3,.3,1),r.hoverPosition=s.Vector3.Zero(),r}return n(e,t),e.prototype.needAlphaBlending=function(){return 1!==this.alpha},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e,i){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e._materialDefines||(e._materialDefines=new lt);var r=this.getScene(),n=e._materialDefines;if(!this.checkReadyOnEveryCall&&e.effect&&n._renderId===r.getRenderId())return!0;if(n._areTexturesDirty)if(n.INNERGLOW=this.innerGlowColorIntensity>0,n.BORDER=this.renderBorders,n.HOVERLIGHT=this.renderHoverLight,this._albedoTexture){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;n.TEXTURE=!0}else n.TEXTURE=!1;var o=r.getEngine();if(n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var a=[s.VertexBuffer.PositionKind];a.push(s.VertexBuffer.NormalKind),a.push(s.VertexBuffer.UVKind);var h=["world","viewProjection","innerGlowColor","albedoColor","borderWidth","edgeSmoothingValue","scaleFactor","borderMinValue","hoverColor","hoverPosition","hoverRadius"],l=["albedoSampler"],u=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:u,samplers:l,defines:n,maxSimultaneousLights:4});var c=n.toString();e.setEffect(r.getEngine().createEffect("fluent",{attributes:a,uniformsNames:h,uniformBuffersNames:u,samplers:l,defines:c,fallbacks:null,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o))}return!(!e.effect||!e.effect.isReady())&&(n._renderId=r.getRenderId(),e.effect._wasPreviouslyReady=!0,!0)},e.prototype.bindForSubMesh=function(t,e,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",r.getTransformMatrix()),this._mustRebind(r,o)&&(this._activeEffect.setColor4("albedoColor",this.albedoColor,this.alpha),n.INNERGLOW&&this._activeEffect.setColor4("innerGlowColor",this.innerGlowColor,this.innerGlowColorIntensity),n.BORDER&&(this._activeEffect.setFloat("borderWidth",this.borderWidth),this._activeEffect.setFloat("edgeSmoothingValue",this.edgeSmoothingValue),this._activeEffect.setFloat("borderMinValue",this.borderMinValue),e.getBoundingInfo().boundingBox.extendSize.multiplyToRef(e.scaling,s.TmpVectors.Vector3[0]),this._activeEffect.setVector3("scaleFactor",s.TmpVectors.Vector3[0])),n.HOVERLIGHT&&(this._activeEffect.setDirectColor4("hoverColor",this.hoverColor),this._activeEffect.setFloat("hoverRadius",this.hoverRadius),this._activeEffect.setVector3("hoverPosition",this.hoverPosition)),n.TEXTURE&&this._activeEffect.setTexture("albedoSampler",this._albedoTexture)),this._afterBind(e,this._activeEffect))}},e.prototype.getActiveTextures=function(){return t.prototype.getActiveTextures.call(this)},e.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var t=s.SerializationHelper.Serialize(this);return t.customType="BABYLON.GUI.FluentMaterial",t},e.prototype.getClassName=function(){return"FluentMaterial"},e.Parse=function(t,i,r){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,r)},o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"innerGlowColorIntensity",void 0),o([Object(s.serializeAsColor3)()],e.prototype,"innerGlowColor",void 0),o([Object(s.serializeAsColor3)()],e.prototype,"albedoColor",void 0),o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderBorders",void 0),o([Object(s.serialize)()],e.prototype,"borderWidth",void 0),o([Object(s.serialize)()],e.prototype,"edgeSmoothingValue",void 0),o([Object(s.serialize)()],e.prototype,"borderMinValue",void 0),o([Object(s.serialize)(),Object(s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderHoverLight",void 0),o([Object(s.serialize)()],e.prototype,"hoverRadius",void 0),o([Object(s.serializeAsColor4)()],e.prototype,"hoverColor",void 0),o([Object(s.serializeAsVector3)()],e.prototype,"hoverPosition",void 0),o([Object(s.serializeAsTexture)("albedoTexture")],e.prototype,"_albedoTexture",void 0),o([Object(s.expandToProperty)("_markAllSubMeshesAsTexturesAndMiscDirty")],e.prototype,"albedoTexture",void 0),e}(s.PushMaterial);s._TypeStore.RegisteredTypes["BABYLON.GUI.FluentMaterial"]=ut;var ct=function(t){function e(e,i){void 0===i&&(i=!0);var r=t.call(this,e)||this;return r._shareMaterials=!0,r._shareMaterials=i,r.pointerEnterAnimation=function(){r.mesh&&r._frontPlate.setEnabled(!0)},r.pointerOutAnimation=function(){r.mesh&&r._frontPlate.setEnabled(!1)},r}return n(e,t),e.prototype._disposeTooltip=function(){this._tooltipFade=null,this._tooltipTextBlock&&this._tooltipTextBlock.dispose(),this._tooltipTexture&&this._tooltipTexture.dispose(),this._tooltipMesh&&this._tooltipMesh.dispose(),this.onPointerEnterObservable.remove(this._tooltipHoverObserver),this.onPointerOutObservable.remove(this._tooltipOutObserver)},Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._backPlate.renderingGroupId},set:function(t){this._backPlate.renderingGroupId=t,this._textPlate.renderingGroupId=t,this._frontPlate.renderingGroupId=t,this._tooltipMesh&&(this._tooltipMesh.renderingGroupId=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tooltipText",{get:function(){return this._tooltipTextBlock?this._tooltipTextBlock.text:null},set:function(t){var e=this;if(t){if(!this._tooltipFade){this._tooltipMesh=s.PlaneBuilder.CreatePlane("",{size:1},this._backPlate._scene);var i=s.PlaneBuilder.CreatePlane("",{size:1,sideOrientation:s.Mesh.DOUBLESIDE},this._backPlate._scene),r=new s.StandardMaterial("",this._backPlate._scene);r.diffuseColor=s.Color3.FromHexString("#212121"),i.material=r,i.isPickable=!1,this._tooltipMesh.addChild(i),i.position.z=.05,this._tooltipMesh.scaling.y=1/3,this._tooltipMesh.position.y=.7,this._tooltipMesh.position.z=-.15,this._tooltipMesh.isPickable=!1,this._tooltipMesh.parent=this._backPlate,this._tooltipTexture=J.CreateForMesh(this._tooltipMesh),this._tooltipTextBlock=new y,this._tooltipTextBlock.scaleY=3,this._tooltipTextBlock.color="white",this._tooltipTextBlock.fontSize=130,this._tooltipTexture.addControl(this._tooltipTextBlock),this._tooltipFade=new s.FadeInOutBehavior,this._tooltipFade.delay=500,this._tooltipMesh.addBehavior(this._tooltipFade),this._tooltipHoverObserver=this.onPointerEnterObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!0)})),this._tooltipOutObserver=this.onPointerOutObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!1)}))}this._tooltipTextBlock&&(this._tooltipTextBlock.text=t)}else this._disposeTooltip()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageUrl",{get:function(){return this._imageUrl},set:function(t){this._imageUrl!==t&&(this._imageUrl=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backMaterial",{get:function(){return this._backMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontMaterial",{get:function(){return this._frontMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plateMaterial",{get:function(){return this._plateMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shareMaterials",{get:function(){return this._shareMaterials},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"HolographicButton"},e.prototype._rebuildContent=function(){this._disposeFacadeTexture();var t=new C;if(t.isVertical=!0,this._imageUrl){var e=new v;e.source=this._imageUrl,e.paddingTop="40px",e.height="180px",e.width="100px",e.paddingBottom="40px",t.addControl(e)}if(this._text){var i=new y;i.text=this._text,i.color="white",i.height="30px",i.fontSize=24,t.addControl(i)}this._frontPlate&&(this.content=t)},e.prototype._createNode=function(e){return this._backPlate=s.BoxBuilder.CreateBox(this.name+"BackMesh",{width:1,height:1,depth:.08},e),this._frontPlate=s.BoxBuilder.CreateBox(this.name+"FrontMesh",{width:1,height:1,depth:.08},e),this._frontPlate.parent=this._backPlate,this._frontPlate.position.z=-.08,this._frontPlate.isPickable=!1,this._frontPlate.setEnabled(!1),this._textPlate=t.prototype._createNode.call(this,e),this._textPlate.parent=this._backPlate,this._textPlate.position.z=-.08,this._textPlate.isPickable=!1,this._backPlate},e.prototype._applyFacade=function(t){this._plateMaterial.emissiveTexture=t,this._plateMaterial.opacityTexture=t},e.prototype._createBackMaterial=function(t){var e=this;this._backMaterial=new ut(this.name+"Back Material",t.getScene()),this._backMaterial.renderHoverLight=!0,this._pickedPointObserver=this._host.onPickedPointChangedObservable.add((function(t){t?(e._backMaterial.hoverPosition=t,e._backMaterial.hoverColor.a=1):e._backMaterial.hoverColor.a=0}))},e.prototype._createFrontMaterial=function(t){this._frontMaterial=new ut(this.name+"Front Material",t.getScene()),this._frontMaterial.innerGlowColorIntensity=0,this._frontMaterial.alpha=.5,this._frontMaterial.renderBorders=!0},e.prototype._createPlateMaterial=function(t){this._plateMaterial=new s.StandardMaterial(this.name+"Plate Material",t.getScene()),this._plateMaterial.specularColor=s.Color3.Black()},e.prototype._affectMaterial=function(t){this._shareMaterials?(this._host._sharedMaterials.backFluentMaterial?this._backMaterial=this._host._sharedMaterials.backFluentMaterial:(this._createBackMaterial(t),this._host._sharedMaterials.backFluentMaterial=this._backMaterial),this._host._sharedMaterials.frontFluentMaterial?this._frontMaterial=this._host._sharedMaterials.frontFluentMaterial:(this._createFrontMaterial(t),this._host._sharedMaterials.frontFluentMaterial=this._frontMaterial)):(this._createBackMaterial(t),this._createFrontMaterial(t)),this._createPlateMaterial(t),this._backPlate.material=this._backMaterial,this._frontPlate.material=this._frontMaterial,this._textPlate.material=this._plateMaterial,this._rebuildContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeTooltip(),this.shareMaterials||(this._backMaterial.dispose(),this._frontMaterial.dispose(),this._plateMaterial.dispose(),this._pickedPointObserver&&(this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver),this._pickedPointObserver=null))},e}(rt),_t=function(t){function e(e,i){var r=t.call(this,i)||this;return r._currentMesh=e,r.pointerEnterAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1.1)},r.pointerOutAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1/1.1)},r.pointerDownAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(.95)},r.pointerUpAnimation=function(){r.mesh&&r.mesh.scaling.scaleInPlace(1/.95)},r}return n(e,t),e.prototype._getTypeName=function(){return"MeshButton3D"},e.prototype._createNode=function(t){var e=this;return this._currentMesh.getChildMeshes().forEach((function(t){t.metadata=e})),this._currentMesh},e.prototype._affectMaterial=function(t){},e}(rt),dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){t.position=e.clone();var r=s.TmpVectors.Vector3[0];switch(r.copyFrom(e),this.orientation){case nt.FACEORIGIN_ORIENTATION:case nt.FACEFORWARD_ORIENTATION:r.addInPlace(new s.Vector3(0,0,1)),i.lookAt(r);break;case nt.FACEFORWARDREVERSED_ORIENTATION:case nt.FACEORIGINREVERSED_ORIENTATION:r.addInPlace(new s.Vector3(0,0,-1)),i.lookAt(r)}}},e}(ot),pt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._iteration=100,e}return n(e,t),Object.defineProperty(e.prototype,"iteration",{get:function(){return this._iteration},set:function(t){var e=this;this._iteration!==t&&(this._iteration=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh,r=this._scatterMapping(e);if(i){switch(this.orientation){case nt.FACEORIGIN_ORIENTATION:case nt.FACEFORWARD_ORIENTATION:i.lookAt(new s.Vector3(0,0,1));break;case nt.FACEFORWARDREVERSED_ORIENTATION:case nt.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(0,0,-1))}t.position=r}},e.prototype._scatterMapping=function(t){return t.x=(1-2*Math.random())*this._cellWidth,t.y=(1-2*Math.random())*this._cellHeight,t},e.prototype._finalProcessing=function(){for(var t=[],e=0,i=this._children;e<i.length;e++){var r=i[e];r.mesh&&t.push(r.mesh)}for(var n=0;n<this._iteration;n++){t.sort((function(t,e){var i=t.position.lengthSquared(),r=e.position.lengthSquared();return i<r?1:i>r?-1:0}));for(var o=Math.pow(this.margin,2),a=Math.max(this._cellWidth,this._cellHeight),h=s.TmpVectors.Vector2[0],l=s.TmpVectors.Vector3[0],u=0;u<t.length-1;u++)for(var c=u+1;c<t.length;c++)if(u!=c){t[c].position.subtractToRef(t[u].position,l),h.x=l.x,h.y=l.y;var _=a,d=h.lengthSquared()-o;(d-=Math.min(d,o))<Math.pow(_,2)&&(h.normalize(),l.scaleInPlace(.5*(_-Math.sqrt(d))),t[c].position.addInPlace(l),t[u].position.subtractInPlace(l))}}},e}(ot),ft=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._radius=5,e}return n(e,t),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){var e=this;this._radius!==t&&(this._radius=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){var r=this._sphericalMapping(e);switch(t.position=r,this.orientation){case nt.FACEORIGIN_ORIENTATION:i.lookAt(new s.Vector3(2*r.x,2*r.y,2*r.z));break;case nt.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(-r.x,-r.y,-r.z));break;case nt.FACEFORWARD_ORIENTATION:break;case nt.FACEFORWARDREVERSED_ORIENTATION:i.rotate(s.Axis.Y,Math.PI,s.Space.LOCAL)}}},e.prototype._sphericalMapping=function(t){var e=new s.Vector3(0,0,this._radius),i=t.y/this._radius,r=-t.x/this._radius;return s.Matrix.RotationYawPitchRollToRef(r,i,0,s.TmpVectors.Matrix[0]),s.Vector3.TransformNormal(e,s.TmpVectors.Matrix[0])},e}(ot),gt=function(t){function e(e){void 0===e&&(e=!1);var i=t.call(this)||this;return i._isVertical=!1,i.margin=.1,i._isVertical=e,i}return n(e,t),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){var e=this;this._isVertical!==t&&(this._isVertical=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._arrangeChildren=function(){for(var t,e=0,i=0,r=0,n=[],o=s.Matrix.Invert(this.node.computeWorldMatrix(!0)),a=0,h=this._children;a<h.length;a++){if((p=h[a]).mesh){r++,p.mesh.computeWorldMatrix(!0),p.mesh.getWorldMatrix().multiplyToRef(o,s.TmpVectors.Matrix[0]);var l=p.mesh.getBoundingInfo().boundingBox,u=s.Vector3.TransformNormal(l.extendSize,s.TmpVectors.Matrix[0]);n.push(u),this._isVertical?i+=u.y:e+=u.x}}this._isVertical?i+=(r-1)*this.margin/2:e+=(r-1)*this.margin/2,t=this._isVertical?-i:-e;for(var c=0,_=0,d=this._children;_<d.length;_++){var p;if((p=d[_]).mesh){r--;u=n[c++];this._isVertical?(p.position.y=t+u.y,p.position.x=0,t+=2*u.y):(p.position.x=t+u.x,p.position.y=0,t+=2*u.x),t+=r>0?this.margin:0}}},e}(nt),mt=function(){function t(t){var e=this;this._lastControlOver={},this._lastControlDown={},this.onPickedPointChangedObservable=new s.Observable,this._sharedMaterials={},this._scene=t||s.EngineStore.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add((function(){e._sceneDisposeObserver=null,e._utilityLayer=null,e.dispose()})),this._utilityLayer=new s.UtilityLayerRenderer(this._scene),this._utilityLayer.onlyCheckPointerDownEvents=!1,this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.mainSceneTrackerPredicate=function(t){return t&&t.metadata&&t.metadata._node},this._rootContainer=new nt("RootContainer"),this._rootContainer._host=this;var i=this._utilityLayer.utilityLayerScene;this._pointerOutObserver=this._utilityLayer.onPointerOutObservable.add((function(t){e._handlePointerOut(t,!0)})),this._pointerObserver=i.onPointerObservable.add((function(t,i){e._doPicking(t)})),this._utilityLayer.utilityLayerScene.autoClear=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,new s.HemisphericLight("hemi",s.Vector3.Up(),this._utilityLayer.utilityLayerScene)}return Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),t.prototype._handlePointerOut=function(t,e){var i=this._lastControlOver[t];i&&(i._onPointerOut(i),delete this._lastControlOver[t]),e&&this._lastControlDown[t]&&(this._lastControlDown[t].forcePointerUp(),delete this._lastControlDown[t]),this.onPickedPointChangedObservable.notifyObservers(null)},t.prototype._doPicking=function(t){if(!this._utilityLayer||!this._utilityLayer.shouldRender||!this._utilityLayer.utilityLayerScene.activeCamera)return!1;var e=t.event,i=e.pointerId||0,r=e.button,n=t.pickInfo;if(!n||!n.hit)return this._handlePointerOut(i,t.type===s.PointerEventTypes.POINTERUP),!1;var o=n.pickedMesh.metadata;return n.pickedPoint&&this.onPickedPointChangedObservable.notifyObservers(n.pickedPoint),o._processObservables(t.type,n.pickedPoint,i,r)||t.type===s.PointerEventTypes.POINTERMOVE&&(this._lastControlOver[i]&&this._lastControlOver[i]._onPointerOut(this._lastControlOver[i]),delete this._lastControlOver[i]),t.type===s.PointerEventTypes.POINTERUP&&(this._lastControlDown[e.pointerId]&&(this._lastControlDown[e.pointerId].forcePointerUp(),delete this._lastControlDown[e.pointerId]),"touch"===e.pointerType&&this._handlePointerOut(i,!1)),!0},Object.defineProperty(t.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),t.prototype.containsControl=function(t){return this._rootContainer.containsControl(t)},t.prototype.addControl=function(t){return this._rootContainer.addControl(t),this},t.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),this},t.prototype.dispose=function(){for(var t in this._rootContainer.dispose(),this._sharedMaterials)this._sharedMaterials.hasOwnProperty(t)&&this._sharedMaterials[t].dispose();this._sharedMaterials={},this._pointerOutObserver&&this._utilityLayer&&(this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver),this._pointerOutObserver=null),this.onPickedPointChangedObservable.clear();var e=this._utilityLayer?this._utilityLayer.utilityLayerScene:null;e&&this._pointerObserver&&(e.onPointerObservable.remove(this._pointerObserver),this._pointerObserver=null),this._scene&&this._sceneDisposeObserver&&(this._scene.onDisposeObservable.remove(this._sceneDisposeObserver),this._sceneDisposeObserver=null),this._utilityLayer&&this._utilityLayer.dispose()},t}()},function(t,e,i){"use strict";i.r(e),function(t){var r=i(1);i.d(e,"Button",(function(){return r.Button})),i.d(e,"Checkbox",(function(){return r.Checkbox})),i.d(e,"ColorPicker",(function(){return r.ColorPicker})),i.d(e,"Container",(function(){return r.Container})),i.d(e,"Control",(function(){return r.Control})),i.d(e,"Ellipse",(function(){return r.Ellipse})),i.d(e,"Grid",(function(){return r.Grid})),i.d(e,"Image",(function(){return r.Image})),i.d(e,"InputText",(function(){return r.InputText})),i.d(e,"InputPassword",(function(){return r.InputPassword})),i.d(e,"Line",(function(){return r.Line})),i.d(e,"MultiLine",(function(){return r.MultiLine})),i.d(e,"RadioButton",(function(){return r.RadioButton})),i.d(e,"StackPanel",(function(){return r.StackPanel})),i.d(e,"SelectorGroup",(function(){return r.SelectorGroup})),i.d(e,"CheckboxGroup",(function(){return r.CheckboxGroup})),i.d(e,"RadioGroup",(function(){return r.RadioGroup})),i.d(e,"SliderGroup",(function(){return r.SliderGroup})),i.d(e,"SelectionPanel",(function(){return r.SelectionPanel})),i.d(e,"ScrollViewer",(function(){return r.ScrollViewer})),i.d(e,"TextWrapping",(function(){return r.TextWrapping})),i.d(e,"TextBlock",(function(){return r.TextBlock})),i.d(e,"TextWrapper",(function(){return r.TextWrapper})),i.d(e,"KeyPropertySet",(function(){return r.KeyPropertySet})),i.d(e,"VirtualKeyboard",(function(){return r.VirtualKeyboard})),i.d(e,"Rectangle",(function(){return r.Rectangle})),i.d(e,"DisplayGrid",(function(){return r.DisplayGrid})),i.d(e,"BaseSlider",(function(){return r.BaseSlider})),i.d(e,"Slider",(function(){return r.Slider})),i.d(e,"ImageBasedSlider",(function(){return r.ImageBasedSlider})),i.d(e,"ScrollBar",(function(){return r.ScrollBar})),i.d(e,"ImageScrollBar",(function(){return r.ImageScrollBar})),i.d(e,"name",(function(){return r.name})),i.d(e,"AdvancedDynamicTexture",(function(){return r.AdvancedDynamicTexture})),i.d(e,"AdvancedDynamicTextureInstrumentation",(function(){return r.AdvancedDynamicTextureInstrumentation})),i.d(e,"Vector2WithInfo",(function(){return r.Vector2WithInfo})),i.d(e,"Matrix2D",(function(){return r.Matrix2D})),i.d(e,"Measure",(function(){return r.Measure})),i.d(e,"MultiLinePoint",(function(){return r.MultiLinePoint})),i.d(e,"Style",(function(){return r.Style})),i.d(e,"ValueAndUnit",(function(){return r.ValueAndUnit})),i.d(e,"XmlLoader",(function(){return r.XmlLoader})),i.d(e,"AbstractButton3D",(function(){return r.AbstractButton3D})),i.d(e,"Button3D",(function(){return r.Button3D})),i.d(e,"Container3D",(function(){return r.Container3D})),i.d(e,"Control3D",(function(){return r.Control3D})),i.d(e,"CylinderPanel",(function(){return r.CylinderPanel})),i.d(e,"HolographicButton",(function(){return r.HolographicButton})),i.d(e,"MeshButton3D",(function(){return r.MeshButton3D})),i.d(e,"PlanePanel",(function(){return r.PlanePanel})),i.d(e,"ScatterPanel",(function(){return r.ScatterPanel})),i.d(e,"SpherePanel",(function(){return r.SpherePanel})),i.d(e,"StackPanel3D",(function(){return r.StackPanel3D})),i.d(e,"VolumeBasedPanel",(function(){return r.VolumeBasedPanel})),i.d(e,"FluentMaterialDefines",(function(){return r.FluentMaterialDefines})),i.d(e,"FluentMaterial",(function(){return r.FluentMaterial})),i.d(e,"GUI3DManager",(function(){return r.GUI3DManager})),i.d(e,"Vector3WithInfo",(function(){return r.Vector3WithInfo}));var n=void 0!==t?t:"undefined"!=typeof window?window:void 0;void 0!==n&&(n.BABYLON=n.BABYLON||{},n.BABYLON.GUI=r)}.call(this,i(3))},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i}])}));
1
+ /*! For license information please see babylonjs.loaders.min.js.LICENSE.txt */
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return(()=>{"use strict";var t={520:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>xt});var e={};r.r(e),r.d(e,{GLTFValidation:()=>y});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>b,GLTFLoaderAnimationStartMode:()=>_,GLTFLoaderCoordinateSystemMode:()=>p,GLTFLoaderState:()=>m});var n={};r.r(n),r.d(n,{EBlendingFunction:()=>w,EComponentType:()=>T,ECullingType:()=>C,EParameterType:()=>E,EShaderType:()=>x,ETextureFilterType:()=>M,ETextureFormat:()=>L,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>ne,GLTFLoader:()=>ee,GLTFLoaderBase:()=>$,GLTFLoaderExtension:()=>te,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>P});var a={};r.r(a);var s={};r.r(s),r.d(s,{EXT_lights_image_based:()=>ie,EXT_mesh_gpu_instancing:()=>ce,EXT_meshopt_compression:()=>de,EXT_texture_webp:()=>fe,ExtrasAsMetadata:()=>st,KHR_draco_mesh_compression:()=>_e,KHR_lights:()=>ye,KHR_materials_clearcoat:()=>xe,KHR_materials_emissive_strength:()=>Le,KHR_materials_ior:()=>Ne,KHR_materials_iridescence:()=>Oe,KHR_materials_pbrSpecularGlossiness:()=>be,KHR_materials_sheen:()=>we,KHR_materials_specular:()=>Re,KHR_materials_translucency:()=>ke,KHR_materials_transmission:()=>Ve,KHR_materials_unlit:()=>Ae,KHR_materials_variants:()=>Ie,KHR_materials_volume:()=>je,KHR_mesh_quantization:()=>Ke,KHR_texture_basisu:()=>qe,KHR_texture_transform:()=>Xe,KHR_xmp_json_ld:()=>Qe,MSFT_audio_emitter:()=>Je,MSFT_lod:()=>et,MSFT_minecraftMesh:()=>nt,MSFT_sRGBFactors:()=>ot});var i={};r.r(i),r.d(i,{ArrayItem:()=>oe,EXT_lights_image_based:()=>ie,EXT_mesh_gpu_instancing:()=>ce,EXT_meshopt_compression:()=>de,EXT_texture_webp:()=>fe,ExtrasAsMetadata:()=>st,GLTFLoader:()=>ae,KHR_draco_mesh_compression:()=>_e,KHR_lights:()=>ye,KHR_materials_clearcoat:()=>xe,KHR_materials_emissive_strength:()=>Le,KHR_materials_ior:()=>Ne,KHR_materials_iridescence:()=>Oe,KHR_materials_pbrSpecularGlossiness:()=>be,KHR_materials_sheen:()=>we,KHR_materials_specular:()=>Re,KHR_materials_translucency:()=>ke,KHR_materials_transmission:()=>Ve,KHR_materials_unlit:()=>Ae,KHR_materials_variants:()=>Ie,KHR_materials_volume:()=>je,KHR_mesh_quantization:()=>Ke,KHR_texture_basisu:()=>qe,KHR_texture_transform:()=>Xe,KHR_xmp_json_ld:()=>Qe,MSFT_audio_emitter:()=>Je,MSFT_lod:()=>et,MSFT_minecraftMesh:()=>nt,MSFT_sRGBFactors:()=>ot});var l={};r.r(l),r.d(l,{MTLFileLoader:()=>it,OBJFileLoader:()=>ct,SolidParser:()=>lt});var c={};r.r(c),r.d(c,{STLFileLoader:()=>ut});var u={};r.r(u),r.d(u,{GLTF1:()=>n,GLTF2:()=>i,GLTFFileLoader:()=>b,GLTFLoaderAnimationStartMode:()=>_,GLTFLoaderCoordinateSystemMode:()=>p,GLTFLoaderState:()=>m,GLTFValidation:()=>y,MTLFileLoader:()=>it,OBJFileLoader:()=>ct,STLFileLoader:()=>ut,SolidParser:()=>lt});var d=r(520);function h(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function f(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":h(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var p,_,m,y=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this;return"function"==typeof Worker?new Promise((function(a,s){var i="".concat(h,"(").concat(f,")()"),l=URL.createObjectURL(new Blob([i],{type:"application/javascript"})),c=new Worker(l),u=function(e){c.removeEventListener("error",u),c.removeEventListener("message",d),s(e)},d=function(e){var t=e.data;switch(t.id){case"getExternalResource":r(t.uri).then((function(e){c.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e])}),(function(e){c.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":c.removeEventListener("error",u),c.removeEventListener("message",d),a(t.value),c.terminate();break;case"validate.reject":c.removeEventListener("error",u),c.removeEventListener("message",d),s(t.reason),c.terminate()}};c.addEventListener("error",u),c.addEventListener("message",d),c.postMessage({id:"init",url:o.Configuration.url}),c.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=d.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return h(e,t,n,r)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}();function v(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(p||(p={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(_||(_={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(m||(m={}));var b=function(){function e(){this.onParsedObservable=new d.Observable,this.coordinateSystemMode=p.AUTO,this.animationStartMode=_.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new d.Observable,this.onTextureLoadedObservable=new d.Observable,this.onMaterialLoadedObservable=new d.Observable,this.onCameraLoadedObservable=new d.Observable,this.onCompleteObservable=new d.Observable,this.onErrorObservable=new d.Observable,this.onDisposeObservable=new d.Observable,this.onExtensionLoadedObservable=new d.Observable,this.validate=!1,this.onValidatedObservable=new d.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new d.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.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:!1,configurable:!0}),Object.defineProperty(e.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,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(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},e.prototype.loadFile=function(e,t,n,r,o,a){var s=this;this._progressCallback=r;var i=t.name?"file:":d.Tools.GetFolderPath(t),l=t.name||d.Tools.GetFilename(t);if(o){if(this.useRangeRequests){this.validate&&d.Logger.Warn("glTF validation is not supported when range requests are enabled");var c={abort:function(){},onCompleteObservable:new d.Observable},u={readAsync:function(n,r){return new Promise((function(o,a){s._loadFile(e,t,(function(e){o(new Uint8Array(e))}),!0,(function(e){a(e)}),(function(e){e.setRequestHeader("Range","bytes=".concat(n,"-").concat(n+r-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new d.DataReader(u)).then((function(e){c.onCompleteObservable.notifyObservers(c),n(e)}),a?function(e){return a(void 0,e)}:void 0),c}return this._loadFile(e,t,(function(t){s._validate(e,t,i,l),s._unpackBinaryAsync(new d.DataReader({readAsync:function(e,n){return v(t,e,n)},byteLength:t.byteLength})).then((function(e){n(e)}),a?function(e){return a(void 0,e)}:void 0)}),!0,a)}return this._loadFile(e,t,(function(t){s._validate(e,t,i,l),n({json:s._parseJson(t)})}),o,a)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var s=this;return Promise.resolve().then((function(){return s.onParsedObservable.notifyObservers(n),s.onParsedObservable.clear(),s._log("Loading ".concat(a||"")),s._loader=s._getLoader(n),s._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var s=new d.AssetContainer(e),i=[];a.onMaterialLoadedObservable.add((function(e){i.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var c=[];return a.onCameraLoadedObservable.add((function(e){c.push(e)})),a._loader.importMeshAsync(null,e,s,t,n,r,o).then((function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,i),Array.prototype.push.apply(s.textures,l),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),s}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||d.StringTools.StartsWith(t,"data:base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(t,"data:;base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(t,"data:application/octet-stream;base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(t,"data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(d.StringTools.StartsWith(n,"base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(n,";base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(n,"application/octet-stream;base64,"+e._MagicBase64Encoded)||d.StringTools.StartsWith(n,"model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,d.DecodeBase64UrlToBinary)(n);return this._validate(t,r),this._unpackBinaryAsync(new d.DataReader({readAsync:function(e,t){return v(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(m[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var s=this,i=e._loadFile(t,n,(function(e){s._onProgress(e,i)}),!0,r,o,a);return i.onCompleteObservable.add((function(e){s._requests.splice(s._requests.indexOf(e),1)})),this._requests.push(i),i},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,s=this._requests;a<s.length;a++){var i=s[a];if(void 0===i._lengthComputable||void 0===i._loaded||void 0===i._total)return;n=n&&i._lengthComputable,r+=i._loaded,o+=i._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},e.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),y.ValidateAsync(t,n,r,(function(t){return o.preprocessUrlAsync(n+t).then((function(t){return e._loadFileAsync(t,void 0,!0,!0)}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),d.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(t){var n=t.json.asset||{};this._log("Asset version: ".concat(n.version)),n.minVersion&&this._log("Asset minimum version: ".concat(n.minVersion)),n.generator&&this._log("Asset generator: ".concat(n.generator));var r=e._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=e._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new d.RuntimeError("Unexpected magic: "+n,d.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();if(0!==e.buffer.byteLength&&a!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength));switch(r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var s=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(s+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(a)};return s()}))},e._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},e._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},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(t){var n=e._logSpaces.substr(0,2*this._logIndentLevel);d.Logger.Log("".concat(n).concat(t))},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){d.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){d.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e._MagicBase64Encoded="Z2xURg",e._logSpaces=" ",e}();d.SceneLoader&&d.SceneLoader.RegisterPlugin(new b);var g=function(e,t){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},g(e,t)};function A(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}g(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var T,x,E,O,M,L,C,w,S=function(){return S=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},S.apply(this,arguments)};Object.create,Object.create,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"}(T||(T={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(x||(x={})),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||(E={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(O||(O={})),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"}(M||(M={})),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"}(L||(L={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(C||(C={})),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"}(w||(w={}));var R,P=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var a=null;if("MODEL"===n.semantic?a=t.getWorldMatrix():"PROJECTION"===n.semantic?a=e.getProjectionMatrix():"VIEW"===n.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?a=d.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?a=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(a=d.Matrix.Transpose(t.getWorldMatrix().invert())),a)switch(n.type){case E.FLOAT_MAT2:o.setMatrix2x2(r,d.Matrix.GetAsMatrix2x2(a));break;case E.FLOAT_MAT3:o.setMatrix3x3(r,d.Matrix.GetAsMatrix3x3(a));break;case E.FLOAT_MAT4:o.setMatrix(r,a)}},e.SetUniform=function(e,t,n,r){switch(r){case E.FLOAT:return e.setFloat(t,n),!0;case E.FLOAT_VEC2:return e.setVector2(t,d.Vector2.FromArray(n)),!0;case E.FLOAT_VEC3:return e.setVector3(t,d.Vector3.FromArray(n)),!0;case E.FLOAT_VEC4:return e.setVector4(t,d.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case O.CLAMP_TO_EDGE:return d.Texture.CLAMP_ADDRESSMODE;case O.MIRRORED_REPEAT:return d.Texture.MIRROR_ADDRESSMODE;case O.REPEAT:default:return d.Texture.WRAP_ADDRESSMODE}},e.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}},e.GetTextureFilterMode=function(e){switch(e){case M.LINEAR:case M.LINEAR_MIPMAP_NEAREST:case M.LINEAR_MIPMAP_LINEAR:return d.Texture.TRILINEAR_SAMPLINGMODE;case M.NEAREST:case M.NEAREST_MIPMAP_NEAREST:return d.Texture.NEAREST_SAMPLINGMODE;default:return d.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,r,o){n=t.byteOffset+n;var a=e.loadedBufferViews[t.buffer];if(n+r>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(n+=a.byteOffset,o){case T.BYTE:return new Int8Array(s,n,r);case T.UNSIGNED_BYTE:return new Uint8Array(s,n,r);case T.SHORT:return new Int16Array(s,n,r);case T.UNSIGNED_SHORT:return new Uint16Array(s,n,r);default:return new Float32Array(s,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){d.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"),d.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new d.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new d.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}();!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(R||(R={}));var N=function(){function e(e){this._pos=0,this.currentToken=R.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 R.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=R.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=R.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}(),F=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],I=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],D=["position","rotationQuaternion","scaling"],V=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},G=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},k=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},U=function(e){var t=null;if(e.translation||e.rotation||e.scale){var n=d.Vector3.FromArray(e.scale||[1,1,1]),r=d.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=d.Vector3.FromArray(e.translation||[0,0,0]);t=d.Matrix.Compose(n,r,o)}else t=d.Matrix.FromArray(e.matrix);return t},j=function(e,t,n,r){for(var o=0;o<r.bones.length;o++)if(r.bones[o].name===n)return r.bones[o];var a=e.nodes;for(var s in a){var i=a[s];if(i.jointName){var l=i.children;for(o=0;o<l.length;o++){var c=e.nodes[l[o]];if(c.jointName&&c.jointName===n){var u=U(i),h=new d.Bone(i.name||"",r,j(e,t,i.jointName,r),u);return h.id=s,h}}}}return null},H=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++)if(r.node.children[o]===t)return r.bone;return null},K=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},W=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},q=function(e,t,n,r,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new d.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=r),!t.babylonNode)return o;for(var a,s=[],i=null,l=new Array,c=new Array,u=new Array,h=new Array,f=0;f<n.length;f++){var p=n[f];if(S=e.meshes[p])for(var _=0;_<S.primitives.length;_++){var m=new d.VertexData,y=S.primitives[_];y.mode;var v=y.attributes,g=null,A=null;for(var T in v)if(g=e.accessors[v[T]],A=P.GetBufferFromAccessor(e,g),"NORMAL"===T)m.normals=new Float32Array(A.length),m.normals.set(A);else if("POSITION"===T){if(b.HomogeneousCoordinates){m.positions=new Float32Array(A.length-A.length/4);for(var x=0;x<A.length;x+=4)m.positions[x]=A[x],m.positions[x+1]=A[x+1],m.positions[x+2]=A[x+2]}else m.positions=new Float32Array(A.length),m.positions.set(A);c.push(m.positions.length)}else if(-1!==T.indexOf("TEXCOORD_")){var E=Number(T.split("_")[1]),O=d.VertexBuffer.UVKind+(0===E?"":E+1),M=new Float32Array(A.length);M.set(A),G(M),m.set(M,O)}else"JOINT"===T?(m.matricesIndices=new Float32Array(A.length),m.matricesIndices.set(A)):"WEIGHT"===T?(m.matricesWeights=new Float32Array(A.length),m.matricesWeights.set(A)):"COLOR"===T&&(m.colors=new Float32Array(A.length),m.colors.set(A));if(g=e.accessors[y.indices])A=P.GetBufferFromAccessor(e,g),m.indices=new Int32Array(A.length),m.indices.set(A),h.push(m.indices.length);else{var L=[];for(x=0;x<m.positions.length/3;x++)L.push(x);m.indices=new Int32Array(L),h.push(m.indices.length)}i?i.merge(m):i=m;var C=e.scene.getMaterialById(y.material);s.push(null===C?P.GetDefaultMaterial(e.scene):C),l.push(0===l.length?0:l[l.length-1]+c[c.length-2]),u.push(0===u.length?0:u[u.length-1]+h[h.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,s.length>1?(a=new d.MultiMaterial("multimat"+r,e.scene)).subMaterials=s:a=new d.StandardMaterial("multimat"+r,e.scene),1===s.length&&(a=s[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new d.Geometry(r,e.scene,i,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var w=0;for(f=0;f<n.length;f++){var S;if(p=n[f],S=e.meshes[p])for(_=0;_<S.primitives.length;_++)S.primitives[_].mode,d.SubMesh.AddToMesh(w,l[w],c[w],u[w],h[w],o,o,!0),w++}return o},Y=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},X=function(e,t,n){var r=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=q(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new d.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],s=o;if(a.jointName&&!W(n,a.jointName)){var i=U(a),l=new d.Bone(a.name||"",t,null,i);l.id=s,r.push({bone:l,node:a,id:s})}}for(var c=0;c<r.length;c++)for(var u=r[c],h=u.node.children,f=0;f<h.length;f++){for(var p=null,_=0;_<r.length;_++)if(r[_].id===h[f]){p=r[_];break}p&&(p.bone._parent=u.bone,u.bone.children.push(p.bone))}}(e,r,t,o),r.bones=[];for(var s=0;s<t.jointNames.length;s++)if(g=K(e,t.jointNames[s])){var i=g.node;if(i){var l=g.id,c=e.scene.getBoneById(l);if(c)r.bones.push(c);else{for(var u=!1,h=null,f=0;f<s;f++){var p=K(e,t.jointNames[f]);if(p){var _=p.node;if(_){var m=_.children;if(m){u=!1;for(var y=0;y<m.length;y++)if(m[y]===l){h=j(e,t,t.jointNames[f],r),u=!0;break}if(u)break}}else d.Tools.Warn("Joint named "+t.jointNames[f]+" does not exist when looking for parent")}}var v=U(i);!h&&o.length>0&&(h=H(o,l))&&-1===a.indexOf(h)&&a.push(h),new d.Bone(i.jointName||"",r,h,v).id=l}}else d.Tools.Warn("Joint named "+t.jointNames[s]+" does not exist")}var b=r.bones;for(r.bones=[],s=0;s<t.jointNames.length;s++){var g;if(g=K(e,t.jointNames[s]))for(f=0;f<b.length;f++)if(b[f].id===g.id){r.bones.push(b[f]);break}}for(r.prepare(),s=0;s<a.length;s++)r.bones.push(a[s]);return r}(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),r=a}}else if(t.meshes){var a;r=a=q(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[t.camera];if(s){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===s.type){var i=new d.FreeCamera(t.camera,d.Vector3.Zero(),e.scene,!1);i.name=t.name||"",i.mode=d.Camera.ORTHOGRAPHIC_CAMERA,i.attachControl(),r=i,i._parentContainer=e.assetContainer}else if("perspective"===s.type){var l=s[s.type],c=new d.FreeCamera(t.camera,d.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(c.maxZ=l.zfar,c.minZ=l.znear),r=c,c._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var u=e.lights[t.light];if(u)if("ambient"===u.type){var h=u[u.type],f=new d.HemisphericLight(t.light,d.Vector3.Zero(),e.scene);f.name=t.name||"",h.color&&(f.diffuse=d.Color3.FromArray(h.color)),r=f}else if("directional"===u.type){var p=u[u.type],_=new d.DirectionalLight(t.light,d.Vector3.Zero(),e.scene);_.name=t.name||"",p.color&&(_.diffuse=d.Color3.FromArray(p.color)),r=_}else if("point"===u.type){var m=u[u.type],y=new d.PointLight(t.light,d.Vector3.Zero(),e.scene);y.name=t.name||"",m.color&&(y.diffuse=d.Color3.FromArray(m.color)),r=y}else if("spot"===u.type){var v=u[u.type],b=new d.SpotLight(t.light,d.Vector3.Zero(),d.Vector3.Zero(),0,0,e.scene);b.name=t.name||"",v.color&&(b.diffuse=d.Color3.FromArray(v.color)),v.fallOfAngle&&(b.angle=v.fallOfAngle),v.fallOffExponent&&(b.exponent=v.fallOffExponent),r=b}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===r){e.scene._blockEntityCollection=!!e.assetContainer;var g=new d.Mesh(t.name||"",e.scene);g._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=g,r=g}}if(null!==r){if(t.matrix&&r instanceof d.Mesh)!function(e,t){if(t.matrix){var n=new d.Vector3(0,0,0),r=new d.Quaternion,o=new d.Vector3(0,0,0);d.Matrix.FromArray(t.matrix).decompose(o,r,n),Y(e,n,r,o)}else t.translation&&t.rotation&&t.scale&&Y(e,d.Vector3.FromArray(t.translation),d.Quaternion.FromArray(t.rotation),d.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(r,t);else{var A=t.translation||[0,0,0],T=t.rotation||[0,0,0,1],x=t.scale||[1,1,1];Y(r,d.Vector3.FromArray(A),d.Quaternion.FromArray(T),d.Vector3.FromArray(x))}r.updateCache(!0),t.babylonNode=r}return r},z=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&r&&null!==(a=X(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var s=0;s<o.children.length;s++)z(e,o.children[s],a,r)},Q=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)z(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)z(e,t.nodes[n],null);for(function(e){for(var t in e.animations){var n=e.animations[t];if(n.channels&&n.samplers)for(var r=null,o=0;o<n.channels.length;o++){var a=n.channels[o],s=n.samplers[a.sampler];if(s){var i=null,l=null;n.parameters?(i=n.parameters[s.input],l=n.parameters[s.output]):(i=s.input,l=s.output);var c=P.GetBufferFromAccessor(e,e.accessors[i]),u=P.GetBufferFromAccessor(e,e.accessors[l]),h=a.target.id,f=e.scene.getNodeById(h);if(null===f&&(f=e.scene.getNodeByName(h)),null!==f){var p=f instanceof d.Bone,_=a.target.path,m=B.indexOf(_);-1!==m&&(_=D[m]);var y=d.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===_?(y=d.Animation.ANIMATIONTYPE_QUATERNION,f.rotationQuaternion=new d.Quaternion):y=d.Animation.ANIMATIONTYPE_VECTOR3);var v=null,b=[],g=0,A=!1;p&&r&&r.getKeys().length===c.length&&(v=r,A=!0),A||(e.scene._blockEntityCollection=!!e.assetContainer,v=new d.Animation(t,p?"_matrix":_,1,y,d.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var T=0;T<c.length;T++){var x=null;if("rotationQuaternion"===_?(x=d.Quaternion.FromArray([u[g],u[g+1],u[g+2],u[g+3]]),g+=4):(x=d.Vector3.FromArray([u[g],u[g+1],u[g+2]]),g+=3),p){var E=f,O=d.Vector3.Zero(),M=new d.Quaternion,L=d.Vector3.Zero(),C=E.getBaseMatrix();A&&r&&(C=r.getKeys()[T].value),C.decompose(L,M,O),"position"===_?O=x:"rotationQuaternion"===_?M=x:L=x,x=d.Matrix.Compose(L,M,O)}A?r&&(r.getKeys()[T].value=x):b.push({frame:c[T],value:x})}!A&&v&&(v.setKeys(b),f.animations.push(v)),r=v,e.scene.stopAnimation(f),e.scene.beginAnimation(f,0,c[c.length-1],!0,1)}else d.Tools.Warn("Creating animation named "+t+". But cannot find node named "+h+" to attach to")}}}}(e),n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},Z=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var s=F.indexOf(a.semantic);if(-1!==s)return delete n[r],I[s]}}return e.currentIdentifier},J=function(e){for(var t in e.materials)te.LoadMaterialAsync(e,t,(function(){}),(function(){}))},$=function(){function e(){}return e.CreateRuntime=function(e,t,n){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:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&V(e.extensions,"extensions",r),e.extensionsUsed&&V(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&V(e.bufferViews,"bufferViews",r),e.accessors&&V(e.accessors,"accessors",r),e.meshes&&V(e.meshes,"meshes",r),e.lights&&V(e.lights,"lights",r),e.cameras&&V(e.cameras,"cameras",r),e.nodes&&V(e.nodes,"nodes",r),e.images&&V(e.images,"images",r),e.textures&&V(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&V(e.programs,"programs",r),e.samplers&&V(e.samplers,"samplers",r),e.techniques&&V(e.techniques,"techniques",r),e.materials&&V(e.materials,"materials",r),e.animations&&V(e.animations,"animations",r),e.skins&&V(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,t,n,r,o){var a=e.buffers[t];d.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(d.Tools.DecodeBase64(a.uri)))})):d.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,n,r){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)n(null);else{var a=e.images[o.source];d.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(d.Tools.DecodeBase64(a.uri)))})):d.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))}else r("")},e.CreateTextureAsync=function(e,t,n,r){var o=e.textures[t];if(o.babylonTexture)r(o.babylonTexture);else{var a=e.samplers[o.sampler],s=a.minFilter===M.NEAREST_MIPMAP_NEAREST||a.minFilter===M.NEAREST_MIPMAP_LINEAR||a.minFilter===M.LINEAR_MIPMAP_NEAREST||a.minFilter===M.LINEAR_MIPMAP_LINEAR,i=d.Texture.BILINEAR_SAMPLINGMODE,l=null==n?new Blob:new Blob([n]),c=URL.createObjectURL(l),u=function(){return URL.revokeObjectURL(c)},h=new d.Texture(c,e.scene,!s,!0,i,u,u);void 0!==a.wrapS&&(h.wrapU=P.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(h.wrapV=P.GetWrapMode(a.wrapT)),h.name=t,o.babylonTexture=h,r(h)}},e.LoadShaderStringAsync=function(e,t,n,r){var o=e.shaders[t];if(d.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);n&&n(a)}else d.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,(function(e){e&&r&&r(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(o.technique){var a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;var s=new d.StandardMaterial(t,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new d.Color3(.5,.5,.5),s.sideOrientation=d.Material.CounterClockWiseSideOrientation,void n(s)}var i=e.programs[a.program],l=a.states,c=d.Effect.ShadersStore[i.vertexShader+"VertexShader"],u=d.Effect.ShadersStore[i.fragmentShader+"PixelShader"],h="",f="",p=new N(c),_=new N(u),m={},y=[],v=[],b=[];for(var g in a.uniforms){var A=a.uniforms[g],T=a.parameters[A];if(m[g]=T,!T.semantic||T.node||T.source)T.type===E.SAMPLER_2D?b.push(g):y.push(g);else{var x=F.indexOf(T.semantic);-1!==x?(y.push(I[x]),delete m[g]):y.push(g)}}for(var O in a.attributes){var M=a.attributes[O];if((B=a.parameters[M]).semantic){var L=k(B);L&&v.push(L)}}for(;!p.isEnd()&&p.getNextToken();)if(p.currentToken===R.IDENTIFIER){var S=!1;for(var O in a.attributes){M=a.attributes[O];var B=a.parameters[M];if(p.currentIdentifier===O&&B.semantic){h+=k(B),S=!0;break}}S||(h+=Z(p,a,m))}else h+=p.currentString;for(;!_.isEnd()&&_.getNextToken();)_.currentToken===R.IDENTIFIER?f+=Z(_,a,m):f+=_.currentString;var D={vertex:i.vertexShader+t,fragment:i.fragmentShader+t},V={attributes:v,uniforms:y,samplers:b,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};d.Effect.ShadersStore[i.vertexShader+t+"VertexShader"]=h,d.Effect.ShadersStore[i.fragmentShader+t+"PixelShader"]=f;var G=new d.ShaderMaterial(t,e.scene,D,V);if(G.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(i,G,r),G.onCompiled=function(e,t,n,r,o,a){return function(s){!function(e,t,n,r,o){var a=r.values||n.parameters,s=n.uniforms,i=function(n){var i=o[n],l=i.type,c=a[s[n]];if(void 0===c&&(c=i.value),!c)return"continue";var u=function(e){return function(n){i.value&&e&&(t.setTexture(e,n),delete o[e])}};l===E.SAMPLER_2D?te.LoadTextureAsync(e,r.values?c:i.value,u(n),(function(){return u(null)})):i.value&&P.SetUniform(t,n,r.values?c:i.value,l)&&delete o[n]};for(var l in o)i(l)}(e,t,n,r,o),t.onBind=function(s){!function(e,t,n,r,o,a,s){var i=a.values||o.parameters;for(var l in n){var c=n[l],u=c.type;if(u===E.FLOAT_MAT2||u===E.FLOAT_MAT3||u===E.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var d=t.scene.getNodeByName(c.source||c.node||"");if(null===d&&(d=t.scene.getNodeById(c.source||c.node||"")),null===d)continue;P.SetMatrix(t.scene,d,c,l,r.getEffect())}}else P.SetMatrix(t.scene,e,c,l,r.getEffect());else{var h=i[o.uniforms[l]];if(!h)continue;if(u===E.SAMPLER_2D){var f=t.textures[a.values?h:c.value].babylonTexture;if(null==f)continue;r.getEffect().setTexture(l,f)}else P.SetUniform(r.getEffect(),l,h,u)}}s(r)}(s,e,o,t,n,r,a)}}}(e,G,a,o,m,n),G.sideOrientation=d.Material.CounterClockWiseSideOrientation,l&&l.functions){var U=l.functions;U.cullFace&&U.cullFace[0]!==C.BACK&&(G.backFaceCulling=!1);var j=U.blendFuncSeparate;j&&(j[0]===w.SRC_ALPHA&&j[1]===w.ONE_MINUS_SRC_ALPHA&&j[2]===w.ONE&&j[3]===w.ONE?G.alphaMode=d.Constants.ALPHA_COMBINE:j[0]===w.ONE&&j[1]===w.ONE&&j[2]===w.ZERO&&j[3]===w.ONE?G.alphaMode=d.Constants.ALPHA_ONEONE:j[0]===w.SRC_ALPHA&&j[1]===w.ONE&&j[2]===w.ZERO&&j[3]===w.ONE?G.alphaMode=d.Constants.ALPHA_ADD:j[0]===w.ZERO&&j[1]===w.ONE_MINUS_SRC_COLOR&&j[2]===w.ONE&&j[3]===w.ONE?G.alphaMode=d.Constants.ALPHA_SUBTRACT:j[0]===w.DST_COLOR&&j[1]===w.ZERO&&j[2]===w.ONE&&j[3]===w.ONE?G.alphaMode=d.Constants.ALPHA_MULTIPLY:j[0]===w.SRC_ALPHA&&j[1]===w.ONE_MINUS_SRC_COLOR&&j[2]===w.ONE&&j[3]===w.ONE&&(G.alphaMode=d.Constants.ALPHA_MAXIMIZED))}}else r&&r("No technique found.")},e}(),ee=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?d.Tools.Error('Tool with the same name "'+t.name+'" already exists'):e.Extensions[t.name]=t},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,t,n,r,o,a,s,i){var l=this;return t.useRightHandedSystem=!0,te.LoadRuntimeAsync(t,n,r,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],d.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var n=new Array,r=new Array;for(var s in t.nodes){var i=t.nodes[s];i.babylonNode instanceof d.AbstractMesh&&n.push(i.babylonNode)}for(var c in t.skins){var u=t.skins[c];u.babylonSkeleton instanceof d.Skeleton&&r.push(u.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){J(t),Q(t),!b.IncrementalLoading&&a&&a(n,r)}))})),b.IncrementalLoading&&a&&a(n,r)}),i),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var s=this;return new Promise((function(i,l){s._importMeshAsync(e,t,r,o,n,(function(e,t){i({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[]})}),a,(function(e){l(new Error(e))}))}))},e.prototype._loadAsync=function(e,t,n,r,o,a){var s=this;e.useRightHandedSystem=!0,te.LoadRuntimeAsync(e,t,n,(function(e){te.LoadRuntimeExtensionsAsync(e,(function(){s._createNodes(e),s._loadBuffersAsync(e,(function(){s._loadShadersAsync(e,(function(){J(e),Q(e),b.IncrementalLoading||r()}))})),b.IncrementalLoading&&r()}),a)}),a)},e.prototype.loadAsync=function(e,t,n,r){var o=this;return new Promise((function(a,s){o._loadAsync(e,t,n,(function(){a()}),r,(function(e){s(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,t){var n=!1,r=function(n,r){te.LoadShaderStringAsync(e,n,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(d.Effect.ShadersStore[n+(r.type===x.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&t())}),(function(){d.Tools.Error("Error when loading shader program named "+n+" located at "+r.uri)}))};for(var o in e.shaders){n=!0;var a=e.shaders[o];a?r.bind(this,o,a)():d.Tools.Error("No shader named: "+o)}n||t()},e.prototype._loadBuffersAsync=function(e,t){var n=!1,r=function(n,r){te.LoadBufferAsync(e,n,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&d.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+r.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){d.Tools.Error("Error when loading buffer named "+n+" located at "+r.uri)}))};for(var o in e.buffers){n=!0;var a=e.buffers[o];a?r.bind(this,o,a)():d.Tools.Error("No buffer named: "+o)}n||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)z(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)z(e,t.nodes[n],null)},e.Extensions={},e}(),te=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,r,o,a)}),(function(){setTimeout((function(){o&&o($.CreateRuntime(n.json,t,r))}))}))},e.LoadRuntimeExtensionsAsync=function(t,n,r){e._ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,n,r)}),(function(){setTimeout((function(){n()}))}))},e.LoadBufferAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadBufferAsync(t,n,r,o,a)}),(function(){$.LoadBufferAsync(t,n,r,o,a)}))},e.LoadTextureAsync=function(t,n,r,o){e._LoadTextureBufferAsync(t,n,(function(a){a&&e._CreateTextureAsync(t,n,a,r,o)}),o)},e.LoadShaderStringAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,r,o)}),(function(){$.LoadShaderStringAsync(t,n,r,o)}))},e.LoadMaterialAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,r,o)}),(function(){$.LoadMaterialAsync(t,n,r,o)}))},e._LoadTextureBufferAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,r,o)}),(function(){$.LoadTextureBufferAsync(t,n,r,o)}))},e._CreateTextureAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.createTextureAsync(t,n,r,o,a)}),(function(){$.CreateTextureAsync(t,n,r,o)}))},e._ApplyExtensions=function(e,t){for(var n in ee.Extensions)if(e(ee.Extensions[n]))return;t()},e}();b._CreateGLTF1Loader=function(){return new ee};var ne=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return A(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,r($.CreateRuntime(t.json,e,n)),0))},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,(function(e){return r(e.message)})),!0)},t.prototype.loadTextureBufferAsync=function(e,t,n){var r=e.textures[t],o=e.images[r.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],s=e.bufferViews[a.bufferView];return n(P.GetBufferFromBufferView(e,s,0,s.byteLength,T.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n){var r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;var o=r.extensions[this.name],a=e.bufferViews[o.bufferView],s=P.GetBufferFromBufferView(e,a,0,a.byteLength,T.UNSIGNED_BYTE);return setTimeout((function(){var e=P.DecodeBufferToText(s);n(e)})),!0},t}(te);ee.RegisterExtension(new ne);var re=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return A(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var n=t.lights;if(n)for(var r in n){var o=n[r];switch(o.type){case"ambient":var a=new d.HemisphericLight(o.name,new d.Vector3(0,1,0),e.scene),s=o.ambient;s&&(a.diffuse=d.Color3.FromArray(s.color||[1,1,1]));break;case"point":var i=new d.PointLight(o.name,new d.Vector3(10,10,10),e.scene),l=o.point;l&&(i.diffuse=d.Color3.FromArray(l.color||[1,1,1]));break;case"directional":var c=new d.DirectionalLight(o.name,new d.Vector3(0,-1,0),e.scene),u=o.directional;u&&(c.diffuse=d.Color3.FromArray(u.color||[1,1,1]));break;case"spot":var h=o.spot;h&&(new d.SpotLight(o.name,new d.Vector3(0,10,0),new d.Vector3(0,-1,0),h.fallOffAngle||Math.PI,h.fallOffExponent||0,e.scene).diffuse=d.Color3.FromArray(h.color||[1,1,1]));break;default:d.Tools.Warn('GLTF Material Common extension: light type "'+o.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var s=new d.StandardMaterial(t,e.scene);return s.sideOrientation=d.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(s.disableLighting=!0),s.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,s.alpha=void 0===a.values.transparency?1:a.values.transparency,s.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,s,"ambientTexture",r):s.ambientColor=d.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,s,"diffuseTexture",r):s.diffuseColor=d.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,s,"emissiveTexture",r):s.emissiveColor=d.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,s,"specularTexture",r):s.specularColor=d.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,n,r,o){$.LoadTextureBufferAsync(e,t,(function(o){$.CreateTextureAsync(e,t,o,(function(e){return n[r]=e}))}),o)},t}(te);ee.RegisterExtension(new re);var oe=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}(),ae=function(){function e(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._parent=e}return e.RegisterExtension=function(t,n){e.UnregisterExtension(t)&&d.Logger.Warn("Extension with the name '".concat(t,"' already exists")),e._RegisteredExtensions[t]={factory:n}},e.UnregisterExtension=function(t){return!!e._RegisteredExtensions[t]&&(delete e._RegisteredExtensions[t],!0)},Object.defineProperty(e.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach((function(e){return e.dispose&&e.dispose()})),this._extensions.length=0,this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},e.prototype.importMeshAsync=function(e,t,n,r,o,a,s){var i=this;return void 0===s&&(s=""),Promise.resolve().then((function(){i._babylonScene=t,i._assetContainer=n,i._loadData(r);var a=null;if(e){var l={};if(i._gltf.nodes)for(var c=0,u=i._gltf.nodes;c<u.length;c++){var d=u[c];d.name&&(l[d.name]=d.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 '".concat(e,"'"));return t}))}return i._loadAsync(o,s,a,(function(){return{meshes:i._getMeshes(),particleSystems:[],skeletons:i._getSkeletons(),animationGroups:i._getAnimationGroups(),lights:i._babylonLights,transformNodes:i._getTransformNodes(),geometries:i._getGeometries()}}))}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return void 0===o&&(o=""),Promise.resolve().then((function(){return a._babylonScene=e,a._loadData(t),a._loadAsync(n,o,null,(function(){}))}))},e.prototype._loadAsync=function(e,t,n,r){var o=this;return Promise.resolve().then((function(){o._rootUrl=e,o._uniqueRootUrl=!d.StringTools.StartsWith(e,"file:")&&t?e:"".concat(e).concat(Date.now(),"/"),o._fileName=t,o._loadExtensions(),o._checkExtensions();var a="".concat(m[m.LOADING]," => ").concat(m[m.READY]),s="".concat(m[m.LOADING]," => ").concat(m[m.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(s),o._parent._setState(m.LOADING),o._extensionsOnLoading();var i=new Array,l=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)i.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var c=oe.Get("/scene",o._gltf.scenes,o._gltf.scene||0);i.push(o.loadSceneAsync("/scenes/".concat(c.index),c))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var u=0;u<o._gltf.materials.length;++u){var h=o._gltf.materials[u],f="/materials/"+u,p=d.Material.TriangleFillMode;i.push(o._loadMaterialAsync(f,h,null,p,(function(){})))}return o._babylonScene.blockMaterialDirtyMechanism=l,o._parent.compileMaterials&&i.push(o._compileMaterialsAsync()),o._parent.compileShadowGenerators&&i.push(o._compileShadowGeneratorsAsync()),Promise.all(i).then((function(){return o._rootBabylonMesh&&o._rootBabylonMesh.setEnabled(!0),o._extensionsOnReady(),o._parent._setState(m.READY),o._startAnimations(),r()})).then((function(e){return o._parent._endPerformanceCounter(a),d.Tools.SetImmediate((function(){o._disposed||Promise.all(o._completePromises).then((function(){o._parent._endPerformanceCounter(s),o._parent._setState(m.COMPLETE),o._parent.onCompleteObservable.notifyObservers(void 0),o._parent.onCompleteObservable.clear(),o.dispose()}),(function(e){o._parent.onErrorObservable.notifyObservers(e),o._parent.onErrorObservable.clear(),o.dispose()}))})),e}))})).catch((function(e){throw o._disposed||(o._parent.onErrorObservable.notifyObservers(e),o._parent.onErrorObservable.clear(),o.dispose()),e}))},e.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLength<e.bin.byteLength-3||n.byteLength>e.bin.byteLength)&&d.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else d.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(oe.Assign(this._gltf.accessors),oe.Assign(this._gltf.animations),oe.Assign(this._gltf.buffers),oe.Assign(this._gltf.bufferViews),oe.Assign(this._gltf.cameras),oe.Assign(this._gltf.images),oe.Assign(this._gltf.materials),oe.Assign(this._gltf.meshes),oe.Assign(this._gltf.nodes),oe.Assign(this._gltf.samplers),oe.Assign(this._gltf.scenes),oe.Assign(this._gltf.skins),oe.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),s=0,i=this._gltf.nodes;s<i.length;s++){var l,c=e[(l=i[s]).index];l.parent=void 0===c?a:this._gltf.nodes[c]}}},e.prototype._loadExtensions=function(){for(var t in e._RegisteredExtensions){var n=e._RegisteredExtensions[t].factory(this);n.name!==t&&d.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(n.name," !== ").concat(t)),this._extensions.push(n),this._parent.onExtensionLoadedObservable.notifyObservers(n)}this._extensions.sort((function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)})),this._parent.onExtensionLoadedObservable.clear()},e.prototype._checkExtensions=function(){if(this._gltf.extensionsRequired)for(var e=function(e){if(!t._extensions.some((function(t){return t.name===e&&t.enabled})))throw new Error("Require extension ".concat(e," is not available"))},t=this,n=0,r=this._gltf.extensionsRequired;n<r.length;n++)e(r[n])},e.prototype._createRootNode=function(){this._babylonScene._blockEntityCollection=!!this._assetContainer,this._rootBabylonMesh=new d.Mesh("__root__",this._babylonScene),this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var t={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case p.AUTO:this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],e._LoadTransform(t,this._rootBabylonMesh));break;case p.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),t},e.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,s=t.nodes;a<s.length;a++){var i=s[a],l=oe.Get("".concat(e,"/nodes/").concat(i),this._gltf.nodes,i);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,(function(e){e.parent=n._rootBabylonMesh})))}for(var c=0,u=this._postSceneLoadActions;c<u.length;c++)(0,u[c])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then((function(){}))},e.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},e.prototype._getGeometries=function(){var e=new Array,t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)}))}return e},e.prototype._getMeshes=function(){var e=new Array;this._rootBabylonMesh&&e.push(this._rootBabylonMesh);var t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){e.push(t)}))}return e},e.prototype._getTransformNodes=function(){var e=new Array,t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},e.prototype._getSkeletons=function(){var e=new Array,t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},e.prototype._getAnimationGroups=function(){var e=new Array,t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},e.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case _.NONE:break;case _.FIRST:0!==(e=this._getAnimationGroups()).length&&e[0].start(!0);break;case _.ALL:for(var e,t=0,n=e=this._getAnimationGroups();t<n.length;t++)n[t].start(!0);break;default:return void d.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},e.prototype.loadNodeAsync=function(t,n,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadNodeAsync(t,n,r);if(a)return a;if(n._babylonTransformNode)throw new Error("".concat(t,": Invalid recursive node hierarchy"));var s=new Array;this.logOpen("".concat(t," ").concat(n.name||""));var i=function(a){if(e.AddPointerMetadata(a,t),e._LoadTransform(n,a),null!=n.camera){var i=oe.Get("".concat(t,"/camera"),o._gltf.cameras,n.camera);s.push(o.loadCameraAsync("/cameras/".concat(i.index),i,(function(e){e.parent=a})))}if(n.children)for(var l=0,c=n.children;l<c.length;l++){var u=c[l],d=oe.Get("".concat(t,"/children/").concat(u),o._gltf.nodes,u);s.push(o.loadNodeAsync("/nodes/".concat(d.index),d,(function(e){e.parent=a})))}r(a)};if(null==n.mesh||null!=n.skin){var l=n.name||"node".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var c=new d.TransformNode(l,this._babylonScene);c._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==n.mesh?n._babylonTransformNode=c:n._babylonTransformNodeForSkin=c,i(c)}if(null!=n.mesh)if(null==n.skin){var u=oe.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh);s.push(this._loadMeshAsync("/meshes/".concat(u.index),n,u,i))}else u=oe.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh),s.push(this._loadMeshAsync("/meshes/".concat(u.index),n,u,(function(e){e.metadata=n._babylonTransformNodeForSkin.metadata;var r=oe.Get("".concat(t,"/skin"),o._gltf.skins,n.skin);s.push(o._loadSkinAsync("/skins/".concat(r.index),n,r,(function(t){o._forEachPrimitive(n,(function(e){e.skeleton=t})),o._postSceneLoadActions.push((function(){if(null!=r.skeleton){var t=oe.Get("/skins/".concat(r.index,"/skeleton"),o._gltf.nodes,r.skeleton).parent;n.index===t.index?e.parent=n._babylonTransformNodeForSkin.parent:e.parent=t._babylonTransformNode}else e.parent=o._rootBabylonMesh}))})))})));return this.logClose(),Promise.all(s).then((function(){return o._forEachPrimitive(n,(function(e){e.geometry&&e.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0)})),n._babylonTransformNode}))},e.prototype._loadMeshAsync=function(e,t,n,r){var o=n.primitives;if(!o||!o.length)throw new Error("".concat(e,": Primitives are missing"));null==o[0].index&&oe.Assign(o);var a=new Array;this.logOpen("".concat(e," ").concat(n.name||""));var s=t.name||"node".concat(t.index);if(1===o.length){var i=n.primitives[0];a.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(i.index),s,t,n,i,(function(e){t._babylonTransformNode=e,t._primitiveBabylonMeshes=[e]})))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new d.TransformNode(s,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(var l=0,c=o;l<c.length;l++)i=c[l],a.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(i.index),"".concat(s,"_primitive").concat(i.index),t,n,i,(function(e){e.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(e)})))}return r(t._babylonTransformNode),this.logClose(),Promise.all(a).then((function(){return t._babylonTransformNode}))},e.prototype._loadMeshPrimitiveAsync=function(t,n,r,o,a,s){var i=this,l=this._extensionsLoadMeshPrimitiveAsync(t,n,r,o,a,s);if(l)return l;this.logOpen("".concat(t));var c,u,h=0===this._disableInstancedMesh&&this._parent.createInstances&&null==r.skin&&!o.primitives[0].targets;if(h&&a._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(c=a._instanceData.babylonSourceMesh.createInstance(n))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,u=a._instanceData.promise;else{var f=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var p=new d.Mesh(n,this._babylonScene);p._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,p.overrideMaterialSideOrientation=this._babylonScene.useRightHandedSystem?d.Material.CounterClockWiseSideOrientation:d.Material.ClockWiseSideOrientation,this._createMorphTargets(t,r,o,a,p),f.push(this._loadVertexDataAsync(t,a,p).then((function(e){return i._loadMorphTargetsAsync(t,a,p,e).then((function(){i._disposed||(i._babylonScene._blockEntityCollection=!!i._assetContainer,e.applyToMesh(p),e._parentContainer=i._assetContainer,i._babylonScene._blockEntityCollection=!1)}))})));var _=e._GetDrawMode(t,a.mode);if(null==a.material){var m=this._defaultBabylonMaterialData[_];m||(m=this._createDefaultMaterial("__GLTFLoader._default",_),this._parent.onMaterialLoadedObservable.notifyObservers(m),this._defaultBabylonMaterialData[_]=m),p.material=m}else if(!this.parent.skipMaterials){var y=oe.Get("".concat(t,"/material"),this._gltf.materials,a.material);f.push(this._loadMaterialAsync("/materials/".concat(y.index),y,p,_,(function(e){p.material=e})))}u=Promise.all(f),h&&(a._instanceData={babylonSourceMesh:p,promise:u}),c=p}return e.AddPointerMetadata(c,t),this._parent.onMeshLoadedObservable.notifyObservers(c),s(c),this.logClose(),u.then((function(){return c}))},e.prototype._loadVertexDataAsync=function(e,t,n){var r=this,o=this._extensionsLoadVertexDataAsync(e,t,n);if(o)return o;var a=t.attributes;if(!a)throw new Error("".concat(e,": Attributes are missing"));var s=new Array,i=new d.Geometry(n.name,this._babylonScene);if(null==t.indices)n.isUnIndexed=!0;else{var l=oe.Get("".concat(e,"/indices"),this._gltf.accessors,t.indices);s.push(this._loadIndicesAccessorAsync("/accessors/".concat(l.index),l).then((function(e){i.setIndices(e)})))}var c=function(t,o,l){if(null!=a[t]){n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(o)&&n._delayInfo.push(o);var c=oe.Get("".concat(e,"/attributes/").concat(t),r._gltf.accessors,a[t]);s.push(r._loadVertexAccessorAsync("/accessors/".concat(c.index),c,o).then((function(e){if(e.getKind()===d.VertexBuffer.PositionKind&&!r.parent.alwaysComputeBoundingBox&&!n.skeleton){var t=c.min,o=c.max;if(void 0!==t&&void 0!==o){if(c.normalized&&5126!==c.componentType){var a=1;switch(c.componentType){case 5120:a=127;break;case 5121:a=255;break;case 5122:a=32767;break;case 5123:a=65535}for(var s=0;s<3;++s)t[s]=Math.max(t[s]/a,-1),o[s]=Math.max(o[s]/a,-1)}var l=d.TmpVectors.Vector3[0],u=d.TmpVectors.Vector3[1];l.copyFromFloats.apply(l,t),u.copyFromFloats.apply(u,o),i._boundingInfo=new d.BoundingInfo(l,u),i.useBoundingInfoFromGeometry=!0}}i.setVerticesBuffer(e,c.count)}))),o==d.VertexBuffer.MatricesIndicesExtraKind&&(n.numBoneInfluencers=8),l&&l(c)}};return c("POSITION",d.VertexBuffer.PositionKind),c("NORMAL",d.VertexBuffer.NormalKind),c("TANGENT",d.VertexBuffer.TangentKind),c("TEXCOORD_0",d.VertexBuffer.UVKind),c("TEXCOORD_1",d.VertexBuffer.UV2Kind),c("TEXCOORD_2",d.VertexBuffer.UV3Kind),c("TEXCOORD_3",d.VertexBuffer.UV4Kind),c("TEXCOORD_4",d.VertexBuffer.UV5Kind),c("TEXCOORD_5",d.VertexBuffer.UV6Kind),c("JOINTS_0",d.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",d.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",d.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",d.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",d.VertexBuffer.ColorKind,(function(e){"VEC4"===e.type&&(n.hasVertexAlpha=!0)})),Promise.all(s).then((function(){return i}))},e.prototype._createMorphTargets=function(e,t,n,r,o){if(r.targets){if(null==t._numMorphTargets)t._numMorphTargets=r.targets.length;else if(r.targets.length!==t._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var a=n.extras?n.extras.targetNames:null;o.morphTargetManager=new d.MorphTargetManager(o.getScene()),o.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<r.targets.length;s++){var i=t.weights?t.weights[s]:n.weights?n.weights[s]:0,l=a?a[s]:"morphTarget".concat(s);o.morphTargetManager.addTarget(new d.MorphTarget(l,i,o.getScene()))}}},e.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,s=0;s<a.numTargets;s++){var i=a.getTarget(s);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(s),r,t.targets[s],i))}return Promise.all(o).then((function(){a.areUpdatesFrozen=!1}))},e.prototype._loadMorphTargetVertexDataAsync=function(e,t,n,r){var o=this,a=new Array,s=function(r,s,i){if(null!=n[r]){var l=t.getVertexBuffer(s);if(l){var c=oe.Get("".concat(e,"/").concat(r),o._gltf.accessors,n[r]);a.push(o._loadFloatAccessorAsync("/accessors/".concat(c.index),c).then((function(e){i(l,e)})))}}};return s("POSITION",d.VertexBuffer.PositionKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,(function(e,r){n[r]=t[r]+e})),r.setPositions(n)})),s("NORMAL",d.VertexBuffer.NormalKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,(function(e,r){n[r]=t[r]+e})),r.setNormals(n)})),s("TANGENT",d.VertexBuffer.TangentKind,(function(e,t){var n=new Float32Array(t.length/3*4),o=0;e.forEach(t.length/3*4,(function(e,r){(r+1)%4!=0&&(n[o]=t[o]+e,o++)})),r.setTangents(n)})),Promise.all(a).then((function(){}))},e._LoadTransform=function(e,t){if(null==e.skin){var n=d.Vector3.Zero(),r=d.Quaternion.Identity(),o=d.Vector3.One();e.matrix?d.Matrix.FromArray(e.matrix).decompose(o,r,n):(e.translation&&(n=d.Vector3.FromArray(e.translation)),e.rotation&&(r=d.Quaternion.FromArray(e.rotation)),e.scale&&(o=d.Vector3.FromArray(e.scale))),t.position=n,t.rotationQuaternion=r,t.scaling=o}},e.prototype._loadSkinAsync=function(e,t,n,r){var o=this,a=this._extensionsLoadSkinAsync(e,t,n);if(a)return a;if(n._data)return r(n._data.babylonSkeleton),n._data.promise;var s="skeleton".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var i=new d.Skeleton(n.name||s,s,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,n,i);var l=this._loadSkinInverseBindMatricesDataAsync(e,n).then((function(e){o._updateBoneMatrices(i,e)}));return n._data={babylonSkeleton:i,promise:l},r(i),l},e.prototype._loadBones=function(e,t,n){if(null==t.skeleton||this._parent.alwaysComputeSkeletonRootNode){var r=this._findSkeletonRootNode("".concat(e,"/joints"),t.joints);if(r)if(void 0===t.skeleton)t.skeleton=r.index;else{var o=oe.Get("".concat(e,"/skeleton"),this._gltf.nodes,t.skeleton);o===r||function(e,t){for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1}(o,r)||(d.Logger.Warn("".concat(e,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),t.skeleton=r.index)}else d.Logger.Warn("".concat(e,": Failed to find common root"))}for(var a={},s=0,i=t.joints;s<i.length;s++){var l=i[s],c=oe.Get("".concat(e,"/joints/").concat(l),this._gltf.nodes,l);this._loadBone(c,t,n,a)}},e.prototype._findSkeletonRootNode=function(e,t){if(0===t.length)return null;for(var n={},r=0,o=t;r<o.length;r++){for(var a=o[r],s=new Array,i=oe.Get("".concat(e,"/").concat(a),this._gltf.nodes,a);-1!==i.index;)s.unshift(i),i=i.parent;n[a]=s}for(var l=null,c=0;;++c){if(c>=(s=n[t[0]]).length)return l;i=s[c];for(var u=1;u<t.length;++u)if(c>=(s=n[t[u]]).length||i!==s[c])return l;l=i}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&d.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var s=t.joints.indexOf(e.index);return o=new d.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,s),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=oe.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n<r.length;n++){var o=r[n],a=d.Matrix.Identity(),s=o._index;t&&-1!==s&&(d.Matrix.FromArrayToRef(t,16*s,a),a.invertToRef(a));var i=o.getParent();i&&a.multiplyToRef(i.getInvertedAbsoluteTransform(),a),o.updateMatrix(a,!1,!1),o._updateDifferenceMatrix(void 0,!1)}},e.prototype._getNodeMatrix=function(e){return e.matrix?d.Matrix.FromArray(e.matrix):d.Matrix.Compose(e.scale?d.Vector3.FromArray(e.scale):d.Vector3.One(),e.rotation?d.Quaternion.FromArray(e.rotation):d.Quaternion.Identity(),e.translation?d.Vector3.FromArray(e.translation):d.Vector3.Zero())},e.prototype.loadCameraAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadCameraAsync(t,n,r);if(o)return o;var a=new Array;this.logOpen("".concat(t," ").concat(n.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new d.FreeCamera(n.name||"camera".concat(n.index),d.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.ignoreParentScaling=!0,s.rotation=new d.Vector3(0,Math.PI,0),n.type){case"perspective":var i=n.perspective;if(!i)throw new Error("".concat(t,": Camera perspective properties are missing"));s.fov=i.yfov,s.minZ=i.znear,s.maxZ=i.zfar||0;break;case"orthographic":if(!n.orthographic)throw new Error("".concat(t,": Camera orthographic properties are missing"));s.mode=d.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-n.orthographic.xmag,s.orthoRight=n.orthographic.xmag,s.orthoBottom=-n.orthographic.ymag,s.orthoTop=n.orthographic.ymag,s.minZ=n.orthographic.znear,s.maxZ=n.orthographic.zfar;break;default:throw new Error("".concat(t,": Invalid camera type (").concat(n.type,")"))}return e.AddPointerMetadata(s,t),this._parent.onCameraLoadedObservable.notifyObservers(s),r(s),this.logClose(),Promise.all(a).then((function(){return s}))},e.prototype._loadAnimationsAsync=function(){var e=this._gltf.animations;if(!e)return Promise.resolve();for(var t=new Array,n=0;n<e.length;n++){var r=e[n];t.push(this.loadAnimationAsync("/animations/".concat(r.index),r).then((function(e){0===e.targetedAnimations.length&&e.dispose()})))}return Promise.all(t).then((function(){}))},e.prototype.loadAnimationAsync=function(e,t){var n=this._extensionsLoadAnimationAsync(e,t);if(n)return n;this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new d.AnimationGroup(t.name||"animation".concat(t.index),this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=r;var o=new Array;oe.Assign(t.channels),oe.Assign(t.samplers);for(var a=0,s=t.channels;a<s.length;a++){var i=s[a];o.push(this._loadAnimationChannelAsync("".concat(e,"/channels/").concat(i.index),e,t,i,r))}return Promise.all(o).then((function(){return r.normalize(0),r}))},e.prototype._loadAnimationChannelAsync=function(e,t,n,r,o,a){var s=this;if(void 0===a&&(a=null),null==r.target.node)return Promise.resolve();var i=oe.Get("".concat(e,"/target/node"),this._gltf.nodes,r.target.node);if("weights"===r.target.path&&!i._numMorphTargets||"weights"!==r.target.path&&!i._babylonTransformNode)return Promise.resolve();var l=oe.Get("".concat(e,"/sampler"),n.samplers,r.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(r.sampler),l).then((function(t){var n,l;switch(r.target.path){case"translation":n="position",l=d.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":n="rotationQuaternion",l=d.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":n="scaling",l=d.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":n="influence",l=d.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(r.target.path,")"))}var c,u,h=0;switch(n){case"position":c=function(e){var n=d.Vector3.FromArray(t.output,h).scaleInPlace(e);return h+=3,n};break;case"rotationQuaternion":c=function(e){var n=d.Quaternion.FromArray(t.output,h).scaleInPlace(e);return h+=4,n};break;case"scaling":c=function(e){var n=d.Vector3.FromArray(t.output,h).scaleInPlace(e);return h+=3,n};break;case"influence":c=function(e){for(var n=new Array(i._numMorphTargets),r=0;r<i._numMorphTargets;r++)n[r]=t.output[h++]*e;return n}}switch(t.interpolation){case"STEP":u=function(e){return{frame:t.input[e]*s.parent.targetFps,value:c(1),interpolation:d.AnimationKeyInterpolation.STEP}};break;case"LINEAR":u=function(e){return{frame:t.input[e]*s.parent.targetFps,value:c(1)}};break;case"CUBICSPLINE":var f=1/s.parent.targetFps;u=function(e){return{frame:t.input[e]*s.parent.targetFps,inTangent:c(f),value:c(1),outTangent:c(f)}}}for(var p=new Array(t.input.length),_=0;_<t.input.length;_++)p[_]=u(_);if("influence"===n)for(var m=function(e){var t="".concat(o.name,"_channel").concat(o.targetedAnimations.length),r=new d.Animation(t,n,s.parent.targetFps,l);r.setKeys(p.map((function(t){return{frame:t.frame,inTangent:t.inTangent?t.inTangent[e]:void 0,value:t.value[e],outTangent:t.outTangent?t.outTangent[e]:void 0}}))),s._forEachPrimitive(i,(function(t){var n=t.morphTargetManager.getTarget(e),a=r.clone();n.animations.push(a),o.addTargetedAnimation(a,n)}))},y=0;y<i._numMorphTargets;y++)m(y);else{var v="".concat(o.name,"_channel").concat(o.targetedAnimations.length),b=new d.Animation(v,n,s.parent.targetFps,l);b.setKeys(p),null!=a&&null!=a.animations?(a.animations.push(b),o.addTargetedAnimation(b,a)):(i._babylonTransformNode.animations.push(b),o.addTargetedAnimation(b,i._babylonTransformNode))}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=oe.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=oe.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=oe.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),s=a*d.VertexBuffer.GetTypeByteLength(n.componentType),i=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(i));else{var l=oe.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(l.index),l).then((function(o){if(5126!==n.componentType||n.normalized||l.byteStride&&l.byteStride!==s){var c=new r(i);return d.VertexBuffer.ForEach(o,n.byteOffset||0,l.byteStride||s,a,n.componentType,c.length,n.normalized||!1,(function(e,t){c[t]=e})),c}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,i)}))}if(n.sparse){var c=n.sparse;n._data=n._data.then((function(i){var l=i,u=oe.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,c.indices.bufferView),h=oe.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,c.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(u.index),u),o.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then((function(o){var i,u=o[0],h=o[1],f=e._GetTypedArray("".concat(t,"/sparse/indices"),c.indices.componentType,u,c.indices.byteOffset,c.count),p=a*c.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,c.values.byteOffset,p);i=new r(p),d.VertexBuffer.ForEach(_,0,s,a,n.componentType,i.length,n.normalized||!1,(function(e,t){i[t]=e}))}else i=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,h,c.values.byteOffset,p);for(var m=0,y=0;y<f.length;y++)for(var v=f[y]*a,b=0;b<a;b++)l[v++]=i[m++];return l}))}))}return n._data},e.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},e.prototype._loadIndicesAccessorAsync=function(t,n){if("SCALAR"!==n.type)throw new Error("".concat(t,"/type: Invalid value ").concat(n.type));if(5121!==n.componentType&&5123!==n.componentType&&5125!==n.componentType)throw new Error("".concat(t,"/componentType: Invalid value ").concat(n.componentType));if(n._data)return n._data;if(n.sparse){var r=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n.componentType);n._data=this._loadAccessorAsync(t,n,r)}else{var o=oe.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then((function(r){return e._GetTypedArray(t,n.componentType,r,n.byteOffset,n.count)}))}return n._data},e.prototype._loadVertexBufferViewAsync=function(e){if(e._babylonBuffer)return e._babylonBuffer;var t=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then((function(e){return new d.Buffer(t,e,!1)})),e._babylonBuffer},e.prototype._loadVertexAccessorAsync=function(t,n,r){var o;if(null===(o=n._babylonVertexBuffer)||void 0===o?void 0:o[r])return n._babylonVertexBuffer[r];n._babylonVertexBuffer||(n._babylonVertexBuffer={});var a=this._babylonScene.getEngine();if(n.sparse)n._babylonVertexBuffer[r]=this._loadFloatAccessorAsync(t,n).then((function(e){return new d.VertexBuffer(a,e,r,!1)}));else if(r===d.VertexBuffer.MatricesIndicesKind||r===d.VertexBuffer.MatricesIndicesExtraKind)n._babylonVertexBuffer[r]=this._loadFloatAccessorAsync(t,n).then((function(e){return new d.VertexBuffer(a,e,r,!1)}));else{var s=oe.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer[r]=this._loadVertexBufferViewAsync(s).then((function(o){var i=e._GetNumComponents(t,n.type);return new d.VertexBuffer(a,o,r,!1,!1,s.byteStride,!1,n.byteOffset,i,n.componentType,n.normalized,!0,1,!0)}))}return n._babylonVertexBuffer[r]},e.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;return t&&(t.baseColorFactor?(n.albedoColor=d.Color3.FromArray(t.baseColorFactor),n.alpha=t.baseColorFactor[3]):n.albedoColor=d.Color3.White(),n.metallic=null==t.metallicFactor?1:t.metallicFactor,n.roughness=null==t.roughnessFactor?1:t.roughnessFactor,t.baseColorTexture&&r.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),t.baseColorTexture,(function(e){e.name="".concat(n.name," (Base Color)"),n.albedoTexture=e}))),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),t.metallicRoughnessTexture,(function(e){e.name="".concat(n.name," (Metallic Roughness)"),n.metallicTexture=e}))),n.useMetallnessFromMetallicTextureBlue=!0,n.useRoughnessFromMetallicTextureGreen=!0,n.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(r).then((function(){}))},e.prototype._loadMaterialAsync=function(t,n,r,o,a){void 0===a&&(a=function(){});var s=this._extensionsLoadMaterialAsync(t,n,r,o,a);if(s)return s;n._data=n._data||{};var i=n._data[o];if(!i){this.logOpen("".concat(t," ").concat(n.name||""));var l=this.createMaterial(t,n,o);i={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(t,n,l)},n._data[o]=i,e.AddPointerMetadata(l,t),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(i.babylonMeshes.push(r),r.onDisposeObservable.addOnce((function(){var e=i.babylonMeshes.indexOf(r);-1!==e&&i.babylonMeshes.splice(e,1)}))),a(i.babylonMaterial),i.promise.then((function(){return i.babylonMaterial}))},e.prototype._createDefaultMaterial=function(e,t){this._babylonScene._blockEntityCollection=!!this._assetContainer;var n=new d.PBRMaterial(e,this._babylonScene);return n._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.fillMode=t,n.enableSpecularAntiAliasing=!0,n.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,n.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,n.transparencyMode=d.PBRMaterial.PBRMATERIAL_OPAQUE,n.metallic=1,n.roughness=1,n},e.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n)},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then((function(){}))},e.prototype.loadMaterialBasePropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;return n.emissiveColor=t.emissiveFactor?d.Color3.FromArray(t.emissiveFactor):new d.Color3(0,0,0),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),t.normalTexture,(function(e){e.name="".concat(n.name," (Normal)"),n.bumpTexture=e}))),n.invertNormalMapX=!this._babylonScene.useRightHandedSystem,n.invertNormalMapY=this._babylonScene.useRightHandedSystem,null!=t.normalTexture.scale&&n.bumpTexture&&(n.bumpTexture.level=t.normalTexture.scale),n.forceIrradianceInFragment=!0),t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,r.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),t.occlusionTexture,(function(e){e.name="".concat(n.name," (Occlusion)"),n.ambientTexture=e}))),n.useAmbientInGrayScale=!0,null!=t.occlusionTexture.strength&&(n.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&r.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),t.emissiveTexture,(function(e){e.name="".concat(n.name," (Emissive)"),n.emissiveTexture=e}))),Promise.all(r).then((function(){}))},e.prototype.loadMaterialAlphaProperties=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));switch(t.alphaMode||"OPAQUE"){case"OPAQUE":n.transparencyMode=d.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":n.transparencyMode=d.PBRMaterial.PBRMATERIAL_ALPHATEST,n.alphaCutOff=null==t.alphaCutoff?.5:t.alphaCutoff,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0);break;case"BLEND":n.transparencyMode=d.PBRMaterial.PBRMATERIAL_ALPHABLEND,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0,n.useAlphaFromAlbedoTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(t.alphaMode,")"))}},e.prototype.loadTextureInfoAsync=function(t,n,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadTextureInfoAsync(t,n,r);if(a)return a;if(this.logOpen("".concat(t)),n.texCoord>=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var s=oe.Get("".concat(t,"/index"),this._gltf.textures,n.index);s._textureInfo=n;var i=this._loadTextureAsync("/textures/".concat(n.index),s,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),i},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:oe.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),s=oe.Get("".concat(t,"/source"),this._gltf.images,n.source),i=this._createTextureAsync(t,a,s,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),i},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var s=this;void 0===r&&(r=function(){});var i=this._loadSampler("/samplers/".concat(t.index),t),l=new Array,c=new d.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var u={noMipmap:i.noMipMaps,invertY:!1,samplingMode:i.samplingMode,onLoad:function(){s._disposed||c.resolve()},onError:function(t,n){s._disposed||c.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},h=new d.Texture(null,this._babylonScene,u);return h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(c.promise),l.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(s._fileName,"#image").concat(n.index),r="data:".concat(s._uniqueRootUrl).concat(t);h.updateURL(r,e)}))),h.wrapU=i.wrapU,h.wrapV=i.wrapV,r(h),Promise.all(l).then((function(){return h}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=oe.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,d.IsBase64DataUrl)(r)){var s=new Uint8Array((0,d.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new d.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){var n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return d.Texture.CLAMP_ADDRESSMODE;case 33648:return d.Texture.MIRROR_ADDRESSMODE;case 10497:return d.Texture.WRAP_ADDRESSMODE;default:return d.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),d.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return d.Texture.LINEAR_NEAREST;case 9729:return d.Texture.LINEAR_LINEAR;case 9984:return d.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return d.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return d.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return d.Texture.LINEAR_LINEAR_MIPLINEAR;default:return d.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),d.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&d.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return d.Texture.NEAREST_NEAREST;case 9729:return d.Texture.NEAREST_LINEAR;case 9984:return d.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return d.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return d.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return d.Texture.NEAREST_LINEAR_MIPLINEAR;default:return d.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),d.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var s=r.buffer;o=r.byteOffset+(o||0);var i=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),l=d.VertexBuffer.GetTypeByteLength(n);return o%l!=0?(d.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(l,")")),new i(s.slice(o,o+a*l),0)):new i(s,o,a)},e._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("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return d.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return d.Material.PointListDrawMode;case 1:return d.Material.LineListDrawMode;case 2:return d.Material.LineLoopDrawMode;case 3:return d.Material.LineStripDrawMode;case 4:return d.Material.TriangleFillMode;case 5:return d.Material.TriangleStripDrawMode;case 6:return d.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var s=o._data[a],i=0,l=s.babylonMeshes;i<l.length;i++){var c=l[i];c.computeWorldMatrix(!0);var u=s.babylonMaterial;t.push(u.forceCompilationAsync(c)),t.push(u.forceCompilationAsync(c,{useInstances:!0})),this._parent.useClipPlane&&(t.push(u.forceCompilationAsync(c,{clipPlane:!0})),t.push(u.forceCompilationAsync(c,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile materials")}))},e.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile shadow generators")}))},e.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},e.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var s="".concat(a.name,".").concat(t),i=e;i._activeLoaderExtensionFunctions=i._activeLoaderExtensionFunctions||{};var l=i._activeLoaderExtensionFunctions;if(!l[s]){l[s]=!0;try{var c=n(a);if(c)return c}finally{delete l[s]}}}}return null},e.prototype._extensionsOnLoading=function(){this._forEachExtensions((function(e){return e.onLoading&&e.onLoading()}))},e.prototype._extensionsOnReady=function(){this._forEachExtensions((function(e){return e.onReady&&e.onReady()}))},e.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",(function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)}))},e.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",(function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)}))},e.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",(function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)}))},e.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",(function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)}))},e.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",(function(s){return s._loadMeshPrimitiveAsync&&s._loadMeshPrimitiveAsync(e,t,n,r,o,a)}))},e.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",(function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)}))},e.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",(function(r){return r.createMaterial&&r.createMaterial(e,t,n)}))},e.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",(function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)}))},e.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",(function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)}))},e.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",(function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)}))},e.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",(function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)}))},e.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",(function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)}))},e.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",(function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)}))},e.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",(function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)}))},e.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",(function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)}))},e.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},e.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},e.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},e.prototype.logOpen=function(e){this._parent._logOpen(e)},e.prototype.logClose=function(){this._parent._logClose()},e.prototype.log=function(e){this._parent._log(e)},e.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},e.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},e._RegisteredExtensions={},e.DefaultSampler={index:-1},e}();b._CreateGLTF2Loader=function(e){return new ae(e)};var se="EXT_lights_image_based",ie=function(){function e(e){this.name=se,this._loader=e,this.enabled=this._loader.isExtensionUsed(se)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return ae.LoadExtensionAsync(e,t,this.name,(function(r,o){var a=new Array;a.push(n._loader.loadSceneAsync(e,t)),n._loader.logOpen("".concat(r));var s=oe.Get("".concat(r,"/light"),n._lights,o.light);return a.push(n._loadLightAsync("/extensions/".concat(n.name,"/lights/").concat(o.light),s).then((function(e){n._loader.babylonScene.environmentTexture=e}))),n._loader.logClose(),Promise.all(a).then((function(){}))}))},e.prototype._loadLightAsync=function(e,t){var n=this;if(!t._loaded){var r=new Array;this._loader.logOpen("".concat(e));for(var o=new Array(t.specularImages.length),a=function(n){var a=t.specularImages[n];o[n]=new Array(a.length);for(var i=function(t){var i="".concat(e,"/specularImages/").concat(n,"/").concat(t);s._loader.logOpen("".concat(i));var l=a[t],c=oe.Get(i,s._loader.gltf.images,l);r.push(s._loader.loadImageAsync("/images/".concat(l),c).then((function(e){o[n][t]=e}))),s._loader.logClose()},l=0;l<a.length;l++)i(l)},s=this,i=0;i<t.specularImages.length;i++)a(i);this._loader.logClose(),t._loaded=Promise.all(r).then((function(){var r=new d.RawCubeTexture(n._loader.babylonScene,null,t.specularImageSize);if(r.name=t.name||"environment",t._babylonTexture=r,null!=t.intensity&&(r.level=t.intensity),t.rotation){var a=d.Quaternion.FromArray(t.rotation);n._loader.babylonScene.useRightHandedSystem||(a=d.Quaternion.Inverse(a)),d.Matrix.FromQuaternionToRef(a,r.getReflectionTextureMatrix())}if(!t.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));var s=d.SphericalHarmonics.FromArray(t.irradianceCoefficients);s.scaleInPlace(t.intensity),s.convertIrradianceToLambertianRadiance();var i=d.SphericalPolynomial.FromHarmonics(s),l=(o.length-1)/d.Scalar.Log2(t.specularImageSize);return r.updateRGBDAsync(o,i,l)}))}return t._loaded.then((function(){return t._babylonTexture}))},e}();ae.RegisterExtension(se,(function(e){return new ie(e)}));var le="EXT_mesh_gpu_instancing",ce=function(){function e(e){this.name=le,this._loader=e,this.enabled=this._loader.isExtensionUsed(le)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(e,o){r._loader._disableInstancedMesh++;var a=r._loader.loadNodeAsync("/nodes/".concat(t.index),t,n);if(r._loader._disableInstancedMesh--,!t._primitiveBabylonMeshes)return a;var s=new Array,i=0,l=function(t){if(null!=o.attributes[t]){var n=oe.Get("".concat(e,"/attributes/").concat(t),r._loader.gltf.accessors,o.attributes[t]);if(s.push(r._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===i)i=n.count;else if(i!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else s.push(Promise.resolve(null))};return l("TRANSLATION"),l("ROTATION"),l("SCALE"),a.then((function(e){return Promise.all(s).then((function(n){var r=n[0],o=n[1],a=n[2],s=new Float32Array(16*i);d.TmpVectors.Vector3[0].copyFromFloats(0,0,0),d.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),d.TmpVectors.Vector3[1].copyFromFloats(1,1,1);for(var l=0;l<i;++l)r&&d.Vector3.FromArrayToRef(r,3*l,d.TmpVectors.Vector3[0]),o&&d.Quaternion.FromArrayToRef(o,4*l,d.TmpVectors.Quaternion[0]),a&&d.Vector3.FromArrayToRef(a,3*l,d.TmpVectors.Vector3[1]),d.Matrix.ComposeToRef(d.TmpVectors.Vector3[1],d.TmpVectors.Quaternion[0],d.TmpVectors.Vector3[0],d.TmpVectors.Matrix[0]),d.TmpVectors.Matrix[0].copyToArray(s,16*l);for(var c=0,u=t._primitiveBabylonMeshes;c<u.length;c++)u[c].thinInstanceSetBuffer("matrix",s,16,!0);return e}))}))}))},e}();ae.RegisterExtension(le,(function(e){return new ce(e)}));var ue="EXT_meshopt_compression",de=function(){function e(e){this.name=ue,this.enabled=e.isExtensionUsed(ue),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,t){var n=this;return ae.LoadExtensionAsync(e,t,this.name,(function(r,o){var a=t;if(a._meshOptData)return a._meshOptData;var s=oe.Get("".concat(e,"/buffer"),n._loader.gltf.buffers,o.buffer);return a._meshOptData=n._loader.loadBufferAsync("/buffers/".concat(s.index),s,o.byteOffset||0,o.byteLength).then((function(e){return d.MeshoptCompression.Default.decodeGltfBufferAsync(e,o.count,o.byteStride,o.mode,o.filter)})),a._meshOptData}))},e}();ae.RegisterExtension(ue,(function(e){return new de(e)}));var he="EXT_texture_webp",fe=function(){function e(e){this.name=he,this._loader=e,this.enabled=e.isExtensionUsed(he)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=null==t.sampler?ae.DefaultSampler:oe.Get("".concat(e,"/sampler"),r._loader.gltf.samplers,t.sampler),i=oe.Get("".concat(o,"/source"),r._loader.gltf.images,a.source);return r._loader._createTextureAsync(e,s,i,(function(e){n(e)}),void 0,!t._textureInfo.nonColorData)}))},e}();ae.RegisterExtension(he,(function(e){return new fe(e)}));var pe="KHR_draco_mesh_compression",_e=function(){function e(e){this.name=pe,this._loader=e,this.enabled=d.DracoCompression.DecoderAvailable&&this._loader.isExtensionUsed(pe)}return e.prototype.dispose=function(){delete this.dracoCompression,this._loader=null},e.prototype._loadVertexDataAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){if(null!=t.mode){if(5!==t.mode&&4!==t.mode)throw new Error("".concat(e,": Unsupported mode ").concat(t.mode));if(5===t.mode)throw new Error("".concat(e,": Mode ").concat(t.mode," is not currently supported"))}var s={},i={},l=function(o,l){var c=a.attributes[o];if(void 0!==c&&void 0!==t.attributes[o]){s[l]=c;var u=oe.Get("".concat(e,"/attributes/").concat(o),r._loader.gltf.accessors,t.attributes[o]);if(u.normalized&&5126!==u.componentType){var d=1;switch(u.componentType){case 5120:d=127;break;case 5121:d=255;break;case 5122:d=32767;break;case 5123:d=65535}i[l]=d}n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(l)&&n._delayInfo.push(l)}};l("POSITION",d.VertexBuffer.PositionKind),l("NORMAL",d.VertexBuffer.NormalKind),l("TANGENT",d.VertexBuffer.TangentKind),l("TEXCOORD_0",d.VertexBuffer.UVKind),l("TEXCOORD_1",d.VertexBuffer.UV2Kind),l("TEXCOORD_2",d.VertexBuffer.UV3Kind),l("TEXCOORD_3",d.VertexBuffer.UV4Kind),l("TEXCOORD_4",d.VertexBuffer.UV5Kind),l("TEXCOORD_5",d.VertexBuffer.UV6Kind),l("JOINTS_0",d.VertexBuffer.MatricesIndicesKind),l("WEIGHTS_0",d.VertexBuffer.MatricesWeightsKind),l("COLOR_0",d.VertexBuffer.ColorKind);var c=oe.Get(o,r._loader.gltf.bufferViews,a.bufferView);return c._dracoBabylonGeometry||(c._dracoBabylonGeometry=r._loader.loadBufferViewAsync("/bufferViews/".concat(c.index),c).then((function(t){return(r.dracoCompression||d.DracoCompression.Default).decodeMeshAsync(t,s,i).then((function(e){var t=new d.Geometry(n.name,r._loader.babylonScene);return e.applyToGeometry(t),t})).catch((function(t){throw new Error("".concat(e,": ").concat(t.message))}))}))),c._dracoBabylonGeometry}))},e}();ae.RegisterExtension(pe,(function(e){return new _e(e)}));var me="KHR_lights_punctual",ye=function(){function e(e){this.name=me,this._loader=e,this.enabled=this._loader.isExtensionUsed(me)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){return r._loader.loadNodeAsync(e,t,(function(e){var t,s=oe.Get(o,r._lights,a.light),i=s.name||e.name;switch(r._loader.babylonScene._blockEntityCollection=!!r._loader._assetContainer,s.type){case"directional":t=new d.DirectionalLight(i,d.Vector3.Backward(),r._loader.babylonScene);break;case"point":t=new d.PointLight(i,d.Vector3.Zero(),r._loader.babylonScene);break;case"spot":var l=new d.SpotLight(i,d.Vector3.Zero(),d.Vector3.Backward(),0,1,r._loader.babylonScene);l.angle=2*(s.spot&&s.spot.outerConeAngle||Math.PI/4),l.innerAngle=2*(s.spot&&s.spot.innerConeAngle||0),t=l;break;default:throw r._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(o,": Invalid light type (").concat(s.type,")"))}t._parentContainer=r._loader._assetContainer,r._loader.babylonScene._blockEntityCollection=!1,t.falloffType=d.Light.FALLOFF_GLTF,t.diffuse=s.color?d.Color3.FromArray(s.color):d.Color3.White(),t.intensity=null==s.intensity?1:s.intensity,t.range=null==s.range?Number.MAX_VALUE:s.range,t.parent=e,r._loader._babylonLights.push(t),ae.AddPointerMetadata(t,o),n(e)}))}))},e}();ae.RegisterExtension(me,(function(e){return new ye(e)}));var ve="KHR_materials_pbrSpecularGlossiness",be=function(){function e(e){this.name=ve,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ve)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),s.push(r._loadSpecularGlossinessPropertiesAsync(o,t,a,n)),r._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(s).then((function(){}))}))},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,t,n,r){if(!(r instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return r.metallic=null,r.roughness=null,n.diffuseFactor?(r.albedoColor=d.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):r.albedoColor=d.Color3.White(),r.reflectivityColor=n.specularFactor?d.Color3.FromArray(n.specularFactor):d.Color3.White(),r.microSurface=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,(function(e){e.name="".concat(r.name," (Diffuse)"),r.albedoTexture=e}))),n.specularGlossinessTexture&&(o.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,(function(e){e.name="".concat(r.name," (Specular Glossiness)"),r.reflectivityTexture=e,r.reflectivityTexture.hasAlpha=!0}))),r.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(o).then((function(){}))},e}();ae.RegisterExtension(ve,(function(e){return new be(e)}));var ge="KHR_materials_unlit",Ae=function(){function e(e){this.name=ge,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(ge)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(){return r._loadUnlitPropertiesAsync(e,t,n)}))},e.prototype._loadUnlitPropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;n.unlit=!0;var o=t.pbrMetallicRoughness;return o&&(o.baseColorFactor?(n.albedoColor=d.Color3.FromArray(o.baseColorFactor),n.alpha=o.baseColorFactor[3]):n.albedoColor=d.Color3.White(),o.baseColorTexture&&r.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),o.baseColorTexture,(function(e){e.name="".concat(n.name," (Base Color)"),n.albedoTexture=e})))),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(r).then((function(){}))},e}();ae.RegisterExtension(ge,(function(e){return new Ae(e)}));var Te="KHR_materials_clearcoat",xe=function(){function e(e){this.name=Te,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Te)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadClearCoatPropertiesAsync(o,a,n)),Promise.all(s).then((function(){}))}))},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;return n.clearCoat.isEnabled=!0,n.clearCoat.useRoughnessFromMainTexture=!1,n.clearCoat.remapF0OnInterfaceChange=!1,null!=t.clearcoatFactor?n.clearCoat.intensity=t.clearcoatFactor:n.clearCoat.intensity=0,t.clearcoatTexture&&r.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,(function(e){e.name="".concat(n.name," (ClearCoat Intensity)"),n.clearCoat.texture=e}))),null!=t.clearcoatRoughnessFactor?n.clearCoat.roughness=t.clearcoatRoughnessFactor:n.clearCoat.roughness=0,t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,r.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,(function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),n.clearCoat.textureRoughness=e})))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,r.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,(function(e){e.name="".concat(n.name," (ClearCoat Normal)"),n.clearCoat.bumpTexture=e}))),n.invertNormalMapX=!n.getScene().useRightHandedSystem,n.invertNormalMapY=n.getScene().useRightHandedSystem,null!=t.clearcoatNormalTexture.scale&&(n.clearCoat.bumpTexture.level=t.clearcoatNormalTexture.scale)),Promise.all(r).then((function(){}))},e}();ae.RegisterExtension(Te,(function(e){return new xe(e)}));var Ee="KHR_materials_iridescence",Oe=function(){function e(e){this.name=Ee,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ee)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadIridescencePropertiesAsync(o,a,n)),Promise.all(s).then((function(){}))}))},e.prototype._loadIridescencePropertiesAsync=function(e,t,n){var r,o,a,s,i;if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var l=new Array;return n.iridescence.isEnabled=!0,n.iridescence.intensity=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,n.iridescence.indexOfRefraction=null!==(a=null!==(o=t.iridescenceIor)&&void 0!==o?o:t.iridescenceIOR)&&void 0!==a?a:1.3,n.iridescence.minimumThickness=null!==(s=t.iridescenceThicknessMinimum)&&void 0!==s?s:100,n.iridescence.maximumThickness=null!==(i=t.iridescenceThicknessMaximum)&&void 0!==i?i:400,t.iridescenceTexture&&l.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceTexture"),t.iridescenceTexture,(function(e){e.name="".concat(n.name," (Iridescence Intensity)"),n.iridescence.texture=e}))),t.iridescenceThicknessTexture&&l.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceThicknessTexture"),t.iridescenceThicknessTexture,(function(e){e.name="".concat(n.name," (Iridescence Thickness)"),n.iridescence.thicknessTexture=e}))),Promise.all(l).then((function(){}))},e}();ae.RegisterExtension(Ee,(function(e){return new Oe(e)}));var Me="KHR_materials_emissive_strength",Le=function(){function e(e){this.name=Me,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(Me)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){return r._loader.loadMaterialPropertiesAsync(e,t,n).then((function(){r._loadEmissiveProperties(o,a,n)}))}))},e.prototype._loadEmissiveProperties=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));void 0!==t.emissiveStrength&&n.emissiveColor.scaleToRef(t.emissiveStrength,n.emissiveColor)},e}();ae.RegisterExtension(Me,(function(e){return new Le(e)}));var Ce="KHR_materials_sheen",we=function(){function e(e){this.name=Ce,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ce)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadSheenPropertiesAsync(o,a,n)),Promise.all(s).then((function(){}))}))},e.prototype._loadSheenPropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;return n.sheen.isEnabled=!0,n.sheen.intensity=1,null!=t.sheenColorFactor?n.sheen.color=d.Color3.FromArray(t.sheenColorFactor):n.sheen.color=d.Color3.Black(),t.sheenColorTexture&&r.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),t.sheenColorTexture,(function(e){e.name="".concat(n.name," (Sheen Color)"),n.sheen.texture=e}))),void 0!==t.sheenRoughnessFactor?n.sheen.roughness=t.sheenRoughnessFactor:n.sheen.roughness=0,t.sheenRoughnessTexture&&(t.sheenRoughnessTexture.nonColorData=!0,r.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),t.sheenRoughnessTexture,(function(e){e.name="".concat(n.name," (Sheen Roughness)"),n.sheen.textureRoughness=e})))),n.sheen.albedoScaling=!0,n.sheen.useRoughnessFromMainTexture=!1,Promise.all(r).then((function(){}))},e}();ae.RegisterExtension(Ce,(function(e){return new we(e)}));var Se="KHR_materials_specular",Re=function(){function e(e){this.name=Se,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Se)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadSpecularPropertiesAsync(o,a,n)),Promise.all(s).then((function(){}))}))},e.prototype._loadSpecularPropertiesAsync=function(e,t,n){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var r=new Array;return void 0!==t.specularFactor&&(n.metallicF0Factor=t.specularFactor),void 0!==t.specularColorFactor&&(n.metallicReflectanceColor=d.Color3.FromArray(t.specularColorFactor)),t.specularTexture&&(t.specularTexture.nonColorData=!0,r.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),t.specularTexture,(function(e){e.name="".concat(n.name," (Specular F0 Strength)"),n.metallicReflectanceTexture=e,n.useOnlyMetallicFromMetallicReflectanceTexture=!0})))),t.specularColorTexture&&r.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),t.specularColorTexture,(function(e){e.name="".concat(n.name," (Specular F0 Color)"),n.reflectanceTexture=e}))),Promise.all(r).then((function(){}))},e}();ae.RegisterExtension(Se,(function(e){return new Re(e)}));var Pe="KHR_materials_ior",Ne=function(){function e(e){this.name=Pe,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(Pe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadIorPropertiesAsync(o,a,n)),Promise.all(s).then((function(){}))}))},e.prototype._loadIorPropertiesAsync=function(t,n,r){if(!(r instanceof d.PBRMaterial))throw new Error("".concat(t,": Material type not supported"));return void 0!==n.ior?r.indexOfRefraction=n.ior:r.indexOfRefraction=e._DEFAULT_IOR,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();ae.RegisterExtension(Pe,(function(e){return new Ne(e)}));var Fe="KHR_materials_variants",Ie=function(){function e(e){this.name=Fe,this._loader=e,this.enabled=this._loader.isExtensionUsed(Fe)}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(Fe," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++)r(a[o]);else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){return e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(Fe," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){return e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(Fe," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n.KHR_materials_variants)||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype._loadMeshPrimitiveAsync=function(t,n,r,o,a,s){var i=this;return ae.LoadExtensionAsync(t,a,this.name,(function(l,c){var u=new Array;return u.push(i._loader._loadMeshPrimitiveAsync(t,n,r,o,a,(function(n){if(s(n),n instanceof d.Mesh){var r=ae._GetDrawMode(t,a.mode),o=i._loader.rootBabylonMesh,h=o?o.metadata=o.metadata||{}:{},f=h.gltf=h.gltf||{},p=f.KHR_materials_variants=f.KHR_materials_variants||{lastSelected:null,original:[],variants:{}};p.original.push({mesh:n,material:n.material});for(var _=function(t){var a=c.mappings[t],s=oe.Get("".concat(l,"/mappings/").concat(t,"/material"),i._loader.gltf.materials,a.material);u.push(i._loader._loadMaterialAsync("#/materials/".concat(a.material),s,n,r,(function(t){for(var r=function(r){var s=a.variants[r],l=oe.Get("/extensions/".concat(Fe,"/variants/").concat(s),i._variants,s);p.variants[l.name]=p.variants[l.name]||[],p.variants[l.name].push({mesh:n,material:t}),n.onClonedObservable.add((function(t){var r=t,a=null,s=r;do{if(!(s=s.parent))return;a=e._GetExtensionMetadata(s)}while(null===a);if(o&&a===e._GetExtensionMetadata(o)){for(var i in s.metadata={},o.metadata)s.metadata[i]=o.metadata[i];for(var i in s.metadata.gltf=[],o.metadata.gltf)s.metadata.gltf[i]=o.metadata.gltf[i];s.metadata.gltf.KHR_materials_variants={lastSelected:null,original:[],variants:{}};for(var c=0,u=a.original;c<u.length;c++){var d=u[c];s.metadata.gltf.KHR_materials_variants.original.push({mesh:d.mesh,material:d.material})}for(var i in a.variants)if(Object.prototype.hasOwnProperty.call(a.variants,i)){s.metadata.gltf.KHR_materials_variants.variants[i]=[];for(var h=0,f=a.variants[i];h<f.length;h++){var p=f[h];s.metadata.gltf.KHR_materials_variants.variants[i].push({mesh:p.mesh,material:p.material})}}a=s.metadata.gltf.KHR_materials_variants}for(var _=0,m=a.original;_<m.length;_++)(b=m[_]).mesh===n&&(b.mesh=r);for(var y=0,v=a.variants[l.name];y<v.length;y++){var b;(b=v[y]).mesh===n&&(b.mesh=r)}}))},s=0;s<a.variants.length;++s)r(s)})))},m=0;m<c.mappings.length;++m)_(m)}}))),Promise.all(u).then((function(e){return e[0]}))}))},e}();ae.RegisterExtension(Fe,(function(e){return new Ie(e)}));var Be=function(){function e(t,n){var r=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._options=S(S({},e._GetDefaultOptions()),t),this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new d.Observable,this._scene.onDisposeObservable.addOnce((function(){r.dispose()})),this._parseScene(),this._setupRenderTargets()}return e._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:d.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.updateOptions=function(e){var t=this,n=Object.keys(e).filter((function(n){return t._options[n]!==e[n]}));if(n.length){var r=S(S({},this._options),e),o=this._options;this._options=r,r.renderSize===o.renderSize&&r.renderTargetTextureType===o.renderTargetTextureType&&r.generateMipmaps===o.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=r.samples,this._opaqueRenderTarget.lodGenerationScale=r.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=r.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype._shouldRenderAsTransmission=function(e){return!!e&&!!(e instanceof d.PBRMaterial&&e.subSurface.isRefractionEnabled)},e.prototype._addMesh=function(e){var t=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),d.Tools.SetImmediate((function(){t._shouldRenderAsTransmission(e.material)?(e.material.refractionTexture=t._opaqueRenderTarget,t._transparentMeshesCache.push(e)):t._opaqueMeshesCache.push(e)}))},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);this._shouldRenderAsTransmission(e.material)?(e.material instanceof d.PBRMaterial&&(e.material.subSurface.refractionTexture=this._opaqueRenderTarget),-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e)):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._setupRenderTargets=function(){var e,t,n,r,o=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new d.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(t=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==t?t:this._scene.clearColor.clone(),this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.onBeforeBindObservable.add((function(e){r=o._scene.environmentIntensity,o._scene.environmentIntensity=1,n=o._scene.imageProcessingConfiguration.applyByPostProcess,o._options.clearColor?e.clearColor.copyFrom(o._options.clearColor):o._scene.clearColor.toLinearSpaceToRef(e.clearColor),o._scene.imageProcessingConfiguration._applyByPostProcess=!0})),this._opaqueRenderTarget.onAfterUnbindObservable.add((function(){o._scene.environmentIntensity=r,o._scene.imageProcessingConfiguration._applyByPostProcess=n})),this._transparentMeshesCache.forEach((function(e){o._shouldRenderAsTransmission(e.material)&&(e.material.refractionTexture=o._opaqueRenderTarget)}))},e.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]},e}(),De="KHR_materials_transmission",Ve=function(){function e(e){this.name=De,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(De),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadTransparentPropertiesAsync(o,t,n,a)),Promise.all(s).then((function(){}))}))},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,r){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=n;if(o.subSurface.isRefractionEnabled=!0,o.subSurface.volumeIndexOfRefraction=1,o.subSurface.useAlbedoToTintRefraction=!0,void 0===r.transmissionFactor)return o.subSurface.refractionIntensity=0,o.subSurface.isRefractionEnabled=!1,Promise.resolve();o.subSurface.refractionIntensity=r.transmissionFactor;var a=o.getScene();return o.subSurface.refractionIntensity&&!a._transmissionHelper&&new Be({},o.getScene()),o.subSurface.minimumThickness=0,o.subSurface.maximumThickness=0,r.transmissionTexture?(r.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),r.transmissionTexture,void 0).then((function(e){o.subSurface.refractionIntensityTexture=e,o.subSurface.useGltfStyleTextures=!0}))):Promise.resolve()},e}();ae.RegisterExtension(De,(function(e){return new Ve(e)}));var Ge="KHR_materials_translucency",ke=function(){function e(e){this.name=Ge,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ge),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadTranslucentPropertiesAsync(o,t,n,a)),Promise.all(s).then((function(){}))}))},e.prototype._loadTranslucentPropertiesAsync=function(e,t,n,r){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=n;return o.subSurface.isTranslucencyEnabled=!0,o.subSurface.volumeIndexOfRefraction=1,o.subSurface.minimumThickness=0,o.subSurface.maximumThickness=0,o.subSurface.useAlbedoToTintTranslucency=!0,void 0===r.translucencyFactor?(o.subSurface.translucencyIntensity=0,o.subSurface.isTranslucencyEnabled=!1,Promise.resolve()):(o.subSurface.translucencyIntensity=r.translucencyFactor,r.translucencyTexture?(r.translucencyTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/translucencyTexture"),r.translucencyTexture).then((function(e){o.subSurface.translucencyIntensityTexture=e}))):Promise.resolve())},e}();ae.RegisterExtension(Ge,(function(e){return new ke(e)}));var Ue="KHR_materials_volume",je=function(){function e(e){this.name=Ue,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ue),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=new Array;return s.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),s.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),s.push(r._loadVolumePropertiesAsync(o,t,n,a)),Promise.all(s).then((function(){}))}))},e.prototype._loadVolumePropertiesAsync=function(e,t,n,r){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));if(!n.subSurface.isRefractionEnabled&&!n.subSurface.isTranslucencyEnabled||!r.thicknessFactor)return Promise.resolve();n.subSurface.volumeIndexOfRefraction=n.indexOfRefraction;var o=void 0!==r.attenuationDistance?r.attenuationDistance:Number.MAX_VALUE;return n.subSurface.tintColorAtDistance=o,void 0!==r.attenuationColor&&3==r.attenuationColor.length&&n.subSurface.tintColor.copyFromFloats(r.attenuationColor[0],r.attenuationColor[1],r.attenuationColor[2]),n.subSurface.minimumThickness=0,n.subSurface.maximumThickness=r.thicknessFactor,n.subSurface.useThicknessAsDepth=!0,r.thicknessTexture?(r.thicknessTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),r.thicknessTexture).then((function(e){n.subSurface.thicknessTexture=e,n.subSurface.useGltfStyleTextures=!0}))):Promise.resolve()},e}();ae.RegisterExtension(Ue,(function(e){return new je(e)}));var He="KHR_mesh_quantization",Ke=function(){function e(e){this.name=He,this.enabled=e.isExtensionUsed(He)}return e.prototype.dispose=function(){},e}();ae.RegisterExtension(He,(function(e){return new Ke(e)}));var We="KHR_texture_basisu",qe=function(){function e(e){this.name=We,this._loader=e,this.enabled=e.isExtensionUsed(We)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){var s=null==t.sampler?ae.DefaultSampler:oe.Get("".concat(e,"/sampler"),r._loader.gltf.samplers,t.sampler),i=oe.Get("".concat(o,"/source"),r._loader.gltf.images,a.source);return r._loader._createTextureAsync(e,s,i,(function(e){n(e)}),t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))},e}();ae.RegisterExtension(We,(function(e){return new qe(e)}));var Ye="KHR_texture_transform",Xe=function(){function e(e){this.name=Ye,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ye)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(o,a){return r._loader.loadTextureInfoAsync(e,t,(function(e){if(!(e instanceof d.Texture))throw new Error("".concat(o,": Texture type not supported"));a.offset&&(e.uOffset=a.offset[0],e.vOffset=a.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,a.rotation&&(e.wAng=-a.rotation),a.scale&&(e.uScale=a.scale[0],e.vScale=a.scale[1]),null!=a.texCoord&&(e.coordinatesIndex=a.texCoord),n(e)}))}))},e}();ae.RegisterExtension(Ye,(function(e){return new Xe(e)}));var ze="KHR_xmp_json_ld",Qe=function(){function e(e){this.name=ze,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(ze)}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();ae.RegisterExtension(ze,(function(e){return new Qe(e)}));var Ze="MSFT_audio_emitter",Je=function(){function e(e){this.name=Ze,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ze)}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,oe.Assign(this._clips),oe.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return ae.LoadExtensionAsync(e,t,this.name,(function(r,o){var a=new Array;a.push(n._loader.loadSceneAsync(e,t));for(var s=0,i=o.emitters;s<i.length;s++){var l=i[s],c=oe.Get("".concat(r,"/emitters"),n._emitters,l);if(null!=c.refDistance||null!=c.maxDistance||null!=c.rolloffFactor||null!=c.distanceModel||null!=c.innerAngle||null!=c.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));a.push(n._loadEmitterAsync("".concat(r,"/emitters/").concat(c.index),c))}return Promise.all(a).then((function(){}))}))},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(e,o){var a=new Array;return r._loader.loadNodeAsync(e,t,(function(t){for(var s=function(n){var o=oe.Get("".concat(e,"/emitters"),r._emitters,n);a.push(r._loadEmitterAsync("".concat(e,"/emitters/").concat(o.index),o).then((function(){for(var e=0,n=o._babylonSounds;e<n.length;e++){var r=n[e];r.attachToMesh(t),null==o.innerAngle&&null==o.outerAngle||(r.setLocalDirectionToMesh(d.Vector3.Forward()),r.setDirectionalCone(2*d.Tools.ToDegrees(null==o.innerAngle?Math.PI:o.innerAngle),2*d.Tools.ToDegrees(null==o.outerAngle?Math.PI:o.outerAngle),0))}})))},i=0,l=o.emitters;i<l.length;i++)s(l[i]);n(t)})).then((function(e){return Promise.all(a).then((function(){return e}))}))}))},e.prototype.loadAnimationAsync=function(e,t){var n=this;return ae.LoadExtensionAsync(e,t,this.name,(function(r,o){return n._loader.loadAnimationAsync(e,t).then((function(a){var s=new Array;oe.Assign(o.events);for(var i=0,l=o.events;i<l.length;i++){var c=l[i];s.push(n._loadAnimationEventAsync("".concat(r,"/events/").concat(c.index),e,t,c,a))}return Promise.all(s).then((function(){return a}))}))}))},e.prototype._loadClipAsync=function(e,t){if(t._objectURL)return t._objectURL;var n;if(t.uri)n=this._loader.loadUriAsync(e,t,t.uri);else{var r=oe.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,t.bufferView);n=this._loader.loadBufferViewAsync("/bufferViews/".concat(r.index),r)}return t._objectURL=n.then((function(e){return URL.createObjectURL(new Blob([e],{type:t.mimeType}))})),t._objectURL},e.prototype._loadEmitterAsync=function(e,t){var n=this;if(t._babylonSounds=t._babylonSounds||[],!t._babylonData){for(var r=new Array,o=t.name||"emitter".concat(t.index),a={loop:!1,autoplay:!1,volume:null==t.volume?1:t.volume},s=function(e){var s="/extensions/".concat(i.name,"/clips"),l=oe.Get(s,i._clips,t.clips[e].clip);r.push(i._loadClipAsync("".concat(s,"/").concat(t.clips[e].clip),l).then((function(r){var s=t._babylonSounds[e]=new d.Sound(o,r,n._loader.babylonScene,null,a);s.refDistance=t.refDistance||1,s.maxDistance=t.maxDistance||256,s.rolloffFactor=t.rolloffFactor||1,s.distanceModel=t.distanceModel||"exponential"})))},i=this,l=0;l<t.clips.length;l++)s(l);var c=Promise.all(r).then((function(){var e=t.clips.map((function(e){return e.weight||1})),n=new d.WeightedSound(t.loop||!1,t._babylonSounds,e);t.innerAngle&&(n.directionalConeInnerAngle=2*d.Tools.ToDegrees(t.innerAngle)),t.outerAngle&&(n.directionalConeOuterAngle=2*d.Tools.ToDegrees(t.outerAngle)),t.volume&&(n.volume=t.volume),t._babylonData.sound=n}));t._babylonData={loaded:c}}return t._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(){t.stop()};case"pause":return function(){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,t,n,r,o){var a=this;if(0==o.targetedAnimations.length)return Promise.resolve();var s=o.targetedAnimations[0],i=r.emitter,l=oe.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,i);return this._loadEmitterAsync(e,l).then((function(){var t=l._babylonData.sound;if(t){var n=new d.AnimationEvent(r.time,a._getEventAction(e,t,r.action,r.time,r.startOffset));s.animation.addEvent(n),o.onAnimationGroupEndObservable.add((function(){t.stop()})),o.onAnimationGroupPauseObservable.add((function(){t.pause()}))}}))},e}();ae.RegisterExtension(Ze,(function(e){return new Je(e)}));var $e="MSFT_lod",et=function(){function e(e){this.name=$e,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new d.Observable,this.onMaterialLODsLoadedObservable=new d.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.enabled=this._loader.isExtensionUsed($e)}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then((function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())}));n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then((function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())}));a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return ae.LoadExtensionAsync(e,t,this.name,(function(e,o){var a,s=r._getLODs(e,t,r._loader.gltf.nodes,o.ids);r._loader.logOpen("".concat(e));for(var i=function(e){var t=s[e];0!==e&&(r._nodeIndexLOD=e,r._nodeSignalLODs[e]=r._nodeSignalLODs[e]||new d.Deferred);var o=r._loader.loadNodeAsync("/nodes/".concat(t.index),t,(function(e){n(e),e.setEnabled(!1)})).then((function(t){if(0!==e){var n=s[e-1];n._babylonTransformNode&&(r._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t}));r._nodePromiseLODs[e]=r._nodePromiseLODs[e]||[],0===e?a=o:(r._nodeIndexLOD=null,r._nodePromiseLODs[e].push(o))},l=0;l<s.length;l++)i(l);return r._loader.logClose(),a}))},e.prototype._loadMaterialAsync=function(e,t,n,r,o){var a=this;return this._nodeIndexLOD?null:ae.LoadExtensionAsync(e,t,this.name,(function(e,s){var i,l=a._getLODs(e,t,a._loader.gltf.materials,s.ids);a._loader.logOpen("".concat(e));for(var c=function(e){var t=l[e];0!==e&&(a._materialIndexLOD=e);var s=a._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,(function(t){0===e&&o(t)})).then((function(t){if(0!==e){o(t);var n=l[e-1]._data;n[r]&&(a._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t}));a._materialPromiseLODs[e]=a._materialPromiseLODs[e]||[],0===e?i=s:(a._materialIndexLOD=null,a._materialPromiseLODs[e].push(s))},u=0;u<l.length;u++)c(u);return a._loader.logClose(),i}))},e.prototype._loadUriAsync=function(e,t,n){var r=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var o=this._nodeIndexLOD-1;return this._nodeSignalLODs[o]=this._nodeSignalLODs[o]||new d.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then((function(){return r._loader.loadUriAsync(e,t,n)}))}return null!==this._materialIndexLOD?(this._loader.log("deferred"),o=this._materialIndexLOD-1,this._materialSignalLODs[o]=this._materialSignalLODs[o]||new d.Deferred,this._materialSignalLODs[o].promise.then((function(){return r._loader.loadUriAsync(e,t,n)}))):null},e.prototype.loadBufferAsync=function(e,t,n,r){if(this._loader.parent.useRangeRequests&&!t.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var o=function(e,t){var o=n,a=o+r-1,s=e[t];return s?(s.start=Math.min(s.start,o),s.end=Math.max(s.end,a)):(s={start:o,end:a,loaded:new d.Deferred},e[t]=s),s.loaded.promise.then((function(e){return new Uint8Array(e.buffer,e.byteOffset+n-s.start,r)}))};return this._loader.log("deferred"),null!==this._nodeIndexLOD?o(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?o(this._materialBufferLODs,this._materialIndexLOD):o(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then((function(e){n.loaded.resolve(e)}),(function(e){n.loaded.reject(e)})))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=new Array,a=r.length-1;a>=0;a--)if(o.push(oe.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var s=a[o];s.material&&n.push(s.material)}e.dispose();var i=n.filter((function(e){return t._loader.babylonScene.meshes.every((function(t){return t.material!=e}))}));this._disposeMaterials(i)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(u=r[n]).getActiveTextures();o<a.length;o++){var s=a[o];t[s.uniqueId]=s}u.dispose()}for(var i in t)for(var l=0,c=this._loader.babylonScene.materials;l<c.length;l++){var u;(u=c[l]).hasTexture(t[i])&&delete t[i]}for(var i in t)t[i].dispose()},e}();ae.RegisterExtension($e,(function(e){return new et(e)}));var tt="MSFT_minecraftMesh",nt=function(){function e(e){this.name=tt,this._loader=e,this.enabled=this._loader.isExtensionUsed(tt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtraAsync(e,t,this.name,(function(o,a){if(a){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(o,": Material type not supported"));var s=r._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,s}return null}))},e}();ae.RegisterExtension(tt,(function(e){return new nt(e)}));var rt="MSFT_sRGBFactors",ot=function(){function e(e){this.name=rt,this._loader=e,this.enabled=this._loader.isExtensionUsed(rt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return ae.LoadExtraAsync(e,t,this.name,(function(o,a){if(a){if(!(n instanceof d.PBRMaterial))throw new Error("".concat(o,": Material type not supported"));var s=r._loader.loadMaterialPropertiesAsync(e,t,n);return n.albedoTexture||n.albedoColor.toLinearSpaceToRef(n.albedoColor),n.reflectivityTexture||n.reflectivityColor.toLinearSpaceToRef(n.reflectivityColor),s}return null}))},e}();ae.RegisterExtension(rt,(function(e){return new ot(e)}));var at="ExtrasAsMetadata",st=function(){function e(e){this.name=at,this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();ae.RegisterExtension(at,(function(e){return new st(e)}));var it=function(){function e(){this.materials=[]}return e.prototype.parseMTL=function(t,n,r,o){if(!(n instanceof ArrayBuffer)){for(var a,s=n.split("\n"),i=/\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(" "),f=h>=0?u.substring(0,h):u;f=f.toLowerCase();var p=h>=0?u.substring(h+1).trim():"";if("newmtl"===f)l&&this.materials.push(l),t._blockEntityCollection=!!o,(l=new d.StandardMaterial(p,t))._parentContainer=o,t._blockEntityCollection=!1;else if("kd"===f&&l)a=p.split(i,3).map(parseFloat),l.diffuseColor=d.Color3.FromArray(a);else if("ka"===f&&l)a=p.split(i,3).map(parseFloat),l.ambientColor=d.Color3.FromArray(a);else if("ks"===f&&l)a=p.split(i,3).map(parseFloat),l.specularColor=d.Color3.FromArray(a);else if("ke"===f&&l)a=p.split(i,3).map(parseFloat),l.emissiveColor=d.Color3.FromArray(a);else if("ns"===f&&l)l.specularPower=parseFloat(p);else if("d"===f&&l)l.alpha=parseFloat(p);else if("map_ka"===f&&l)l.ambientTexture=e._GetTexture(r,p,t);else if("map_kd"===f&&l)l.diffuseTexture=e._GetTexture(r,p,t);else if("map_ks"===f&&l)l.specularTexture=e._GetTexture(r,p,t);else if("map_ns"===f);else if("map_bump"===f&&l){var _=p.split(i),m=_.indexOf("-bm"),y=null;m>=0&&(y=_[m+1],_.splice(m,2)),l.bumpTexture=e._GetTexture(r,_.join(" "),t),l.bumpTexture&&null!==y&&(l.bumpTexture.level=parseFloat(y))}else"map_d"===f&&l&&(l.opacityTexture=e._GetTexture(r,p,t))}}l&&this.materials.push(l)}},e._GetTexture=function(t,n,r){if(!n)return null;var o=t;if("file:"===t){var a=n.lastIndexOf("\\");-1===a&&(a=n.lastIndexOf("/")),o+=a>-1?n.substr(a+1):n}else o+=n;return new d.Texture(o,r,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),lt=function(){function e(e,t,n){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new d.Color4(.5,.5,.5,1),this._materialToUse=e,this._babylonMeshesArray=t,this._loadingOptions=n}return e.prototype._isInArray=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]},e.prototype._isInArrayUV=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1},e.prototype._setData=function(e,t,n,r,o,a,s){var i;-1===(i=this._loadingOptions.optimizeWithUV?this._isInArrayUV(this._tuplePosNorm,[e,n,t]):this._isInArray(this._tuplePosNorm,[e,n]))?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(r),this._wrappedUvsForBabylon.push(o),this._wrappedNormalsForBabylon.push(a),void 0!==s&&this._wrappedColorsForBabylon.push(s),this._tuplePosNorm[e].normals.push(n),this._tuplePosNorm[e].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e].uv.push(t)):this._indicesForBabylon.push(i)},e.prototype._unwrapData=function(){for(var e=0;e<this._wrappedPositionForBabylon.length;e++)this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x,this._wrappedPositionForBabylon[e].y,this._wrappedPositionForBabylon[e].z),this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x,this._wrappedNormalsForBabylon[e].y,this._wrappedNormalsForBabylon[e].z),this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x,this._wrappedUvsForBabylon[e].y),this._loadingOptions.importVertexColors&&this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r,this._wrappedColorsForBabylon[e].g,this._wrappedColorsForBabylon[e].b,this._wrappedColorsForBabylon[e].a);this._wrappedPositionForBabylon=[],this._wrappedNormalsForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0},e.prototype._getTriangles=function(e,t){for(var n=t;n<e.length-1;n++)this._triangles.push(e[0],e[n],e[n+1])},e.prototype._setDataForCurrentFaceWithPattern1=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=parseInt(this._triangles[n])-1;this._setData(r,0,0,this._positions[r],d.Vector2.Zero(),d.Vector3.Up(),this._loadingOptions.importVertexColors?this._colors[r]:void 0)}this._triangles=[]},e.prototype._setDataForCurrentFaceWithPattern2=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData(o,a,0,this._positions[o],this._uvs[a],d.Vector3.Up(),this._loadingOptions.importVertexColors?this._colors[o]:void 0)}this._triangles=[]},e.prototype._setDataForCurrentFaceWithPattern3=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1,s=parseInt(r[2])-1;this._setData(o,a,s,this._positions[o],this._uvs[a],this._normals[s])}this._triangles=[]},e.prototype._setDataForCurrentFaceWithPattern4=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("//"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData(o,1,a,this._positions[o],d.Vector2.Zero(),this._normals[a],this._loadingOptions.importVertexColors?this._colors[o]:void 0)}this._triangles=[]},e.prototype._setDataForCurrentFaceWithPattern5=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=this._positions.length+parseInt(r[0]),a=this._uvs.length+parseInt(r[1]),s=this._normals.length+parseInt(r[2]);this._setData(o,a,s,this._positions[o],this._uvs[a],this._normals[s],this._loadingOptions.importVertexColors?this._colors[o]:void 0)}this._triangles=[]},e.prototype._addPreviousObjMesh=function(){this._meshesFromObj.length>0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice(),this._handledMesh.uvs=this._unwrappedUVForBabylon.slice(),this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._indicesForBabylon=[],this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[])},e.prototype._optimizeNormals=function(e){var t=e.getVerticesData(d.VertexBuffer.PositionKind),n=e.getVerticesData(d.VertexBuffer.NormalKind),r={};if(t&&n){for(var o=0;o<t.length/3;o++)(i=r[s=t[3*o+0]+"_"+t[3*o+1]+"_"+t[3*o+2]])||(i=[],r[s]=i),i.push(o);var a=new d.Vector3;for(var s in r){var i;if(!((i=r[s]).length<2)){var l=i[0];for(o=1;o<i.length;++o){var c=i[o];n[3*l+0]+=n[3*c+0],n[3*l+1]+=n[3*c+1],n[3*l+2]+=n[3*c+2]}for(a.copyFromFloats(n[3*l+0],n[3*l+1],n[3*l+2]),a.normalize(),o=0;o<i.length;++o)n[3*(c=i[o])+0]=a.x,n[3*c+1]=a.y,n[3*c+2]=a.z}}e.setVerticesData(d.VertexBuffer.NormalKind,n)}},e.prototype.parse=function(t,n,r,o,a){for(var s,i=n.split("\n"),l=0;l<i.length;l++){var c=i[l].trim().replace(/\s\s/g," "),u=void 0;if(0!==c.length&&"#"!==c.charAt(0))if(e.VertexPattern.test(c)){if(u=c.match(/[^ ]+/g),this._positions.push(new d.Vector3(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]))),this._loadingOptions.importVertexColors)if(u.length>=7){var h=parseFloat(u[4]),f=parseFloat(u[5]),p=parseFloat(u[6]);this._colors.push(new d.Color4(h>1?h/255:h,f>1?f/255:f,p>1?p/255:p,7===u.length||void 0===u[7]?1:parseFloat(u[7])))}else this._colors.push(this._grayColor)}else if(null!==(u=e.NormalPattern.exec(c)))this._normals.push(new d.Vector3(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])));else if(null!==(u=e.UVPattern.exec(c)))this._uvs.push(new d.Vector2(parseFloat(u[1])*this._loadingOptions.UVScaling.x,parseFloat(u[2])*this._loadingOptions.UVScaling.y));else if(null!==(u=e.FacePattern3.exec(c)))this._setDataForCurrentFaceWithPattern3(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern4.exec(c)))this._setDataForCurrentFaceWithPattern4(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern5.exec(c)))this._setDataForCurrentFaceWithPattern5(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern2.exec(c)))this._setDataForCurrentFaceWithPattern2(u[1].trim().split(" "),1);else if(null!==(u=e.FacePattern1.exec(c)))this._setDataForCurrentFaceWithPattern1(u[1].trim().split(" "),1);else if(e.GroupDescriptor.test(c)||e.ObjectDescriptor.test(c)){var _={name:c.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:""};this._addPreviousObjMesh(),this._meshesFromObj.push(_),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else e.UseMtlDescriptor.test(c)?(this._materialNameFromObj=c.substring(7).trim(),this._isFirstMaterial&&this._hasMeshes||(this._addPreviousObjMesh(),_={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,colors:void 0,materialName:this._materialNameFromObj},this._increment++,this._meshesFromObj.push(_),this._hasMeshes=!0),this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)):e.MtlLibGroupDescriptor.test(c)?a(c.substring(7).trim()):e.SmoothDescriptor.test(c)||console.log("Unhandled expression at line : "+c)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._handledMesh.normals=this._unwrappedNormalsForBabylon,this._handledMesh.uvs=this._unwrappedUVForBabylon,this._loadingOptions.importVertexColors&&(this._handledMesh.colors=this._unwrappedColorsForBabylon)),!this._hasMeshes){var m=null;if(this._indicesForBabylon.length)this._indicesForBabylon.reverse(),this._unwrapData();else{for(var y=0,v=this._positions;y<v.length;y++){var b=v[y];this._unwrappedPositionsForBabylon.push(b.x,b.y,b.z)}if(this._normals.length)for(var g=0,A=this._normals;g<A.length;g++){var T=A[g];this._unwrappedNormalsForBabylon.push(T.x,T.y,T.z)}if(this._uvs.length)for(var x=0,E=this._uvs;x<E.length;x++){var O=E[x];this._unwrappedUVForBabylon.push(O.x,O.y)}if(this._colors.length)for(var M=0,L=this._colors;M<L.length;M++){var C=L[M];this._unwrappedColorsForBabylon.push(C.r,C.g,C.b,C.a)}this._materialNameFromObj||((m=new d.StandardMaterial(d.Geometry.RandomId(),r)).pointsCloud=!0,this._materialNameFromObj=m.name,this._normals.length||(m.disableLighting=!0,m.emissiveColor=d.Color3.White()))}this._meshesFromObj.push({name:d.Geometry.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:m})}for(var w=0;w<this._meshesFromObj.length;w++){if(t&&this._meshesFromObj[w].name)if(t instanceof Array){if(-1===t.indexOf(this._meshesFromObj[w].name))continue}else if(this._meshesFromObj[w].name!==t)continue;this._handledMesh=this._meshesFromObj[w],r._blockEntityCollection=!!o;var S=new d.Mesh(this._meshesFromObj[w].name,r);if(S._parentContainer=o,r._blockEntityCollection=!1,this._materialToUse.push(this._meshesFromObj[w].materialName),0!==(null===(s=this._handledMesh.positions)||void 0===s?void 0:s.length)){var R=new d.VertexData;if(R.uvs=this._handledMesh.uvs,R.indices=this._handledMesh.indices,R.positions=this._handledMesh.positions,this._loadingOptions.computeNormals){var P=new Array;d.VertexData.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,P),R.normals=P}else R.normals=this._handledMesh.normals;this._loadingOptions.importVertexColors&&(R.colors=this._handledMesh.colors),R.applyToMesh(S),this._loadingOptions.invertY&&(S.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(S),this._babylonMeshesArray.push(S),this._handledMesh.directMaterial&&(S.material=this._handledMesh.directMaterial)}else this._babylonMeshesArray.push(S)}},e.ObjectDescriptor=/^o/,e.GroupDescriptor=/^g/,e.MtlLibGroupDescriptor=/^mtllib /,e.UseMtlDescriptor=/^usemtl /,e.SmoothDescriptor=/^s /,e.VertexPattern=/v(\s+[\d|.|+|\-|e|E]+){3,7}/,e.NormalPattern=/vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.UVPattern=/vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.FacePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,e.FacePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern5=/f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,e}(),ct=function(){function e(t){this.name="obj",this.extensions=".obj",this._assetContainer=null,this._loadingOptions=t||e._DefaultLoadingOptions}return Object.defineProperty(e,"INVERT_TEXTURE_Y",{get:function(){return it.INVERT_TEXTURE_Y},set:function(e){it.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"_DefaultLoadingOptions",{get:function(){return{computeNormals:e.COMPUTE_NORMALS,optimizeNormals:e.OPTIMIZE_NORMALS,importVertexColors:e.IMPORT_VERTEX_COLORS,invertY:e.INVERT_Y,invertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,materialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:e.OPTIMIZE_WITH_UV,skipMaterials:e.SKIP_MATERIALS}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,t,n,r){var o=t+e;d.Tools.LoadFile(o,n,void 0,void 0,!1,(function(e,t){r(o,t)}))},e.prototype.createPlugin=function(){return new e(e._DefaultLoadingOptions)},e.prototype.canDirectLoad=function(){return!1},e.prototype.importMeshAsync=function(e,t,n,r){return this._parseSolid(e,t,n,r).then((function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[]}}))},e.prototype.loadAsync=function(e,t,n){return this.importMeshAsync(null,e,t,n).then((function(){}))},e.prototype.loadAssetContainerAsync=function(e,t,n){var r=this,o=new d.AssetContainer(e);return this._assetContainer=o,this.importMeshAsync(null,e,t,n).then((function(e){return e.meshes.forEach((function(e){return o.meshes.push(e)})),e.meshes.forEach((function(e){var t=e.material;t&&-1==o.materials.indexOf(t)&&(o.materials.push(t),t.getActiveTextures().forEach((function(e){-1==o.textures.indexOf(e)&&o.textures.push(e)})))})),r._assetContainer=null,o})).catch((function(e){throw r._assetContainer=null,e}))},e.prototype._parseSolid=function(e,t,n,r){var o=this,a="",s=new it,i=new Array,l=[];new lt(i,l,this._loadingOptions).parse(e,n,t,this._assetContainer,(function(e){a=e}));var c=[];return""===a||this._loadingOptions.skipMaterials||c.push(new Promise((function(e,n){o._loadMTL(a,r,(function(c){try{s.parseMTL(t,c,r,o._assetContainer);for(var u=0;u<s.materials.length;u++){for(var h=0,f=[],p=void 0;(p=i.indexOf(s.materials[u].name,h))>-1;)f.push(p),h=p+1;if(-1===p&&0===f.length)s.materials[u].dispose();else for(var _=0;_<f.length;_++){var m=l[f[_]],y=s.materials[u];m.material=y,m.getTotalIndices()||(y.pointsCloud=!0)}}e()}catch(t){d.Tools.Warn("Error processing MTL file: '".concat(a,"'")),o._loadingOptions.materialLoadingFailsSilently?e():n(t)}}),(function(t,r){d.Tools.Warn("Error downloading MTL file: '".concat(a,"'")),o._loadingOptions.materialLoadingFailsSilently?e():n(r)}))}))),Promise.all(c).then((function(){return l}))},e.OPTIMIZE_WITH_UV=!0,e.INVERT_Y=!1,e.IMPORT_VERTEX_COLORS=!1,e.COMPUTE_NORMALS=!1,e.OPTIMIZE_NORMALS=!1,e.UV_SCALING=new d.Vector2(1,1),e.SKIP_MATERIALS=!1,e.MATERIAL_LOADING_FAILS_SILENTLY=!0,e}();d.SceneLoader&&d.SceneLoader.RegisterPlugin(new ct);var ut=function(){function e(){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 e.prototype.importMesh=function(e,t,n,r,o){var a;if("string"!=typeof n){if(this._isBinary(n)){var s=new d.Mesh("stlmesh",t);return this._parseBinary(s,n),o&&o.push(s),!0}for(var i=new Uint8Array(n),l="",c=0;c<n.byteLength;c++)l+=String.fromCharCode(i[c]);n=l}for(;a=this.solidPattern.exec(n);){var u=a[1];if(u!=a[3])return d.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&u)if(e instanceof Array){if(!e.indexOf(u))continue}else if(u!==e)continue;u=u||"stlmesh",s=new d.Mesh(u,t),this._parseASCII(s,a[2]),o&&o.push(s)}return!0},e.prototype.load=function(e,t,n){return this.importMesh(null,e,t,n,null)},e.prototype.loadAssetContainer=function(e,t,n){var r=new d.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,t,n,r.meshes),e._blockEntityCollection=!1,r},e.prototype._isBinary=function(e){var t=new DataView(e);if(t.byteLength<=80)return!1;if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var n=t.byteLength,r=0;r<n;r++)if(t.getUint8(r)>127)return!0;return!1},e.prototype._parseBinary=function(t,n){for(var r=new DataView(n),o=r.getUint32(80,!0),a=0,s=new Float32Array(3*o*3),i=new Float32Array(3*o*3),l=new Uint32Array(3*o),c=0,u=0;u<o;u++){for(var h=84+50*u,f=r.getFloat32(h,!0),p=r.getFloat32(h+4,!0),_=r.getFloat32(h+8,!0),m=1;m<=3;m++){var y=h+12*m;s[a]=r.getFloat32(y,!0),i[a]=f,e.DO_NOT_ALTER_FILE_COORDINATES?(s[a+1]=r.getFloat32(y+4,!0),s[a+2]=r.getFloat32(y+8,!0),i[a+1]=p,i[a+2]=_):(s[a+2]=r.getFloat32(y+4,!0),s[a+1]=r.getFloat32(y+8,!0),i[a+2]=p,i[a+1]=_),a+=3}l[c]=c++,l[c]=c++,l[c]=c++}t.setVerticesData(d.VertexBuffer.PositionKind,s),t.setVerticesData(d.VertexBuffer.NormalKind,i),t.setIndices(l),t.computeWorldMatrix(!0)},e.prototype._parseASCII=function(t,n){for(var r,o=[],a=[],s=[],i=0;r=this.facetsPattern.exec(n);){var l=r[1],c=this.normalPattern.exec(l);if(this.normalPattern.lastIndex=0,c){for(var u=[Number(c[1]),Number(c[5]),Number(c[3])],h=void 0;h=this.vertexPattern.exec(l);)e.DO_NOT_ALTER_FILE_COORDINATES?(o.push(Number(h[1]),Number(h[3]),Number(h[5])),a.push(u[0],u[2],u[1])):(o.push(Number(h[1]),Number(h[5]),Number(h[3])),a.push(u[0],u[1],u[2]));s.push(i++,i++,i++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,t.setVerticesData(d.VertexBuffer.PositionKind,o),t.setVerticesData(d.VertexBuffer.NormalKind,a),t.setIndices(s),t.computeWorldMatrix(!0)},e.DO_NOT_ALTER_FILE_COORDINATES=!1,e}();d.SceneLoader&&d.SceneLoader.RegisterPlugin(new ut);var dt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==dt){for(var ht in dt.BABYLON=dt.BABYLON||{},t)dt.BABYLON[ht]=t[ht];for(var ht in e)dt.BABYLON[ht]=e[ht]}var ft=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==ft)for(var pt in ft.BABYLON=ft.BABYLON||{},ft.BABYLON.GLTF1=ft.BABYLON.GLTF1||{},n)ft.BABYLON.GLTF1[pt]=n[pt];var _t=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==_t){_t.BABYLON=_t.BABYLON||{};var mt=_t.BABYLON;mt.GLTF2=mt.GLTF2||{},mt.GLTF2.Loader=mt.GLTF2.Loader||{},mt.GLTF2.Loader.Extensions=mt.GLTF2.Loader.Extensions||{};var yt=[];for(var vt in s)mt.GLTF2.Loader.Extensions[vt]=s[vt],yt.push(vt);for(var vt in a)mt.GLTF2.Loader[vt]=a[vt],yt.push(vt);for(var vt in i)yt.indexOf(vt)>-1||(mt.GLTF2[vt]=i[vt])}var bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==bt)for(var gt in l)bt.BABYLON[gt]=l[gt];var At=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==At)for(var Tt in c)At.BABYLON[Tt]=c[Tt];const xt=u})(),o.default})()}));
3
+ /*! For license information please see babylonjs.materials.min.js.LICENSE.txt */
4
+ !function(e,i){"object"==typeof exports&&"object"==typeof module?module.exports=i(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-materials",["babylonjs"],i):"object"==typeof exports?exports["babylonjs-materials"]=i(require("babylonjs")):e.MATERIALS=i(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return(()=>{"use strict";var i={520:i=>{i.exports=e}},t={};function n(e){var r=t[e];if(void 0!==r)return r.exports;var o=t[e]={exports:{}};return i[e](o,o.exports,n),o.exports}n.d=(e,i)=>{for(var t in i)n.o(i,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:i[t]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,i)=>Object.prototype.hasOwnProperty.call(e,i),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{n.d(r,{default:()=>W});var e={};n.r(e),n.d(e,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>v,FurMaterial:()=>x,GradientMaterial:()=>_,GridMaterial:()=>E,LavaMaterial:()=>C,MixMaterial:()=>M,NormalMaterial:()=>F,PBRCustomMaterial:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>L,SimpleMaterial:()=>N,SkyMaterial:()=>R,TerrainMaterial:()=>V,TriPlanarMaterial:()=>w,WaterMaterial:()=>z});var i={};n.r(i),n.d(i,{CellMaterial:()=>l,CustomMaterial:()=>c,CustomShaderStructure:()=>u,FireMaterial:()=>v,FurMaterial:()=>x,GradientMaterial:()=>_,GridMaterial:()=>E,LavaMaterial:()=>C,MixMaterial:()=>M,NormalMaterial:()=>F,PBRCustomMaterial:()=>h,ShaderAlebdoParts:()=>p,ShaderSpecialParts:()=>d,ShadowOnlyMaterial:()=>L,SimpleMaterial:()=>N,SkyMaterial:()=>R,TerrainMaterial:()=>V,TriPlanarMaterial:()=>w,WaterMaterial:()=>z});var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t])},t(e,i)};function o(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}function s(e,i,t,n){var r,o=arguments.length,s=o<3?i:null===n?n=Object.getOwnPropertyDescriptor(i,t):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,i,t,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(s=(o<3?r(s):o>3?r(i,t,s):r(i,t))||s);return o>3&&s&&Object.defineProperty(i,t,s),s}Object.create,Object.create;var a=n(520);a.ShaderStore.ShadersStore.cellPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.cellVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\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#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var f=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.NDOTL=!0,i.CUSTOMUSERLIGHTING=!0,i.CELLBASIC=!0,i.DEPTHPREPASS=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),l=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n._computeHighLevel=!1,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new f);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.CELLBASIC=!this.computeHighLevel,a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var l=[a.VertexBuffer.PositionKind];n.NORMAL&&l.push(a.VertexBuffer.NormalKind),n.UV1&&l.push(a.VertexBuffer.UVKind),n.UV2&&l.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(l,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],c=["diffuseSampler"],p=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("cell",{attributes:l,uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:u,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights-1}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this._maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.getClassName=function(){return"CellMaterial"},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.CellMaterial",i},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("computeHighLevel")],i.prototype,"_computeHighLevel",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"computeHighLevel",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.CellMaterial",l);var u=function(){},d=function(){},c=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.CustomParts=new d,n.customShaderNameResolve=n.Builder,n.FragmentShader=a.Effect.ShadersStore.defaultPixelShader,n.VertexShader=a.Effect.ShadersStore.defaultVertexShader,n}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?i.setVector4(n[1],this._newUniformInstances[t]):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);return i},i.prototype.Builder=function(e,t,n,r,o,s){var f=this;if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",t),this.ReviewUniform("sampler",r),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,i.ShaderIndexer++;var l="custom_"+i.ShaderIndexer,u=this._afterBind.bind(this);return this._afterBind=function(e,i){if(i){f.AttachAfterBind(e,i);try{u(e,i)}catch(i){}}},a.Effect.ShadersStore[l+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(a.Effect.ShadersStore[l+"VertexShader"]=a.Effect.ShadersStore[l+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),a.Effect.ShadersStore[l+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE",this.CustomParts.Fragment_Custom_Diffuse?this.CustomParts.Fragment_Custom_Diffuse:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:"").replace("#define CUSTOM_FRAGMENT_MAIN_END",this.CustomParts.Fragment_MainEnd?this.CustomParts.Fragment_MainEnd:""),this.CustomParts.Fragment_Before_Fog&&(a.Effect.ShadersStore[l+"PixelShader"]=a.Effect.ShadersStore[l+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=l,l},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Fragment_Custom_Diffuse=function(e){return this.CustomParts.Fragment_Custom_Diffuse=e.replace("result","diffuseColor"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.StandardMaterial);(0,a.RegisterClass)("BABYLON.CustomMaterial",c);var p=function(){},h=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.CustomParts=new p,n.customShaderNameResolve=n.Builder,n.FragmentShader=a.Effect.ShadersStore.pbrPixelShader,n.VertexShader=a.Effect.ShadersStore.pbrVertexShader,n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockAlbedoOpacity>/g,a.Effect.IncludesShadersStore.pbrBlockAlbedoOpacity),n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockReflectivity>/g,a.Effect.IncludesShadersStore.pbrBlockReflectivity),n.FragmentShader=n.FragmentShader.replace(/#include<pbrBlockFinalColorComposition>/g,a.Effect.IncludesShadersStore.pbrBlockFinalColorComposition),n}return o(i,e),i.prototype.AttachAfterBind=function(e,i){if(this._newUniformInstances)for(var t in this._newUniformInstances)"vec2"==(n=t.toString().split("-"))[0]?i.setVector2(n[1],this._newUniformInstances[t]):"vec3"==n[0]?i.setVector3(n[1],this._newUniformInstances[t]):"vec4"==n[0]?i.setVector4(n[1],this._newUniformInstances[t]):"mat4"==n[0]?i.setMatrix(n[1],this._newUniformInstances[t]):"float"==n[0]&&i.setFloat(n[1],this._newUniformInstances[t]);if(this._newSamplerInstances)for(var t in this._newSamplerInstances){var n;"sampler2D"==(n=t.toString().split("-"))[0]&&this._newSamplerInstances[t].isReady&&this._newSamplerInstances[t].isReady()&&i.setTexture(n[1],this._newSamplerInstances[t])}},i.prototype.ReviewUniform=function(e,i){if("uniform"==e&&this._newUniforms)for(var t=0;t<this._newUniforms.length;t++)-1==this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);if("sampler"==e&&this._newUniforms)for(t=0;t<this._newUniforms.length;t++)-1!=this._customUniform[t].indexOf("sampler")&&i.push(this._newUniforms[t]);return i},i.prototype.Builder=function(e,t,n,r,o,s,f){var l=this;if(f){var u=f.processFinalCode;f.processFinalCode=function(e,i){if("vertex"===e)return u?u(e,i):i;var t=new a.ShaderCodeInliner(i);return t.inlineToken="#define pbr_inline",t.processCode(),u?u(e,t.code):t.code}}if(s&&this._customAttributes&&this._customAttributes.length>0&&s.push.apply(s,this._customAttributes),this.ReviewUniform("uniform",t),this.ReviewUniform("sampler",r),this._isCreatedShader)return this._createdShaderName;this._isCreatedShader=!1,i.ShaderIndexer++;var d="custom_"+i.ShaderIndexer,c=this._afterBind.bind(this);return this._afterBind=function(e,i){if(i){l.AttachAfterBind(e,i);try{c(e,i)}catch(i){}}},a.Effect.ShadersStore[d+"VertexShader"]=this.VertexShader.replace("#define CUSTOM_VERTEX_BEGIN",this.CustomParts.Vertex_Begin?this.CustomParts.Vertex_Begin:"").replace("#define CUSTOM_VERTEX_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Vertex_Definitions?this.CustomParts.Vertex_Definitions:"")).replace("#define CUSTOM_VERTEX_MAIN_BEGIN",this.CustomParts.Vertex_MainBegin?this.CustomParts.Vertex_MainBegin:"").replace("#define CUSTOM_VERTEX_UPDATE_POSITION",this.CustomParts.Vertex_Before_PositionUpdated?this.CustomParts.Vertex_Before_PositionUpdated:"").replace("#define CUSTOM_VERTEX_UPDATE_NORMAL",this.CustomParts.Vertex_Before_NormalUpdated?this.CustomParts.Vertex_Before_NormalUpdated:"").replace("#define CUSTOM_VERTEX_MAIN_END",this.CustomParts.Vertex_MainEnd?this.CustomParts.Vertex_MainEnd:""),this.CustomParts.Vertex_After_WorldPosComputed&&(a.Effect.ShadersStore[d+"VertexShader"]=a.Effect.ShadersStore[d+"VertexShader"].replace("#define CUSTOM_VERTEX_UPDATE_WORLDPOS",this.CustomParts.Vertex_After_WorldPosComputed)),a.Effect.ShadersStore[d+"PixelShader"]=this.FragmentShader.replace("#define CUSTOM_FRAGMENT_BEGIN",this.CustomParts.Fragment_Begin?this.CustomParts.Fragment_Begin:"").replace("#define CUSTOM_FRAGMENT_MAIN_BEGIN",this.CustomParts.Fragment_MainBegin?this.CustomParts.Fragment_MainBegin:"").replace("#define CUSTOM_FRAGMENT_DEFINITIONS",(this._customUniform?this._customUniform.join("\n"):"")+(this.CustomParts.Fragment_Definitions?this.CustomParts.Fragment_Definitions:"")).replace("#define CUSTOM_FRAGMENT_UPDATE_ALBEDO",this.CustomParts.Fragment_Custom_Albedo?this.CustomParts.Fragment_Custom_Albedo:"").replace("#define CUSTOM_FRAGMENT_UPDATE_ALPHA",this.CustomParts.Fragment_Custom_Alpha?this.CustomParts.Fragment_Custom_Alpha:"").replace("#define CUSTOM_FRAGMENT_BEFORE_LIGHTS",this.CustomParts.Fragment_Before_Lights?this.CustomParts.Fragment_Before_Lights:"").replace("#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS",this.CustomParts.Fragment_Custom_MetallicRoughness?this.CustomParts.Fragment_Custom_MetallicRoughness:"").replace("#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE",this.CustomParts.Fragment_Custom_MicroSurface?this.CustomParts.Fragment_Custom_MicroSurface:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FINALCOLORCOMPOSITION",this.CustomParts.Fragment_Before_FinalColorComposition?this.CustomParts.Fragment_Before_FinalColorComposition:"").replace("#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR",this.CustomParts.Fragment_Before_FragColor?this.CustomParts.Fragment_Before_FragColor:"").replace("#define CUSTOM_FRAGMENT_MAIN_END",this.CustomParts.Fragment_MainEnd?this.CustomParts.Fragment_MainEnd:""),this.CustomParts.Fragment_Before_Fog&&(a.Effect.ShadersStore[d+"PixelShader"]=a.Effect.ShadersStore[d+"PixelShader"].replace("#define CUSTOM_FRAGMENT_BEFORE_FOG",this.CustomParts.Fragment_Before_Fog)),this._isCreatedShader=!0,this._createdShaderName=d,d},i.prototype.AddUniform=function(e,i,t){return this._customUniform||(this._customUniform=new Array,this._newUniforms=new Array,this._newSamplerInstances={},this._newUniformInstances={}),t&&(-1!=i.indexOf("sampler")?this._newSamplerInstances[i+"-"+e]=t:this._newUniformInstances[i+"-"+e]=t),this._customUniform.push("uniform "+i+" "+e+";"),this._newUniforms.push(e),this},i.prototype.AddAttribute=function(e){return this._customAttributes||(this._customAttributes=[]),this._customAttributes.push(e),this},i.prototype.Fragment_Begin=function(e){return this.CustomParts.Fragment_Begin=e,this},i.prototype.Fragment_Definitions=function(e){return this.CustomParts.Fragment_Definitions=e,this},i.prototype.Fragment_MainBegin=function(e){return this.CustomParts.Fragment_MainBegin=e,this},i.prototype.Fragment_Custom_Albedo=function(e){return this.CustomParts.Fragment_Custom_Albedo=e.replace("result","surfaceAlbedo"),this},i.prototype.Fragment_Custom_Alpha=function(e){return this.CustomParts.Fragment_Custom_Alpha=e.replace("result","alpha"),this},i.prototype.Fragment_Before_Lights=function(e){return this.CustomParts.Fragment_Before_Lights=e,this},i.prototype.Fragment_Custom_MetallicRoughness=function(e){return this.CustomParts.Fragment_Custom_MetallicRoughness=e,this},i.prototype.Fragment_Custom_MicroSurface=function(e){return this.CustomParts.Fragment_Custom_MicroSurface=e,this},i.prototype.Fragment_Before_Fog=function(e){return this.CustomParts.Fragment_Before_Fog=e,this},i.prototype.Fragment_Before_FinalColorComposition=function(e){return this.CustomParts.Fragment_Before_FinalColorComposition=e,this},i.prototype.Fragment_Before_FragColor=function(e){return this.CustomParts.Fragment_Before_FragColor=e.replace("result","color"),this},i.prototype.Fragment_MainEnd=function(e){return this.CustomParts.Fragment_MainEnd=e,this},i.prototype.Vertex_Begin=function(e){return this.CustomParts.Vertex_Begin=e,this},i.prototype.Vertex_Definitions=function(e){return this.CustomParts.Vertex_Definitions=e,this},i.prototype.Vertex_MainBegin=function(e){return this.CustomParts.Vertex_MainBegin=e,this},i.prototype.Vertex_Before_PositionUpdated=function(e){return this.CustomParts.Vertex_Before_PositionUpdated=e.replace("result","positionUpdated"),this},i.prototype.Vertex_Before_NormalUpdated=function(e){return this.CustomParts.Vertex_Before_NormalUpdated=e.replace("result","normalUpdated"),this},i.prototype.Vertex_After_WorldPosComputed=function(e){return this.CustomParts.Vertex_After_WorldPosComputed=e,this},i.prototype.Vertex_MainEnd=function(e){return this.CustomParts.Vertex_MainEnd=e,this},i.ShaderIndexer=1,i}(a.PBRMaterial);(0,a.RegisterClass)("BABYLON.PBRCustomMaterial",h);a.ShaderStore.ShadersStore.firePixelShader="precision highp float;uniform vec4 vEyePosition;varying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\nuniform sampler2D distortionSampler;uniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{return vec4(2.0)*x-vec4(1.0);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);float alpha=1.0;\n#ifdef DIFFUSE\nconst float distortionAmount0 =0.092;const float distortionAmount1 =0.092;const float distortionAmount2 =0.092;vec2 heightAttenuation=vec2(0.3,0.39);vec4 noise0=texture2D(distortionSampler,vDistortionCoords1);vec4 noise1=texture2D(distortionSampler,vDistortionCoords2);vec4 noise2=texture2D(distortionSampler,vDistortionCoords3);vec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;vec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);vec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;baseColor*=opacityColor;baseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.fireVertexShader="precision highp float;attribute vec3 position;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nuniform float time;uniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;varying vec2 vDistortionCoords2;varying vec2 vDistortionCoords3;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef DIFFUSE\nvDiffuseUV=uv;vDiffuseUV.y-=0.2;\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;vDistortionCoords1.x=uv.x;vDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;vDistortionCoords2.x=uv.x;vDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;vDistortionCoords3.x=uv.x;vDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var m=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.UV1=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.BonesPerMesh=0,i.NUM_BONE_INFLUENCERS=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),v=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.speed=1,n._scaledDiffuse=new a.Color3,n._lastTime=0,n}return o(i,e),i.prototype.needAlphaBlending=function(){return!1},i.prototype.needAlphaTesting=function(){return!0},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new m);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(n.ALPHATEST=!!this._opacityTexture,n._areMiscDirty&&(n.POINTSIZE=this.pointsCloud||r.forcePointsCloud,n.FOG=r.fogEnabled&&e.applyFog&&r.fogMode!==a.Scene.FOGMODE_NONE&&this.fogEnabled),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.UV1&&f.push(a.VertexBuffer.UVKind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString();i.setEffect(r.getEngine().createEffect("fire",{attributes:f,uniformsNames:["world","view","viewProjection","vEyePosition","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","time","speed"],uniformBuffersNames:[],samplers:["diffuseSampler","distortionSampler","opacitySampler"],defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:null,maxSimultaneousLights:4,transformFeedbackVaryings:null},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene();if(t.materialDefines){var r=t.effect;r&&(this._activeEffect=r,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,r)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix()),this._activeEffect.setTexture("distortionSampler",this._distortionTexture),this._activeEffect.setTexture("opacitySampler",this._opacityTexture)),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(r)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime),this._activeEffect.setFloat("speed",this.speed),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._distortionTexture&&this._distortionTexture.animations&&this._distortionTexture.animations.length>0&&e.push(this._distortionTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),this._distortionTexture&&i.push(this._distortionTexture),this._opacityTexture&&i.push(this._opacityTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTexture===i||this._distortionTexture===i||this._opacityTexture===i},i.prototype.getClassName=function(){return"FireMaterial"},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),this._distortionTexture&&this._distortionTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.FireMaterial",i.diffuseColor=this.diffuseColor.asArray(),i.speed=this.speed,this._diffuseTexture&&(i._diffuseTexture=this._diffuseTexture.serialize()),this._distortionTexture&&(i._distortionTexture=this._distortionTexture.serialize()),this._opacityTexture&&(i._opacityTexture=this._opacityTexture.serialize()),i},i.Parse=function(e,t,n){var r=new i(e.name,t);return r.diffuseColor=a.Color3.FromArray(e.diffuseColor),r.speed=e.speed,r.alpha=e.alpha,r.id=e.id,a.Tags.AddTagsTo(r,e.tags),r.backFaceCulling=e.backFaceCulling,r.wireframe=e.wireframe,e._diffuseTexture&&(r._diffuseTexture=a.Texture.Parse(e._diffuseTexture,t,n)),e._distortionTexture&&(r._distortionTexture=a.Texture.Parse(e._distortionTexture,t,n)),e._opacityTexture&&(r._opacityTexture=a.Texture.Parse(e._opacityTexture,t,n)),r},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)("distortionTexture")],i.prototype,"_distortionTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"distortionTexture",void 0),s([(0,a.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)()],i.prototype,"speed",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.FireMaterial",v);a.ShaderStore.ShadersStore.furPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;uniform vec4 furColor;uniform float furLength;varying vec3 vPositionW;varying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform float furOcclusion;uniform sampler2D furTexture;varying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=furColor;vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));if (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {discard;}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);baseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;vec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.furVertexShader="precision highp float;attribute vec3 position;attribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\nuniform float furLength;uniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;uniform vec3 furGravity;uniform float furTime;uniform float furSpacing;uniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {float x=dot(rv,vec3(12.9898,78.233,24.65487));return fract(sin(x)*43758.5453);}\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else \nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);vec3 tangent2=vec3(-normal.z,0,normal.x);r=Rand(tangent1*r);float J=(2.0+4.0*r);r=Rand(tangent2*r);float K=(2.0+2.0*r);tangent1=tangent1*J+tangent2*K;tangent1=normalize(tangent1);vec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\nvec3 forceDirection=vec3(0.0,0.0,0.0);forceDirection.x=sin(furTime+position.x*0.05)*0.2;forceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;forceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;vec3 displacement=vec3(0.0,0.0,0.0);displacement=furGravity+forceDirection;float displacementFactor=pow(furOffset,3.0);vec3 aNormal=normal;aNormal.xyz+=displacement*displacementFactor;newPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos);\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x==0.)\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var g=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.HEIGHTMAP=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.HIGHLEVEL=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),x=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.furLength=1,n.furAngle=0,n.furColor=new a.Color3(.44,.21,.02),n.furOffset=0,n.furSpacing=12,n.furGravity=new a.Vector3(0,0,0),n.furSpeed=100,n.furDensity=20,n.furOcclusion=0,n._disableLighting=!1,n._maxSimultaneousLights=4,n.highLevelFur=!0,n._furTime=0,n}return o(i,e),Object.defineProperty(i.prototype,"furTime",{get:function(){return this._furTime},set:function(e){this._furTime=e},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.updateFur=function(){for(var e=1;e<this._meshes.length;e++){var i=this._meshes[e].material;i.furLength=this.furLength,i.furAngle=this.furAngle,i.furGravity=this.furGravity,i.furSpacing=this.furSpacing,i.furSpeed=this.furSpeed,i.furColor=this.furColor,i.diffuseTexture=this.diffuseTexture,i.furTexture=this.furTexture,i.highLevelFur=this.highLevelFur,i.furTime=this.furTime,i.furDensity=this.furDensity}},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new g);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&r.texturesEnabled){if(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(this.heightTexture&&o.getCaps().maxVertexTextureImageUnits){if(!this.heightTexture.isReady())return!1;n._needUVs=!0,n.HEIGHTMAP=!0}}if(this.highLevelFur!==n.HIGHLEVEL&&(n.HIGHLEVEL=!0,n.markAsUnprocessed()),a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","furLength","furAngle","furColor","furOffset","furGravity","furTime","furSpacing","furDensity","furOcclusion"],d=["diffuseSampler","heightTexture","furTexture"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("fur",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),n.getCachedMaterial()!==this&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._heightTexture&&this._activeEffect.setTexture("heightTexture",this._heightTexture),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._activeEffect.setFloat("furLength",this.furLength),this._activeEffect.setFloat("furAngle",this.furAngle),this._activeEffect.setColor4("furColor",this.furColor,1),this.highLevelFur&&(this._activeEffect.setVector3("furGravity",this.furGravity),this._activeEffect.setFloat("furOffset",this.furOffset),this._activeEffect.setFloat("furSpacing",this.furSpacing),this._activeEffect.setFloat("furDensity",this.furDensity),this._activeEffect.setFloat("furOcclusion",this.furOcclusion),this._furTime+=this.getScene().getEngine().getDeltaTime()/this.furSpeed,this._activeEffect.setFloat("furTime",this._furTime),this._activeEffect.setTexture("furTexture",this.furTexture)),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.heightTexture&&this.heightTexture.animations&&this.heightTexture.animations.length>0&&e.push(this.heightTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),this._heightTexture&&i.push(this._heightTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i||this._heightTexture===i},i.prototype.dispose=function(i){if(this.diffuseTexture&&this.diffuseTexture.dispose(),this._meshes)for(var t=1;t<this._meshes.length;t++){var n=this._meshes[t].material;n&&n.dispose(i),this._meshes[t].dispose()}e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.FurMaterial",this._meshes&&(i.sourceMeshName=this._meshes[0].name,i.quality=this._meshes.length),i},i.prototype.getClassName=function(){return"FurMaterial"},i.Parse=function(e,t,n){var r=a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n);return e.sourceMeshName&&r.highLevelFur&&t.executeWhenReady((function(){var n=t.getMeshByName(e.sourceMeshName);if(n){var o=i.GenerateTexture("Fur Texture",t);r.furTexture=o,i.FurifyMesh(n,e.quality)}})),r},i.GenerateTexture=function(e,i){for(var t=new a.DynamicTexture("FurTexture "+e,256,i,!0),n=t.getContext(),r=0;r<2e4;++r)n.fillStyle="rgba(255, "+Math.floor(255*Math.random())+", "+Math.floor(255*Math.random())+", 1)",n.fillRect(Math.random()*t.getSize().width,Math.random()*t.getSize().height,2,2);return t.update(!1),t.wrapU=a.Texture.WRAP_ADDRESSMODE,t.wrapV=a.Texture.WRAP_ADDRESSMODE,t},i.FurifyMesh=function(e,t){var n,r=[e],o=e.material;if(!(o instanceof i))throw"The material of the source mesh must be a Fur Material";for(n=1;n<t;n++){var s=new i(o.name+n,e.getScene());e.getScene().materials.pop(),a.Tags.EnableFor(s),a.Tags.AddTagsTo(s,"furShellMaterial"),s.furLength=o.furLength,s.furAngle=o.furAngle,s.furGravity=o.furGravity,s.furSpacing=o.furSpacing,s.furSpeed=o.furSpeed,s.furColor=o.furColor,s.diffuseTexture=o.diffuseTexture,s.furOffset=n/t,s.furTexture=o.furTexture,s.highLevelFur=o.highLevelFur,s.furTime=o.furTime,s.furDensity=o.furDensity;var f=e.clone(e.name+n);f.material=s,f.skeleton=e.skeleton,f.position=a.Vector3.Zero(),r.push(f)}for(n=1;n<r.length;n++)r[n].parent=e;return e.material._meshes=r,r},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)("heightTexture")],i.prototype,"_heightTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"heightTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)()],i.prototype,"furLength",void 0),s([(0,a.serialize)()],i.prototype,"furAngle",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"furColor",void 0),s([(0,a.serialize)()],i.prototype,"furOffset",void 0),s([(0,a.serialize)()],i.prototype,"furSpacing",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"furGravity",void 0),s([(0,a.serialize)()],i.prototype,"furSpeed",void 0),s([(0,a.serialize)()],i.prototype,"furDensity",void 0),s([(0,a.serialize)()],i.prototype,"furOcclusion",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serialize)()],i.prototype,"highLevelFur",void 0),s([(0,a.serialize)()],i.prototype,"furTime",null),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.FurMaterial",x);a.ShaderStore.ShadersStore.gradientPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float scale;\nuniform float smoothness;\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nfloat h=vPosition.y*scale+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\nvec3 diffuseColor=baseColor.rgb;\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef EMISSIVE\nvec3 diffuseBase=baseColor.rgb;\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);\n#endif\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.gradientVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\nvPosition=position;\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var T=function(e){function i(){var i=e.call(this)||this;return i.EMISSIVE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),_=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n._maxSimultaneousLights=4,n.topColor=new a.Color3(1,0,0),n.topColorAlpha=1,n.bottomColor=new a.Color3(0,0,1),n.bottomColorAlpha=1,n.offset=0,n.scale=1,n.smoothness=1,n._disableLighting=!1,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1||this.topColorAlpha<1||this.bottomColorAlpha<1},i.prototype.needAlphaTesting=function(){return!0},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new T);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),n.EMISSIVE=this._disableLighting,a.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","topColor","bottomColor","offset","smoothness","scale"],d=[],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:4}),i.setEffect(r.getEngine().createEffect("gradient",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,o),this._mustRebind(n,o)&&(a.MaterialHelper.BindClipPlane(o,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._activeEffect.setColor4("topColor",this.topColor,this.topColorAlpha),this._activeEffect.setColor4("bottomColor",this.bottomColor,this.bottomColorAlpha),this._activeEffect.setFloat("offset",this.offset),this._activeEffect.setFloat("scale",this.scale),this._activeEffect.setFloat("smoothness",this.smoothness),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){return[]},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.GradientMaterial",i},i.prototype.getClassName=function(){return"GradientMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"topColor",void 0),s([(0,a.serialize)()],i.prototype,"topColorAlpha",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"bottomColor",void 0),s([(0,a.serialize)()],i.prototype,"bottomColorAlpha",void 0),s([(0,a.serialize)()],i.prototype,"offset",void 0),s([(0,a.serialize)()],i.prototype,"scale",void 0),s([(0,a.serialize)()],i.prototype,"smoothness",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.GradientMaterial",_);a.ShaderStore.ShadersStore.gridPixelShader="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform float visibility;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\nfloat getDynamicVisibility(float position) {\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5)==floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n} \nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result; \n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2; \nfloat result=isPointOnLine(position,differentialLength);\nfloat dynamicVisibility=getDynamicVisibility(position);\nresult*=dynamicVisibility;\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset.xyz)/gridRatio;\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n#ifdef MAX_LINE \nfloat grid=clamp(max(max(x,y),z),0.,1.);\n#else\nfloat grid=clamp(x+y+z,0.,1.);\n#endif\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\nfloat opacity=1.0;\n#ifdef TRANSPARENT\nopacity=clamp(grid,0.08,gridControl.w*grid);\n#endif \n#ifdef OPACITY\nopacity*=texture2D(opacitySampler,vOpacityUV).a;\n#endif \ngl_FragColor=vec4(color.rgb,opacity*visibility);\n#ifdef TRANSPARENT\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else \n#endif\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.gridVertexShader="precision highp float;\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#include<instancesDeclaration>\nuniform mat4 projection;\nuniform mat4 view;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include<fogVertex>\nvec4 cameraSpacePosition=view*worldPos;\ngl_Position=projection*cameraSpacePosition;\n#ifdef OPACITY\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\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 \nvPosition=position;\nvNormal=normal;\n#define CUSTOM_VERTEX_MAIN_END\n}";var S=function(e){function i(){var i=e.call(this)||this;return i.OPACITY=!1,i.TRANSPARENT=!1,i.FOG=!1,i.PREMULTIPLYALPHA=!1,i.MAX_LINE=!1,i.UV1=!1,i.UV2=!1,i.INSTANCES=!1,i.THIN_INSTANCES=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),E=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.mainColor=a.Color3.Black(),n.lineColor=a.Color3.Teal(),n.gridRatio=1,n.gridOffset=a.Vector3.Zero(),n.majorUnitFrequency=10,n.minorUnitVisibility=.33,n.opacity=1,n.preMultiplyAlpha=!1,n.useMaxLine=!1,n._gridControl=new a.Vector4(n.gridRatio,n.majorUnitFrequency,n.minorUnitVisibility,n.opacity),n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.opacity<1||this._opacityTexture&&this._opacityTexture.isReady()},i.prototype.needAlphaBlendingForMesh=function(e){return e.visibility<1||this.needAlphaBlending()},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new S);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;if(n.TRANSPARENT!==this.opacity<1&&(n.TRANSPARENT=!n.TRANSPARENT,n.markAsUnprocessed()),n.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(n.PREMULTIPLYALPHA=!n.PREMULTIPLYALPHA,n.markAsUnprocessed()),n.MAX_LINE!==this.useMaxLine&&(n.MAX_LINE=!n.MAX_LINE,n.markAsUnprocessed()),n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._opacityTexture&&a.MaterialFlags.OpacityTextureEnabled)){if(!this._opacityTexture.isReady())return!1;n._needUVs=!0,n.OPACITY=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,!1,this.fogEnabled,!1,n),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,r.getEngine(),n,!!t),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial(),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!1,!1);var o=[a.VertexBuffer.PositionKind,a.VertexBuffer.NormalKind];n.UV1&&o.push(a.VertexBuffer.UVKind),n.UV2&&o.push(a.VertexBuffer.UV2Kind),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess,a.MaterialHelper.PrepareAttributesForInstances(o,n);var s=n.toString();i.setEffect(r.getEngine().createEffect("grid",o,["projection","mainColor","lineColor","gridControl","gridOffset","vFogInfos","vFogColor","world","view","opacityMatrix","vOpacityInfos","visibility"],["opacitySampler"],s,void 0,this.onCompiled,this.onError),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this._activeEffect.setFloat("visibility",i.visibility),r.INSTANCES&&!r.THIN_INSTANCE||this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("view",n.getViewMatrix()),this._activeEffect.setMatrix("projection",n.getProjectionMatrix()),this._mustRebind(n,o)&&(this._activeEffect.setColor3("mainColor",this.mainColor),this._activeEffect.setColor3("lineColor",this.lineColor),this._activeEffect.setVector3("gridOffset",this.gridOffset),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4("gridControl",this._gridControl),this._opacityTexture&&a.MaterialFlags.OpacityTextureEnabled&&(this._activeEffect.setTexture("opacitySampler",this._opacityTexture),this._activeEffect.setFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._activeEffect.setMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix()))),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.GridMaterial",i},i.prototype.getClassName=function(){return"GridMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsColor3)()],i.prototype,"mainColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"lineColor",void 0),s([(0,a.serialize)()],i.prototype,"gridRatio",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"gridOffset",void 0),s([(0,a.serialize)()],i.prototype,"majorUnitFrequency",void 0),s([(0,a.serialize)()],i.prototype,"minorUnitVisibility",void 0),s([(0,a.serialize)()],i.prototype,"opacity",void 0),s([(0,a.serialize)()],i.prototype,"preMultiplyAlpha",void 0),s([(0,a.serialize)()],i.prototype,"useMaxLine",void 0),s([(0,a.serializeAsTexture)("opacityTexture")],i.prototype,"_opacityTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.GridMaterial",E);a.ShaderStore.ShadersStore.lavaPixelShader="precision highp float;uniform vec4 vEyePosition;uniform vec4 vDiffuseColor;varying vec3 vPositionW;uniform float time;uniform float speed;uniform float movingSpeed;uniform vec3 fogColor;uniform sampler2D noiseTexture;uniform float fogDensity;varying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform sampler2D diffuseSampler;uniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){return fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);vec4 baseColor=vec4(1.,1.,1.,1.);vec3 diffuseColor=vDiffuseColor.rgb;float alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );vec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time *0.02;vec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;T1.x+=noiseTex.x*2.0;T1.y+=noiseTex.y*2.0;T2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;T2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;float p=texture2D( noiseTexture,T1*3.0 ).a;vec4 lavaColor=texture2D( diffuseSampler,T2*4.0);vec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );baseColor=temp;float depth=gl_FragCoord.z*4.0;const float LOG2=1.442695;float fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );fogFactor=1.0-clamp( fogFactor,0.0,1.0 );baseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );diffuseColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\nvec3 diffuseBase=vec3(0.,0.,0.);lightingInfo info;float shadow=1.;float glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;vec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.lavaVertexShader="precision highp float;uniform float time;uniform float lowFrequencySpeed;varying float noise;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;uniform mat4 diffuseMatrix;uniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n/* NOISE FUNCTIONS */\nvec3 mod289(vec3 x)\n{return x-floor(x*(1.0/289.0))*289.0;}\nvec4 mod289(vec4 x)\n{return x-floor(x*(1.0/289.0))*289.0;}\nvec4 permute(vec4 x)\n{return mod289(((x*34.0)+1.0)*x);}\nvec4 taylorInvSqrt(vec4 r)\n{return 1.79284291400159-0.85373472095314*r;}\nvec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}\nfloat pnoise(vec3 P,vec3 rep)\n{vec3 Pi0=mod(floor(P),rep); \nvec3 Pi1=mod(Pi0+vec3(1.0),rep); \nPi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P); \nvec3 Pf1=Pf0-vec3(1.0); \nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}\n/* END FUNCTION */\nfloat turbulence( vec3 p ) {float w=100.0;float t=-.5;for (float f=1.0 ; f<=10.0 ; f++ ){float power=pow( 2.0,f );t+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );}\nreturn t;}\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\n#ifdef NORMAL\nnoise=10.0* -.10*turbulence( .5*normal+time*1.15 );float b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );float displacement=- 1.5*noise+b;vec3 newPosition=position+normal*displacement;gl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );vec4 worldPos=finalWorld*vec4(newPosition,1.0);vPositionW=vec3(worldPos);vNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x==0.)\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));}\nelse\n{vDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";var P=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.LIGHT0=!1,i.LIGHT1=!1,i.LIGHT2=!1,i.LIGHT3=!1,i.SPOTLIGHT0=!1,i.SPOTLIGHT1=!1,i.SPOTLIGHT2=!1,i.SPOTLIGHT3=!1,i.HEMILIGHT0=!1,i.HEMILIGHT1=!1,i.HEMILIGHT2=!1,i.HEMILIGHT3=!1,i.DIRLIGHT0=!1,i.DIRLIGHT1=!1,i.DIRLIGHT2=!1,i.DIRLIGHT3=!1,i.POINTLIGHT0=!1,i.POINTLIGHT1=!1,i.POINTLIGHT2=!1,i.POINTLIGHT3=!1,i.SHADOW0=!1,i.SHADOW1=!1,i.SHADOW2=!1,i.SHADOW3=!1,i.SHADOWS=!1,i.SHADOWESM0=!1,i.SHADOWESM1=!1,i.SHADOWESM2=!1,i.SHADOWESM3=!1,i.SHADOWPOISSON0=!1,i.SHADOWPOISSON1=!1,i.SHADOWPOISSON2=!1,i.SHADOWPOISSON3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!1,i.SHADOWPCSS0=!1,i.SHADOWPCSS1=!1,i.SHADOWPCSS2=!1,i.SHADOWPCSS3=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.UNLIT=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),C=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.speed=1,n.movingSpeed=1,n.lowFrequencySpeed=1,n.fogDensity=.15,n._lastTime=0,n.diffuseColor=new a.Color3(1,1,1),n._disableLighting=!1,n._unlit=!1,n._maxSimultaneousLights=4,n._scaledDiffuse=new a.Color3,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new P);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix","time","speed","movingSpeed","fogColor","fogDensity","lowFrequencySpeed"],d=["diffuseSampler","noiseTexture"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("lava",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,r.UNLIT=this._unlit,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.noiseTexture&&this._activeEffect.setTexture("noiseTexture",this.noiseTexture),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this._scaledDiffuse,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._lastTime+=n.getEngine().getDeltaTime(),this._activeEffect.setFloat("time",this._lastTime*this.speed/1e3),this.fogColor||(this.fogColor=a.Color3.Black()),this._activeEffect.setColor3("fogColor",this.fogColor),this._activeEffect.setFloat("fogDensity",this.fogDensity),this._activeEffect.setFloat("lowFrequencySpeed",this.lowFrequencySpeed),this._activeEffect.setFloat("movingSpeed",this.movingSpeed),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.noiseTexture&&this.noiseTexture.animations&&this.noiseTexture.animations.length>0&&e.push(this.noiseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this.diffuseTexture&&this.diffuseTexture.dispose(),this.noiseTexture&&this.noiseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.LavaMaterial",i},i.prototype.getClassName=function(){return"LavaMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsTexture)()],i.prototype,"noiseTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"fogColor",void 0),s([(0,a.serialize)()],i.prototype,"speed",void 0),s([(0,a.serialize)()],i.prototype,"movingSpeed",void 0),s([(0,a.serialize)()],i.prototype,"lowFrequencySpeed",void 0),s([(0,a.serialize)()],i.prototype,"fogDensity",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("unlit")],i.prototype,"_unlit",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"unlit",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.LavaMaterial",C);a.ShaderStore.ShadersStore.mixPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D mixMap1Sampler;\nuniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform sampler2D diffuse4Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\nuniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;\nuniform sampler2D diffuse6Sampler;\nuniform sampler2D diffuse7Sampler;\nuniform sampler2D diffuse8Sampler;\nuniform vec2 diffuse5Infos;\nuniform vec2 diffuse6Infos;\nuniform vec2 diffuse7Infos;\nuniform vec2 diffuse8Infos;\n#endif\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\ndiffuse1Color.rgb*=mixColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.mixVertexShader="precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x==0.)\n{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}\nelse\n{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var y=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.MIXMAP2=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),M=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.specularColor=new a.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new y);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(r.texturesEnabled){if(!this._mixTexture1||!this._mixTexture1.isReady())return!1;if(n._needUVs=!0,a.MaterialFlags.DiffuseTextureEnabled){if(!this._diffuseTexture1||!this._diffuseTexture1.isReady())return!1;if(n.DIFFUSE=!0,!this._diffuseTexture2||!this._diffuseTexture2.isReady())return!1;if(!this._diffuseTexture3||!this._diffuseTexture3.isReady())return!1;if(!this._diffuseTexture4||!this._diffuseTexture4.isReady())return!1;if(this._mixTexture2){if(!this._mixTexture2.isReady())return!1;if(n.MIXMAP2=!0,!this._diffuseTexture5||!this._diffuseTexture5.isReady())return!1;if(!this._diffuseTexture6||!this._diffuseTexture6.isReady())return!1;if(!this._diffuseTexture7||!this._diffuseTexture7.isReady())return!1;if(!this._diffuseTexture8||!this._diffuseTexture8.isReady())return!1}}}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos","diffuse4Infos","diffuse5Infos","diffuse6Infos","diffuse7Infos","diffuse8Infos"],d=["mixMap1Sampler","mixMap2Sampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","diffuse4Sampler","diffuse5Sampler","diffuse6Sampler","diffuse7Sampler","diffuse8Sampler"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("mix",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this._mixTexture1&&(this._activeEffect.setTexture("mixMap1Sampler",this._mixTexture1),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture1.coordinatesIndex,this._mixTexture1.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture1.getTextureMatrix()),a.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture("diffuse1Sampler",this._diffuseTexture1),this._activeEffect.setFloat2("diffuse1Infos",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture("diffuse2Sampler",this._diffuseTexture2),this._activeEffect.setFloat2("diffuse2Infos",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture("diffuse3Sampler",this._diffuseTexture3),this._activeEffect.setFloat2("diffuse3Infos",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale)),this._diffuseTexture4&&(this._activeEffect.setTexture("diffuse4Sampler",this._diffuseTexture4),this._activeEffect.setFloat2("diffuse4Infos",this._diffuseTexture4.uScale,this._diffuseTexture4.vScale)))),this._mixTexture2&&(this._activeEffect.setTexture("mixMap2Sampler",this._mixTexture2),a.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture5&&(this._activeEffect.setTexture("diffuse5Sampler",this._diffuseTexture5),this._activeEffect.setFloat2("diffuse5Infos",this._diffuseTexture5.uScale,this._diffuseTexture5.vScale)),this._diffuseTexture6&&(this._activeEffect.setTexture("diffuse6Sampler",this._diffuseTexture6),this._activeEffect.setFloat2("diffuse6Infos",this._diffuseTexture6.uScale,this._diffuseTexture6.vScale)),this._diffuseTexture7&&(this._activeEffect.setTexture("diffuse7Sampler",this._diffuseTexture7),this._activeEffect.setFloat2("diffuse7Infos",this._diffuseTexture7.uScale,this._diffuseTexture7.vScale)),this._diffuseTexture8&&(this._activeEffect.setTexture("diffuse8Sampler",this._diffuseTexture8),this._activeEffect.setFloat2("diffuse8Infos",this._diffuseTexture8.uScale,this._diffuseTexture8.vScale)))),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._mixTexture1&&this._mixTexture1.animations&&this._mixTexture1.animations.length>0&&e.push(this._mixTexture1),this._mixTexture2&&this._mixTexture2.animations&&this._mixTexture2.animations.length>0&&e.push(this._mixTexture2),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._mixTexture1&&i.push(this._mixTexture1),this._diffuseTexture1&&i.push(this._diffuseTexture1),this._diffuseTexture2&&i.push(this._diffuseTexture2),this._diffuseTexture3&&i.push(this._diffuseTexture3),this._diffuseTexture4&&i.push(this._diffuseTexture4),this._mixTexture2&&i.push(this._mixTexture2),this._diffuseTexture5&&i.push(this._diffuseTexture5),this._diffuseTexture6&&i.push(this._diffuseTexture6),this._diffuseTexture7&&i.push(this._diffuseTexture7),this._diffuseTexture8&&i.push(this._diffuseTexture8),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._mixTexture1===i||this._diffuseTexture1===i||this._diffuseTexture2===i||this._diffuseTexture3===i||this._diffuseTexture4===i||this._mixTexture2===i||this._diffuseTexture5===i||this._diffuseTexture6===i||this._diffuseTexture7===i||this._diffuseTexture8===i},i.prototype.dispose=function(i){this._mixTexture1&&this._mixTexture1.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.MixMaterial",i},i.prototype.getClassName=function(){return"MixMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("mixTexture1")],i.prototype,"_mixTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture1",void 0),s([(0,a.serializeAsTexture)("mixTexture2")],i.prototype,"_mixTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture1",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture3",void 0),s([(0,a.serializeAsTexture)("diffuseTexture4")],i.prototype,"_diffuseTexture4",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture4",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture5",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture5",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture6",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture6",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture7",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture7",void 0),s([(0,a.serializeAsTexture)("diffuseTexture4")],i.prototype,"_diffuseTexture8",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture8",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.MixMaterial",M);a.ShaderStore.ShadersStore.normalPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef LIGHTING\n#include<helperFunctions>\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#endif\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef NORMAL\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef LIGHTING\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse= baseColor.rgb;\n#endif\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.normalVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\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#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var A=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.LIGHT0=!1,i.LIGHT1=!1,i.LIGHT2=!1,i.LIGHT3=!1,i.SPOTLIGHT0=!1,i.SPOTLIGHT1=!1,i.SPOTLIGHT2=!1,i.SPOTLIGHT3=!1,i.HEMILIGHT0=!1,i.HEMILIGHT1=!1,i.HEMILIGHT2=!1,i.HEMILIGHT3=!1,i.DIRLIGHT0=!1,i.DIRLIGHT1=!1,i.DIRLIGHT2=!1,i.DIRLIGHT3=!1,i.POINTLIGHT0=!1,i.POINTLIGHT1=!1,i.POINTLIGHT2=!1,i.POINTLIGHT3=!1,i.SHADOW0=!1,i.SHADOW1=!1,i.SHADOW2=!1,i.SHADOW3=!1,i.SHADOWS=!1,i.SHADOWESM0=!1,i.SHADOWESM1=!1,i.SHADOWESM2=!1,i.SHADOWESM3=!1,i.SHADOWPOISSON0=!1,i.SHADOWPOISSON1=!1,i.SHADOWPOISSON2=!1,i.SHADOWPOISSON3=!1,i.SHADOWPCF0=!1,i.SHADOWPCF1=!1,i.SHADOWPCF2=!1,i.SHADOWPCF3=!1,i.SHADOWPCSS0=!1,i.SHADOWPCSS1=!1,i.SHADOWPCSS2=!1,i.SHADOWPCSS3=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.LIGHTING=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),F=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new A);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=!0,a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),n.LIGHTING=!this._disableLighting,a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],d=["diffuseSampler"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:4}),i.setEffect(r.getEngine().createEffect("normal",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this.diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this.diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this.diffuseTexture&&this.diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.NormalMaterial",i},i.prototype.getClassName=function(){return"NormalMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.NormalMaterial",F);a.ShaderStore.ShadersStore.shadowOnlyPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.shadowOnlyVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var b=function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),L=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n._needAlphaBlending=!0,n.shadowColor=a.Color3.Black(),n}return o(i,e),i.prototype.needAlphaBlending=function(){return this._needAlphaBlending},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},Object.defineProperty(i.prototype,"activeLight",{get:function(){return this._activeLight},set:function(e){this._activeLight=e},enumerable:!1,configurable:!0}),i.prototype._getFirstShadowLightForMesh=function(e){for(var i=0,t=e.lightSources;i<t.length;i++){var n=t[i];if(n.shadowEnabled)return n}return null},i.prototype.isReadyForSubMesh=function(e,i,t){var n;if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new b);var r=i.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(i))return!0;var s=o.getEngine();if(this._activeLight)for(var f=0,l=e.lightSources;f<l.length;f++){var u=l[f];if(u.shadowEnabled){if(this._activeLight===u)break;var d=e.lightSources.indexOf(this._activeLight);-1!==d&&(e.lightSources.splice(d,1),e.lightSources.splice(0,0,this._activeLight));break}}a.MaterialHelper.PrepareDefinesForFrameBoundValues(o,s,r,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,o,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),r._needNormals=a.MaterialHelper.PrepareDefinesForLights(o,e,r,!1,1);var c=null===(n=this._getFirstShadowLightForMesh(e))||void 0===n?void 0:n.getShadowGenerator();if(this._needAlphaBlending=!0,c&&c.getClassName&&"CascadedShadowGenerator"===c.getClassName()){var p=c;this._needAlphaBlending=!p.autoCalcDepthBounds}if(a.MaterialHelper.PrepareDefinesForAttributes(e,r,!1,!0),r.isDirty){r.markAsProcessed(),o.resetCachedMaterial();var h=new a.EffectFallbacks;r.FOG&&h.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(r,h,1),r.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(0,e),r.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var m=[a.VertexBuffer.PositionKind];r.NORMAL&&m.push(a.VertexBuffer.NormalKind),a.MaterialHelper.PrepareAttributesForBones(m,e,r,h),a.MaterialHelper.PrepareAttributesForInstances(m,r);var v=r.toString(),g=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","alpha","shadowColor","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6"],x=new Array,T=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:g,uniformBuffersNames:T,samplers:x,defines:r,maxSimultaneousLights:1}),i.setEffect(o.getEngine().createEffect("shadowOnly",{attributes:m,uniformsNames:g,uniformBuffersNames:T,samplers:x,defines:v,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:1}},s),r,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(r._renderId=o.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;if(o){if(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),this._activeEffect.setFloat("alpha",this.alpha),this._activeEffect.setColor3("shadowColor",this.shadowColor),n.bindEyePosition(o)),n.lightsEnabled){a.MaterialHelper.BindLights(n,i,this._activeEffect,r,1);var s=this._getFirstShadowLightForMesh(i);s&&(s._renderId=-1)}(n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE||r.SHADOWCSM0)&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect)}}},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.ShadowOnlyMaterial",i},i.prototype.getClassName=function(){return"ShadowOnlyMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.ShadowOnlyMaterial",L);a.ShaderStore.ShadersStore.simplePixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif \n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";a.ShaderStore.ShadersStore.simpleVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\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#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var I=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),N=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new I);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled&&this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled)){if(!this._diffuseTexture.isReady())return!1;n._needUVs=!0,n.DIFFUSE=!0}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","diffuseMatrix"],d=["diffuseSampler"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("simple",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights-1}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this._diffuseTexture&&a.MaterialFlags.DiffuseTextureEnabled&&(this._activeEffect.setTexture("diffuseSampler",this._diffuseTexture),this._activeEffect.setFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._activeEffect.setMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&i.push(this._diffuseTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this.diffuseTexture===i},i.prototype.dispose=function(i){this._diffuseTexture&&this._diffuseTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.SimpleMaterial",i},i.prototype.getClassName=function(){return"SimpleMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),s([(0,a.serializeAsColor3)("diffuse")],i.prototype,"diffuseColor",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.SimpleMaterial",N);a.ShaderStore.ShadersStore.skyPixelShader="precision highp float;\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\nuniform vec3 cameraPosition;\nuniform vec3 cameraOffset;\nuniform vec3 up;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n#include<fogFragmentDeclaration>\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{ \nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition+cameraOffset))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0);\ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance; \nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled); \nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\nvec3 retColor=curr*whiteScale;\n/**\n*--------------------------------------------------------------------------------------------------\n* Sky Color\n*--------------------------------------------------------------------------------------------------\n*/\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.skyVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#include<clipPlaneVertex>\n#include<fogVertex>\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var O=function(e){function i(){var i=e.call(this)||this;return i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.POINTSIZE=!1,i.FOG=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),R=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.luminance=1,n.turbidity=10,n.rayleigh=2,n.mieCoefficient=.005,n.mieDirectionalG=.8,n.distance=500,n.inclination=.49,n.azimuth=.25,n.sunPosition=new a.Vector3(0,100,0),n.useSunPosition=!1,n.cameraOffset=a.Vector3.Zero(),n.up=a.Vector3.Up(),n._cameraPosition=a.Vector3.Zero(),n._skyOrientation=new a.Quaternion,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new O);var t=i.materialDefines,n=this.getScene();if(this._isReadyForSubMesh(i))return!0;if(a.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,!1,t),a.MaterialHelper.PrepareDefinesForAttributes(e,t,!0,!1),t.IMAGEPROCESSINGPOSTPROCESS!==n.imageProcessingConfiguration.applyByPostProcess&&t.markAsMiscDirty(),t.isDirty){t.markAsProcessed(),n.resetCachedMaterial();var r=new a.EffectFallbacks;t.FOG&&r.addFallback(1,"FOG"),t.IMAGEPROCESSINGPOSTPROCESS=n.imageProcessingConfiguration.applyByPostProcess;var o=[a.VertexBuffer.PositionKind];t.VERTEXCOLOR&&o.push(a.VertexBuffer.ColorKind);var s=t.toString();i.setEffect(n.getEngine().createEffect("sky",o,["world","viewProjection","view","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","luminance","turbidity","rayleigh","mieCoefficient","mieDirectionalG","sunPosition","cameraPosition","cameraOffset","up"],[],s,r,this.onCompiled,this.onError),t,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(t._renderId=n.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene();if(t.materialDefines){var r=t.effect;if(r){this._activeEffect=r,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),this._mustRebind(n,r)&&(a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize)),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect);var o=n.activeCamera;if(o){var s=o.getWorldMatrix();this._cameraPosition.x=s.m[12],this._cameraPosition.y=s.m[13],this._cameraPosition.z=s.m[14],this._activeEffect.setVector3("cameraPosition",this._cameraPosition)}if(this._activeEffect.setVector3("cameraOffset",this.cameraOffset),this._activeEffect.setVector3("up",this.up),this.luminance>0&&this._activeEffect.setFloat("luminance",this.luminance),this._activeEffect.setFloat("turbidity",this.turbidity),this._activeEffect.setFloat("rayleigh",this.rayleigh),this._activeEffect.setFloat("mieCoefficient",this.mieCoefficient),this._activeEffect.setFloat("mieDirectionalG",this.mieDirectionalG),!this.useSunPosition){var f=Math.PI*(this.inclination-.5),l=2*Math.PI*(this.azimuth-.5);this.sunPosition.x=this.distance*Math.cos(l)*Math.cos(f),this.sunPosition.y=this.distance*Math.sin(-f),this.sunPosition.z=this.distance*Math.sin(l)*Math.cos(f),a.Quaternion.FromUnitVectorsToRef(a.Vector3.UpReadOnly,this.up,this._skyOrientation),this.sunPosition.rotateByQuaternionToRef(this._skyOrientation,this.sunPosition)}this._activeEffect.setVector3("sunPosition",this.sunPosition),this._afterBind(i,this._activeEffect)}}},i.prototype.getAnimatables=function(){return[]},i.prototype.dispose=function(i){e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.SkyMaterial",i},i.prototype.getClassName=function(){return"SkyMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serialize)()],i.prototype,"luminance",void 0),s([(0,a.serialize)()],i.prototype,"turbidity",void 0),s([(0,a.serialize)()],i.prototype,"rayleigh",void 0),s([(0,a.serialize)()],i.prototype,"mieCoefficient",void 0),s([(0,a.serialize)()],i.prototype,"mieDirectionalG",void 0),s([(0,a.serialize)()],i.prototype,"distance",void 0),s([(0,a.serialize)()],i.prototype,"inclination",void 0),s([(0,a.serialize)()],i.prototype,"azimuth",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"sunPosition",void 0),s([(0,a.serialize)()],i.prototype,"useSunPosition",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"cameraOffset",void 0),s([(0,a.serializeAsVector3)()],i.prototype,"up",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.SkyMaterial",R);a.ShaderStore.ShadersStore.terrainPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{\nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.terrainVertexShader="precision highp float;attribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;uniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;uniform mat4 textureMatrix;uniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);gl_Position=viewProjection*worldPos;vPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x==0.)\n{vTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));}\nelse\n{vTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var D=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSE=!1,i.BUMP=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),V=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.diffuseColor=new a.Color3(1,1,1),n.specularColor=new a.Color3(0,0,0),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new D);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(r.texturesEnabled){if(!this.mixTexture||!this.mixTexture.isReady())return!1;if(n._needUVs=!0,a.MaterialFlags.DiffuseTextureEnabled){if(!this.diffuseTexture1||!this.diffuseTexture1.isReady())return!1;if(!this.diffuseTexture2||!this.diffuseTexture2.isReady())return!1;if(!this.diffuseTexture3||!this.diffuseTexture3.isReady())return!1;n.DIFFUSE=!0}if(this.bumpTexture1&&this.bumpTexture2&&this.bumpTexture3&&a.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture1.isReady())return!1;if(!this.bumpTexture2.isReady())return!1;if(!this.bumpTexture3.isReady())return!1;n._needNormals=!0,n.BUMP=!0}}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new a.EffectFallbacks;n.FOG&&s.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,s,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var f=[a.VertexBuffer.PositionKind];n.NORMAL&&f.push(a.VertexBuffer.NormalKind),n.UV1&&f.push(a.VertexBuffer.UVKind),n.UV2&&f.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&f.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(f,e,n,s),a.MaterialHelper.PrepareAttributesForInstances(f,n);var l=n.toString(),u=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vTextureInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMatrix","diffuse1Infos","diffuse2Infos","diffuse3Infos"],d=["textureSampler","diffuse1Sampler","diffuse2Sampler","diffuse3Sampler","bump1Sampler","bump2Sampler","bump3Sampler"],c=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("terrain",{attributes:f,uniformsNames:u,uniformBuffersNames:c,samplers:d,defines:l,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this.mixTexture&&(this._activeEffect.setTexture("textureSampler",this._mixTexture),this._activeEffect.setFloat2("vTextureInfos",this._mixTexture.coordinatesIndex,this._mixTexture.level),this._activeEffect.setMatrix("textureMatrix",this._mixTexture.getTextureMatrix()),a.MaterialFlags.DiffuseTextureEnabled&&(this._diffuseTexture1&&(this._activeEffect.setTexture("diffuse1Sampler",this._diffuseTexture1),this._activeEffect.setFloat2("diffuse1Infos",this._diffuseTexture1.uScale,this._diffuseTexture1.vScale)),this._diffuseTexture2&&(this._activeEffect.setTexture("diffuse2Sampler",this._diffuseTexture2),this._activeEffect.setFloat2("diffuse2Infos",this._diffuseTexture2.uScale,this._diffuseTexture2.vScale)),this._diffuseTexture3&&(this._activeEffect.setTexture("diffuse3Sampler",this._diffuseTexture3),this._activeEffect.setFloat2("diffuse3Infos",this._diffuseTexture3.uScale,this._diffuseTexture3.vScale))),a.MaterialFlags.BumpTextureEnabled&&n.getEngine().getCaps().standardDerivatives&&(this._bumpTexture1&&this._activeEffect.setTexture("bump1Sampler",this._bumpTexture1),this._bumpTexture2&&this._activeEffect.setTexture("bump2Sampler",this._bumpTexture2),this._bumpTexture3&&this._activeEffect.setTexture("bump3Sampler",this._bumpTexture3))),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._mixTexture&&i.push(this._mixTexture),this._diffuseTexture1&&i.push(this._diffuseTexture1),this._diffuseTexture2&&i.push(this._diffuseTexture2),this._diffuseTexture3&&i.push(this._diffuseTexture3),this._bumpTexture1&&i.push(this._bumpTexture1),this._bumpTexture2&&i.push(this._bumpTexture2),this._bumpTexture3&&i.push(this._bumpTexture3),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._mixTexture===i||this._diffuseTexture1===i||this._diffuseTexture2===i||this._diffuseTexture3===i||this._bumpTexture1===i||this._bumpTexture2===i||this._bumpTexture3===i},i.prototype.dispose=function(i){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.TerrainMaterial",i},i.prototype.getClassName=function(){return"TerrainMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)("mixTexture")],i.prototype,"_mixTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"mixTexture",void 0),s([(0,a.serializeAsTexture)("diffuseTexture1")],i.prototype,"_diffuseTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture1",void 0),s([(0,a.serializeAsTexture)("diffuseTexture2")],i.prototype,"_diffuseTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture2",void 0),s([(0,a.serializeAsTexture)("diffuseTexture3")],i.prototype,"_diffuseTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture3",void 0),s([(0,a.serializeAsTexture)("bumpTexture1")],i.prototype,"_bumpTexture1",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture1",void 0),s([(0,a.serializeAsTexture)("bumpTexture2")],i.prototype,"_bumpTexture2",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture2",void 0),s([(0,a.serializeAsTexture)("bumpTexture3")],i.prototype,"_bumpTexture3",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture3",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.TerrainMaterial",V);a.ShaderStore.ShadersStore.triplanarPixelShader="precision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.triplanarVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvPositionW=vec3(worldPos);\n#ifdef DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,0.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,0.0)).xyz;\nvec3 worldNormal=(world*vec4(normalize(normal),0.0)).xyz;\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var U=function(e){function i(){var i=e.call(this)||this;return i.DIFFUSEX=!1,i.DIFFUSEY=!1,i.DIFFUSEZ=!1,i.BUMPX=!1,i.BUMPY=!1,i.BUMPZ=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.SPECULARTERM=!1,i.NORMAL=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),w=function(e){function i(i,t){var n=e.call(this,i,t)||this;return n.tileSize=1,n.diffuseColor=new a.Color3(1,1,1),n.specularColor=new a.Color3(.2,.2,.2),n.specularPower=64,n._disableLighting=!1,n._maxSimultaneousLights=4,n}return o(i,e),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new U);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&r.texturesEnabled){if(a.MaterialFlags.DiffuseTextureEnabled)for(var s=[this.diffuseTextureX,this.diffuseTextureY,this.diffuseTextureZ],f=["DIFFUSEX","DIFFUSEY","DIFFUSEZ"],l=0;l<s.length;l++)if(s[l]){if(!s[l].isReady())return!1;n[f[l]]=!0}if(a.MaterialFlags.BumpTextureEnabled)for(s=[this.normalTextureX,this.normalTextureY,this.normalTextureZ],f=["BUMPX","BUMPY","BUMPZ"],l=0;l<s.length;l++)if(s[l]){if(!s[l].isReady())return!1;n[f[l]]=!0}}if(a.MaterialHelper.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!1,this._maxSimultaneousLights,this._disableLighting),a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var u=new a.EffectFallbacks;n.FOG&&u.addFallback(1,"FOG"),a.MaterialHelper.HandleFallbacksForShadows(n,u,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&u.addCPUSkinningFallback(0,e),n.IMAGEPROCESSINGPOSTPROCESS=r.imageProcessingConfiguration.applyByPostProcess;var d=[a.VertexBuffer.PositionKind];n.NORMAL&&d.push(a.VertexBuffer.NormalKind),n.VERTEXCOLOR&&d.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(d,e,n,u),a.MaterialHelper.PrepareAttributesForInstances(d,n);var c=n.toString(),p=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","tileSize"],h=["diffuseSamplerX","diffuseSamplerY","diffuseSamplerZ","normalSamplerX","normalSamplerY","normalSamplerZ"],m=new Array;a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:m,samplers:h,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("triplanar",{attributes:d,uniformsNames:p,uniformBuffersNames:m,samplers:h,defines:c,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._activeEffect.setFloat("tileSize",this.tileSize),n.getCachedMaterial()!==this&&(this.diffuseTextureX&&this._activeEffect.setTexture("diffuseSamplerX",this.diffuseTextureX),this.diffuseTextureY&&this._activeEffect.setTexture("diffuseSamplerY",this.diffuseTextureY),this.diffuseTextureZ&&this._activeEffect.setTexture("diffuseSamplerZ",this.diffuseTextureZ),this.normalTextureX&&this._activeEffect.setTexture("normalSamplerX",this.normalTextureX),this.normalTextureY&&this._activeEffect.setTexture("normalSamplerY",this.normalTextureY),this.normalTextureZ&&this._activeEffect.setTexture("normalSamplerZ",this.normalTextureZ),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),this._afterBind(i,this._activeEffect))}},i.prototype.getAnimatables=function(){var e=[];return this.mixTexture&&this.mixTexture.animations&&this.mixTexture.animations.length>0&&e.push(this.mixTexture),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._diffuseTextureX&&i.push(this._diffuseTextureX),this._diffuseTextureY&&i.push(this._diffuseTextureY),this._diffuseTextureZ&&i.push(this._diffuseTextureZ),this._normalTextureX&&i.push(this._normalTextureX),this._normalTextureY&&i.push(this._normalTextureY),this._normalTextureZ&&i.push(this._normalTextureZ),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._diffuseTextureX===i||this._diffuseTextureY===i||this._diffuseTextureZ===i||this._normalTextureX===i||this._normalTextureY===i||this._normalTextureZ===i},i.prototype.dispose=function(i){this.mixTexture&&this.mixTexture.dispose(),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);return i.customType="BABYLON.TriPlanarMaterial",i},i.prototype.getClassName=function(){return"TriPlanarMaterial"},i.Parse=function(e,t,n){return a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n)},s([(0,a.serializeAsTexture)()],i.prototype,"mixTexture",void 0),s([(0,a.serializeAsTexture)("diffuseTextureX")],i.prototype,"_diffuseTextureX",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureX",void 0),s([(0,a.serializeAsTexture)("diffuseTexturY")],i.prototype,"_diffuseTextureY",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureY",void 0),s([(0,a.serializeAsTexture)("diffuseTextureZ")],i.prototype,"_diffuseTextureZ",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTextureZ",void 0),s([(0,a.serializeAsTexture)("normalTextureX")],i.prototype,"_normalTextureX",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureX",void 0),s([(0,a.serializeAsTexture)("normalTextureY")],i.prototype,"_normalTextureY",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureY",void 0),s([(0,a.serializeAsTexture)("normalTextureZ")],i.prototype,"_normalTextureZ",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"normalTextureZ",void 0),s([(0,a.serialize)()],i.prototype,"tileSize",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.TriPlanarMaterial",w);a.ShaderStore.ShadersStore.waterPixelShader="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\nuniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<helperFunctions>\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform sampler2D normalSampler;\nuniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;\nuniform sampler2D reflectionSampler;\nconst float LOG2=1.442695;\nuniform vec3 cameraPosition;\nuniform vec4 waterColor;\nuniform float colorBlendFactor;\nuniform vec4 waterColor2;\nuniform float colorBlendFactor2;\nuniform float bumpHeight;\nuniform float time;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvarying vec3 vPosition;\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.xyz-vPositionW);\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\nfloat alpha=vDiffuseColor.a;\n#ifdef BUMP\n#ifdef BUMPSUPERIMPOSE\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\n#else\nbaseColor=texture2D(normalSampler,vNormalUV);\n#endif\nvec3 bumpColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vNormalInfos.y;\n#else\nvec3 bumpColor=vec3(1.0);\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef NORMAL\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\n#ifdef BUMPAFFECTSREFLECTION\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\nif (normalW.y<0.0) {\nnormalW.y=-normalW.y;\n}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=clamp(abs(pow(dot(viewDirectionW,upVector),3.0)),0.05,0.65);\nfloat IfresnelTerm=1.0-fresnelTerm;\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\nbaseColor=combinedColor;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#else \n#ifdef REFLECTION\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\n#ifdef IS_REFRACTION_LINEAR\nrefractiveColor.rgb=toGammaSpace(refractiveColor.rgb);\n#endif\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\n#ifdef IS_REFLECTION_LINEAR\nreflectiveColor.rgb=toGammaSpace(reflectiveColor.rgb);\n#endif\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=max(dot(viewDirectionW,upVector),0.0);\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#elif defined(IMAGEPROCESSING)\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";a.ShaderStore.ShadersStore.waterVertexShader="precision highp float;\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\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<bonesDeclaration>\n#include<bakedVertexAnimationDeclaration>\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;\nuniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\nuniform mat4 worldReflectionViewProjection;\nuniform vec2 windDirection;\nuniform float waveLength;\nuniform float time;\nuniform float windForce;\nuniform float waveHeight;\nuniform float waveSpeed;\nuniform float waveCount;\nvarying vec3 vPosition;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include<instancesVertex>\n#include<bonesVertex>\n#include<bakedVertexAnimation>\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef BUMP\nif (vNormalInfos.x==0.)\n{\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\n#endif\n}\nelse\n{\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\n#endif\n}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#include<vertexColorMixing>\n#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif\nfloat finalWaveCount=1.0/(waveCount*0.5);\nvec3 p=position;\nfloat newY=(sin(((p.x/finalWaveCount)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+ (cos(((p.z/finalWaveCount)+ time*waveSpeed))*waveHeight*windDirection.y*5.0);\np.y+=abs(newY);\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#ifdef REFLECTION\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\nvPosition=position;\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvRefractionMapTexCoord.z=worldPos.w;\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";var B=function(e){function i(){var i=e.call(this)||this;return i.BUMP=!1,i.REFLECTION=!1,i.CLIPPLANE=!1,i.CLIPPLANE2=!1,i.CLIPPLANE3=!1,i.CLIPPLANE4=!1,i.CLIPPLANE5=!1,i.CLIPPLANE6=!1,i.ALPHATEST=!1,i.DEPTHPREPASS=!1,i.POINTSIZE=!1,i.FOG=!1,i.NORMAL=!1,i.UV1=!1,i.UV2=!1,i.VERTEXCOLOR=!1,i.VERTEXALPHA=!1,i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0,i.INSTANCES=!1,i.INSTANCESCOLOR=!1,i.SPECULARTERM=!1,i.LOGARITHMICDEPTH=!1,i.USE_REVERSE_DEPTHBUFFER=!1,i.FRESNELSEPARATE=!1,i.BUMPSUPERIMPOSE=!1,i.BUMPAFFECTSREFLECTION=!1,i.IMAGEPROCESSING=!1,i.VIGNETTE=!1,i.VIGNETTEBLENDMODEMULTIPLY=!1,i.VIGNETTEBLENDMODEOPAQUE=!1,i.TONEMAPPING=!1,i.TONEMAPPING_ACES=!1,i.CONTRAST=!1,i.EXPOSURE=!1,i.COLORCURVES=!1,i.COLORGRADING=!1,i.COLORGRADING3D=!1,i.SAMPLER3DGREENDEPTH=!1,i.SAMPLER3DBGRMAP=!1,i.IMAGEPROCESSINGPOSTPROCESS=!1,i.SKIPFINALCOLORCLAMP=!1,i.rebuild(),i}return o(i,e),i}(a.MaterialDefines),z=function(e){function i(i,t,n){void 0===n&&(n=new a.Vector2(512,512));var r=e.call(this,i,t)||this;return r.renderTargetSize=n,r.diffuseColor=new a.Color3(1,1,1),r.specularColor=new a.Color3(0,0,0),r.specularPower=64,r._disableLighting=!1,r._maxSimultaneousLights=4,r.windForce=6,r.windDirection=new a.Vector2(0,1),r.waveHeight=.4,r.bumpHeight=.4,r._bumpSuperimpose=!1,r._fresnelSeparate=!1,r._bumpAffectsReflection=!1,r.waterColor=new a.Color3(.1,.1,.6),r.colorBlendFactor=.2,r.waterColor2=new a.Color3(.1,.1,.6),r.colorBlendFactor2=.2,r.waveLength=.1,r.waveSpeed=1,r.waveCount=20,r.disableClipPlane=!1,r._renderTargets=new a.SmartArray(16),r._mesh=null,r._reflectionTransform=a.Matrix.Zero(),r._lastTime=0,r._lastDeltaTime=0,r._createRenderTargets(r.getScene(),n),r.getRenderTargetTextures=function(){return r._renderTargets.reset(),r._renderTargets.push(r._reflectionRTT),r._renderTargets.push(r._refractionRTT),r._renderTargets},r._imageProcessingConfiguration=r.getScene().imageProcessingConfiguration,r._imageProcessingConfiguration&&(r._imageProcessingObserver=r._imageProcessingConfiguration.onUpdateParameters.add((function(){r._markAllSubMeshesAsImageProcessingDirty()}))),r}return o(i,e),Object.defineProperty(i.prototype,"hasRenderTargetTextures",{get:function(){return!0},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"refractionTexture",{get:function(){return this._refractionRTT},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"reflectionTexture",{get:function(){return this._reflectionRTT},enumerable:!1,configurable:!0}),i.prototype.addToRenderList=function(e){this._refractionRTT&&this._refractionRTT.renderList&&this._refractionRTT.renderList.push(e),this._reflectionRTT&&this._reflectionRTT.renderList&&this._reflectionRTT.renderList.push(e)},i.prototype.enableRenderTargets=function(e){var i=e?1:0;this._refractionRTT&&(this._refractionRTT.refreshRate=i),this._reflectionRTT&&(this._reflectionRTT.refreshRate=i)},i.prototype.getRenderList=function(){return this._refractionRTT?this._refractionRTT.renderList:[]},Object.defineProperty(i.prototype,"renderTargetsEnabled",{get:function(){return!(this._refractionRTT&&0===this._refractionRTT.refreshRate)},enumerable:!1,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1},i.prototype.needAlphaTesting=function(){return!1},i.prototype.getAlphaTestTexture=function(){return null},i.prototype.isReadyForSubMesh=function(e,i,t){if(this.isFrozen&&i.effect&&i.effect._wasPreviouslyReady)return!0;i.materialDefines||(i.materialDefines=new B);var n=i.materialDefines,r=this.getScene();if(this._isReadyForSubMesh(i))return!0;var o=r.getEngine();if(n._areTexturesDirty&&(n._needUVs=!1,r.texturesEnabled)){if(this.bumpTexture&&a.MaterialFlags.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;n._needUVs=!0,n.BUMP=!0}a.MaterialFlags.ReflectionTextureEnabled&&(n.REFLECTION=!0)}if(a.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,!!t),a.MaterialHelper.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),n._areMiscDirty&&(this._fresnelSeparate&&(n.FRESNELSEPARATE=!0),this._bumpSuperimpose&&(n.BUMPSUPERIMPOSE=!0),this._bumpAffectsReflection&&(n.BUMPAFFECTSREFLECTION=!0)),n._needNormals=a.MaterialHelper.PrepareDefinesForLights(r,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n),n.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,n.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(a.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0),this._mesh=e,this._waitingRenderList){for(var s=0;s<this._waitingRenderList.length;s++)this.addToRenderList(r.getNodeById(this._waitingRenderList[s]));this._waitingRenderList=null}if(n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var f=new a.EffectFallbacks;n.FOG&&f.addFallback(1,"FOG"),n.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),a.MaterialHelper.HandleFallbacksForShadows(n,f,this.maxSimultaneousLights),n.NUM_BONE_INFLUENCERS>0&&f.addCPUSkinningFallback(0,e);var l=[a.VertexBuffer.PositionKind];n.NORMAL&&l.push(a.VertexBuffer.NormalKind),n.UV1&&l.push(a.VertexBuffer.UVKind),n.UV2&&l.push(a.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&l.push(a.VertexBuffer.ColorKind),a.MaterialHelper.PrepareAttributesForBones(l,e,n,f),a.MaterialHelper.PrepareAttributesForInstances(l,n);var u=n.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vDiffuseColor","vSpecularColor","vFogInfos","vFogColor","pointSize","vNormalInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","normalMatrix","logarithmicDepthConstant","worldReflectionViewProjection","windDirection","waveLength","time","windForce","cameraPosition","bumpHeight","waveHeight","waterColor","waterColor2","colorBlendFactor","colorBlendFactor2","waveSpeed","waveCount"],c=["normalSampler","refractionSampler","reflectionSampler"],p=new Array;a.ImageProcessingConfiguration&&(a.ImageProcessingConfiguration.PrepareUniforms(d,n),a.ImageProcessingConfiguration.PrepareSamplers(c,n)),a.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:n,maxSimultaneousLights:this.maxSimultaneousLights}),i.setEffect(r.getEngine().createEffect("water",{attributes:l,uniformsNames:d,uniformBuffersNames:p,samplers:c,defines:u,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},o),n,this._materialContext)}return!(!i.effect||!i.effect.isReady()||(n._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,0))},i.prototype.bindForSubMesh=function(e,i,t){var n=this.getScene(),r=t.materialDefines;if(r){var o=t.effect;if(o&&this._mesh){this._activeEffect=o,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),a.MaterialHelper.BindBonesParameters(i,this._activeEffect),this._mustRebind(n,o)&&(this.bumpTexture&&a.MaterialFlags.BumpTextureEnabled&&(this._activeEffect.setTexture("normalSampler",this.bumpTexture),this._activeEffect.setFloat2("vNormalInfos",this.bumpTexture.coordinatesIndex,this.bumpTexture.level),this._activeEffect.setMatrix("normalMatrix",this.bumpTexture.getTextureMatrix())),a.MaterialHelper.BindClipPlane(this._activeEffect,n),this.pointsCloud&&this._activeEffect.setFloat("pointSize",this.pointSize),n.bindEyePosition(o)),this._activeEffect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility),r.SPECULARTERM&&this._activeEffect.setColor4("vSpecularColor",this.specularColor,this.specularPower),n.lightsEnabled&&!this.disableLighting&&a.MaterialHelper.BindLights(n,i,this._activeEffect,r,this.maxSimultaneousLights),n.fogEnabled&&i.applyFog&&n.fogMode!==a.Scene.FOGMODE_NONE&&this._activeEffect.setMatrix("view",n.getViewMatrix()),a.MaterialHelper.BindFogParameters(n,i,this._activeEffect),a.MaterialHelper.BindLogDepth(r,this._activeEffect,n),a.MaterialFlags.ReflectionTextureEnabled&&(this._activeEffect.setTexture("refractionSampler",this._refractionRTT),this._activeEffect.setTexture("reflectionSampler",this._reflectionRTT));var s=this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(n.getProjectionMatrix()),f=n.getEngine().getDeltaTime();f!==this._lastDeltaTime&&(this._lastDeltaTime=f,this._lastTime+=this._lastDeltaTime),this._activeEffect.setMatrix("worldReflectionViewProjection",s),this._activeEffect.setVector2("windDirection",this.windDirection),this._activeEffect.setFloat("waveLength",this.waveLength),this._activeEffect.setFloat("time",this._lastTime/1e5),this._activeEffect.setFloat("windForce",this.windForce),this._activeEffect.setFloat("waveHeight",this.waveHeight),this._activeEffect.setFloat("bumpHeight",this.bumpHeight),this._activeEffect.setColor4("waterColor",this.waterColor,1),this._activeEffect.setFloat("colorBlendFactor",this.colorBlendFactor),this._activeEffect.setColor4("waterColor2",this.waterColor2,1),this._activeEffect.setFloat("colorBlendFactor2",this.colorBlendFactor2),this._activeEffect.setFloat("waveSpeed",this.waveSpeed),this._activeEffect.setFloat("waveCount",this.waveCount),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect),this._afterBind(i,this._activeEffect)}}},i.prototype._createRenderTargets=function(e,i){var t,n=this;this._refractionRTT=new a.RenderTargetTexture(name+"_refraction",{width:i.x,height:i.y},e,!1,!0),this._refractionRTT.wrapU=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.wrapV=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._refractionRTT.ignoreCameraViewport=!0,this._reflectionRTT=new a.RenderTargetTexture(name+"_reflection",{width:i.x,height:i.y},e,!1,!0),this._reflectionRTT.wrapU=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.wrapV=a.Constants.TEXTURE_MIRROR_ADDRESSMODE,this._reflectionRTT.ignoreCameraViewport=!0;var r,o=null,s=a.Matrix.Zero();this._refractionRTT.onBeforeRender=function(){if(n._mesh&&(t=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){o=e.clipPlane;var i=n._mesh?n._mesh.position.y:0;e.clipPlane=a.Plane.FromPositionAndNormal(new a.Vector3(0,i+.05,0),new a.Vector3(0,1,0))}},this._refractionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=t),n.disableClipPlane||(e.clipPlane=o)},this._reflectionRTT.onBeforeRender=function(){if(n._mesh&&(t=n._mesh.isVisible,n._mesh.isVisible=!1),!n.disableClipPlane){o=e.clipPlane;var i=n._mesh?n._mesh.position.y:0;e.clipPlane=a.Plane.FromPositionAndNormal(new a.Vector3(0,i-.05,0),new a.Vector3(0,-1,0)),a.Matrix.ReflectionToRef(e.clipPlane,s)}r=e.getViewMatrix(),s.multiplyToRef(r,n._reflectionTransform),e.setTransformMatrix(n._reflectionTransform,e.getProjectionMatrix()),e.getEngine().cullBackFaces=!1,e._mirroredCameraPosition=a.Vector3.TransformCoordinates(e.activeCamera.position,s)},this._reflectionRTT.onAfterRender=function(){n._mesh&&(n._mesh.isVisible=t),e.clipPlane=o,e.setTransformMatrix(r,e.getProjectionMatrix()),e.getEngine().cullBackFaces=null,e._mirroredCameraPosition=null}},i.prototype.getAnimatables=function(){var e=[];return this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this._reflectionRTT&&this._reflectionRTT.animations&&this._reflectionRTT.animations.length>0&&e.push(this._reflectionRTT),this._refractionRTT&&this._refractionRTT.animations&&this._refractionRTT.animations.length>0&&e.push(this._refractionRTT),e},i.prototype.getActiveTextures=function(){var i=e.prototype.getActiveTextures.call(this);return this._bumpTexture&&i.push(this._bumpTexture),i},i.prototype.hasTexture=function(i){return!!e.prototype.hasTexture.call(this,i)||this._bumpTexture===i},i.prototype.dispose=function(i){this.bumpTexture&&this.bumpTexture.dispose();var t=this.getScene().customRenderTargets.indexOf(this._refractionRTT);-1!=t&&this.getScene().customRenderTargets.splice(t,1),t=-1,-1!=(t=this.getScene().customRenderTargets.indexOf(this._reflectionRTT))&&this.getScene().customRenderTargets.splice(t,1),this._reflectionRTT&&this._reflectionRTT.dispose(),this._refractionRTT&&this._refractionRTT.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,i)},i.prototype.clone=function(e){var t=this;return a.SerializationHelper.Clone((function(){return new i(e,t.getScene())}),this)},i.prototype.serialize=function(){var i=e.prototype.serialize.call(this);if(i.customType="BABYLON.WaterMaterial",i.renderList=[],this._refractionRTT&&this._refractionRTT.renderList)for(var t=0;t<this._refractionRTT.renderList.length;t++)i.renderList.push(this._refractionRTT.renderList[t].id);return i},i.prototype.getClassName=function(){return"WaterMaterial"},i.Parse=function(e,t,n){var r=a.SerializationHelper.Parse((function(){return new i(e.name,t)}),e,t,n);return r._waitingRenderList=e.renderList,r},i.CreateDefaultMesh=function(e,i){return(0,a.CreateGround)(e,{width:512,height:512,subdivisions:32,updatable:!1},i)},s([(0,a.serializeAsTexture)("bumpTexture")],i.prototype,"_bumpTexture",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"diffuseColor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"specularColor",void 0),s([(0,a.serialize)()],i.prototype,"specularPower",void 0),s([(0,a.serialize)("disableLighting")],i.prototype,"_disableLighting",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),s([(0,a.serialize)("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),s([(0,a.serialize)()],i.prototype,"windForce",void 0),s([(0,a.serializeAsVector2)()],i.prototype,"windDirection",void 0),s([(0,a.serialize)()],i.prototype,"waveHeight",void 0),s([(0,a.serialize)()],i.prototype,"bumpHeight",void 0),s([(0,a.serialize)("bumpSuperimpose")],i.prototype,"_bumpSuperimpose",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"bumpSuperimpose",void 0),s([(0,a.serialize)("fresnelSeparate")],i.prototype,"_fresnelSeparate",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"fresnelSeparate",void 0),s([(0,a.serialize)("bumpAffectsReflection")],i.prototype,"_bumpAffectsReflection",void 0),s([(0,a.expandToProperty)("_markAllSubMeshesAsMiscDirty")],i.prototype,"bumpAffectsReflection",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"waterColor",void 0),s([(0,a.serialize)()],i.prototype,"colorBlendFactor",void 0),s([(0,a.serializeAsColor3)()],i.prototype,"waterColor2",void 0),s([(0,a.serialize)()],i.prototype,"colorBlendFactor2",void 0),s([(0,a.serialize)()],i.prototype,"waveLength",void 0),s([(0,a.serialize)()],i.prototype,"waveSpeed",void 0),s([(0,a.serialize)()],i.prototype,"waveCount",void 0),s([(0,a.serialize)()],i.prototype,"disableClipPlane",void 0),s([(0,a.serialize)()],i.prototype,"useLogarithmicDepth",null),i}(a.PushMaterial);(0,a.RegisterClass)("BABYLON.WaterMaterial",z);var H=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==H)for(var G in H.BABYLON=H.BABYLON||{},e)H.BABYLON[G]=e[G];const W=i})(),r.default})()}));
5
+ /*! For license information please see babylon.gui.min.js.LICENSE.txt */
6
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-gui",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-gui"]=e(require("babylonjs")):(t.BABYLON=t.BABYLON||{},t.BABYLON.GUI=e(t.BABYLON))}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(t){return(()=>{"use strict";var e={520:e=>{e.exports=t}},i={};function o(t){var n=i[t];if(void 0!==n)return n.exports;var r=i[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};return(()=>{o.d(n,{default:()=>Yt});var t={};o.r(t),o.d(t,{AbstractButton3D:()=>st,AdvancedDynamicTexture:()=>tt,AdvancedDynamicTextureInstrumentation:()=>et,BaseSlider:()=>N,Button:()=>P,Button3D:()=>lt,Checkbox:()=>C,CheckboxGroup:()=>z,ColorPicker:()=>R,Container:()=>m,Container3D:()=>_t,Control:()=>g,Control3D:()=>rt,CornerHandle:()=>Ct,CylinderPanel:()=>ct,DisplayGrid:()=>Z,Ellipse:()=>S,FluentBackplateMaterial:()=>It,FluentButtonMaterial:()=>gt,FluentMaterial:()=>dt,FluentMaterialDefines:()=>ut,FocusableButton:()=>w,GUI3DManager:()=>jt,GizmoHandle:()=>Pt,Grid:()=>I,HandMenu:()=>wt,HandleMaterial:()=>xt,HandleState:()=>yt,HolographicBackplate:()=>Ut,HolographicButton:()=>ft,HolographicSlate:()=>Rt,Image:()=>x,ImageBasedSlider:()=>q,ImageScrollBar:()=>U,InputPassword:()=>M,InputText:()=>O,KeyPropertySet:()=>Y,Line:()=>E,MRDLBackplateMaterial:()=>Qt,MRDLSliderBarMaterial:()=>Nt,MRDLSliderThumbMaterial:()=>At,Matrix2D:()=>p,Measure:()=>d,MeshButton3D:()=>Mt,MultiLine:()=>F,MultiLinePoint:()=>D,NearMenu:()=>Et,PlanePanel:()=>Dt,RadioButton:()=>L,RadioGroup:()=>Q,Rectangle:()=>v,ScatterPanel:()=>Ft,ScrollBar:()=>G,ScrollViewer:()=>j,SelectionPanel:()=>H,SelectorGroup:()=>A,SideHandle:()=>Bt,SlateGizmo:()=>Tt,Slider:()=>k,Slider3D:()=>Vt,SliderGroup:()=>V,SpherePanel:()=>Ht,StackPanel:()=>B,StackPanel3D:()=>Wt,Style:()=>$,TextBlock:()=>y,TextWrapper:()=>T,TextWrapping:()=>b,ToggleButton:()=>X,TouchButton3D:()=>mt,TouchHolographicButton:()=>bt,TouchHolographicMenu:()=>St,TouchMeshButton3D:()=>Gt,ValueAndUnit:()=>l,Vector2WithInfo:()=>f,Vector3WithInfo:()=>nt,VirtualKeyboard:()=>K,VolumeBasedPanel:()=>ht,XmlLoader:()=>ot,name:()=>J});var e={};o.r(e),o.d(e,{AbstractButton3D:()=>st,AdvancedDynamicTexture:()=>tt,AdvancedDynamicTextureInstrumentation:()=>et,BaseSlider:()=>N,Button:()=>P,Button3D:()=>lt,Checkbox:()=>C,CheckboxGroup:()=>z,ColorPicker:()=>R,Container:()=>m,Container3D:()=>_t,Control:()=>g,Control3D:()=>rt,CornerHandle:()=>Ct,CylinderPanel:()=>ct,DisplayGrid:()=>Z,Ellipse:()=>S,FluentBackplateMaterial:()=>It,FluentButtonMaterial:()=>gt,FluentMaterial:()=>dt,FluentMaterialDefines:()=>ut,FocusableButton:()=>w,GUI3DManager:()=>jt,GizmoHandle:()=>Pt,Grid:()=>I,HandMenu:()=>wt,HandleMaterial:()=>xt,HandleState:()=>yt,HolographicBackplate:()=>Ut,HolographicButton:()=>ft,HolographicSlate:()=>Rt,Image:()=>x,ImageBasedSlider:()=>q,ImageScrollBar:()=>U,InputPassword:()=>M,InputText:()=>O,KeyPropertySet:()=>Y,Line:()=>E,MRDLBackplateMaterial:()=>Qt,MRDLSliderBarMaterial:()=>Nt,MRDLSliderThumbMaterial:()=>At,Matrix2D:()=>p,Measure:()=>d,MeshButton3D:()=>Mt,MultiLine:()=>F,MultiLinePoint:()=>D,NearMenu:()=>Et,PlanePanel:()=>Dt,RadioButton:()=>L,RadioGroup:()=>Q,Rectangle:()=>v,ScatterPanel:()=>Ft,ScrollBar:()=>G,ScrollViewer:()=>j,SelectionPanel:()=>H,SelectorGroup:()=>A,SideHandle:()=>Bt,SlateGizmo:()=>Tt,Slider:()=>k,Slider3D:()=>Vt,SliderGroup:()=>V,SpherePanel:()=>Ht,StackPanel:()=>B,StackPanel3D:()=>Wt,Style:()=>$,TextBlock:()=>y,TextWrapper:()=>T,TextWrapping:()=>b,ToggleButton:()=>X,TouchButton3D:()=>mt,TouchHolographicButton:()=>bt,TouchHolographicMenu:()=>St,TouchMeshButton3D:()=>Gt,ValueAndUnit:()=>l,Vector2WithInfo:()=>f,Vector3WithInfo:()=>nt,VirtualKeyboard:()=>K,VolumeBasedPanel:()=>ht,XmlLoader:()=>ot,name:()=>J});var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}function a(t,e,i,o){var n,r=arguments.length,a=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(a=(r<3?n(a):r>3?n(e,i,a):n(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}Object.create,Object.create;var s=o(520),l=function(){function t(e,i,o){void 0===i&&(i=t.UNITMODE_PIXEL),void 0===o&&(o=!0),this.negativeValueAllowed=o,this._value=1,this._unit=t.UNITMODE_PIXEL,this.ignoreAdaptiveScaling=!1,this.onChangedObservable=new s.Observable,this._value=e,this._unit=i,this._originalUnit=i}return Object.defineProperty(t.prototype,"isPercentage",{get:function(){return this._unit===t.UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPixel",{get:function(){return this._unit===t.UNITMODE_PIXEL},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"internalValue",{get:function(){return this._value},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){t!==this._value&&(this._value=t,this.onChangedObservable.notifyObservers())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unit",{get:function(){return this._unit},set:function(t){t!==this._unit&&(this._unit=t,this.onChangedObservable.notifyObservers())},enumerable:!1,configurable:!0}),t.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},t.prototype.updateInPlace=function(e,i){return void 0===i&&(i=t.UNITMODE_PIXEL),this.value===e&&this.unit===i||(this._value=e,this._unit=i,this.onChangedObservable.notifyObservers()),this},t.prototype.getValue=function(e){if(e&&!this.ignoreAdaptiveScaling&&this.unit!==t.UNITMODE_PERCENTAGE){var i=0,o=0;if(e.idealWidth&&(i=this._value*e.getSize().width/e.idealWidth),e.idealHeight&&(o=this._value*e.getSize().height/e.idealHeight),e.useSmallestIdeal&&e.idealWidth&&e.idealHeight)return window.innerWidth<window.innerHeight?i:o;if(e.idealWidth)return i;if(e.idealHeight)return o}return this._value},t.prototype.toString=function(e,i){switch(this._unit){case t.UNITMODE_PERCENTAGE:var o=100*this.getValue(e);return(i?o.toFixed(i):o)+"%";case t.UNITMODE_PIXEL:var n=this.getValue(e);return(i?n.toFixed(i):n)+"px"}return this._unit.toString()},t.prototype.fromString=function(e){var i=t._Regex.exec(e.toString());if(!i||0===i.length)return!1;var o=parseFloat(i[1]),n=this._originalUnit;if(this.negativeValueAllowed||o<0&&(o=0),4===i.length)switch(i[3]){case"px":n=t.UNITMODE_PIXEL;break;case"%":n=t.UNITMODE_PERCENTAGE,o/=100}return(o!==this._value||n!==this._unit)&&(this._value=o,this._unit=n,this.onChangedObservable.notifyObservers(),!0)},Object.defineProperty(t,"UNITMODE_PERCENTAGE",{get:function(){return t._UNITMODE_PERCENTAGE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"UNITMODE_PIXEL",{get:function(){return t._UNITMODE_PIXEL},enumerable:!1,configurable:!0}),t._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,t._UNITMODE_PERCENTAGE=0,t._UNITMODE_PIXEL=1,t}(),_=[new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0)],h=[new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0),new s.Vector2(0,0)],c=new s.Vector2(0,0),u=new s.Vector2(0,0),d=function(){function t(t,e,i,o){this.left=t,this.top=e,this.width=i,this.height=o}return t.prototype.copyFrom=function(t){this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height},t.prototype.copyFromFloats=function(t,e,i,o){this.left=t,this.top=e,this.width=i,this.height=o},t.CombineToRef=function(t,e,i){var o=Math.min(t.left,e.left),n=Math.min(t.top,e.top),r=Math.max(t.left+t.width,e.left+e.width),a=Math.max(t.top+t.height,e.top+e.height);i.left=o,i.top=n,i.width=r-o,i.height=a-n},t.prototype.addAndTransformToRef=function(t,e,i,o,n,r){var a=this.left+e,s=this.top+i,l=this.width+o,d=this.height+n;_[0].copyFromFloats(a,s),_[1].copyFromFloats(a+l,s),_[2].copyFromFloats(a+l,s+d),_[3].copyFromFloats(a,s+d),c.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE),u.copyFromFloats(0,0);for(var f=0;f<4;f++)t.transformCoordinates(_[f].x,_[f].y,h[f]),c.x=Math.floor(Math.min(c.x,h[f].x)),c.y=Math.floor(Math.min(c.y,h[f].y)),u.x=Math.ceil(Math.max(u.x,h[f].x)),u.y=Math.ceil(Math.max(u.y,h[f].y));r.left=c.x,r.top=c.y,r.width=u.x-c.x,r.height=u.y-c.y},t.prototype.transformToRef=function(t,e){this.addAndTransformToRef(t,0,0,0,0,e)},t.prototype.isEqualsTo=function(t){return this.left===t.left&&this.top===t.top&&this.width===t.width&&this.height===t.height},t.Empty=function(){return new t(0,0,0,0)},t}(),f=function(t){function e(e,i){void 0===i&&(i=0);var o=t.call(this,e.x,e.y)||this;return o.buttonIndex=i,o}return r(e,t),e}(s.Vector2),p=function(){function t(t,e,i,o,n,r){this.m=new Float32Array(6),this.fromValues(t,e,i,o,n,r)}return t.prototype.fromValues=function(t,e,i,o,n,r){return this.m[0]=t,this.m[1]=e,this.m[2]=i,this.m[3]=o,this.m[4]=n,this.m[5]=r,this},t.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},t.prototype.invertToRef=function(t){var e=this.m[0],i=this.m[1],o=this.m[2],n=this.m[3],r=this.m[4],a=this.m[5],l=this.determinant();if(l<s.Epsilon*s.Epsilon)return t.m[0]=0,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[5]=0,this;var _=1/l,h=o*a-n*r,c=i*r-e*a;return t.m[0]=n*_,t.m[1]=-i*_,t.m[2]=-o*_,t.m[3]=e*_,t.m[4]=h*_,t.m[5]=c*_,this},t.prototype.multiplyToRef=function(t,e){var i=this.m[0],o=this.m[1],n=this.m[2],r=this.m[3],a=this.m[4],s=this.m[5],l=t.m[0],_=t.m[1],h=t.m[2],c=t.m[3],u=t.m[4],d=t.m[5];return e.m[0]=i*l+o*h,e.m[1]=i*_+o*c,e.m[2]=n*l+r*h,e.m[3]=n*_+r*c,e.m[4]=a*l+s*h+u,e.m[5]=a*_+s*c+d,this},t.prototype.transformCoordinates=function(t,e,i){return i.x=t*this.m[0]+e*this.m[2]+this.m[4],i.y=t*this.m[1]+e*this.m[3]+this.m[5],this},t.Identity=function(){return new t(1,0,0,1,0,0)},t.IdentityToRef=function(t){t.m[0]=1,t.m[1]=0,t.m[2]=0,t.m[3]=1,t.m[4]=0,t.m[5]=0},t.TranslationToRef=function(t,e,i){i.fromValues(1,0,0,1,t,e)},t.ScalingToRef=function(t,e,i){i.fromValues(t,0,0,e,0,0)},t.RotationToRef=function(t,e){var i=Math.sin(t),o=Math.cos(t);e.fromValues(o,i,-i,o,0,0)},t.ComposeToRef=function(e,i,o,n,r,a,s){t.TranslationToRef(e,i,t._TempPreTranslationMatrix),t.ScalingToRef(n,r,t._TempScalingMatrix),t.RotationToRef(o,t._TempRotationMatrix),t.TranslationToRef(-e,-i,t._TempPostTranslationMatrix),t._TempPreTranslationMatrix.multiplyToRef(t._TempScalingMatrix,t._TempCompose0),t._TempCompose0.multiplyToRef(t._TempRotationMatrix,t._TempCompose1),a?(t._TempCompose1.multiplyToRef(t._TempPostTranslationMatrix,t._TempCompose2),t._TempCompose2.multiplyToRef(a,s)):t._TempCompose1.multiplyToRef(t._TempPostTranslationMatrix,s)},t._TempPreTranslationMatrix=t.Identity(),t._TempPostTranslationMatrix=t.Identity(),t._TempRotationMatrix=t.Identity(),t._TempScalingMatrix=t.Identity(),t._TempCompose0=t.Identity(),t._TempCompose1=t.Identity(),t._TempCompose2=t.Identity(),t}(),g=function(){function t(e){this.name=e,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=d.Empty(),this._tempPaddingMeasure=d.Empty(),this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new l(18,l.UNITMODE_PIXEL,!1),this._width=new l(1,l.UNITMODE_PERCENTAGE,!1),this._height=new l(1,l.UNITMODE_PERCENTAGE,!1),this._color="",this._style=null,this._horizontalAlignment=t.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=t.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._wasDirty=!1,this._tempParentMeasure=d.Empty(),this._prevCurrentMeasureTransformedIntoGlobalSpace=d.Empty(),this._cachedParentMeasure=d.Empty(),this._descendantsOnlyPadding=!1,this._paddingLeft=new l(0),this._paddingRight=new l(0),this._paddingTop=new l(0),this._paddingBottom=new l(0),this._left=new l(0),this._top=new l(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=p.Identity(),this._invertTransformMatrix=p.Identity(),this._transformedPosition=s.Vector2.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._isHighlighted=!1,this._highlightColor="#4affff",this._highlightLineWidth=2,this._fontSet=!1,this._dummyVector2=s.Vector2.Zero(),this._downCount=0,this._enterCount=-1,this._doNotRender=!1,this._downPointerIds={},this._evaluatedMeasure=new d(0,0,0,0),this._evaluatedParentMeasure=new d(0,0,0,0),this._isEnabled=!0,this._disabledColor="#9a9a9a",this._disabledColorItem="#6a6a6a",this._isReadOnly=!1,this._rebuildLayout=!1,this._customData={},this._isClipped=!1,this._automaticSize=!1,this.metadata=null,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this.isFocusInvisible=!1,this.clipChildren=!0,this.clipContent=!0,this.useBitmapCache=!1,this._shadowOffsetX=0,this._shadowOffsetY=0,this._shadowBlur=0,this._previousShadowBlur=0,this._shadowColor="black",this.hoverCursor="",this._linkOffsetX=new l(0),this._linkOffsetY=new l(0),this.onWheelObservable=new s.Observable,this.onPointerMoveObservable=new s.Observable,this.onPointerOutObservable=new s.Observable,this.onPointerDownObservable=new s.Observable,this.onPointerUpObservable=new s.Observable,this.onPointerClickObservable=new s.Observable,this.onPointerEnterObservable=new s.Observable,this.onDirtyObservable=new s.Observable,this.onBeforeDrawObservable=new s.Observable,this.onAfterDrawObservable=new s.Observable,this.onDisposeObservable=new s.Observable,this.fixedRatio=0,this._fixedRatioMasterIsWidth=!0,this._tmpMeasureA=new d(0,0,0,0)}return Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return this._isReadOnly},set:function(t){this._isReadOnly=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transformedMeasure",{get:function(){return this._evaluatedMeasure},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOffsetX",{get:function(){return this._shadowOffsetX},set:function(t){this._shadowOffsetX!==t&&(this._shadowOffsetX=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOffsetY",{get:function(){return this._shadowOffsetY},set:function(t){this._shadowOffsetY!==t&&(this._shadowOffsetY=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowBlur",{get:function(){return this._shadowBlur},set:function(t){this._shadowBlur!==t&&(this._previousShadowBlur=this._shadowBlur,this._shadowBlur=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowColor",{get:function(){return this._shadowColor},set:function(t){this._shadowColor!==t&&(this._shadowColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return this._getTypeName()},Object.defineProperty(t.prototype,"host",{get:function(){return this._host},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontOffset",{get:function(){return this._fontOffset},set:function(t){this._fontOffset=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alphaSet=!0,this._alpha=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightLineWidth",{get:function(){return this._highlightLineWidth},set:function(t){this._highlightLineWidth!==t&&(this._highlightLineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHighlighted",{get:function(){return this._isHighlighted},set:function(t){this._isHighlighted!==t&&(this._isHighlighted=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightColor",{get:function(){return this._highlightColor},set:function(t){this._highlightColor!==t&&(this._highlightColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this._scaleX!==t&&(this._scaleX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this._scaleY!==t&&(this._scaleY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(t){this._transformCenterY!==t&&(this._transformCenterY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(t){this._transformCenterX!==t&&(this._transformCenterX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(t){this._horizontalAlignment!==t&&(this._horizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(t){this._verticalAlignment!==t&&(this._verticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!0,this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"widthInPixels",{get:function(){return this._width.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!0,this.width=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._fixedRatioMasterIsWidth=!1,this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"heightInPixels",{get:function(){return this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this._fixedRatioMasterIsWidth=!1,this.height=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"style",{get:function(){return this._style},set:function(t){var e=this;this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._style=t,this._style&&(this._styleObserver=this._style.onChangedObservable.add((function(){e._markAsDirty(),e._resetFontCache()}))),this._markAsDirty(),this._resetFontCache()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_isFontSizeInPercentage",{get:function(){return this._fontSize.isPercentage},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontSizeInPixels",{get:function(){var t=this._style?this._style._fontSize:this._fontSize;return t.isPixel?t.getValue(this._host):t.getValueInPixel(this._host,this._tempParentMeasure.height||this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.fontSize=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&(this._markAsDirty(),this._resetFontCache())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._color},set:function(t){this._color!==t&&(this._color=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this.zIndex!==t&&(this._zIndex=t,this.parent&&this.parent._reOrderControl(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"notRenderable",{get:function(){return this._doNotRender},set:function(t){this._doNotRender!==t&&(this._doNotRender=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!==t&&(this._isVisible=t,this._markAsDirty(!0))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkedMesh",{get:function(){return this._linkedMesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"descendantsOnlyPadding",{get:function(){return this._descendantsOnlyPadding},set:function(t){this._descendantsOnlyPadding!==t&&(this._descendantsOnlyPadding=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(t){this._paddingLeft.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingLeftInPixels",{get:function(){return this._paddingLeft.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingLeft=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_paddingLeftInPixels",{get:function(){return this._descendantsOnlyPadding?0:this.paddingLeftInPixels},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(t){this._paddingRight.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingRightInPixels",{get:function(){return this._paddingRight.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.paddingRight=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_paddingRightInPixels",{get:function(){return this._descendantsOnlyPadding?0:this.paddingRightInPixels},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(t){this._paddingTop.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingTopInPixels",{get:function(){return this._paddingTop.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingTop=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_paddingTopInPixels",{get:function(){return this._descendantsOnlyPadding?0:this.paddingTopInPixels},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(t){this._paddingBottom.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"paddingBottomInPixels",{get:function(){return this._paddingBottom.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.paddingBottom=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_paddingBottomInPixels",{get:function(){return this._descendantsOnlyPadding?0:this.paddingBottomInPixels},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(t){this._left.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftInPixels",{get:function(){return this._left.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.left=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(t){this._top.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"topInPixels",{get:function(){return this._top.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.top=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(t){this._linkOffsetX.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetXInPixels",{get:function(){return this._linkOffsetX.getValueInPixel(this._host,this._cachedParentMeasure.width)},set:function(t){isNaN(t)||(this.linkOffsetX=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(t){this._linkOffsetY.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkOffsetYInPixels",{get:function(){return this._linkOffsetY.getValueInPixel(this._host,this._cachedParentMeasure.height)},set:function(t){isNaN(t)||(this.linkOffsetY=t+"px")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(t){var e=this;if(this._isEnabled!==t){this._isEnabled=t,this._markAsDirty();var i=function(t){if(t.host){for(var o in t.host._lastControlOver)t===e.host._lastControlOver[o]&&(t._onPointerOut(t,null,!0),delete t.host._lastControlOver[o]);void 0!==t.children&&t.children.forEach(i)}};i(this)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disabledColor",{get:function(){return this._disabledColor},set:function(t){this._disabledColor!==t&&(this._disabledColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"disabledColorItem",{get:function(){return this._disabledColorItem},set:function(t){this._disabledColorItem!==t&&(this._disabledColorItem=t,this._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype._getTypeName=function(){return"Control"},t.prototype.getAscendantOfClass=function(t){return this.parent?this.parent.getClassName()===t?this.parent:this.parent.getAscendantOfClass(t):null},t.prototype.markAsDirty=function(t){void 0===t&&(t=!1),this._markAsDirty(t)},t.prototype.markAllAsDirty=function(){this._markAllAsDirty()},t.prototype._resetFontCache=function(){this._fontSet=!0,this._markAsDirty()},t.prototype.isAscendant=function(t){return!!this.parent&&(this.parent===t||this.parent.isAscendant(t))},t.prototype.getLocalCoordinates=function(t){var e=s.Vector2.Zero();return this.getLocalCoordinatesToRef(t,e),e},t.prototype.getLocalCoordinatesToRef=function(t,e){return e.x=t.x-this._currentMeasure.left,e.y=t.y-this._currentMeasure.top,this},t.prototype.getParentLocalCoordinates=function(t){var e=s.Vector2.Zero();return e.x=t.x-this._cachedParentMeasure.left,e.y=t.y-this._cachedParentMeasure.top,e},t.prototype.moveToVector3=function(e,i){if(this._host&&this.parent===this._host._rootContainer){this.horizontalAlignment=t.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.VERTICAL_ALIGNMENT_TOP;var o=this._host._getGlobalViewport(),n=s.Vector3.Project(e,s.Matrix.Identity(),i.getTransformMatrix(),o);this._moveToProjectedPosition(n),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},t.prototype.getDescendantsToRef=function(t,e,i){void 0===e&&(e=!1)},t.prototype.getDescendants=function(t,e){var i=new Array;return this.getDescendantsToRef(i,t,e),i},t.prototype.linkWithMesh=function(e){if(!this._host||this.parent&&this.parent!==this._host._rootContainer)e&&s.Tools.Error("Cannot link a control to a mesh if the control is not at root level");else{var i=this._host._linkedControls.indexOf(this);if(-1!==i)return this._linkedMesh=e,void(e||this._host._linkedControls.splice(i,1));e&&(this.horizontalAlignment=t.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this))}},t.prototype.setPadding=function(t,e,i,o){var n=t,r=null!=e?e:n,a=null!=i?i:n,s=null!=o?o:r;this.paddingTop=n,this.paddingRight=r,this.paddingBottom=a,this.paddingLeft=s},t.prototype.setPaddingInPixels=function(t,e,i,o){var n=t,r=null!=e?e:n,a=null!=i?i:n,s=null!=o?o:r;this.paddingTopInPixels=n,this.paddingRightInPixels=r,this.paddingBottomInPixels=a,this.paddingLeftInPixels=s},t.prototype._moveToProjectedPosition=function(t){var e,i=this._left.getValue(this._host),o=this._top.getValue(this._host),n=null===(e=this.parent)||void 0===e?void 0:e._currentMeasure;n&&this._processMeasures(n,this._host.getContext());var r=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,a=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(r-i)<.5&&(r=i),Math.abs(a-o)<.5&&(a=o)),this.left=r+"px",this.top=a+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},t.prototype._offsetLeft=function(t){this._isDirty=!0,this._currentMeasure.left+=t},t.prototype._offsetTop=function(t){this._isDirty=!0,this._currentMeasure.top+=t},t.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},t.prototype._flagDescendantsAsMatrixDirty=function(){},t.prototype._intersectsRect=function(t,e){return this._transform(e),!(this._evaluatedMeasure.left>=t.left+t.width||this._evaluatedMeasure.top>=t.top+t.height||this._evaluatedMeasure.left+this._evaluatedMeasure.width<=t.left||this._evaluatedMeasure.top+this._evaluatedMeasure.height<=t.top)},t.prototype._computeAdditionnalOffsetX=function(){return 0},t.prototype._computeAdditionnalOffsetY=function(){return 0},t.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization){this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),d.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA);var t=this.shadowOffsetX,e=this.shadowOffsetY,i=Math.max(this._previousShadowBlur,this.shadowBlur),o=Math.min(Math.min(t,0)-2*i,0),n=Math.max(Math.max(t,0)+2*i,0),r=Math.min(Math.min(e,0)-2*i,0),a=Math.max(Math.max(e,0)+2*i,0),s=this._computeAdditionnalOffsetX(),l=this._computeAdditionnalOffsetY();this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+o-s),Math.floor(this._tmpMeasureA.top+r-l),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+n+s),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+a+l))}},t.prototype._markAsDirty=function(t){void 0===t&&(t=!1),(this._isVisible||t)&&(this._isDirty=!0,this._markMatrixAsDirty(),this._host&&this._host.markAsDirty())},t.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},t.prototype._link=function(t){this._host=t,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},t.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var e=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,i=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t&&(t.translate(e,i),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-e,-i)),(this._isMatrixDirty||this._cachedOffsetX!==e||this._cachedOffsetY!==i)&&(this._cachedOffsetX=e,this._cachedOffsetY=i,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),p.ComposeToRef(-e,-i,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix),this._currentMeasure.transformToRef(this._transformMatrix,this._evaluatedMeasure))}},t.prototype._renderHighlight=function(t){this.isHighlighted&&(t.save(),t.strokeStyle=this._highlightColor,t.lineWidth=this._highlightLineWidth,this._renderHighlightSpecific(t),t.restore())},t.prototype._renderHighlightSpecific=function(t){t.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},t.prototype._applyStates=function(e){this._isFontSizeInPercentage&&(this._fontSet=!0),this._host&&this._host.useSmallestIdeal&&!this._font&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(e.font=this._font),this._color&&(e.fillStyle=this._color),t.AllowAlphaInheritance?e.globalAlpha*=this._alpha:this._alphaSet&&(e.globalAlpha=this.parent&&!this.parent.renderToIntermediateTexture?this.parent.alpha*this._alpha:this._alpha)},t.prototype._layout=function(t,e){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(t)){this.host._numLayoutCalls++,this._currentMeasure.addAndTransformToRef(this._transformMatrix,0|-this._paddingLeftInPixels,0|-this._paddingTopInPixels,0|this._paddingRightInPixels,0|this._paddingBottomInPixels,this._prevCurrentMeasureTransformedIntoGlobalSpace),e.save(),this._applyStates(e);var i=0;do{this._rebuildLayout=!1,this._processMeasures(t,e),i++}while(this._rebuildLayout&&i<3);i>=3&&s.Logger.Error("Layout cycle detected in GUI (Control name=".concat(this.name,", uniqueId=").concat(this.uniqueId,")")),e.restore(),this.invalidateRect(),this._evaluateClippingState(t)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},t.prototype._processMeasures=function(t,e){this._tempPaddingMeasure.copyFrom(t),this.parent&&this.parent.descendantsOnlyPadding&&(this._tempPaddingMeasure.left+=this.parent.paddingLeftInPixels,this._tempPaddingMeasure.top+=this.parent.paddingTopInPixels,this._tempPaddingMeasure.width-=this.parent.paddingLeftInPixels+this.parent.paddingRightInPixels,this._tempPaddingMeasure.height-=this.parent.paddingTopInPixels+this.parent.paddingBottomInPixels),this._currentMeasure.copyFrom(this._tempPaddingMeasure),this._preMeasure(this._tempPaddingMeasure,e),this._measure(),this._computeAlignment(this._tempPaddingMeasure,e),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(this._tempPaddingMeasure,e),this._cachedParentMeasure.copyFrom(this._tempPaddingMeasure),this._currentMeasure.transformToRef(this._transformMatrix,this._evaluatedMeasure),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},t.prototype._evaluateClippingState=function(t){if(this._currentMeasure.transformToRef(this._transformMatrix,this._evaluatedMeasure),this.parent&&this.parent.clipChildren){if(t.transformToRef(this.parent._transformMatrix,this._evaluatedParentMeasure),this._evaluatedMeasure.left>this._evaluatedParentMeasure.left+this._evaluatedParentMeasure.width)return void(this._isClipped=!0);if(this._evaluatedMeasure.left+this._evaluatedMeasure.width<this._evaluatedParentMeasure.left)return void(this._isClipped=!0);if(this._evaluatedMeasure.top>this._evaluatedParentMeasure.top+this._evaluatedParentMeasure.height)return void(this._isClipped=!0);if(this._evaluatedMeasure.top+this._evaluatedMeasure.height<this._evaluatedParentMeasure.top)return void(this._isClipped=!0)}this._isClipped=!1},t.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host),0!==this.fixedRatio&&(this._fixedRatioMasterIsWidth?this._currentMeasure.height=this._currentMeasure.width*this.fixedRatio:this._currentMeasure.width=this._currentMeasure.height*this.fixedRatio)},t.prototype._computeAlignment=function(e,i){var o=this._currentMeasure.width,n=this._currentMeasure.height,r=e.width,a=e.height,s=0,l=0;switch(this.horizontalAlignment){case t.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case t.HORIZONTAL_ALIGNMENT_RIGHT:s=r-o;break;case t.HORIZONTAL_ALIGNMENT_CENTER:s=(r-o)/2}switch(this.verticalAlignment){case t.VERTICAL_ALIGNMENT_TOP:l=0;break;case t.VERTICAL_ALIGNMENT_BOTTOM:l=a-n;break;case t.VERTICAL_ALIGNMENT_CENTER:l=(a-n)/2}this.descendantsOnlyPadding||(this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=r*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=r*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=r*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=a*this._paddingTop.getValue(this._host),this._currentMeasure.height-=a*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=a*this._paddingBottom.getValue(this._host)),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=r*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=a*this._top.getValue(this._host),this._currentMeasure.left+=s,this._currentMeasure.top+=l},t.prototype._preMeasure=function(t,e){},t.prototype._additionalProcessing=function(t,e){},t.prototype._clipForChildren=function(t){},t.prototype._clip=function(e,i){if(e.beginPath(),t._ClipMeasure.copyFrom(this._currentMeasure),i){i.transformToRef(this._invertTransformMatrix,this._tmpMeasureA);var o=new d(0,0,0,0);o.left=Math.max(this._tmpMeasureA.left,this._currentMeasure.left),o.top=Math.max(this._tmpMeasureA.top,this._currentMeasure.top),o.width=Math.min(this._tmpMeasureA.left+this._tmpMeasureA.width,this._currentMeasure.left+this._currentMeasure.width)-o.left,o.height=Math.min(this._tmpMeasureA.top+this._tmpMeasureA.height,this._currentMeasure.top+this._currentMeasure.height)-o.top,t._ClipMeasure.copyFrom(o)}if(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var n=this.shadowOffsetX,r=this.shadowOffsetY,a=this.shadowBlur,s=Math.min(Math.min(n,0)-2*a,0),l=Math.max(Math.max(n,0)+2*a,0),_=Math.min(Math.min(r,0)-2*a,0),h=Math.max(Math.max(r,0)+2*a,0);e.rect(t._ClipMeasure.left+s,t._ClipMeasure.top+_,t._ClipMeasure.width+l-s,t._ClipMeasure.height+h-_)}else e.rect(t._ClipMeasure.left,t._ClipMeasure.top,t._ClipMeasure.width,t._ClipMeasure.height);e.clip()},t.prototype._render=function(t,e){return!this.isVisible||this.notRenderable||this._isClipped?(this._isDirty=!1,!1):(this.host._numRenderCalls++,t.save(),this._applyStates(t),this._transform(t),this.clipContent&&this._clip(t,e),this.onBeforeDrawObservable.hasObservers()&&this.onBeforeDrawObservable.notifyObservers(this),this.useBitmapCache&&!this._wasDirty&&this._cacheData?t.putImageData(this._cacheData,this._currentMeasure.left,this._currentMeasure.top):this._draw(t,e),this.useBitmapCache&&this._wasDirty&&(this._cacheData=t.getImageData(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._renderHighlight(t),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this),t.restore(),!0)},t.prototype._draw=function(t,e){},t.prototype.contains=function(t,e){return this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y,!(t<this._currentMeasure.left||t>this._currentMeasure.left+this._currentMeasure.width||e<this._currentMeasure.top||e>this._currentMeasure.top+this._currentMeasure.height||(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),0))},t.prototype._processPicking=function(t,e,i,o,n,r,a,s){return!(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this._doNotRender||!this.contains(t,e)||(this._processObservables(o,t,e,i,n,r,a,s),0))},t.prototype._onPointerMove=function(t,e,i,o){this.onPointerMoveObservable.notifyObservers(e,-1,t,this,o)&&null!=this.parent&&this.parent._onPointerMove(t,e,i,o)},t.prototype._onPointerEnter=function(t,e){return!(!this._isEnabled||this._enterCount>0||(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this,e)&&null!=this.parent&&this.parent._onPointerEnter(t,e),0))},t.prototype._onPointerOut=function(t,e,i){if(void 0===i&&(i=!1),i||this._isEnabled&&t!==this){this._enterCount=0;var o=!0;t.isAscendant(this)||(o=this.onPointerOutObservable.notifyObservers(this,-1,t,this,e)),o&&null!=this.parent&&this.parent._onPointerOut(t,e,i)}},t.prototype._onPointerDown=function(t,e,i,o,n){return this._onPointerEnter(this,n),0===this._downCount&&(this._downCount++,this._downPointerIds[i]=!0,this.onPointerDownObservable.notifyObservers(new f(e,o),-1,t,this,n)&&null!=this.parent&&this.parent._onPointerDown(t,e,i,o,n),!0)},t.prototype._onPointerUp=function(t,e,i,o,n,r){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[i];var a=n;n&&(this._enterCount>0||-1===this._enterCount)&&(a=this.onPointerClickObservable.notifyObservers(new f(e,o),-1,t,this,r)),this.onPointerUpObservable.notifyObservers(new f(e,o),-1,t,this,r)&&null!=this.parent&&this.parent._onPointerUp(t,e,i,o,a,r)}},t.prototype._forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector2.Zero(),t,0,!0);else for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector2.Zero(),+e,0,!0)},t.prototype._onWheelScroll=function(t,e){this._isEnabled&&this.onWheelObservable.notifyObservers(new s.Vector2(t,e))&&null!=this.parent&&this.parent._onWheelScroll(t,e)},t.prototype._onCanvasBlur=function(){},t.prototype._processObservables=function(t,e,i,o,n,r,a,l){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(e,i),t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,n,o);var _=this._host._lastControlOver[n];return _&&_!==this&&_._onPointerOut(this,o),_!==this&&this._onPointerEnter(this,o),this._host._lastControlOver[n]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,n,r,o),this._host._registerLastControlDown(this,n),this._host._lastPickedControl=this,!0):t===s.PointerEventTypes.POINTERUP?(this._host._lastControlDown[n]&&this._host._lastControlDown[n]._onPointerUp(this,this._dummyVector2,n,r,!0,o),delete this._host._lastControlDown[n],!0):!(t!==s.PointerEventTypes.POINTERWHEEL||!this._host._lastControlOver[n]||(this._host._lastControlOver[n]._onWheelScroll(a,l),0))},t.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=t._GetFontOffset(this._font),this.getDescendants().forEach((function(t){return t._markAllAsDirty()})))},t.prototype.serialize=function(t){s.SerializationHelper.Serialize(this,t),t.name=this.name,t.className=this.getClassName(),this._font&&(t.fontFamily=this._fontFamily,t.fontSize=this.fontSize,t.fontWeight=this.fontWeight,t.fontStyle=this.fontStyle)},t.prototype._parseFromContent=function(t,e){t.fontFamily&&(this.fontFamily=t.fontFamily),t.fontSize&&(this.fontSize=t.fontSize),t.fontWeight&&(this.fontWeight=t.fontWeight),t.fontStyle&&(this.fontStyle=t.fontStyle)},t.prototype.dispose=function(){this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this.onWheelObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host&&this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return t._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return t._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return t._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_TOP",{get:function(){return t._VERTICAL_ALIGNMENT_TOP},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return t._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!1,configurable:!0}),Object.defineProperty(t,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return t._VERTICAL_ALIGNMENT_CENTER},enumerable:!1,configurable:!0}),t._GetFontOffset=function(e){if(t._FontHeightSizes[e])return t._FontHeightSizes[e];var i=s.EngineStore.LastCreatedEngine;if(!i)throw new Error("Invalid engine. Unable to create a canvas.");var o=i.getFontOffset(e);return t._FontHeightSizes[e]=o,o},t.Parse=function(t,e){var i=s.Tools.Instantiate("BABYLON.GUI."+t.className),o=s.SerializationHelper.Parse((function(){return new i}),t,null);return o.name=t.name,o._parseFromContent(t,e),o},t.drawEllipse=function(t,e,i,o,n){n.translate(t,e),n.scale(i,o),n.beginPath(),n.arc(0,0,1,0,2*Math.PI),n.closePath(),n.scale(1/i,1/o),n.translate(-t,-e)},t.AllowAlphaInheritance=!1,t._ClipMeasure=new d(0,0,0,0),t._HORIZONTAL_ALIGNMENT_LEFT=0,t._HORIZONTAL_ALIGNMENT_RIGHT=1,t._HORIZONTAL_ALIGNMENT_CENTER=2,t._VERTICAL_ALIGNMENT_TOP=0,t._VERTICAL_ALIGNMENT_BOTTOM=1,t._VERTICAL_ALIGNMENT_CENTER=2,t._FontHeightSizes={},t.AddHeader=function(){},a([(0,s.serialize)()],t.prototype,"metadata",void 0),a([(0,s.serialize)()],t.prototype,"isHitTestVisible",void 0),a([(0,s.serialize)()],t.prototype,"isPointerBlocker",void 0),a([(0,s.serialize)()],t.prototype,"isFocusInvisible",void 0),a([(0,s.serialize)()],t.prototype,"clipChildren",void 0),a([(0,s.serialize)()],t.prototype,"clipContent",void 0),a([(0,s.serialize)()],t.prototype,"useBitmapCache",void 0),a([(0,s.serialize)()],t.prototype,"shadowOffsetX",null),a([(0,s.serialize)()],t.prototype,"shadowOffsetY",null),a([(0,s.serialize)()],t.prototype,"shadowBlur",null),a([(0,s.serialize)()],t.prototype,"shadowColor",null),a([(0,s.serialize)()],t.prototype,"hoverCursor",void 0),a([(0,s.serialize)()],t.prototype,"fontOffset",null),a([(0,s.serialize)()],t.prototype,"alpha",null),a([(0,s.serialize)()],t.prototype,"scaleX",null),a([(0,s.serialize)()],t.prototype,"scaleY",null),a([(0,s.serialize)()],t.prototype,"rotation",null),a([(0,s.serialize)()],t.prototype,"transformCenterY",null),a([(0,s.serialize)()],t.prototype,"transformCenterX",null),a([(0,s.serialize)()],t.prototype,"horizontalAlignment",null),a([(0,s.serialize)()],t.prototype,"verticalAlignment",null),a([(0,s.serialize)()],t.prototype,"fixedRatio",void 0),a([(0,s.serialize)()],t.prototype,"width",null),a([(0,s.serialize)()],t.prototype,"height",null),a([(0,s.serialize)()],t.prototype,"style",null),a([(0,s.serialize)()],t.prototype,"color",null),a([(0,s.serialize)()],t.prototype,"zIndex",null),a([(0,s.serialize)()],t.prototype,"notRenderable",null),a([(0,s.serialize)()],t.prototype,"isVisible",null),a([(0,s.serialize)()],t.prototype,"descendantsOnlyPadding",null),a([(0,s.serialize)()],t.prototype,"paddingLeft",null),a([(0,s.serialize)()],t.prototype,"paddingRight",null),a([(0,s.serialize)()],t.prototype,"paddingTop",null),a([(0,s.serialize)()],t.prototype,"paddingBottom",null),a([(0,s.serialize)()],t.prototype,"left",null),a([(0,s.serialize)()],t.prototype,"top",null),a([(0,s.serialize)()],t.prototype,"linkOffsetX",null),a([(0,s.serialize)()],t.prototype,"linkOffsetY",null),a([(0,s.serialize)()],t.prototype,"isEnabled",null),a([(0,s.serialize)()],t.prototype,"disabledColor",null),a([(0,s.serialize)()],t.prototype,"disabledColorItem",null),a([(0,s.serialize)()],t.prototype,"overlapGroup",void 0),a([(0,s.serialize)()],t.prototype,"overlapDeltaMultiplier",void 0),t}();(0,s.RegisterClass)("BABYLON.GUI.Control",g);var m=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._children=new Array,i._measureForChildren=d.Empty(),i._background="",i._adaptWidthToChildren=!1,i._adaptHeightToChildren=!1,i._renderToIntermediateTexture=!1,i._intermediateTexture=null,i.logLayoutCycleErrors=!1,i.maxLayoutCycle=3,i}return r(e,t),Object.defineProperty(e.prototype,"renderToIntermediateTexture",{get:function(){return this._renderToIntermediateTexture},set:function(t){this._renderToIntermediateTexture!==t&&(this._renderToIntermediateTexture=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(t){this._adaptHeightToChildren!==t&&(this._adaptHeightToChildren=t,t&&(this.height="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(t){this._adaptWidthToChildren!==t&&(this._adaptWidthToChildren=t,t&&(this.width="100%"),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return this._isReadOnly},set:function(t){this._isReadOnly=t;for(var e=0,i=this._children;e<i.length;e++)i[e].isReadOnly=t},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Container"},e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this.children;t<e.length;t++)e[t]._markMatrixAsDirty()},e.prototype.getChildByName=function(t){for(var e=0,i=this.children;e<i.length;e++){var o=i[e];if(o.name===t)return o}return null},e.prototype.getChildByType=function(t,e){for(var i=0,o=this.children;i<o.length;i++){var n=o[i];if(n.typeName===e)return n}return null},e.prototype.containsControl=function(t){return-1!==this.children.indexOf(t)},e.prototype.addControl=function(t){return t?(-1!==this._children.indexOf(t)||(t._link(this._host),t._markAllAsDirty(),this._reOrderControl(t),this._markAsDirty()),this):this},e.prototype.clearControls=function(){for(var t=0,e=this.children.slice();t<e.length;t++){var i=e[t];this.removeControl(i)}return this},e.prototype.removeControl=function(t){var e=this._children.indexOf(t);return-1!==e&&(this._children.splice(e,1),t.parent=null),t.linkWithMesh(null),this._host&&this._host._cleanControlAfterRemoval(t),this._markAsDirty(),this},e.prototype._reOrderControl=function(t){this.removeControl(t);for(var e=!1,i=0;i<this._children.length;i++)if(this._children[i].zIndex>t.zIndex){this._children.splice(i,0,t),e=!0;break}e||this._children.push(t),t.parent=this,this._markAsDirty()},e.prototype._offsetLeft=function(e){t.prototype._offsetLeft.call(this,e);for(var i=0,o=this._children;i<o.length;i++)o[i]._offsetLeft(e)},e.prototype._offsetTop=function(e){t.prototype._offsetTop.call(this,e);for(var i=0,o=this._children;i<o.length;i++)o[i]._offsetTop(e)},e.prototype._markAllAsDirty=function(){t.prototype._markAllAsDirty.call(this);for(var e=0;e<this._children.length;e++)this._children[e]._markAllAsDirty()},e.prototype._localDraw=function(t){this._background&&(t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),t.restore())},e.prototype._link=function(e){t.prototype._link.call(this,e);for(var i=0,o=this._children;i<o.length;i++)o[i]._link(e)},e.prototype._beforeLayout=function(){},e.prototype._processMeasures=function(e,i){!this._isDirty&&this._cachedParentMeasure.isEqualsTo(e)||(t.prototype._processMeasures.call(this,e,i),this._evaluateClippingState(e),this._renderToIntermediateTexture&&(this._intermediateTexture&&this._host.getScene()!=this._intermediateTexture.getScene()&&(this._intermediateTexture.dispose(),this._intermediateTexture=null),this._intermediateTexture?this._intermediateTexture.scaleTo(this._currentMeasure.width,this._currentMeasure.height):(this._intermediateTexture=new s.DynamicTexture("",{width:this._currentMeasure.width,height:this._currentMeasure.height},this._host.getScene(),!1,s.Texture.NEAREST_SAMPLINGMODE,s.Constants.TEXTUREFORMAT_RGBA,!1),this._intermediateTexture.hasAlpha=!0)))},e.prototype._layout=function(t,e){var i,o;if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;this.host._numLayoutCalls++,this._isDirty&&this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace);var n=0;e.save(),this._applyStates(e),this._beforeLayout();do{var r=-1,a=-1;if(this._rebuildLayout=!1,this._processMeasures(t,e),!this._isClipped){for(var l=0,_=this._children;l<_.length;l++){var h=_[l];h._tempParentMeasure.copyFrom(this._measureForChildren),h._layout(this._measureForChildren,e)&&h.isVisible&&!h.notRenderable&&(this.adaptWidthToChildren&&h._width.isPixel&&(r=Math.max(r,h._currentMeasure.width+h._paddingLeftInPixels+h._paddingRightInPixels)),this.adaptHeightToChildren&&h._height.isPixel&&(a=Math.max(a,h._currentMeasure.height+h._paddingTopInPixels+h._paddingBottomInPixels)))}this.adaptWidthToChildren&&r>=0&&(r+=this.paddingLeftInPixels+this.paddingRightInPixels,this.width!==r+"px"&&(null===(i=this.parent)||void 0===i||i._markAsDirty(),this.width=r+"px",this._width.ignoreAdaptiveScaling=!0,this._rebuildLayout=!0)),this.adaptHeightToChildren&&a>=0&&(a+=this.paddingTopInPixels+this.paddingBottomInPixels,this.height!==a+"px"&&(null===(o=this.parent)||void 0===o||o._markAsDirty(),this.height=a+"px",this._height.ignoreAdaptiveScaling=!0,this._rebuildLayout=!0)),this._postMeasure()}n++}while(this._rebuildLayout&&n<this.maxLayoutCycle);return n>=3&&this.logLayoutCycleErrors&&s.Logger.Error("Layout cycle detected in GUI (Container name=".concat(this.name,", uniqueId=").concat(this.uniqueId,")")),e.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},e.prototype._postMeasure=function(){},e.prototype._draw=function(t,e){var i=this._renderToIntermediateTexture&&this._intermediateTexture,o=i?this._intermediateTexture.getContext():t;i&&(o.save(),o.translate(-this._currentMeasure.left,-this._currentMeasure.top),e?o.clearRect(e.left,e.top,e.width,e.height):o.clearRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._localDraw(o),t.save(),this.clipChildren&&this._clipForChildren(o);for(var n=0,r=this._children;n<r.length;n++){var a=r[n];e&&!a._intersectsRect(e)||a._render(o,e)}i&&(o.restore(),t.save(),t.globalAlpha=this.alpha,t.drawImage(o.canvas,this._currentMeasure.left,this._currentMeasure.top),t.restore()),t.restore()},e.prototype.getDescendantsToRef=function(t,e,i){if(void 0===e&&(e=!1),this.children)for(var o=0;o<this.children.length;o++){var n=this.children[o];i&&!i(n)||t.push(n),e||n.getDescendantsToRef(t,!1,i)}},e.prototype._processPicking=function(e,i,o,n,r,a,s,l){if(!this._isEnabled||!this.isVisible||this.notRenderable)return!1;var _=t.prototype.contains.call(this,e,i);if(!_&&this.clipChildren)return!1;for(var h=this._children.length-1;h>=0;h--){var c=this._children[h];if(c._processPicking(e,i,o,n,r,a,s,l))return c.hoverCursor&&this._host._changeCursor(c.hoverCursor),!0}return!!_&&!!this.isHitTestVisible&&this._processObservables(n,e,i,o,r,a,s,l)},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(this._currentMeasure)},e.prototype.serialize=function(e){if(t.prototype.serialize.call(this,e),this.children.length){e.children=[];for(var i=0,o=this.children;i<o.length;i++){var n={};o[i].serialize(n),e.children.push(n)}}},e.prototype.dispose=function(){var e;t.prototype.dispose.call(this);for(var i=this.children.length-1;i>=0;i--)this.children[i].dispose();null===(e=this._intermediateTexture)||void 0===e||e.dispose()},e.prototype._parseFromContent=function(e,i){if(t.prototype._parseFromContent.call(this,e,i),this._link(i),e.children)for(var o=0,n=e.children;o<n.length;o++){var r=n[o];this.addControl(g.Parse(r,i))}},a([(0,s.serialize)()],e.prototype,"renderToIntermediateTexture",null),a([(0,s.serialize)()],e.prototype,"maxLayoutCycle",void 0),a([(0,s.serialize)()],e.prototype,"adaptHeightToChildren",null),a([(0,s.serialize)()],e.prototype,"adaptWidthToChildren",null),a([(0,s.serialize)()],e.prototype,"background",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.Container",m);var b,v=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return r(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cornerRadius",{get:function(){return this._cornerRadius},set:function(t){t<0&&(t=0),this._cornerRadius!==t&&(this._cornerRadius=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Rectangle"},e.prototype._computeAdditionnalOffsetX=function(){return this._cornerRadius?1:0},e.prototype._computeAdditionnalOffsetY=function(){return this._cornerRadius?1:0},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._background&&(t.fillStyle="Button"===this.typeName?this.isEnabled?this._background:this.disabledColor:this._background,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.fill()):t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),this._thickness&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,this._cornerRadius?(this._drawRoundedRect(t,this._thickness/2),t.stroke()):t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._drawRoundedRect=function(t,e){void 0===e&&(e=0);var i=this._currentMeasure.left+e,o=this._currentMeasure.top+e,n=this._currentMeasure.width-2*e,r=this._currentMeasure.height-2*e,a=Math.min(r/2-2,Math.min(n/2-2,this._cornerRadius));t.beginPath(),t.moveTo(i+a,o),t.lineTo(i+n-a,o),t.quadraticCurveTo(i+n,o,i+n,o+a),t.lineTo(i+n,o+r-a),t.quadraticCurveTo(i+n,o+r,i+n-a,o+r),t.lineTo(i+a,o+r),t.quadraticCurveTo(i,o+r,i,o+r-a),t.lineTo(i,o+a),t.quadraticCurveTo(i,o,i+a,o),t.closePath()},e.prototype._clipForChildren=function(t){this._cornerRadius&&(this._drawRoundedRect(t,this._thickness),t.clip())},a([(0,s.serialize)()],e.prototype,"thickness",null),a([(0,s.serialize)()],e.prototype,"cornerRadius",null),e}(m);(0,s.RegisterClass)("BABYLON.GUI.Rectangle",v),function(t){t[t.Clip=0]="Clip",t[t.WordWrap=1]="WordWrap",t[t.Ellipsis=2]="Ellipsis",t[t.WordWrapEllipsis=3]="WordWrapEllipsis"}(b||(b={}));var y=function(t){function e(e,i){void 0===i&&(i="");var o=t.call(this,e)||this;return o.name=e,o._text="",o._textWrapping=b.Clip,o._textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,o._textVerticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,o._resizeToFit=!1,o._lineSpacing=new l(0),o._outlineWidth=0,o._outlineColor="white",o._underline=!1,o._lineThrough=!1,o.onTextChangedObservable=new s.Observable,o.onLinesReadyObservable=new s.Observable,o.text=i,o}return r(e,t),Object.defineProperty(e.prototype,"lines",{get:function(){return this._lines},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"resizeToFit",{get:function(){return this._resizeToFit},set:function(t){this._resizeToFit!==t&&(this._resizeToFit=t,this._resizeToFit&&(this._width.ignoreAdaptiveScaling=!0,this._height.ignoreAdaptiveScaling=!0),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(t){this._textWrapping!==t&&(this._textWrapping=+t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t+"",this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(t){this._textHorizontalAlignment!==t&&(this._textHorizontalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(t){this._textVerticalAlignment!==t&&(this._textVerticalAlignment=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineSpacing",{get:function(){return this._lineSpacing.toString(this._host)},set:function(t){this._lineSpacing.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineWidth",{get:function(){return this._outlineWidth},set:function(t){this._outlineWidth!==t&&(this._outlineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"underline",{get:function(){return this._underline},set:function(t){this._underline!==t&&(this._underline=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineThrough",{get:function(){return this._lineThrough},set:function(t){this._lineThrough!==t&&(this._lineThrough=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outlineColor",{get:function(){return this._outlineColor},set:function(t){this._outlineColor!==t&&(this._outlineColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"TextBlock"},e.prototype._processMeasures=function(e,i){this._fontOffset&&!this.isDirty||(this._fontOffset=g._GetFontOffset(i.font)),t.prototype._processMeasures.call(this,e,i),this._lines=this._breakLines(this._currentMeasure.width,this._currentMeasure.height,i),this.onLinesReadyObservable.notifyObservers(this);for(var o=0,n=0;n<this._lines.length;n++){var r=this._lines[n];r.width>o&&(o=r.width)}if(this._resizeToFit){if(this._textWrapping===b.Clip){var a=this._paddingLeftInPixels+this._paddingRightInPixels+o|0;a!==this._width.internalValue&&(this._width.updateInPlace(a,l.UNITMODE_PIXEL),this._rebuildLayout=!0)}var s=this._paddingTopInPixels+this._paddingBottomInPixels+this._fontOffset.height*this._lines.length|0;if(this._lines.length>0&&0!==this._lineSpacing.internalValue){var _;_=this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height),s+=(this._lines.length-1)*_}s!==this._height.internalValue&&(this._height.updateInPlace(s,l.UNITMODE_PIXEL),this._rebuildLayout=!0)}},e.prototype._drawText=function(t,e,i,o){var n=this._currentMeasure.width,r=0;switch(this._textHorizontalAlignment){case g.HORIZONTAL_ALIGNMENT_LEFT:r=0;break;case g.HORIZONTAL_ALIGNMENT_RIGHT:r=n-e;break;case g.HORIZONTAL_ALIGNMENT_CENTER:r=(n-e)/2}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(o.shadowColor=this.shadowColor,o.shadowBlur=this.shadowBlur,o.shadowOffsetX=this.shadowOffsetX,o.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&o.strokeText(t,this._currentMeasure.left+r,i),o.fillText(t,this._currentMeasure.left+r,i),this._underline&&(o.beginPath(),o.lineWidth=Math.round(.05*this.fontSizeInPixels),o.moveTo(this._currentMeasure.left+r,i+3),o.lineTo(this._currentMeasure.left+r+e,i+3),o.stroke(),o.closePath()),this._lineThrough&&(o.beginPath(),o.lineWidth=Math.round(.05*this.fontSizeInPixels),o.moveTo(this._currentMeasure.left+r,i-this.fontSizeInPixels/3),o.lineTo(this._currentMeasure.left+r+e,i-this.fontSizeInPixels/3),o.stroke(),o.closePath())},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._renderLines(t),t.restore()},e.prototype._applyStates=function(e){t.prototype._applyStates.call(this,e),this.outlineWidth&&(e.lineWidth=this.outlineWidth,e.strokeStyle=this.outlineColor,e.lineJoin="miter",e.miterLimit=2)},e.prototype._breakLines=function(t,e,i){var o=[],n=this.text.split("\n");if(this._textWrapping===b.Ellipsis)for(var r=0,a=n;r<a.length;r++){var s=a[r];o.push(this._parseLineEllipsis(s,t,i))}else if(this._textWrapping===b.WordWrap)for(var l=0,_=n;l<_.length;l++)s=_[l],o.push.apply(o,this._parseLineWordWrap(s,t,i));else if(this._textWrapping===b.WordWrapEllipsis)for(var h=0,c=n;h<c.length;h++)s=c[h],o.push.apply(o,this._parseLineWordWrapEllipsis(s,t,e,i));else for(var u=0,d=n;u<d.length;u++)s=d[u],o.push(this._parseLine(s,i));return o},e.prototype._parseLine=function(t,e){return void 0===t&&(t=""),{text:t,width:this._getTextMetricsWidth(e.measureText(t))}},e.prototype._getCharsToRemove=function(t,e,i){var o=t>e?t-e:0,n=t/i;return Math.max(Math.floor(o/n),1)},e.prototype._parseLineEllipsis=function(t,e,i){void 0===t&&(t="");var o=this._getTextMetricsWidth(i.measureText(t)),n=this._getCharsToRemove(o,e,t.length),r=Array.from&&Array.from(t);if(r)for(;r.length&&o>e;)r.splice(r.length-n,n),t="".concat(r.join(""),"…"),o=this._getTextMetricsWidth(i.measureText(t)),n=this._getCharsToRemove(o,e,t.length);else{for(;t.length>2&&o>e;)t=t.slice(0,-n),o=this._getTextMetricsWidth(i.measureText(t+"…")),n=this._getCharsToRemove(o,e,t.length);t+="…"}return{text:t,width:o}},e.prototype._getTextMetricsWidth=function(t){return void 0!==t.actualBoundingBoxLeft?Math.abs(t.actualBoundingBoxLeft)+Math.abs(t.actualBoundingBoxRight):t.width},e.prototype._parseLineWordWrap=function(t,e,i){void 0===t&&(t="");for(var o=[],n=this.wordSplittingFunction?this.wordSplittingFunction(t):t.split(" "),r=this._getTextMetricsWidth(i.measureText(t)),a=0;a<n.length;a++){var s=a>0?t+" "+n[a]:n[0],l=this._getTextMetricsWidth(i.measureText(s));l>e&&a>0?(o.push({text:t,width:r}),t=n[a],r=this._getTextMetricsWidth(i.measureText(t))):(r=l,t=s)}return o.push({text:t,width:r}),o},e.prototype._parseLineWordWrapEllipsis=function(t,e,i,o){void 0===t&&(t="");for(var n=this._parseLineWordWrap(t,e,o),r=1;r<=n.length;r++)if(this._computeHeightForLinesOf(r)>i&&r>1){var a=n[r-2],s=n[r-1];n[r-2]=this._parseLineEllipsis("".concat(a.text+s.text),e,o);for(var l=n.length-r+1,_=0;_<l;_++)n.pop();return n}return n},e.prototype._renderLines=function(t){var e=this._currentMeasure.height,i=0;switch(this._textVerticalAlignment){case g.VERTICAL_ALIGNMENT_TOP:i=this._fontOffset.ascent;break;case g.VERTICAL_ALIGNMENT_BOTTOM:i=e-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case g.VERTICAL_ALIGNMENT_CENTER:i=this._fontOffset.ascent+(e-this._fontOffset.height*this._lines.length)/2}i+=this._currentMeasure.top;for(var o=0;o<this._lines.length;o++){var n=this._lines[o];0!==o&&0!==this._lineSpacing.internalValue&&(this._lineSpacing.isPixel?i+=this._lineSpacing.getValue(this._host):i+=this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height)),this._drawText(n.text,n.width,i,t),i+=this._fontOffset.height}},e.prototype._computeHeightForLinesOf=function(t){var e=this._paddingTopInPixels+this._paddingBottomInPixels+this._fontOffset.height*t;return t>0&&0!==this._lineSpacing.internalValue&&(e+=(t-1)*(this._lineSpacing.isPixel?this._lineSpacing.getValue(this._host):this._lineSpacing.getValue(this._host)*this._height.getValueInPixel(this._host,this._cachedParentMeasure.height))),e},e.prototype.computeExpectedHeight=function(){var t;if(this.text&&this.widthInPixels){var e=null===(t=s.EngineStore.LastCreatedEngine)||void 0===t?void 0:t.createCanvas(0,0).getContext("2d");if(e){this._applyStates(e),this._fontOffset||(this._fontOffset=g._GetFontOffset(e.font));var i=this._lines?this._lines:this._breakLines(this.widthInPixels-this._paddingLeftInPixels-this._paddingRightInPixels,this.heightInPixels-this._paddingTopInPixels-this._paddingBottomInPixels,e);return this._computeHeightForLinesOf(i.length)}}return 0},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onTextChangedObservable.clear()},a([(0,s.serialize)()],e.prototype,"resizeToFit",null),a([(0,s.serialize)()],e.prototype,"textWrapping",null),a([(0,s.serialize)()],e.prototype,"text",null),a([(0,s.serialize)()],e.prototype,"textHorizontalAlignment",null),a([(0,s.serialize)()],e.prototype,"textVerticalAlignment",null),a([(0,s.serialize)()],e.prototype,"lineSpacing",null),a([(0,s.serialize)()],e.prototype,"outlineWidth",null),a([(0,s.serialize)()],e.prototype,"underline",null),a([(0,s.serialize)()],e.prototype,"lineThrough",null),a([(0,s.serialize)()],e.prototype,"outlineColor",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.TextBlock",y);var x=function(t){function e(i,o){void 0===o&&(o=null);var n=t.call(this,i)||this;return n.name=i,n._workingCanvas=null,n._loaded=!1,n._stretch=e.STRETCH_FILL,n._autoScale=!1,n._sourceLeft=0,n._sourceTop=0,n._sourceWidth=0,n._sourceHeight=0,n._svgAttributesComputationCompleted=!1,n._isSVG=!1,n._cellWidth=0,n._cellHeight=0,n._cellId=-1,n._populateNinePatchSlicesFromImage=!1,n._imageDataCache={data:null,key:""},n.onImageLoadedObservable=new s.Observable,n.onSVGAttributesComputedObservable=new s.Observable,n.source=o,n}return r(e,t),Object.defineProperty(e.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(t){this._detectPointerOnOpaqueOnly!==t&&(this._detectPointerOnOpaqueOnly=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(t){this._sliceLeft!==t&&(this._sliceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(t){this._sliceRight!==t&&(this._sliceRight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(t){this._sliceTop!==t&&(this._sliceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(t){this._sliceBottom!==t&&(this._sliceBottom=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(t){this._sourceLeft!==t&&(this._sourceLeft=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(t){this._sourceTop!==t&&(this._sourceTop=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(t){this._sourceWidth!==t&&(this._sourceWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(t){this._sourceHeight!==t&&(this._sourceHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageWidth",{get:function(){return this._imageWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageHeight",{get:function(){return this._imageHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(t){this._populateNinePatchSlicesFromImage!==t&&(this._populateNinePatchSlicesFromImage=t,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSVG",{get:function(){return this._isSVG},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"svgAttributesComputationCompleted",{get:function(){return this._svgAttributesComputationCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoScale",{get:function(){return this._autoScale},set:function(t){this._autoScale!==t&&(this._autoScale=t,t&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stretch",{get:function(){return this._stretch},set:function(t){this._stretch!==t&&(this._stretch=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._rotate90=function(t,i){var o,n;void 0===i&&(i=!1);var r=this._domImage.width,a=this._domImage.height,l=(null===(n=null===(o=this._host)||void 0===o?void 0:o.getScene())||void 0===n?void 0:n.getEngine())||s.EngineStore.LastCreatedEngine;if(!l)throw new Error("Invalid engine. Unable to create a canvas.");var _=l.createCanvas(a,r),h=_.getContext("2d");h.translate(_.width/2,_.height/2),h.rotate(t*Math.PI/2),h.drawImage(this._domImage,0,0,r,a,-r/2,-a/2,r,a);var c=_.toDataURL("image/jpg"),u=new e(this.name+"rotated",c);return i&&(u._stretch=this._stretch,u._autoScale=this._autoScale,u._cellId=this._cellId,u._cellWidth=t%1?this._cellHeight:this._cellWidth,u._cellHeight=t%1?this._cellWidth:this._cellHeight),this._handleRotationForSVGImage(this,u,t),this._imageDataCache.data=null,u},e.prototype._handleRotationForSVGImage=function(t,e,i){var o=this;t._isSVG&&(t._svgAttributesComputationCompleted?(this._rotate90SourceProperties(t,e,i),this._markAsDirty()):t.onSVGAttributesComputedObservable.addOnce((function(){o._rotate90SourceProperties(t,e,i),o._markAsDirty()})))},e.prototype._rotate90SourceProperties=function(t,e,i){var o,n,r=t.sourceLeft,a=t.sourceTop,s=t.domImage.width,l=t.domImage.height,_=r,h=a,c=t.sourceWidth,u=t.sourceHeight;if(0!=i){var d=i<0?-1:1;i%=4;for(var f=0;f<Math.abs(i);++f)_=-(a-l/2)*d+l/2,h=(r-s/2)*d+s/2,c=(o=[u,c])[0],u=o[1],i<0?h-=u:_-=c,r=_,a=h,s=(n=[l,s])[0],l=n[1]}e.sourceLeft=_,e.sourceTop=h,e.sourceWidth=c,e.sourceHeight=u},e.prototype._extractNinePatchSliceDataFromImage=function(){var t,e,i=this._domImage.width,o=this._domImage.height;if(!this._workingCanvas){var n=(null===(e=null===(t=this._host)||void 0===t?void 0:t.getScene())||void 0===e?void 0:e.getEngine())||s.EngineStore.LastCreatedEngine;if(!n)throw new Error("Invalid engine. Unable to create a canvas.");this._workingCanvas=n.createCanvas(i,o)}var r=this._workingCanvas.getContext("2d");r.drawImage(this._domImage,0,0,i,o);var a=r.getImageData(0,0,i,o);this._sliceLeft=-1,this._sliceRight=-1;for(var l=0;l<i;l++)if((h=a.data[4*l+3])>127&&-1===this._sliceLeft)this._sliceLeft=l;else if(h<127&&this._sliceLeft>-1){this._sliceRight=l;break}this._sliceTop=-1,this._sliceBottom=-1;for(var _=0;_<o;_++){var h;if((h=a.data[_*i*4+3])>127&&-1===this._sliceTop)this._sliceTop=_;else if(h<127&&this._sliceTop>-1){this._sliceBottom=_;break}}},Object.defineProperty(e.prototype,"domImage",{get:function(){return this._domImage},set:function(t){var e=this;this._domImage=t,this._loaded=!1,this._imageDataCache.data=null,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){e._onImageLoaded()}},enumerable:!1,configurable:!0}),e.prototype._onImageLoaded=function(){this._imageDataCache.data=null,this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._populateNinePatchSlicesFromImage&&this._extractNinePatchSliceDataFromImage(),this._autoScale&&this.synchronizeSizeWithContent(),this.onImageLoadedObservable.notifyObservers(this),this._markAsDirty()},Object.defineProperty(e.prototype,"source",{get:function(){return this._source},set:function(t){var e,i,o=this;if(this._source!==t){this._loaded=!1,this._source=t,this._imageDataCache.data=null,t&&(t=this._svgCheck(t));var n=(null===(i=null===(e=this._host)||void 0===e?void 0:e.getScene())||void 0===i?void 0:i.getEngine())||s.EngineStore.LastCreatedEngine;if(!n)throw new Error("Invalid engine. Unable to create a canvas.");this._domImage=n.createCanvasImage(),this._domImage.onload=function(){o._onImageLoaded()},t&&(s.Tools.SetCorsBehavior(t,this._domImage),this._domImage.src=t)}},enumerable:!1,configurable:!0}),e.prototype._svgCheck=function(t){var e=this;if(window.SVGSVGElement&&-1!==t.search(/.svg#/gi)&&t.indexOf("#")===t.lastIndexOf("#")){this._isSVG=!0;var i=t.split("#")[0],o=t.split("#")[1],n=document.body.querySelector('object[data="'+i+'"]');if(n){var r=n.contentDocument;if(r&&r.documentElement){var a=r.documentElement.getAttribute("viewBox"),s=Number(r.documentElement.getAttribute("width")),l=Number(r.documentElement.getAttribute("height"));if(r.getElementById(o)&&a&&s&&l)return this._getSVGAttribs(n,o),t}n.addEventListener("load",(function(){e._getSVGAttribs(n,o)}))}else{var _=document.createElement("object");_.data=i,_.type="image/svg+xml",_.width="0%",_.height="0%",document.body.appendChild(_),_.onload=function(){var t=document.body.querySelector('object[data="'+i+'"]');t&&e._getSVGAttribs(t,o)}}return i}return t},e.prototype._getSVGAttribs=function(t,e){var i=t.contentDocument;if(i&&i.documentElement){var o=i.documentElement.getAttribute("viewBox"),n=Number(i.documentElement.getAttribute("width")),r=Number(i.documentElement.getAttribute("height")),a=i.getElementById(e);if(o&&n&&r&&a){var s=Number(o.split(" ")[2]),l=Number(o.split(" ")[3]),_=a.getBBox(),h=1,c=1,u=0,d=0,f=a.transform.baseVal.consolidate().matrix;a.transform&&a.transform.baseVal.consolidate()&&(h=f.a,c=f.d,u=f.e,d=f.f),this.sourceLeft=(h*_.x+u)*n/s,this.sourceTop=(c*_.y+d)*r/l,this.sourceWidth=_.width*h*(n/s),this.sourceHeight=_.height*c*(r/l),this._svgAttributesComputationCompleted=!0,this.onSVGAttributesComputedObservable.notifyObservers(this)}}},Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth!==t&&(this._cellWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight!==t&&(this._cellHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellId",{get:function(){return this._cellId},set:function(t){this._cellId!==t&&(this._cellId=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.contains=function(e,i){if(!t.prototype.contains.call(this,e,i))return!1;if(!this._detectPointerOnOpaqueOnly||!this._workingCanvas)return!0;var o=0|this._currentMeasure.width,n=0|this._currentMeasure.height,r=o+"_"+n,a=this._imageDataCache.data;if(!a||this._imageDataCache.key!==r){var s=this._workingCanvas.getContext("2d");this._imageDataCache.data=a=s.getImageData(0,0,o,n).data,this._imageDataCache.key=r}return a[4*((e=e-this._currentMeasure.left|0)+(i=i-this._currentMeasure.top|0)*o)+3]>0},e.prototype._getTypeName=function(){return"Image"},e.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},e.prototype._processMeasures=function(i,o){if(this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:case e.STRETCH_UNIFORM:case e.STRETCH_NINE_PATCH:break;case e.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0)}t.prototype._processMeasures.call(this,i,o)},e.prototype._prepareWorkingCanvasForOpaqueDetection=function(){var t,e;if(this._detectPointerOnOpaqueOnly){var i=this._currentMeasure.width,o=this._currentMeasure.height;if(!this._workingCanvas){var n=(null===(e=null===(t=this._host)||void 0===t?void 0:t.getScene())||void 0===e?void 0:e.getEngine())||s.EngineStore.LastCreatedEngine;if(!n)throw new Error("Invalid engine. Unable to create a canvas.");this._workingCanvas=n.createCanvas(i,o)}this._workingCanvas.getContext("2d").clearRect(0,0,i,o)}},e.prototype._drawImage=function(t,e,i,o,n,r,a,s,l){t.drawImage(this._domImage,e,i,o,n,r,a,s,l),this._detectPointerOnOpaqueOnly&&(t=this._workingCanvas.getContext("2d")).drawImage(this._domImage,e,i,o,n,r-this._currentMeasure.left,a-this._currentMeasure.top,s,l)},e.prototype._draw=function(t){var i,o,n,r;if(t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),-1==this.cellId)i=this._sourceLeft,o=this._sourceTop,n=this._sourceWidth?this._sourceWidth:this._imageWidth,r=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var a=this._domImage.naturalWidth/this.cellWidth,s=this.cellId/a>>0,l=this.cellId%a;i=this.cellWidth*l,o=this.cellHeight*s,n=this.cellWidth,r=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(t),this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:this._drawImage(t,i,o,n,r,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_UNIFORM:var _=this._currentMeasure.width/n,h=this._currentMeasure.height/r,c=Math.min(_,h),u=(this._currentMeasure.width-n*c)/2,d=(this._currentMeasure.height-r*c)/2;this._drawImage(t,i,o,n,r,this._currentMeasure.left+u,this._currentMeasure.top+d,n*c,r*c);break;case e.STRETCH_EXTEND:this._drawImage(t,i,o,n,r,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_NINE_PATCH:this._renderNinePatch(t)}t.restore()},e.prototype._renderNinePatch=function(t){var e=this._sliceLeft,i=this._sliceTop,o=this._imageHeight-this._sliceBottom,n=this._imageWidth-this._sliceRight,r=this._sliceRight-this._sliceLeft,a=this._sliceBottom-this._sliceTop,s=this._currentMeasure.width-n-e+2,l=this._currentMeasure.height-o-i+2,_=this._currentMeasure.left+e-1,h=this._currentMeasure.top+i-1,c=this._currentMeasure.left+this._currentMeasure.width-n,u=this._currentMeasure.top+this._currentMeasure.height-o;this._drawImage(t,0,0,e,i,this._currentMeasure.left,this._currentMeasure.top,e,i),t.clearRect(_,this._currentMeasure.top,s,i),this._drawImage(t,this._sliceLeft,0,r,i,_,this._currentMeasure.top,s,i),t.clearRect(c,this._currentMeasure.top,n,i),this._drawImage(t,this._sliceRight,0,n,i,c,this._currentMeasure.top,n,i),t.clearRect(this._currentMeasure.left,h,e,l),this._drawImage(t,0,this._sliceTop,e,a,this._currentMeasure.left,h,e,l),t.clearRect(_,h,s,l),this._drawImage(t,this._sliceLeft,this._sliceTop,r,a,_,h,s,l),t.clearRect(c,h,n,l),this._drawImage(t,this._sliceRight,this._sliceTop,n,a,c,h,n,l),t.clearRect(this._currentMeasure.left,u,e,o),this._drawImage(t,0,this._sliceBottom,e,o,this._currentMeasure.left,u,e,o),t.clearRect(_,u,s,o),this._drawImage(t,this.sliceLeft,this._sliceBottom,r,o,_,u,s,o),t.clearRect(c,u,n,o),this._drawImage(t,this._sliceRight,this._sliceBottom,n,o,c,u,n,o)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onImageLoadedObservable.clear(),this.onSVGAttributesComputedObservable.clear()},e.STRETCH_NONE=0,e.STRETCH_FILL=1,e.STRETCH_UNIFORM=2,e.STRETCH_EXTEND=3,e.STRETCH_NINE_PATCH=4,a([(0,s.serialize)()],e.prototype,"detectPointerOnOpaqueOnly",null),a([(0,s.serialize)()],e.prototype,"sliceLeft",null),a([(0,s.serialize)()],e.prototype,"sliceRight",null),a([(0,s.serialize)()],e.prototype,"sliceTop",null),a([(0,s.serialize)()],e.prototype,"sliceBottom",null),a([(0,s.serialize)()],e.prototype,"sourceLeft",null),a([(0,s.serialize)()],e.prototype,"sourceTop",null),a([(0,s.serialize)()],e.prototype,"sourceWidth",null),a([(0,s.serialize)()],e.prototype,"sourceHeight",null),a([(0,s.serialize)()],e.prototype,"populateNinePatchSlicesFromImage",null),a([(0,s.serialize)()],e.prototype,"autoScale",null),a([(0,s.serialize)()],e.prototype,"stretch",null),a([(0,s.serialize)()],e.prototype,"source",null),a([(0,s.serialize)()],e.prototype,"cellWidth",null),a([(0,s.serialize)()],e.prototype,"cellHeight",null),a([(0,s.serialize)()],e.prototype,"cellId",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.Image",x);var P=function(t){function e(e){var i=t.call(this,e)||this;i.name=e,i.delegatePickingToChildren=!1,i.thickness=1,i.isPointerBlocker=!0;var o=null;return i.pointerEnterAnimation=function(){o=i.alpha,i.alpha-=.1},i.pointerOutAnimation=function(){null!==o&&(i.alpha=o)},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return r(e,t),Object.defineProperty(e.prototype,"image",{get:function(){return this._image},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textBlock",{get:function(){return this._textBlock},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Button"},e.prototype._processPicking=function(e,i,o,n,r,a,s,l){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable)return!1;if(!t.prototype.contains.call(this,e,i))return!1;if(this.delegatePickingToChildren){for(var _=!1,h=this._children.length-1;h>=0;h--){var c=this._children[h];if(c.isEnabled&&c.isHitTestVisible&&c.isVisible&&!c.notRenderable&&c.contains(e,i)){_=!0;break}}if(!_)return!1}return this._processObservables(n,e,i,o,r,a,s,l),!0},e.prototype._onPointerEnter=function(e,i){return!!t.prototype._onPointerEnter.call(this,e,i)&&(!this.isReadOnly&&this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},e.prototype._onPointerOut=function(e,i,o){void 0===o&&(o=!1),!this.isReadOnly&&this.pointerOutAnimation&&this.pointerOutAnimation(),t.prototype._onPointerOut.call(this,e,i,o)},e.prototype._onPointerDown=function(e,i,o,n,r){return!!t.prototype._onPointerDown.call(this,e,i,o,n,r)&&(!this.isReadOnly&&this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},e.prototype._onPointerUp=function(e,i,o,n,r,a){!this.isReadOnly&&this.pointerUpAnimation&&this.pointerUpAnimation(),t.prototype._onPointerUp.call(this,e,i,o,n,r,a)},e.prototype.serialize=function(e){t.prototype.serialize.call(this,e),this._textBlock&&(e.textBlockName=this._textBlock.name),this._image&&(e.imageName=this._image.name)},e.prototype._parseFromContent=function(e,i){t.prototype._parseFromContent.call(this,e,i),e.textBlockName&&(this._textBlock=this.getChildByName(e.textBlockName)),e.imageName&&(this._image=this.getChildByName(e.imageName))},e.CreateImageButton=function(t,e,i){var o=new this(t),n=new y(t+"_button",e);n.textWrapping=!0,n.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,n.paddingLeft="20%",o.addControl(n);var r=new x(t+"_icon",i);return r.width="20%",r.stretch=x.STRETCH_UNIFORM,r.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o.addControl(r),o._image=r,o._textBlock=n,o},e.CreateImageOnlyButton=function(t,e){var i=new this(t),o=new x(t+"_icon",e);return o.stretch=x.STRETCH_FILL,o.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,i.addControl(o),i._image=o,i},e.CreateSimpleButton=function(t,e){var i=new this(t),o=new y(t+"_button",e);return o.textWrapping=!0,o.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,i.addControl(o),i._textBlock=o,i},e.CreateImageWithCenterTextButton=function(t,e,i){var o=new this(t),n=new x(t+"_icon",i);n.stretch=x.STRETCH_FILL,o.addControl(n);var r=new y(t+"_button",e);return r.textWrapping=!0,r.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,o.addControl(r),o._image=n,o._textBlock=r,o},e}(v);(0,s.RegisterClass)("BABYLON.GUI.Button",P);var B=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isVertical=!0,i._manualWidth=!1,i._manualHeight=!1,i._doNotTrackManualChanges=!1,i._spacing=0,i.ignoreLayoutWarnings=!1,i}return r(e,t),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spacing",{get:function(){return this._spacing},set:function(t){this._spacing!==t&&(this._spacing=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==t&&this._width.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"StackPanel"},e.prototype._preMeasure=function(e,i){for(var o=0,n=this._children;o<n.length;o++){var r=n[o];this._isVertical?r.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP:r.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT}t.prototype._preMeasure.call(this,e,i)},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.copyFrom(e),this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this.isVertical&&!this._manualWidth||(this._measureForChildren.width=this._currentMeasure.width),(this.isVertical||this._manualHeight)&&(this._measureForChildren.height=this._currentMeasure.height)},e.prototype._postMeasure=function(){for(var e=0,i=0,o=this._children.length,n=0;n<o;n++){var r=this._children[n];r.isVisible&&!r.notRenderable&&(this._isVertical?(r.top!==i+"px"&&(r.top=i+"px",this._rebuildLayout=!0,r._top.ignoreAdaptiveScaling=!0),r._height.isPercentage&&!r._automaticSize?this.ignoreLayoutWarnings||s.Tools.Warn("Control (Name:".concat(r.name,", UniqueId:").concat(r.uniqueId,") is using height in percentage mode inside a vertical StackPanel")):i+=r._currentMeasure.height+r._paddingTopInPixels+r._paddingBottomInPixels+(n<o-1?this._spacing:0)):(r.left!==e+"px"&&(r.left=e+"px",this._rebuildLayout=!0,r._left.ignoreAdaptiveScaling=!0),r._width.isPercentage&&!r._automaticSize?this.ignoreLayoutWarnings||s.Tools.Warn("Control (Name:".concat(r.name,", UniqueId:").concat(r.uniqueId,") is using width in percentage mode inside a horizontal StackPanel")):e+=r._currentMeasure.width+r._paddingLeftInPixels+r._paddingRightInPixels+(n<o-1?this._spacing:0)))}e+=this._paddingLeftInPixels+this._paddingRightInPixels,i+=this._paddingTopInPixels+this._paddingBottomInPixels,this._doNotTrackManualChanges=!0;var a=!1,l=!1;if(!this._manualHeight&&this._isVertical){var _=this.height;this.height=i+"px",l=_!==this.height||!this._height.ignoreAdaptiveScaling}if(!this._manualWidth&&!this._isVertical){var h=this.width;this.width=e+"px",a=h!==this.width||!this._width.ignoreAdaptiveScaling}l&&(this._height.ignoreAdaptiveScaling=!0),a&&(this._width.ignoreAdaptiveScaling=!0),this._doNotTrackManualChanges=!1,(a||l)&&(this._rebuildLayout=!0),t.prototype._postMeasure.call(this)},e.prototype.serialize=function(e){t.prototype.serialize.call(this,e),e.manualWidth=this._manualWidth,e.manualHeight=this._manualHeight},e.prototype._parseFromContent=function(e,i){this._manualWidth=e.manualWidth,this._manualHeight=e.manualHeight,t.prototype._parseFromContent.call(this,e,i)},a([(0,s.serialize)()],e.prototype,"ignoreLayoutWarnings",void 0),a([(0,s.serialize)()],e.prototype,"isVertical",null),a([(0,s.serialize)()],e.prototype,"spacing",null),a([(0,s.serialize)()],e.prototype,"width",null),a([(0,s.serialize)()],e.prototype,"height",null),e}(m);(0,s.RegisterClass)("BABYLON.GUI.StackPanel",B);var C=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.onIsCheckedChangedObservable=new s.Observable,i.isPointerBlocker=!0,i}return r(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){return this._isChecked},set:function(t){this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Checkbox"},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=this._currentMeasure.width-this._thickness,i=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fillRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,e,i),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._isChecked){t.fillStyle=this._isEnabled?this.color:this._disabledColorItem;var o=e*this._checkSizeRatio,n=i*this._checkSizeRatio;t.fillRect(this._currentMeasure.left+this._thickness/2+(e-o)/2,this._currentMeasure.top+this._thickness/2+(i-n)/2,o,n)}t.strokeStyle=this.color,t.lineWidth=this._thickness,t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,e,i),t.restore()},e.prototype._onPointerDown=function(e,i,o,n,r){return!!t.prototype._onPointerDown.call(this,e,i,o,n,r)&&(this.isReadOnly||(this.isChecked=!this.isChecked),!0)},e.AddCheckBoxWithHeader=function(t,i){var o=new B;o.isVertical=!1,o.height="30px";var n=new e;n.width="20px",n.height="20px",n.isChecked=!0,n.color="green",n.onIsCheckedChangedObservable.add(i),o.addControl(n);var r=new y;return r.text=t,r.width="180px",r.paddingLeft="5px",r.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,r.color="white",o.addControl(r),o},a([(0,s.serialize)()],e.prototype,"thickness",null),a([(0,s.serialize)()],e.prototype,"checkSizeRatio",null),a([(0,s.serialize)()],e.prototype,"background",null),a([(0,s.serialize)()],e.prototype,"isChecked",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.Checkbox",C);var T=function(){function t(){}return Object.defineProperty(t.prototype,"text",{get:function(){return this._characters?this._characters.join(""):this._text},set:function(t){this._text=t,this._characters=Array.from&&Array.from(t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._characters?this._characters.length:this._text.length},enumerable:!1,configurable:!0}),t.prototype.removePart=function(t,e,i){var o;if(this._text=this._text.slice(0,t)+(i||"")+this._text.slice(e),this._characters){var n=i?Array.from(i):[];(o=this._characters).splice.apply(o,function(t,e,i){if(i||2===arguments.length)for(var o,n=0,r=e.length;n<r;n++)!o&&n in e||(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return t.concat(o||Array.prototype.slice.call(e))}([t,e-t],n,!1))}},t.prototype.charAt=function(t){return this._characters?this._characters[t]:this._text.charAt(t)},t.prototype.substr=function(t,e){if(this._characters){t=isNaN(t)?0:t>=0?Math.min(t,this._characters.length):this._characters.length+Math.max(t,-this._characters.length),void 0===e?e=this._characters.length-t:(isNaN(e)||e<0)&&(e=0);for(var i=[];--e>=0;)i[e]=this._characters[t+e];return i.join("")}return this._text.substr(t,e)},t.prototype.substring=function(t,e){if(this._characters){isNaN(t)?t=0:t>this._characters.length?t=this._characters.length:t<0&&(t=0),void 0===e?e=this._characters.length:isNaN(e)?e=0:e>this._characters.length?e=this._characters.length:e<0&&(e=0);for(var i=[],o=0;t<e;)i[o++]=this._characters[t++];return i.join("")}return this._text.substring(t,e)},t.prototype.isWord=function(t){var e=/\w/g;return this._characters?-1!==this._characters[t].search(e):-1!==this._text.search(e)},t}(),O=function(t){function e(e,i){void 0===i&&(i="");var o=t.call(this,e)||this;return o.name=e,o._placeholderText="",o._background="#222222",o._focusedBackground="#000000",o._focusedColor="white",o._placeholderColor="gray",o._thickness=1,o._margin=new l(10,l.UNITMODE_PIXEL),o._autoStretchWidth=!0,o._maxWidth=new l(1,l.UNITMODE_PERCENTAGE,!1),o._isFocused=!1,o._blinkIsEven=!1,o._cursorOffset=0,o._deadKey=!1,o._addKey=!0,o._currentKey="",o._isTextHighlightOn=!1,o._textHighlightColor="#d5e0ff",o._highligherOpacity=.4,o._highlightedText="",o._startHighlightIndex=0,o._endHighlightIndex=0,o._cursorIndex=-1,o._onFocusSelectAll=!1,o._isPointerDown=!1,o.promptMessage="Please enter text:",o.disableMobilePrompt=!1,o.onTextChangedObservable=new s.Observable,o.onBeforeKeyAddObservable=new s.Observable,o.onFocusObservable=new s.Observable,o.onBlurObservable=new s.Observable,o.onTextHighlightObservable=new s.Observable,o.onTextCopyObservable=new s.Observable,o.onTextCutObservable=new s.Observable,o.onTextPasteObservable=new s.Observable,o.onKeyboardEventProcessedObservable=new s.Observable,o.text=i,o.isPointerBlocker=!0,o}return r(e,t),Object.defineProperty(e.prototype,"maxWidth",{get:function(){return this._maxWidth.toString(this._host)},set:function(t){this._maxWidth.toString(this._host)!==t&&this._maxWidth.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxWidthInPixels",{get:function(){return this._maxWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highligherOpacity",{get:function(){return this._highligherOpacity},set:function(t){this._highligherOpacity!==t&&(this._highligherOpacity=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onFocusSelectAll",{get:function(){return this._onFocusSelectAll},set:function(t){this._onFocusSelectAll!==t&&(this._onFocusSelectAll=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textHighlightColor",{get:function(){return this._textHighlightColor},set:function(t){this._textHighlightColor!==t&&(this._textHighlightColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"margin",{get:function(){return this._margin.toString(this._host)},set:function(t){this._margin.toString(this._host)!==t&&this._margin.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"marginInPixels",{get:function(){return this._margin.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(t){this._autoStretchWidth!==t&&(this._autoStretchWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"focusedBackground",{get:function(){return this._focusedBackground},set:function(t){this._focusedBackground!==t&&(this._focusedBackground=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"focusedColor",{get:function(){return this._focusedColor},set:function(t){this._focusedColor!==t&&(this._focusedColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"placeholderColor",{get:function(){return this._placeholderColor},set:function(t){this._placeholderColor!==t&&(this._placeholderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"placeholderText",{get:function(){return this._placeholderText},set:function(t){this._placeholderText!==t&&(this._placeholderText=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"deadKey",{get:function(){return this._deadKey},set:function(t){this._deadKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightedText",{get:function(){return this._highlightedText},set:function(t){this._highlightedText!==t&&(this._highlightedText=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"addKey",{get:function(){return this._addKey},set:function(t){this._addKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentKey",{get:function(){return this._currentKey},set:function(t){this._currentKey=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._textWrapper.text},set:function(t){var e=t.toString();this._textWrapper||(this._textWrapper=new T),this._textWrapper.text!==e&&(this._textWrapper.text=e,this._textHasChanged())},enumerable:!1,configurable:!0}),e.prototype._textHasChanged=function(){this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this)},Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._width.toString(this._host)!==t&&(this._width.fromString(t)&&this._markAsDirty(),this.autoStretchWidth=!1)},enumerable:!1,configurable:!0}),e.prototype.onBlur=function(){this._isFocused=!1,this._scrollLeft=null,this._cursorOffset=0,clearTimeout(this._blinkTimeout),this._markAsDirty(),this.onBlurObservable.notifyObservers(this),this._host.unRegisterClipboardEvents(),this._onClipboardObserver&&this._host.onClipboardObservable.remove(this._onClipboardObserver);var t=this._host.getScene();this._onPointerDblTapObserver&&t&&t.onPointerObservable.remove(this._onPointerDblTapObserver)},e.prototype.onFocus=function(){var t=this;if(this._isEnabled){if(this._scrollLeft=null,this._isFocused=!0,this._blinkIsEven=!1,this._cursorOffset=0,this._markAsDirty(),this.onFocusObservable.notifyObservers(this),"touch"===this._focusedBy&&!this.disableMobilePrompt){var e=prompt(this.promptMessage);return null!==e&&(this.text=e),void(this._host.focusedControl=null)}this._host.registerClipboardEvents(),this._onClipboardObserver=this._host.onClipboardObservable.add((function(e){switch(e.type){case s.ClipboardEventTypes.COPY:t._onCopyText(e.event),t.onTextCopyObservable.notifyObservers(t);break;case s.ClipboardEventTypes.CUT:t._onCutText(e.event),t.onTextCutObservable.notifyObservers(t);break;case s.ClipboardEventTypes.PASTE:t._onPasteText(e.event),t.onTextPasteObservable.notifyObservers(t);break;default:return}}));var i=this._host.getScene();i&&(this._onPointerDblTapObserver=i.onPointerObservable.add((function(e){t._isFocused&&e.type===s.PointerEventTypes.POINTERDOUBLETAP&&t._processDblClick(e)}))),this._onFocusSelectAll&&this._selectAllText()}},e.prototype.focus=function(){this._host.moveFocusToControl(this)},e.prototype.blur=function(){this._host.focusedControl=null},e.prototype._getTypeName=function(){return"InputText"},e.prototype.keepsFocusWith=function(){return this._connectedVirtualKeyboard?[this._connectedVirtualKeyboard]:null},e.prototype.processKey=function(t,e,i){if(!this.isReadOnly&&(!i||!i.ctrlKey&&!i.metaKey||67!==t&&86!==t&&88!==t)){if(i&&(i.ctrlKey||i.metaKey)&&65===t)return this._selectAllText(),void i.preventDefault();switch(t){case 32:e=" ";break;case 191:i&&i.preventDefault();break;case 8:if(this._textWrapper.text&&this._textWrapper.length>0){if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._blinkIsEven=!1,void(i&&i.preventDefault());0===this._cursorOffset?this.text=this._textWrapper.substr(0,this._textWrapper.length-1):(o=this._textWrapper.length-this._cursorOffset)>0&&(this._textWrapper.removePart(o-1,o),this._textHasChanged())}return void(i&&i.preventDefault());case 46:if(this._isTextHighlightOn)return this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,void(i&&i.preventDefault());if(this._textWrapper.text&&this._textWrapper.length>0&&this._cursorOffset>0){var o=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(o,o+1),this._textHasChanged(),this._cursorOffset--}return void(i&&i.preventDefault());case 13:return this._host.focusedControl=null,void(this._isTextHighlightOn=!1);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._textWrapper.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 37:if(this._cursorOffset++,this._cursorOffset>this._textWrapper.length&&(this._cursorOffset=this._textWrapper.length),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(this._textWrapper.length===this._cursorOffset)return;this._endHighlightIndex=this._textWrapper.length-this._cursorOffset+1}return this._startHighlightIndex=0,this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=this._textWrapper.length,this._isTextHighlightOn=!0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._endHighlightIndex,this._cursorOffset=0===this._startHighlightIndex?this._textWrapper.length:this._textWrapper.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._textWrapper.length?this._textWrapper.length:this._cursorOffset-1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=this._textWrapper.length,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),i&&i.shiftKey){if(this._blinkIsEven=!1,i.ctrlKey||i.metaKey){if(!this._isTextHighlightOn){if(0===this._cursorOffset)return;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset-1}return this._endHighlightIndex=this._textWrapper.length,this._isTextHighlightOn=!0,this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._textWrapper.length-this._startHighlightIndex,this._cursorOffset=this._textWrapper.length===this._endHighlightIndex?0:this._textWrapper.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndex<this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset):this._cursorIndex>this._cursorOffset?(this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._textWrapper.length-this._endHighlightIndex,this._isTextHighlightOn=!1),i&&(i.ctrlKey||i.metaKey)&&(this._cursorOffset=0,i.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 222:i?"Quote"==i.code?i.shiftKey?(t=34,e='"'):(t=39,e="'"):(i.preventDefault(),this._cursorIndex=-1,this.deadKey=!0):(this._cursorIndex=-1,this.deadKey=!0)}if(e&&(-1===t||32===t||34===t||39===t||t>47&&t<64||t>64&&t<91||t>159&&t<193||t>218&&t<223||t>95&&t<112)&&(this._currentKey=e,this.onBeforeKeyAddObservable.notifyObservers(this),e=this._currentKey,this._addKey))if(this._isTextHighlightOn)this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex,e),this._textHasChanged(),this._cursorOffset=this._textWrapper.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(0===this._cursorOffset)this.text+=e;else{var n=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(n,n,e),this._textHasChanged()}}},e.prototype._updateValueFromCursorIndex=function(t){if(this._blinkIsEven=!1,-1===this._cursorIndex)this._cursorIndex=t;else if(this._cursorIndex<this._cursorOffset)this._endHighlightIndex=this._textWrapper.length-this._cursorIndex,this._startHighlightIndex=this._textWrapper.length-this._cursorOffset;else{if(!(this._cursorIndex>this._cursorOffset))return this._isTextHighlightOn=!1,void this._markAsDirty();this._endHighlightIndex=this._textWrapper.length-this._cursorOffset,this._startHighlightIndex=this._textWrapper.length-this._cursorIndex}this._isTextHighlightOn=!0,this._markAsDirty()},e.prototype._processDblClick=function(t){var e,i;this._startHighlightIndex=this._textWrapper.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;do{i=this._endHighlightIndex<this._textWrapper.length&&this._textWrapper.isWord(this._endHighlightIndex)?++this._endHighlightIndex:0,e=this._startHighlightIndex>0&&this._textWrapper.isWord(this._startHighlightIndex-1)?--this._startHighlightIndex:0}while(e||i);this._cursorOffset=this._textWrapper.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},e.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._textWrapper.length,this._cursorOffset=this._textWrapper.length,this._cursorIndex=-1,this._markAsDirty()},e.prototype.processKeyboard=function(t){this.processKey(t.keyCode,t.key,t),this.onKeyboardEventProcessedObservable.notifyObservers(t)},e.prototype._onCopyText=function(t){this._isTextHighlightOn=!1;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText},e.prototype._onCutText=function(t){if(this._highlightedText){this._textWrapper.removePart(this._startHighlightIndex,this._endHighlightIndex),this._textHasChanged(),this._isTextHighlightOn=!1,this._cursorOffset=this._textWrapper.length-this._startHighlightIndex;try{t.clipboardData&&t.clipboardData.setData("text/plain",this._highlightedText)}catch(t){}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},e.prototype._onPasteText=function(t){var e;e=t.clipboardData&&-1!==t.clipboardData.types.indexOf("text/plain")?t.clipboardData.getData("text/plain"):this._host.clipboardData;var i=this._textWrapper.length-this._cursorOffset;this._textWrapper.removePart(i,i,e),this._textHasChanged()},e.prototype._draw=function(t){var e=this;t.save(),this._applyStates(t),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(t.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._fontOffset&&!this._wasDirty||(this._fontOffset=g._GetFontOffset(t.font));var i=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(t.fillStyle=this.color);var o=this._beforeRenderText(this._textWrapper);this._isFocused||this._textWrapper.text||!this._placeholderText||((o=new T).text=this._placeholderText,this._placeholderColor&&(t.fillStyle=this._placeholderColor)),this._textWidth=t.measureText(o.text).width;var n=2*this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+n)+"px",this._autoStretchWidth=!0);var r=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,a=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-n;if(t.save(),t.beginPath(),t.rect(i,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,a+2,this._currentMeasure.height),t.clip(),this._isFocused&&this._textWidth>a){var s=i-this._textWidth+a;this._scrollLeft||(this._scrollLeft=s)}else this._scrollLeft=i;if(t.fillText(o.text,this._scrollLeft,this._currentMeasure.top+r),this._isFocused){if(this._clickedCoordinate){var l=this._scrollLeft+this._textWidth-this._clickedCoordinate,_=0;this._cursorOffset=0;var h=0;do{this._cursorOffset&&(h=Math.abs(l-_)),this._cursorOffset++,_=t.measureText(o.substr(o.length-this._cursorOffset,this._cursorOffset)).width}while(_<l&&o.length>=this._cursorOffset);Math.abs(l-_)>h&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var c=o.substr(o.length-this._cursorOffset),u=t.measureText(c).width,d=this._scrollLeft+this._textWidth-u;d<i?(this._scrollLeft+=i-d,d=i,this._markAsDirty()):d>i+a&&(this._scrollLeft+=i+a-d,d=i+a,this._markAsDirty()),this._isTextHighlightOn||t.fillRect(d,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){e._blinkIsEven=!e._blinkIsEven,e._markAsDirty()}),500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var f=t.measureText(o.substring(this._startHighlightIndex)).width,p=this._scrollLeft+this._textWidth-f;this._highlightedText=o.substring(this._startHighlightIndex,this._endHighlightIndex);var m=t.measureText(o.substring(this._startHighlightIndex,this._endHighlightIndex)).width;p<i&&((m-=i-p)||(m=t.measureText(o.charAt(o.length-this._cursorOffset)).width),p=i),t.globalAlpha=this._highligherOpacity,t.fillStyle=this._textHighlightColor,t.fillRect(p,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,m,this._fontOffset.height),t.globalAlpha=1}}t.restore(),this._thickness&&(this._isFocused?this.focusedColor&&(t.strokeStyle=this.focusedColor):this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,t.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness)),t.restore()},e.prototype._onPointerDown=function(e,i,o,n,r){return!(!t.prototype._onPointerDown.call(this,e,i,o,n,r)||!this.isReadOnly&&(this._clickedCoordinate=i.x,this._isTextHighlightOn=!1,this._highlightedText="",this._cursorIndex=-1,this._isPointerDown=!0,this._host._capturingControl[o]=this,this._focusedBy=r.event.pointerType,this._host.focusedControl===this?(clearTimeout(this._blinkTimeout),this._markAsDirty(),0):!this._isEnabled||(this._host.focusedControl=this,0)))},e.prototype._onPointerMove=function(e,i,o,n){this._host.focusedControl===this&&this._isPointerDown&&!this.isReadOnly&&(this._clickedCoordinate=i.x,this._markAsDirty(),this._updateValueFromCursorIndex(this._cursorOffset)),t.prototype._onPointerMove.call(this,e,i,o,n)},e.prototype._onPointerUp=function(e,i,o,n,r){this._isPointerDown=!1,delete this._host._capturingControl[o],t.prototype._onPointerUp.call(this,e,i,o,n,r)},e.prototype._beforeRenderText=function(t){return t},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onTextChangedObservable.clear(),this.onTextCopyObservable.clear(),this.onTextCutObservable.clear(),this.onTextPasteObservable.clear(),this.onTextHighlightObservable.clear(),this.onKeyboardEventProcessedObservable.clear()},a([(0,s.serialize)()],e.prototype,"promptMessage",void 0),a([(0,s.serialize)()],e.prototype,"disableMobilePrompt",void 0),a([(0,s.serialize)()],e.prototype,"maxWidth",null),a([(0,s.serialize)()],e.prototype,"highligherOpacity",null),a([(0,s.serialize)()],e.prototype,"onFocusSelectAll",null),a([(0,s.serialize)()],e.prototype,"textHighlightColor",null),a([(0,s.serialize)()],e.prototype,"margin",null),a([(0,s.serialize)()],e.prototype,"autoStretchWidth",null),a([(0,s.serialize)()],e.prototype,"thickness",null),a([(0,s.serialize)()],e.prototype,"focusedBackground",null),a([(0,s.serialize)()],e.prototype,"focusedColor",null),a([(0,s.serialize)()],e.prototype,"background",null),a([(0,s.serialize)()],e.prototype,"placeholderColor",null),a([(0,s.serialize)()],e.prototype,"placeholderText",null),a([(0,s.serialize)()],e.prototype,"deadKey",null),a([(0,s.serialize)()],e.prototype,"text",null),a([(0,s.serialize)()],e.prototype,"width",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.InputText",O);var I=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._rowDefinitions=new Array,i._rowDefinitionObservers=[],i._columnDefinitions=new Array,i._columnDefinitionObservers=[],i._cells={},i._childControls=new Array,i}return r(e,t),Object.defineProperty(e.prototype,"columnCount",{get:function(){return this._columnDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rowCount",{get:function(){return this._rowDefinitions.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._childControls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cells",{get:function(){return this._cells},enumerable:!1,configurable:!0}),e.prototype.getRowDefinition=function(t){return t<0||t>=this._rowDefinitions.length?null:this._rowDefinitions[t]},e.prototype.getColumnDefinition=function(t){return t<0||t>=this._columnDefinitions.length?null:this._columnDefinitions[t]},e.prototype.addRowDefinition=function(t,e){var i=this;return void 0===e&&(e=!1),this._rowDefinitions.push(new l(t,e?l.UNITMODE_PIXEL:l.UNITMODE_PERCENTAGE)),this._rowDefinitionObservers.push(this._rowDefinitions[this.rowCount-1].onChangedObservable.add((function(){return i._markAsDirty()}))),this._markAsDirty(),this},e.prototype.addColumnDefinition=function(t,e){var i=this;return void 0===e&&(e=!1),this._columnDefinitions.push(new l(t,e?l.UNITMODE_PIXEL:l.UNITMODE_PERCENTAGE)),this._columnDefinitionObservers.push(this._columnDefinitions[this.columnCount-1].onChangedObservable.add((function(){return i._markAsDirty()}))),this._markAsDirty(),this},e.prototype.setRowDefinition=function(t,e,i){var o=this;if(void 0===i&&(i=!1),t<0||t>=this._rowDefinitions.length)return this;var n=this._rowDefinitions[t];return n&&n.isPixel===i&&n.value===e||(this._rowDefinitions[t].onChangedObservable.remove(this._rowDefinitionObservers[t]),this._rowDefinitions[t]=new l(e,i?l.UNITMODE_PIXEL:l.UNITMODE_PERCENTAGE),this._rowDefinitionObservers[t]=this._rowDefinitions[t].onChangedObservable.add((function(){return o._markAsDirty()})),this._markAsDirty()),this},e.prototype.setColumnDefinition=function(t,e,i){var o=this;if(void 0===i&&(i=!1),t<0||t>=this._columnDefinitions.length)return this;var n=this._columnDefinitions[t];return n&&n.isPixel===i&&n.value===e||(this._columnDefinitions[t].onChangedObservable.remove(this._columnDefinitionObservers[t]),this._columnDefinitions[t]=new l(e,i?l.UNITMODE_PIXEL:l.UNITMODE_PERCENTAGE),this._columnDefinitionObservers[t]=this._columnDefinitions[t].onChangedObservable.add((function(){return o._markAsDirty()})),this._markAsDirty()),this},e.prototype.getChildrenAt=function(t,e){var i=this._cells["".concat(t,":").concat(e)];return i?i.children:null},e.prototype.getChildCellInfo=function(t){return t._tag},e.prototype._removeCell=function(e,i){if(e){t.prototype.removeControl.call(this,e);for(var o=0,n=e.children;o<n.length;o++){var r=n[o],a=this._childControls.indexOf(r);-1!==a&&this._childControls.splice(a,1)}delete this._cells[i]}},e.prototype._offsetCell=function(t,e){if(this._cells[e]){this._cells[t]=this._cells[e];for(var i=0,o=this._cells[t].children;i<o.length;i++)o[i]._tag=t;delete this._cells[e]}},e.prototype.removeColumnDefinition=function(t){if(t<0||t>=this._columnDefinitions.length)return this;for(var e=0;e<this._rowDefinitions.length;e++){var i="".concat(e,":").concat(t),o=this._cells[i];this._removeCell(o,i)}for(e=0;e<this._rowDefinitions.length;e++)for(var n=t+1;n<this._columnDefinitions.length;n++){var r="".concat(e,":").concat(n-1);i="".concat(e,":").concat(n),this._offsetCell(r,i)}return this._columnDefinitions[t].onChangedObservable.remove(this._columnDefinitionObservers[t]),this._columnDefinitions.splice(t,1),this._columnDefinitionObservers.splice(t,1),this._markAsDirty(),this},e.prototype.removeRowDefinition=function(t){if(t<0||t>=this._rowDefinitions.length)return this;for(var e=0;e<this._columnDefinitions.length;e++){var i="".concat(t,":").concat(e),o=this._cells[i];this._removeCell(o,i)}for(e=0;e<this._columnDefinitions.length;e++)for(var n=t+1;n<this._rowDefinitions.length;n++){var r="".concat(n-1,":").concat(e);i="".concat(n,":").concat(e),this._offsetCell(r,i)}return this._rowDefinitions[t].onChangedObservable.remove(this._rowDefinitionObservers[t]),this._rowDefinitions.splice(t,1),this._rowDefinitionObservers.splice(t,1),this._markAsDirty(),this},e.prototype.addControl=function(e,i,o){if(void 0===i&&(i=0),void 0===o&&(o=0),0===this._rowDefinitions.length&&this.addRowDefinition(1,!1),0===this._columnDefinitions.length&&this.addColumnDefinition(1,!1),-1!==this._childControls.indexOf(e))return s.Tools.Warn("Control (Name:".concat(e.name,", UniqueId:").concat(e.uniqueId,") is already associated with this grid. You must remove it before reattaching it")),this;var n=Math.min(i,this._rowDefinitions.length-1),r=Math.min(o,this._columnDefinitions.length-1),a="".concat(n,":").concat(r),l=this._cells[a];return l||(l=new m(a),this._cells[a]=l,l.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,l.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,t.prototype.addControl.call(this,l)),l.addControl(e),this._childControls.push(e),e._tag=a,e.parent=this,this._markAsDirty(),this},e.prototype.removeControl=function(t){var e=this._childControls.indexOf(t);-1!==e&&this._childControls.splice(e,1);var i=this._cells[t._tag];return i&&(i.removeControl(t),t._tag=null),this._markAsDirty(),this},e.prototype._getTypeName=function(){return"Grid"},e.prototype._getGridDefinitions=function(t){for(var e=[],i=[],o=[],n=[],r=this._currentMeasure.width,a=0,s=this._currentMeasure.height,l=0,_=0,h=0,c=this._rowDefinitions;h<c.length;h++)(g=c[h]).isPixel?(s-=p=g.getValue(this._host),i[_]=p):l+=g.value,_++;var u=0;_=0;for(var d=0,f=this._rowDefinitions;d<f.length;d++){var p,g=f[d];n.push(u),g.isPixel?u+=g.getValue(this._host):(u+=p=g.value/l*s,i[_]=p),_++}_=0;for(var m=0,b=this._columnDefinitions;m<b.length;m++)(B=b[m]).isPixel?(r-=P=B.getValue(this._host),e[_]=P):a+=B.value,_++;var v=0;_=0;for(var y=0,x=this._columnDefinitions;y<x.length;y++){var P,B=x[y];o.push(v),B.isPixel?v+=B.getValue(this._host):(v+=P=B.value/a*r,e[_]=P),_++}t(o,n,e,i)},e.prototype._additionalProcessing=function(e,i){var o=this;this._getGridDefinitions((function(t,e,i,n){for(var r in o._cells)if(Object.prototype.hasOwnProperty.call(o._cells,r)){var a=r.split(":"),s=parseInt(a[0]),l=parseInt(a[1]),_=o._cells[r];_.left=t[l]+"px",_.top=e[s]+"px",_.width=i[l]+"px",_.height=n[s]+"px",_._left.ignoreAdaptiveScaling=!0,_._top.ignoreAdaptiveScaling=!0,_._width.ignoreAdaptiveScaling=!0,_._height.ignoreAdaptiveScaling=!0}})),t.prototype._additionalProcessing.call(this,e,i)},e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t in this._cells)Object.prototype.hasOwnProperty.call(this._cells,t)&&this._cells[t]._markMatrixAsDirty()},e.prototype._renderHighlightSpecific=function(e){var i=this;t.prototype._renderHighlightSpecific.call(this,e),this._getGridDefinitions((function(t,o,n,r){for(var a=0;a<t.length;a++){var s=i._currentMeasure.left+t[a]+n[a];e.beginPath(),e.moveTo(s,i._currentMeasure.top),e.lineTo(s,i._currentMeasure.top+i._currentMeasure.height),e.stroke()}for(a=0;a<o.length;a++){var l=i._currentMeasure.top+o[a]+r[a];e.beginPath(),e.moveTo(i._currentMeasure.left,l),e.lineTo(i._currentMeasure.left+i._currentMeasure.width,l),e.stroke()}})),e.restore()},e.prototype.dispose=function(){t.prototype.dispose.call(this);for(var e=0,i=this._childControls;e<i.length;e++)i[e].dispose();for(var o=0;o<this._rowDefinitions.length;o++)this._rowDefinitions[o].onChangedObservable.remove(this._rowDefinitionObservers[o]);for(o=0;o<this._columnDefinitions.length;o++)this._columnDefinitions[o].onChangedObservable.remove(this._columnDefinitionObservers[o]);this._rowDefinitionObservers=[],this._rowDefinitions=[],this._columnDefinitionObservers=[],this._columnDefinitions=[],this._cells={},this._childControls=[]},e.prototype.serialize=function(e){t.prototype.serialize.call(this,e),e.columnCount=this.columnCount,e.rowCount=this.rowCount,e.columns=[],e.rows=[],e.tags=[];for(var i=0;i<this.columnCount;++i){var o=this.getColumnDefinition(i),n={value:null==o?void 0:o.getValue(this.host),unit:null==o?void 0:o.unit};e.columns.push(n)}for(i=0;i<this.rowCount;++i){var r=this.getRowDefinition(i);n={value:null==r?void 0:r.getValue(this.host),unit:null==r?void 0:r.unit},e.rows.push(n)}this.children.forEach((function(t){e.tags.push(t._tag)}))},e.prototype._parseFromContent=function(e,i){t.prototype._parseFromContent.call(this,e,i);var o=[];this.children.forEach((function(t){o.push(t)})),this.removeRowDefinition(0),this.removeColumnDefinition(0);for(var n=0;n<e.columnCount;++n){var r=e.columns[n].value,a=e.columns[n].unit;this.addColumnDefinition(r,1===a)}for(n=0;n<e.rowCount;++n){var s=e.rows[n].value;a=e.rows[n].unit,this.addRowDefinition(s,1===a)}for(n=0;n<o.length;++n){var l=e.tags[n],_=parseInt(l.substring(0,l.search(":")));isNaN(_)&&(_=0);var h=parseInt(l.substring(l.search(":")+1));isNaN(h)&&(h=0),this.addControl(o[n],_,h)}},e}(m);(0,s.RegisterClass)("BABYLON.GUI.Grid",I);var R=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._value=s.Color3.Red(),i._tmpColor=new s.Color3,i._pointerStartedOnSquare=!1,i._pointerStartedOnWheel=!1,i._squareLeft=0,i._squareTop=0,i._squareSize=0,i._h=360,i._s=1,i._v=1,i._lastPointerDownId=-1,i.onValueChangedObservable=new s.Observable,i._pointerIsDown=!1,i.value=new s.Color3(.88,.1,.1),i.size="200px",i.isPointerBlocker=!0,i}return r(e,t),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){this._value.equals(t)||(this._value.copyFrom(t),this._value.toHSVToRef(this._tmpColor),this._h=this._tmpColor.r,this._s=Math.max(this._tmpColor.g,1e-5),this._v=Math.max(this._tmpColor.b,1e-5),this._markAsDirty(),this._value.r<=e._Epsilon&&(this._value.r=0),this._value.g<=e._Epsilon&&(this._value.g=0),this._value.b<=e._Epsilon&&(this._value.b=0),this._value.r>=1-e._Epsilon&&(this._value.r=1),this._value.g>=1-e._Epsilon&&(this._value.g=1),this._value.b>=1-e._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(t){this._width.toString(this._host)!==t&&this._width.fromString(t)&&(0===this._width.getValue(this._host)&&(t="1px",this._width.fromString(t)),this._height.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._height.toString(this._host)!==t&&this._height.fromString(t)&&(0===this._height.getValue(this._host)&&(t="1px",this._height.fromString(t)),this._width.fromString(t),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(t){this.width=t},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ColorPicker"},e.prototype._preMeasure=function(t){t.width<t.height?this._currentMeasure.height=t.width:this._currentMeasure.width=t.height},e.prototype._updateSquareProps=function(){var t=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),e=2*(t-.2*t)/Math.sqrt(2),i=t-.5*e;this._squareLeft=this._currentMeasure.left+i,this._squareTop=this._currentMeasure.top+i,this._squareSize=e},e.prototype._drawGradientSquare=function(t,e,i,o,n,r){var a=r.createLinearGradient(e,i,o+e,i);a.addColorStop(0,"#fff"),a.addColorStop(1,"hsl("+t+", 100%, 50%)"),r.fillStyle=a,r.fillRect(e,i,o,n);var s=r.createLinearGradient(e,i,e,n+i);s.addColorStop(0,"rgba(0,0,0,0)"),s.addColorStop(1,"#000"),r.fillStyle=s,r.fillRect(e,i,o,n)},e.prototype._drawCircle=function(t,e,i,o){o.beginPath(),o.arc(t,e,i+1,0,2*Math.PI,!1),o.lineWidth=3,o.strokeStyle="#333333",o.stroke(),o.beginPath(),o.arc(t,e,i,0,2*Math.PI,!1),o.lineWidth=3,o.strokeStyle="#ffffff",o.stroke()},e.prototype._createColorWheelCanvas=function(t,e){var i=s.EngineStore.LastCreatedEngine;if(!i)throw new Error("Invalid engine. Unable to create a canvas.");for(var o=i.createCanvas(2*t,2*t),n=o.getContext("2d"),r=n.getImageData(0,0,2*t,2*t),a=r.data,l=this._tmpColor,_=t*t,h=t-e,c=h*h,u=-t;u<t;u++)for(var d=-t;d<t;d++){var f=u*u+d*d;if(!(f>_||f<c)){var p=Math.sqrt(f),g=Math.atan2(d,u);s.Color3.HSVtoRGBToRef(180*g/Math.PI+180,p/t,1,l);var m=4*(u+t+2*(d+t)*t);a[m]=255*l.r,a[m+1]=255*l.g,a[m+2]=255*l.b;var b,v;v=t<50?.2:t>150?.04:-.16*(t-50)/100+.2,b=(p-h)/(t-h),a[m+3]=b<v?b/v*255:b>1-v?255*(1-(b-(1-v))/v):255}}return n.putImageData(r,0,0),o},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=.2*e,o=this._currentMeasure.left,n=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*e||(this._colorWheelCanvas=this._createColorWheelCanvas(e,i)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY,t.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),t.drawImage(this._colorWheelCanvas,o,n),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,t);var r=this._squareLeft+this._squareSize*this._s,a=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(r,a,.04*e,t);var s=e-.5*i;r=o+e+Math.cos((this._h-180)*Math.PI/180)*s,a=n+e+Math.sin((this._h-180)*Math.PI/180)*s,this._drawCircle(r,a,.35*i,t),t.restore()},e.prototype._updateValueFromPointer=function(t,i){if(this._pointerStartedOnWheel){var o=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),n=o+this._currentMeasure.left,r=o+this._currentMeasure.top;this._h=180*Math.atan2(i-r,t-n)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(i-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,e._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,e._Epsilon));s.Color3.HSVtoRGBToRef(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},e.prototype._isPointOnSquare=function(t,e){this._updateSquareProps();var i=this._squareLeft,o=this._squareTop,n=this._squareSize;return t>=i&&t<=i+n&&e>=o&&e<=o+n},e.prototype._isPointOnWheel=function(t,e){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),o=i-.2*i,n=t-(i+this._currentMeasure.left),r=e-(i+this._currentMeasure.top),a=n*n+r*r;return a<=i*i&&a>=o*o},e.prototype._onPointerDown=function(e,i,o,n,r){if(!t.prototype._onPointerDown.call(this,e,i,o,n,r))return!1;if(this.isReadOnly)return!0;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var a=this._transformedPosition.x,s=this._transformedPosition.y;return this._isPointOnSquare(a,s)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(a,s)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(a,s),this._host._capturingControl[o]=this,this._lastPointerDownId=o,!0},e.prototype._onPointerMove=function(e,i,o,n){if(o==this._lastPointerDownId){if(!this.isReadOnly){this._invertTransformMatrix.transformCoordinates(i.x,i.y,this._transformedPosition);var r=this._transformedPosition.x,a=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(r,a)}t.prototype._onPointerMove.call(this,e,i,o,n)}},e.prototype._onPointerUp=function(e,i,o,n,r,a){this._pointerIsDown=!1,delete this._host._capturingControl[o],t.prototype._onPointerUp.call(this,e,i,o,n,r,a)},e.prototype._onCanvasBlur=function(){this._forcePointerUp(),t.prototype._onCanvasBlur.call(this)},e.ShowPickerDialogAsync=function(t,i){return new Promise((function(o){i.pickerWidth=i.pickerWidth||"640px",i.pickerHeight=i.pickerHeight||"400px",i.headerHeight=i.headerHeight||"35px",i.lastColor=i.lastColor||"#000000",i.swatchLimit=i.swatchLimit||20,i.numSwatchesPerLine=i.numSwatchesPerLine||10;var n,r,a,l,_,h,c,u=i.swatchLimit/i.numSwatchesPerLine,d=parseFloat(i.pickerWidth)/i.numSwatchesPerLine,f=Math.floor(.25*d),p=f*(i.numSwatchesPerLine+1),m=Math.floor((parseFloat(i.pickerWidth)-p)/i.numSwatchesPerLine),b=m*u+f*(u+1),x=(parseInt(i.pickerHeight)+b+Math.floor(.25*m)).toString()+"px",B="#c0c0c0",C="#535353",T="#414141",R="515151",S=s.Color3.FromHexString("#dddddd"),w=S.r+S.g+S.b,M=["R","G","B"],E="#454545",D="#f0f0f0",F=!1,L=new I;if(L.name="Dialog Container",L.width=i.pickerWidth,i.savedColors){L.height=x;var N=parseInt(i.pickerHeight)/parseInt(x);L.addRowDefinition(N,!1),L.addRowDefinition(1-N,!1)}else L.height=i.pickerHeight,L.addRowDefinition(1,!1);if(t.addControl(L),i.savedColors){(l=new I).name="Swatch Drawer",l.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,l.background=C,l.width=i.pickerWidth;var k,A=i.savedColors.length/i.numSwatchesPerLine;k=0==A?0:A+1,l.height=(m*A+k*f).toString()+"px",l.top=Math.floor(.25*m).toString()+"px";for(var z=0;z<2*Math.ceil(i.savedColors.length/i.numSwatchesPerLine)+1;z++)z%2!=0?l.addRowDefinition(m,!0):l.addRowDefinition(f,!0);for(z=0;z<2*i.numSwatchesPerLine+1;z++)z%2!=0?l.addColumnDefinition(m,!0):l.addColumnDefinition(f,!0);L.addControl(l,1,0)}var Q=new I;Q.name="Picker Panel",Q.height=i.pickerHeight;var V=parseInt(i.headerHeight)/parseInt(i.pickerHeight),H=[V,1-V];Q.addRowDefinition(H[0],!1),Q.addRowDefinition(H[1],!1),L.addControl(Q,0,0);var W=new v;W.name="Dialogue Header Bar",W.background="#cccccc",W.thickness=0,Q.addControl(W,0,0);var G=P.CreateSimpleButton("closeButton","a");G.fontFamily="coreglyphs";var U=s.Color3.FromHexString(W.background),j=new s.Color3(1-U.r,1-U.g,1-U.b);G.color=j.toHexString(),G.fontSize=Math.floor(.6*parseInt(i.headerHeight)),G.textBlock.textVerticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,G.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_RIGHT,G.height=G.width=i.headerHeight,G.background=W.background,G.thickness=0,G.pointerDownAnimation=function(){},G.pointerUpAnimation=function(){G.background=W.background},G.pointerEnterAnimation=function(){G.color=W.background,G.background="red"},G.pointerOutAnimation=function(){G.color=j.toHexString(),G.background=W.background},G.onPointerClickObservable.add((function(){Qt(_t.background)})),Q.addControl(G,0,0);var X=new I;X.name="Dialogue Body",X.background=C;var Y=[.4375,.5625];X.addRowDefinition(1,!1),X.addColumnDefinition(Y[0],!1),X.addColumnDefinition(Y[1],!1),Q.addControl(X,1,0);var K=new I;K.name="Picker Grid",K.addRowDefinition(.85,!1),K.addRowDefinition(.15,!1),X.addControl(K,0,0);var Z=new e;Z.name="GUI Color Picker",i.pickerHeight<i.pickerWidth?Z.width=.89:Z.height=.89,Z.value=s.Color3.FromHexString(i.lastColor),Z.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,Z.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,Z.onPointerDownObservable.add((function(){c=Z.name,h="",Nt(!1)})),Z.onValueChangedObservable.add((function(t){c==Z.name&&Et(t,Z.name)})),K.addControl(Z,0,0);var q=new I;q.name="Dialogue Right Half",q.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT;var J=[.514,.486];q.addRowDefinition(J[0],!1),q.addRowDefinition(J[1],!1),X.addControl(q,1,1);var $=new I;$.name="Swatches and Buttons";var tt=[.417,.583];$.addRowDefinition(1,!1),$.addColumnDefinition(tt[0],!1),$.addColumnDefinition(tt[1],!1),q.addControl($,0,0);var et=new I;et.name="New and Current Swatches";var it=[.04,.16,.64,.16];et.addRowDefinition(it[0],!1),et.addRowDefinition(it[1],!1),et.addRowDefinition(it[2],!1),et.addRowDefinition(it[3],!1),$.addControl(et,0,0);var ot=new I;ot.name="Active Swatches",ot.width=.67,ot.addRowDefinition(.5,!1),ot.addRowDefinition(.5,!1),et.addControl(ot,2,0);var nt,rt=Math.floor(parseInt(i.pickerWidth)*Y[1]*tt[0]*.11),at=Math.floor(parseInt(i.pickerHeight)*H[1]*J[0]*it[1]*.5);nt=i.pickerWidth>i.pickerHeight?at:rt;var st=new y;st.text="new",st.name="New Color Label",st.color=B,st.fontSize=nt,et.addControl(st,1,0);var lt=new v;lt.name="New Color Swatch",lt.background=i.lastColor,lt.thickness=0,ot.addControl(lt,0,0);var _t=P.CreateSimpleButton("currentSwatch","");_t.background=i.lastColor,_t.thickness=0,_t.onPointerClickObservable.add((function(){Et(s.Color3.FromHexString(_t.background),_t.name),Nt(!1)})),_t.pointerDownAnimation=function(){},_t.pointerUpAnimation=function(){},_t.pointerEnterAnimation=function(){},_t.pointerOutAnimation=function(){},ot.addControl(_t,1,0);var ht=new v;ht.name="Swatch Outline",ht.width=.67,ht.thickness=2,ht.color="#404040",ht.isHitTestVisible=!1,et.addControl(ht,2,0);var ct=new y;ct.name="Current Color Label",ct.text="current",ct.color=B,ct.fontSize=nt,et.addControl(ct,3,0);var ut=new I;ut.name="Button Grid",ut.height=.8;var dt=1/3;ut.addRowDefinition(dt,!1),ut.addRowDefinition(dt,!1),ut.addRowDefinition(dt,!1),$.addControl(ut,0,1);var ft=Math.floor(parseInt(i.pickerWidth)*Y[1]*tt[1]*.67).toString()+"px",pt=Math.floor(parseInt(i.pickerHeight)*H[1]*J[0]*(parseFloat(ut.height.toString())/100)*dt*.7).toString()+"px";n=parseFloat(ft)>parseFloat(pt)?Math.floor(.45*parseFloat(pt)):Math.floor(.11*parseFloat(ft));var gt=P.CreateSimpleButton("butOK","OK");gt.width=ft,gt.height=pt,gt.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,gt.thickness=2,gt.color=B,gt.fontSize=n,gt.background=C,gt.onPointerEnterObservable.add((function(){gt.background=T})),gt.onPointerOutObservable.add((function(){gt.background=C})),gt.pointerDownAnimation=function(){gt.background=R},gt.pointerUpAnimation=function(){gt.background=T},gt.onPointerClickObservable.add((function(){Nt(!1),Qt(lt.background)})),ut.addControl(gt,0,0);var mt=P.CreateSimpleButton("butCancel","Cancel");mt.width=ft,mt.height=pt,mt.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,mt.thickness=2,mt.color=B,mt.fontSize=n,mt.background=C,mt.onPointerEnterObservable.add((function(){mt.background=T})),mt.onPointerOutObservable.add((function(){mt.background=C})),mt.pointerDownAnimation=function(){mt.background=R},mt.pointerUpAnimation=function(){mt.background=T},mt.onPointerClickObservable.add((function(){Nt(!1),Qt(_t.background)})),ut.addControl(mt,1,0),i.savedColors&&((_=P.CreateSimpleButton("butSave","Save")).width=ft,_.height=pt,_.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,_.thickness=2,_.fontSize=n,i.savedColors.length<i.swatchLimit?(_.color=B,_.background=C):zt(_,!0),_.onPointerEnterObservable.add((function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(_.background=T)})),_.onPointerOutObservable.add((function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(_.background=C)})),_.pointerDownAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(_.background=R)},_.pointerUpAnimation=function(){i.savedColors&&i.savedColors.length<i.swatchLimit&&(_.background=T)},_.onPointerClickObservable.add((function(){i.savedColors&&(0==i.savedColors.length&&At(!0),i.savedColors.length<i.swatchLimit&&kt(lt.background,_),Nt(!1))})),i.savedColors.length>0&&At(!0),ut.addControl(_,2,0));var bt=new I;bt.name="Dialog Lower Right",bt.addRowDefinition(.02,!1),bt.addRowDefinition(.63,!1),bt.addRowDefinition(.21,!1),bt.addRowDefinition(.14,!1),q.addControl(bt,1,0);var vt=s.Color3.FromHexString(i.lastColor),yt=new I;for(yt.name="RGB Values",yt.width=.82,yt.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,yt.addRowDefinition(1/3,!1),yt.addRowDefinition(1/3,!1),yt.addRowDefinition(1/3,!1),yt.addColumnDefinition(.1,!1),yt.addColumnDefinition(.2,!1),yt.addColumnDefinition(.7,!1),bt.addControl(yt,1,0),z=0;z<M.length;z++){var xt=new y;xt.text=M[z],xt.color=B,xt.fontSize=n,yt.addControl(xt,z,0)}var Pt=new O;Pt.width=.83,Pt.height=.72,Pt.name="rIntField",Pt.fontSize=n,Pt.text=(255*vt.r).toString(),Pt.color=D,Pt.background=E,Pt.onFocusObservable.add((function(){c=Pt.name,h=Pt.text,Nt(!1)})),Pt.onBlurObservable.add((function(){""==Pt.text&&(Pt.text="0"),Dt(Pt,"r"),c==Pt.name&&(c="")})),Pt.onTextChangedObservable.add((function(){c==Pt.name&&Dt(Pt,"r")})),yt.addControl(Pt,0,1);var Bt=new O;Bt.width=.83,Bt.height=.72,Bt.name="gIntField",Bt.fontSize=n,Bt.text=(255*vt.g).toString(),Bt.color=D,Bt.background=E,Bt.onFocusObservable.add((function(){c=Bt.name,h=Bt.text,Nt(!1)})),Bt.onBlurObservable.add((function(){""==Bt.text&&(Bt.text="0"),Dt(Bt,"g"),c==Bt.name&&(c="")})),Bt.onTextChangedObservable.add((function(){c==Bt.name&&Dt(Bt,"g")})),yt.addControl(Bt,1,1);var Ct=new O;Ct.width=.83,Ct.height=.72,Ct.name="bIntField",Ct.fontSize=n,Ct.text=(255*vt.b).toString(),Ct.color=D,Ct.background=E,Ct.onFocusObservable.add((function(){c=Ct.name,h=Ct.text,Nt(!1)})),Ct.onBlurObservable.add((function(){""==Ct.text&&(Ct.text="0"),Dt(Ct,"b"),c==Ct.name&&(c="")})),Ct.onTextChangedObservable.add((function(){c==Ct.name&&Dt(Ct,"b")})),yt.addControl(Ct,2,1);var Tt=new O;Tt.width=.95,Tt.height=.72,Tt.name="rDecField",Tt.fontSize=n,Tt.text=vt.r.toString(),Tt.color=D,Tt.background=E,Tt.onFocusObservable.add((function(){c=Tt.name,h=Tt.text,Nt(!1)})),Tt.onBlurObservable.add((function(){0!=parseFloat(Tt.text)&&""!=Tt.text||(Tt.text="0",Ft(Tt,"r")),c==Tt.name&&(c="")})),Tt.onTextChangedObservable.add((function(){c==Tt.name&&Ft(Tt,"r")})),yt.addControl(Tt,0,2);var Ot=new O;Ot.width=.95,Ot.height=.72,Ot.name="gDecField",Ot.fontSize=n,Ot.text=vt.g.toString(),Ot.color=D,Ot.background=E,Ot.onFocusObservable.add((function(){c=Ot.name,h=Ot.text,Nt(!1)})),Ot.onBlurObservable.add((function(){0!=parseFloat(Ot.text)&&""!=Ot.text||(Ot.text="0",Ft(Ot,"g")),c==Ot.name&&(c="")})),Ot.onTextChangedObservable.add((function(){c==Ot.name&&Ft(Ot,"g")})),yt.addControl(Ot,1,2);var It=new O;It.width=.95,It.height=.72,It.name="bDecField",It.fontSize=n,It.text=vt.b.toString(),It.color=D,It.background=E,It.onFocusObservable.add((function(){c=It.name,h=It.text,Nt(!1)})),It.onBlurObservable.add((function(){0!=parseFloat(It.text)&&""!=It.text||(It.text="0",Ft(It,"b")),c==It.name&&(c="")})),It.onTextChangedObservable.add((function(){c==It.name&&Ft(It,"b")})),yt.addControl(It,2,2);var Rt=new I;Rt.name="Hex Value",Rt.width=.82,Rt.addRowDefinition(1,!1),Rt.addColumnDefinition(.1,!1),Rt.addColumnDefinition(.9,!1),bt.addControl(Rt,2,0);var St=new y;St.text="#",St.color=B,St.fontSize=n,Rt.addControl(St,0,0);var wt=new O;wt.width=.96,wt.height=.72,wt.name="hexField",wt.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,wt.fontSize=n;var Mt=i.lastColor.split("#");function Et(t,e){c=e;var i=t.toHexString();if(lt.background=i,Pt.name!=c&&(Pt.text=Math.floor(255*t.r).toString()),Bt.name!=c&&(Bt.text=Math.floor(255*t.g).toString()),Ct.name!=c&&(Ct.text=Math.floor(255*t.b).toString()),Tt.name!=c&&(Tt.text=t.r.toString()),Ot.name!=c&&(Ot.text=t.g.toString()),It.name!=c&&(It.text=t.b.toString()),wt.name!=c){var o=i.split("#");wt.text=o[1]}Z.name!=c&&(Z.value=t)}function Dt(t,e){var i=t.text;if(/[^0-9]/g.test(i))t.text=h;else if(""!=i&&(Math.floor(parseInt(i))<0?i="0":Math.floor(parseInt(i))>255?i="255":isNaN(parseInt(i))&&(i="0")),c==t.name&&(h=i),""!=i){i=parseInt(i).toString(),t.text=i;var o=s.Color3.FromHexString(lt.background);c==t.name&&Et("r"==e?new s.Color3(parseInt(i)/255,o.g,o.b):"g"==e?new s.Color3(o.r,parseInt(i)/255,o.b):new s.Color3(o.r,o.g,parseInt(i)/255),t.name)}}function Ft(t,e){var i=t.text;if(/[^0-9.]/g.test(i))t.text=h;else{""!=i&&"."!=i&&0!=parseFloat(i)&&(parseFloat(i)<0?i="0.0":parseFloat(i)>1?i="1.0":isNaN(parseFloat(i))&&(i="0.0")),c==t.name&&(h=i),""!=i&&"."!=i&&0!=parseFloat(i)?(i=parseFloat(i).toString(),t.text=i):i="0.0";var o=s.Color3.FromHexString(lt.background);c==t.name&&Et("r"==e?new s.Color3(parseFloat(i),o.g,o.b):"g"==e?new s.Color3(o.r,parseFloat(i),o.b):new s.Color3(o.r,o.g,parseFloat(i)),t.name)}}function Lt(){if(i.savedColors&&i.savedColors[a]){var t;t=F?"b":"";var e=P.CreateSimpleButton("Swatch_"+a,t);e.fontFamily="coreglyphs";var o=s.Color3.FromHexString(i.savedColors[a]),n=o.r+o.g+o.b;e.color=n>w?"#aaaaaa":"#ffffff",e.fontSize=Math.floor(.7*m),e.textBlock.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,e.height=e.width=m.toString()+"px",e.background=i.savedColors[a],e.thickness=2;var r=a;return e.pointerDownAnimation=function(){e.thickness=4},e.pointerUpAnimation=function(){e.thickness=3},e.pointerEnterAnimation=function(){e.thickness=3},e.pointerOutAnimation=function(){e.thickness=2},e.onPointerClickObservable.add((function(){var t;F?(t=r,i.savedColors&&i.savedColors.splice(t,1),i.savedColors&&0==i.savedColors.length&&(At(!1),F=!1),kt("",_)):i.savedColors&&Et(s.Color3.FromHexString(i.savedColors[r]),e.name)})),e}return null}function Nt(t){if(void 0!==t&&(F=t),F){for(var e=0;e<l.children.length;e++)l.children[e].textBlock.text="b";void 0!==r&&(r.textBlock.text="Done")}else{for(e=0;e<l.children.length;e++)l.children[e].textBlock.text="";void 0!==r&&(r.textBlock.text="Edit")}}function kt(t,e){if(i.savedColors){""!=t&&i.savedColors.push(t),a=0,l.clearControls();var o,n=Math.ceil(i.savedColors.length/i.numSwatchesPerLine);if(o=0==n?0:n+1,l.rowCount!=n+o){for(var r=l.rowCount,s=0;s<r;s++)l.removeRowDefinition(0);for(s=0;s<n+o;s++)s%2?l.addRowDefinition(m,!0):l.addRowDefinition(f,!0)}l.height=(m*n+o*f).toString()+"px";for(var _=1,h=1;_<n+o;_+=2,h++){var c;c=i.savedColors.length>h*i.numSwatchesPerLine?i.numSwatchesPerLine:i.savedColors.length-(h-1)*i.numSwatchesPerLine;for(var u=Math.min(Math.max(c,0),i.numSwatchesPerLine),d=0,p=1;d<u;d++)if(!(d>i.numSwatchesPerLine)){var g=Lt();null!=g&&(l.addControl(g,_,p),p+=2,a++)}}i.savedColors.length>=i.swatchLimit?zt(e,!0):zt(e,!1)}}function At(t){t?((r=P.CreateSimpleButton("butEdit","Edit")).width=ft,r.height=pt,r.left=Math.floor(.1*parseInt(ft)).toString()+"px",r.top=(-1*parseFloat(r.left)).toString()+"px",r.verticalAlignment=g.VERTICAL_ALIGNMENT_BOTTOM,r.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,r.thickness=2,r.color=B,r.fontSize=n,r.background=C,r.onPointerEnterObservable.add((function(){r.background=T})),r.onPointerOutObservable.add((function(){r.background=C})),r.pointerDownAnimation=function(){r.background=R},r.pointerUpAnimation=function(){r.background=T},r.onPointerClickObservable.add((function(){F=!F,Nt()})),K.addControl(r,1,0)):K.removeControl(r)}function zt(t,e){e?(t.color="#555555",t.background="#454545"):(t.color=B,t.background=C)}function Qt(e){i.savedColors&&i.savedColors.length>0?o({savedColors:i.savedColors,pickedColor:e}):o({pickedColor:e}),t.removeControl(L)}wt.text=Mt[1],wt.color=D,wt.background=E,wt.onFocusObservable.add((function(){c=wt.name,h=wt.text,Nt(!1)})),wt.onBlurObservable.add((function(){if(3==wt.text.length){var t=wt.text.split("");wt.text=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]}""==wt.text&&(wt.text="000000",Et(s.Color3.FromHexString(wt.text),"b")),c==wt.name&&(c="")})),wt.onTextChangedObservable.add((function(){var t=wt.text,e=/[^0-9A-F]/i.test(t);if((wt.text.length>6||e)&&c==wt.name)wt.text=h;else{if(wt.text.length<6)for(var i=6-wt.text.length,o=0;o<i;o++)t="0"+t;if(3==wt.text.length){var n=wt.text.split("");t=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]}t="#"+t,c==wt.name&&(h=wt.text,Et(s.Color3.FromHexString(t),wt.name))}})),Rt.addControl(wt,0,1),i.savedColors&&i.savedColors.length>0&&kt("",_)}))},e._Epsilon=1e-6,a([(0,s.serialize)()],e.prototype,"value",null),a([(0,s.serialize)()],e.prototype,"width",null),a([(0,s.serialize)()],e.prototype,"height",null),a([(0,s.serialize)()],e.prototype,"size",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.ColorPicker",R);var S=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i}return r(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Ellipse"},e.prototype._localDraw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),g.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),this._background&&(t.fillStyle=this._background,t.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),this._thickness&&(this.color&&(t.strokeStyle=this.color),t.lineWidth=this._thickness,t.stroke()),t.restore()},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},e.prototype._clipForChildren=function(t){g.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,t),t.clip()},e.prototype._renderHighlightSpecific=function(t){g.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._highlightLineWidth/2,this._currentMeasure.height/2-this._highlightLineWidth/2,t),t.stroke()},a([(0,s.serialize)()],e.prototype,"thickness",null),e}(m);(0,s.RegisterClass)("BABYLON.GUI.Ellipse",S);var w=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i.focusedColor=null,i._isFocused=!1,i._unfocusedColor=null,i.onFocusObservable=new s.Observable,i.onBlurObservable=new s.Observable,i.onKeyboardEventProcessedObservable=new s.Observable,i._unfocusedColor=i.color,i}return r(e,t),e.prototype.onBlur=function(){this._isFocused&&(this._isFocused=!1,this.focusedColor&&null!=this._unfocusedColor&&(this.color=this._unfocusedColor),this.onBlurObservable.notifyObservers(this))},e.prototype.onFocus=function(){this._isFocused=!0,this.focusedColor&&(this._unfocusedColor=this.color,this.color=this.focusedColor),this.onFocusObservable.notifyObservers(this)},e.prototype.keepsFocusWith=function(){return null},e.prototype.focus=function(){this._host.moveFocusToControl(this)},e.prototype.blur=function(){this._host.focusedControl=null},e.prototype.processKeyboard=function(t){this.onKeyboardEventProcessedObservable.notifyObservers(t,-1,this)},e.prototype._onPointerDown=function(e,i,o,n,r){return this.isReadOnly||this.focus(),t.prototype._onPointerDown.call(this,e,i,o,n,r)},e.prototype.displose=function(){t.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onKeyboardEventProcessedObservable.clear()},e}(P);(0,s.RegisterClass)("BABYLON.GUI.FocusableButton",w);var M=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._getTypeName=function(){return"InputPassword"},e.prototype._beforeRenderText=function(t){for(var e=new T,i="",o=0;o<t.length;o++)i+="•";return e.text=i,e},e}(O);(0,s.RegisterClass)("BABYLON.GUI.InputPassword",M);var E=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._lineWidth=1,i._x1=new l(0),i._y1=new l(0),i._x2=new l(0),i._y2=new l(0),i._dash=new Array,i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,i}return r(e,t),Object.defineProperty(e.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectedControl",{get:function(){return this._connectedControl},set:function(t){var e=this;this._connectedControl!==t&&(this._connectedControlDirtyObserver&&this._connectedControl&&(this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver),this._connectedControlDirtyObserver=null),t&&(this._connectedControlDirtyObserver=t.onDirtyObservable.add((function(){return e._markAsDirty()}))),this._connectedControl=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x1",{get:function(){return this._x1.toString(this._host)},set:function(t){this._x1.toString(this._host)!==t&&this._x1.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y1",{get:function(){return this._y1.toString(this._host)},set:function(t){this._y1.toString(this._host)!==t&&this._y1.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x2",{get:function(){return this._x2.toString(this._host)},set:function(t){this._x2.toString(this._host)!==t&&this._x2.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y2",{get:function(){return this._y2.toString(this._host)},set:function(t){this._y2.toString(this._host)!==t&&this._y2.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Line"},e.prototype._draw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._applyStates(t),t.strokeStyle=this.color,t.lineWidth=this._lineWidth,t.setLineDash(this._dash),t.beginPath(),t.moveTo(this._cachedParentMeasure.left+this._x1.getValue(this._host),this._cachedParentMeasure.top+this._y1.getValue(this._host)),t.lineTo(this._cachedParentMeasure.left+this._effectiveX2,this._cachedParentMeasure.top+this._effectiveY2),t.stroke(),t.restore()},e.prototype._measure=function(){this._currentMeasure.width=Math.abs(this._x1.getValue(this._host)-this._effectiveX2)+this._lineWidth,this._currentMeasure.height=Math.abs(this._y1.getValue(this._host)-this._effectiveY2)+this._lineWidth},e.prototype._computeAlignment=function(t){this._currentMeasure.left=t.left+Math.min(this._x1.getValue(this._host),this._effectiveX2)-this._lineWidth/2,this._currentMeasure.top=t.top+Math.min(this._y1.getValue(this._host),this._effectiveY2)-this._lineWidth/2},e.prototype.moveToVector3=function(t,e,i){if(void 0===i&&(i=!1),this._host&&this.parent===this._host._rootContainer){var o=this._host._getGlobalViewport(),n=s.Vector3.Project(t,s.Matrix.Identity(),e.getTransformMatrix(),o);this._moveToProjectedPosition(n,i),n.z<0||n.z>1?this.notRenderable=!0:this.notRenderable=!1}else s.Tools.Error("Cannot move a control to a vector3 if the control is not at root level")},e.prototype._moveToProjectedPosition=function(t,e){void 0===e&&(e=!1);var i=t.x+this._linkOffsetX.getValue(this._host)+"px",o=t.y+this._linkOffsetY.getValue(this._host)+"px";e?(this.x2=i,this.y2=o,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=i,this.y1=o,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},a([(0,s.serialize)()],e.prototype,"dash",null),a([(0,s.serialize)()],e.prototype,"x1",null),a([(0,s.serialize)()],e.prototype,"y1",null),a([(0,s.serialize)()],e.prototype,"x2",null),a([(0,s.serialize)()],e.prototype,"y2",null),a([(0,s.serialize)()],e.prototype,"lineWidth",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.Line",E);var D=function(){function t(t){this._multiLine=t,this._x=new l(0),this._y=new l(0),this._point=new s.Vector3(0,0,0)}return Object.defineProperty(t.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(t){this._x.toString(this._multiLine._host)!==t&&this._x.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(t){this._y.toString(this._multiLine._host)!==t&&this._y.fromString(t)&&this._multiLine._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"control",{get:function(){return this._control},set:function(t){this._control!==t&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=t,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},set:function(t){this._mesh!==t&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=t,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!1,configurable:!0}),t.prototype.resetLinks=function(){this.control=null,this.mesh=null},t.prototype.translate=function(){return this._point=this._translatePoint(),this._point},t.prototype._translatePoint=function(){if(null!=this._mesh)return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(null!=this._control)return new s.Vector3(this._control.centerX,this._control.centerY,1-s.Epsilon);var t=this._multiLine._host,e=this._x.getValueInPixel(t,Number(t._canvas.width)),i=this._y.getValueInPixel(t,Number(t._canvas.height));return new s.Vector3(e,i,1-s.Epsilon)},t.prototype.dispose=function(){this.resetLinks()},t}(),F=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i._automaticSize=!0,i.isHitTestVisible=!1,i._horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return r(e,t),Object.defineProperty(e.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype.getAt=function(t){return this._points[t]||(this._points[t]=new D(this)),this._points[t]},e.prototype.add=function(){for(var t=this,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.map((function(e){return t.push(e)}))},e.prototype.push=function(t){var e=this.getAt(this._points.length);return null==t||(t instanceof s.AbstractMesh?e.mesh=t:t instanceof g?e.control=t:null!=t.x&&null!=t.y&&(e.x=t.x,e.y=t.y)),e},e.prototype.remove=function(t){var e;if(t instanceof D){if(-1===(e=this._points.indexOf(t)))return}else e=t;var i=this._points[e];i&&(i.dispose(),this._points.splice(e,1))},e.prototype.reset=function(){for(;this._points.length>0;)this.remove(this._points.length-1)},e.prototype.resetLinks=function(){this._points.forEach((function(t){null!=t&&t.resetLinks()}))},Object.defineProperty(e.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalAlignment",{set:function(t){},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"MultiLine"},e.prototype._draw=function(t){t.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._applyStates(t),t.strokeStyle=this.color,t.lineWidth=this._lineWidth,t.setLineDash(this._dash),t.beginPath();var e,i=!0;this._points.forEach((function(o){o&&(i?(t.moveTo(o._point.x,o._point.y),i=!1):o._point.z<1&&e.z<1?t.lineTo(o._point.x,o._point.y):t.moveTo(o._point.x,o._point.y),e=o._point)})),t.stroke(),t.restore()},e.prototype._additionalProcessing=function(){var t=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach((function(e){e&&(e.translate(),(null==t._minX||e._point.x<t._minX)&&(t._minX=e._point.x),(null==t._minY||e._point.y<t._minY)&&(t._minY=e._point.y),(null==t._maxX||e._point.x>t._maxX)&&(t._maxX=e._point.x),(null==t._maxY||e._point.y>t._maxY)&&(t._maxY=e._point.y))})),null==this._minX&&(this._minX=0),null==this._minY&&(this._minY=0),null==this._maxX&&(this._maxX=0),null==this._maxY&&(this._maxY=0)},e.prototype._measure=function(){null!=this._minX&&null!=this._maxX&&null!=this._minY&&null!=this._maxY&&(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},e.prototype._computeAlignment=function(){null!=this._minX&&null!=this._minY&&(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},e.prototype.dispose=function(){this.reset(),t.prototype.dispose.call(this)},a([(0,s.serialize)()],e.prototype,"dash",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.MultiLine",F);var L=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._isChecked=!1,i._background="black",i._checkSizeRatio=.8,i._thickness=1,i.group="",i.onIsCheckedChangedObservable=new s.Observable,i.isPointerBlocker=!0,i}return r(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){return this._isChecked},set:function(t){var e=this;this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t),this._isChecked&&this._host&&this._host.executeOnAllControls((function(t){if(t!==e&&void 0!==t.group){var i=t;i.group===e.group&&(i.isChecked=!1)}})))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"RadioButton"},e.prototype._draw=function(t){t.save(),this._applyStates(t);var e=this._currentMeasure.width-this._thickness,i=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),g.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,t),t.fillStyle=this._isEnabled?this._background:this._disabledColor,t.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this.color,t.lineWidth=this._thickness,t.stroke(),this._isChecked){t.fillStyle=this._isEnabled?this.color:this._disabledColor;var o=e*this._checkSizeRatio,n=i*this._checkSizeRatio;g.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,o/2-this._thickness/2,n/2-this._thickness/2,t),t.fill()}t.restore()},e.prototype._onPointerDown=function(e,i,o,n,r){return!!t.prototype._onPointerDown.call(this,e,i,o,n,r)&&(this.isReadOnly||this.isChecked||(this.isChecked=!0),!0)},e.AddRadioButtonWithHeader=function(t,i,o,n){var r=new B;r.isVertical=!1,r.height="30px";var a=new e;a.width="20px",a.height="20px",a.isChecked=o,a.color="green",a.group=i,a.onIsCheckedChangedObservable.add((function(t){return n(a,t)})),r.addControl(a);var s=new y;return s.text=t,s.width="180px",s.paddingLeft="5px",s.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,s.color="white",r.addControl(s),r},a([(0,s.serialize)()],e.prototype,"thickness",null),a([(0,s.serialize)()],e.prototype,"group",void 0),a([(0,s.serialize)()],e.prototype,"checkSizeRatio",null),a([(0,s.serialize)()],e.prototype,"background",null),a([(0,s.serialize)()],e.prototype,"isChecked",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.RadioButton",L);var N=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbWidth=new l(20,l.UNITMODE_PIXEL,!1),i._minimum=0,i._maximum=100,i._value=50,i._isVertical=!1,i._barOffset=new l(5,l.UNITMODE_PIXEL,!1),i._isThumbClamped=!1,i._displayThumb=!0,i._step=0,i._lastPointerDownId=-1,i._effectiveBarOffset=0,i.onValueChangedObservable=new s.Observable,i._pointerIsDown=!1,i.isPointerBlocker=!0,i}return r(e,t),Object.defineProperty(e.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(t){this._displayThumb!==t&&(this._displayThumb=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"step",{get:function(){return this._step},set:function(t){this._step!==t&&(this._step=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(t){this._barOffset.toString(this._host)!==t&&this._barOffset.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(t){this._thumbWidth.toString(this._host)!==t&&this._thumbWidth.fromString(t)&&this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimum",{get:function(){return this._minimum},set:function(t){this._minimum!==t&&(this._minimum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this._maximum},set:function(t){this._maximum!==t&&(this._maximum=t,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){t=Math.max(Math.min(t,this._maximum),this._minimum),this._value!==t&&(this._value=t,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(t){this._isThumbClamped!==t&&(this._isThumbClamped=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"BaseSlider"},e.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},e.prototype._getThumbThickness=function(t){var e=0;switch(t){case"circle":e=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":e=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return e},e.prototype._prepareRenderingData=function(t){this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(t),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height<this._currentMeasure.width?console.error("Height should be greater than width"):(this._barOffset.isPixel?this._effectiveBarOffset=Math.min(this._barOffset.getValue(this._host),this._backgroundBoxThickness):this._effectiveBarOffset=this._backgroundBoxThickness*this._barOffset.getValue(this._host),this._backgroundBoxThickness-=2*this._effectiveBarOffset,this.isVertical?(this._renderLeft+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderTop+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxLength,this._renderWidth=this._backgroundBoxThickness):(this._renderTop+=this._effectiveBarOffset,!this.isThumbClamped&&this.displayThumb&&(this._renderLeft+=this._effectiveThumbThickness/2),this._renderHeight=this._backgroundBoxThickness,this._renderWidth=this._backgroundBoxLength))},e.prototype._updateValueFromPointer=function(t,e){var i;0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),i=this._isVertical?this._minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this._maximum-this._minimum):this._minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this._maximum-this._minimum),this.value=this._step?Math.round(i/this._step)*this._step:i},e.prototype._onPointerDown=function(e,i,o,n,r){return!!t.prototype._onPointerDown.call(this,e,i,o,n,r)&&(this.isReadOnly||(this._pointerIsDown=!0,this._updateValueFromPointer(i.x,i.y),this._host._capturingControl[o]=this,this._lastPointerDownId=o),!0)},e.prototype._onPointerMove=function(e,i,o,n){o==this._lastPointerDownId&&(this._pointerIsDown&&!this.isReadOnly&&this._updateValueFromPointer(i.x,i.y),t.prototype._onPointerMove.call(this,e,i,o,n))},e.prototype._onPointerUp=function(e,i,o,n,r){this._pointerIsDown=!1,delete this._host._capturingControl[o],t.prototype._onPointerUp.call(this,e,i,o,n,r)},e.prototype._onCanvasBlur=function(){this._forcePointerUp(),t.prototype._onCanvasBlur.call(this)},a([(0,s.serialize)()],e.prototype,"displayThumb",null),a([(0,s.serialize)()],e.prototype,"step",null),a([(0,s.serialize)()],e.prototype,"barOffset",null),a([(0,s.serialize)()],e.prototype,"thumbWidth",null),a([(0,s.serialize)()],e.prototype,"minimum",null),a([(0,s.serialize)()],e.prototype,"maximum",null),a([(0,s.serialize)()],e.prototype,"value",null),a([(0,s.serialize)()],e.prototype,"isVertical",null),a([(0,s.serialize)()],e.prototype,"isThumbClamped",null),e}(g),k=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._thumbColor="",i._isThumbCircle=!1,i._displayValueBar=!0,i}return r(e,t),Object.defineProperty(e.prototype,"displayValueBar",{get:function(){return this._displayValueBar},set:function(t){this._displayValueBar!==t&&(this._displayValueBar=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbColor",{get:function(){return this._thumbColor},set:function(t){this._thumbColor!==t&&(this._thumbColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isThumbCircle",{get:function(){return this._isThumbCircle},set:function(t){this._isThumbCircle!==t&&(this._isThumbCircle=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Slider"},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData(this.isThumbCircle?"circle":"rectangle");var e=this._renderLeft,i=this._renderTop,o=this._renderWidth,n=this._renderHeight,r=0;this.isThumbClamped&&this.isThumbCircle?(this.isVertical?i+=this._effectiveThumbThickness/2:e+=this._effectiveThumbThickness/2,r=this._backgroundBoxThickness/2):r=(this._effectiveThumbThickness-this._effectiveBarOffset)/2,(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY);var a=this._getThumbPosition();t.fillStyle=this._background,this.isVertical?this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(e+this._backgroundBoxThickness/2,i,r,Math.PI,2*Math.PI),t.fill(),t.fillRect(e,i,o,n)):t.fillRect(e,i,o,n+this._effectiveThumbThickness):t.fillRect(e,i,o,n):this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(e+this._backgroundBoxLength,i+this._backgroundBoxThickness/2,r,0,2*Math.PI),t.fill(),t.fillRect(e,i,o,n)):t.fillRect(e,i,o+this._effectiveThumbThickness,n):t.fillRect(e,i,o,n),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillStyle=this.color,this._displayValueBar&&(this.isVertical?this.isThumbClamped?this.isThumbCircle?(t.beginPath(),t.arc(e+this._backgroundBoxThickness/2,i+this._backgroundBoxLength,r,0,2*Math.PI),t.fill(),t.fillRect(e,i+a,o,n-a)):t.fillRect(e,i+a,o,n-a+this._effectiveThumbThickness):t.fillRect(e,i+a,o,n-a):this.isThumbClamped&&this.isThumbCircle?(t.beginPath(),t.arc(e,i+this._backgroundBoxThickness/2,r,0,2*Math.PI),t.fill(),t.fillRect(e,i,a,n)):t.fillRect(e,i,a,n)),t.fillStyle=this._thumbColor||this.color,this.displayThumb&&((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowColor=this.shadowColor,t.shadowBlur=this.shadowBlur,t.shadowOffsetX=this.shadowOffsetX,t.shadowOffsetY=this.shadowOffsetY),this._isThumbCircle?(t.beginPath(),this.isVertical?t.arc(e+this._backgroundBoxThickness/2,i+a,r,0,2*Math.PI):t.arc(e+a,i+this._backgroundBoxThickness/2,r,0,2*Math.PI),t.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this._borderColor,t.stroke()):(this.isVertical?t.fillRect(e-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):t.fillRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.strokeStyle=this._borderColor,this.isVertical?t.strokeRect(e-this._effectiveBarOffset,this._currentMeasure.top+a,this._currentMeasure.width,this._effectiveThumbThickness):t.strokeRect(this._currentMeasure.left+a,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height))),t.restore()},a([(0,s.serialize)()],e.prototype,"displayValueBar",null),a([(0,s.serialize)()],e.prototype,"borderColor",null),a([(0,s.serialize)()],e.prototype,"background",null),a([(0,s.serialize)()],e.prototype,"thumbColor",null),a([(0,s.serialize)()],e.prototype,"isThumbCircle",null),e}(N);(0,s.RegisterClass)("BABYLON.GUI.Slider",k);var A=function(){function t(t){this.name=t,this._groupPanel=new B,this._selectors=new Array,this._groupPanel.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,this._groupPanel.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,this._groupHeader=this._addGroupHeader(t)}return Object.defineProperty(t.prototype,"groupPanel",{get:function(){return this._groupPanel},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectors",{get:function(){return this._selectors},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"header",{get:function(){return this._groupHeader.text},set:function(t){"label"!==this._groupHeader.text&&(this._groupHeader.text=t)},enumerable:!1,configurable:!0}),t.prototype._addGroupHeader=function(t){var e=new y("groupHead",t);return e.width=.9,e.height="30px",e.textWrapping=!0,e.color="black",e.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,e.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,e.left="2px",this._groupPanel.addControl(e),e},t.prototype._getSelector=function(t){if(!(t<0||t>=this._selectors.length))return this._selectors[t]},t.prototype.removeSelector=function(t){t<0||t>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[t]),this._selectors.splice(t,1))},t}(),z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.addCheckbox=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1),i=i||!1;var o=new C;o.width="20px",o.height="20px",o.color="#364249",o.background="#CCCCCC",o.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o.onIsCheckedChangedObservable.add((function(t){e(t)}));var n=g.AddHeader(o,t,"200px",{isHorizontal:!0,controlFirst:!0});n.height="30px",n.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,n.left="4px",this.groupPanel.addControl(n),this.selectors.push(n),o.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(o.color=this.groupPanel.parent.parent.buttonColor,o.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(A),Q=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._selectNb=0,e}return r(e,t),e.prototype.addRadio=function(t,e,i){void 0===e&&(e=function(t){}),void 0===i&&(i=!1);var o=this._selectNb++,n=new L;n.name=t,n.width="20px",n.height="20px",n.color="#364249",n.background="#CCCCCC",n.group=this.name,n.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,n.onIsCheckedChangedObservable.add((function(t){t&&e(o)}));var r=g.AddHeader(n,t,"200px",{isHorizontal:!0,controlFirst:!0});r.height="30px",r.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,r.left="4px",this.groupPanel.addControl(r),this.selectors.push(r),n.isChecked=i,this.groupPanel.parent&&this.groupPanel.parent.parent&&(n.color=this.groupPanel.parent.parent.buttonColor,n.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[1].text=e},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[0].background=e},e}(A),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.addSlider=function(t,e,i,o,n,r,a){void 0===e&&(e=function(t){}),void 0===i&&(i="Units"),void 0===o&&(o=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=function(t){return 0|t});var s=new k;s.name=i,s.value=r,s.minimum=o,s.maximum=n,s.width=.9,s.height="20px",s.color="#364249",s.background="#CCCCCC",s.borderColor="black",s.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,s.left="4px",s.paddingBottom="4px",s.onValueChangedObservable.add((function(t){s.parent.children[0].text=s.parent.children[0].name+": "+a(t)+" "+s.name,e(t)}));var l=g.AddHeader(s,t+": "+a(r)+" "+i,"30px",{isHorizontal:!1,controlFirst:!1});l.height="60px",l.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,l.left="4px",l.children[0].name=t,this.groupPanel.addControl(l),this.selectors.push(l),this.groupPanel.parent&&this.groupPanel.parent.parent&&(s.color=this.groupPanel.parent.parent.buttonColor,s.background=this.groupPanel.parent.parent.buttonBackground)},e.prototype._setSelectorLabel=function(t,e){this.selectors[t].children[0].name=e,this.selectors[t].children[0].text=e+": "+this.selectors[t].children[1].value+" "+this.selectors[t].children[1].name},e.prototype._setSelectorLabelColor=function(t,e){this.selectors[t].children[0].color=e},e.prototype._setSelectorButtonColor=function(t,e){this.selectors[t].children[1].color=e},e.prototype._setSelectorButtonBackground=function(t,e){this.selectors[t].children[1].background=e},e}(A),H=function(t){function e(e,i){void 0===i&&(i=[]);var o=t.call(this,e)||this;if(o.name=e,o.groups=i,o._buttonColor="#364249",o._buttonBackground="#CCCCCC",o._headerColor="black",o._barColor="white",o._barHeight="2px",o._spacerHeight="20px",o._bars=new Array,o._groups=i,o.thickness=2,o._panel=new B,o._panel.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,o._panel.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o._panel.top=5,o._panel.left=5,o._panel.width=.95,i.length>0){for(var n=0;n<i.length-1;n++)o._panel.addControl(i[n].groupPanel),o._addSpacer();o._panel.addControl(i[i.length-1].groupPanel)}return o.addControl(o._panel),o}return r(e,t),e.prototype._getTypeName=function(){return"SelectionPanel"},Object.defineProperty(e.prototype,"panel",{get:function(){return this._panel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headerColor",{get:function(){return this._headerColor},set:function(t){this._headerColor!==t&&(this._headerColor=t,this._setHeaderColor())},enumerable:!1,configurable:!0}),e.prototype._setHeaderColor=function(){for(var t=0;t<this._groups.length;t++)this._groups[t].groupPanel.children[0].color=this._headerColor},Object.defineProperty(e.prototype,"buttonColor",{get:function(){return this._buttonColor},set:function(t){this._buttonColor!==t&&(this._buttonColor=t,this._setbuttonColor())},enumerable:!1,configurable:!0}),e.prototype._setbuttonColor=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorButtonColor(e,this._buttonColor)},Object.defineProperty(e.prototype,"labelColor",{get:function(){return this._labelColor},set:function(t){this._labelColor!==t&&(this._labelColor=t,this._setLabelColor())},enumerable:!1,configurable:!0}),e.prototype._setLabelColor=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorLabelColor(e,this._labelColor)},Object.defineProperty(e.prototype,"buttonBackground",{get:function(){return this._buttonBackground},set:function(t){this._buttonBackground!==t&&(this._buttonBackground=t,this._setButtonBackground())},enumerable:!1,configurable:!0}),e.prototype._setButtonBackground=function(){for(var t=0;t<this._groups.length;t++)for(var e=0;e<this._groups[t].selectors.length;e++)this._groups[t]._setSelectorButtonBackground(e,this._buttonBackground)},Object.defineProperty(e.prototype,"barColor",{get:function(){return this._barColor},set:function(t){this._barColor!==t&&(this._barColor=t,this._setBarColor())},enumerable:!1,configurable:!0}),e.prototype._setBarColor=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].children[0].background=this._barColor},Object.defineProperty(e.prototype,"barHeight",{get:function(){return this._barHeight},set:function(t){this._barHeight!==t&&(this._barHeight=t,this._setBarHeight())},enumerable:!1,configurable:!0}),e.prototype._setBarHeight=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].children[0].height=this._barHeight},Object.defineProperty(e.prototype,"spacerHeight",{get:function(){return this._spacerHeight},set:function(t){this._spacerHeight!==t&&(this._spacerHeight=t,this._setSpacerHeight())},enumerable:!1,configurable:!0}),e.prototype._setSpacerHeight=function(){for(var t=0;t<this._bars.length;t++)this._bars[t].height=this._spacerHeight},e.prototype._addSpacer=function(){var t=new m;t.width=1,t.height=this._spacerHeight,t.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT;var e=new v;e.width=1,e.height=this._barHeight,e.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,e.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,e.background=this._barColor,e.color="transparent",t.addControl(e),this._panel.addControl(t),this._bars.push(t)},e.prototype.addGroup=function(t){this._groups.length>0&&this._addSpacer(),this._panel.addControl(t.groupPanel),this._groups.push(t),t.groupPanel.children[0].color=this._headerColor;for(var e=0;e<t.selectors.length;e++)t._setSelectorButtonColor(e,this._buttonColor),t._setSelectorButtonBackground(e,this._buttonBackground)},e.prototype.removeGroup=function(t){if(!(t<0||t>=this._groups.length)){var e=this._groups[t];this._panel.removeControl(e.groupPanel),this._groups.splice(t,1),t<this._bars.length&&(this._panel.removeControl(this._bars[t]),this._bars.splice(t,1))}},e.prototype.setHeaderName=function(t,e){e<0||e>=this._groups.length||(this._groups[e].groupPanel.children[0].text=t)},e.prototype.relabel=function(t,e,i){if(!(e<0||e>=this._groups.length)){var o=this._groups[e];i<0||i>=o.selectors.length||o._setSelectorLabel(i,t)}},e.prototype.removeFromGroupSelector=function(t,e){if(!(t<0||t>=this._groups.length)){var i=this._groups[t];e<0||e>=i.selectors.length||i.removeSelector(e)}},e.prototype.addToGroupCheckbox=function(t,e,i,o){void 0===i&&(i=function(){}),void 0===o&&(o=!1),t<0||t>=this._groups.length||this._groups[t].addCheckbox(e,i,o)},e.prototype.addToGroupRadio=function(t,e,i,o){void 0===i&&(i=function(){}),void 0===o&&(o=!1),t<0||t>=this._groups.length||this._groups[t].addRadio(e,i,o)},e.prototype.addToGroupSlider=function(t,e,i,o,n,r,a,s){void 0===i&&(i=function(){}),void 0===o&&(o="Units"),void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),void 0===s&&(s=function(t){return 0|t}),t<0||t>=this._groups.length||this._groups[t].addSlider(e,i,o,n,r,a,s)},e}(v),W=function(t){function e(e){var i=t.call(this,e)||this;return i._freezeControls=!1,i._bucketWidth=0,i._bucketHeight=0,i._buckets={},i}return r(e,t),Object.defineProperty(e.prototype,"freezeControls",{get:function(){return this._freezeControls},set:function(t){if(this._freezeControls!==t){t||this._restoreMeasures(),this._freezeControls=!1;var e=this.host.getSize(),i=e.width,o=e.height,n=this.host.getContext(),r=new d(0,0,i,o);this.host._numLayoutCalls=0,this.host._rootContainer._layout(r,n),t&&(this._updateMeasures(),this._useBuckets()&&this._makeBuckets()),this._freezeControls=t,this.host.markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketWidth",{get:function(){return this._bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketHeight",{get:function(){return this._bucketHeight},enumerable:!1,configurable:!0}),e.prototype.setBucketSizes=function(t,e){this._bucketWidth=t,this._bucketHeight=e,this._useBuckets()?this._freezeControls&&this._makeBuckets():this._buckets={}},e.prototype._useBuckets=function(){return this._bucketWidth>0&&this._bucketHeight>0},e.prototype._makeBuckets=function(){this._buckets={},this._bucketLen=Math.ceil(this.widthInPixels/this._bucketWidth),this._dispatchInBuckets(this._children),this._oldLeft=null,this._oldTop=null},e.prototype._dispatchInBuckets=function(t){for(var e=0;e<t.length;++e){for(var i=t[e],o=Math.max(0,Math.floor((i._customData._origLeft-this._customData.origLeft)/this._bucketWidth)),n=Math.floor((i._customData._origLeft-this._customData.origLeft+i._currentMeasure.width-1)/this._bucketWidth),r=Math.floor((i._customData._origTop-this._customData.origTop+i._currentMeasure.height-1)/this._bucketHeight),a=Math.max(0,Math.floor((i._customData._origTop-this._customData.origTop)/this._bucketHeight));a<=r;){for(var s=o;s<=n;++s){var l=a*this._bucketLen+s,_=this._buckets[l];_||(_=[],this._buckets[l]=_),_.push(i)}a++}i instanceof m&&i._children.length>0&&this._dispatchInBuckets(i._children)}},e.prototype._updateMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left-=t,this._measureForChildren.top-=e,this._currentMeasure.left-=t,this._currentMeasure.top-=e,this._customData.origLeftForChildren=this._measureForChildren.left,this._customData.origTopForChildren=this._measureForChildren.top,this._customData.origLeft=this._currentMeasure.left,this._customData.origTop=this._currentMeasure.top,this._updateChildrenMeasures(this._children,t,e)},e.prototype._updateChildrenMeasures=function(t,e,i){for(var o=0;o<t.length;++o){var n=t[o];n._currentMeasure.left-=e,n._currentMeasure.top-=i,n._customData._origLeft=n._currentMeasure.left,n._customData._origTop=n._currentMeasure.top,n instanceof m&&n._children.length>0&&this._updateChildrenMeasures(n._children,e,i)}},e.prototype._restoreMeasures=function(){var t=0|this.leftInPixels,e=0|this.topInPixels;this._measureForChildren.left=this._customData.origLeftForChildren+t,this._measureForChildren.top=this._customData.origTopForChildren+e,this._currentMeasure.left=this._customData.origLeft+t,this._currentMeasure.top=this._customData.origTop+e},e.prototype._getTypeName=function(){return"ScrollViewerWindow"},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._parentMeasure=e,this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=e.width,this._measureForChildren.height=e.height},e.prototype._layout=function(e,i){return this._freezeControls?(this.invalidateRect(),!1):t.prototype._layout.call(this,e,i)},e.prototype._scrollChildren=function(t,e,i){for(var o=0;o<t.length;++o){var n=t[o];n._currentMeasure.left=n._customData._origLeft+e,n._currentMeasure.top=n._customData._origTop+i,n._isClipped=!1,n instanceof m&&n._children.length>0&&this._scrollChildren(n._children,e,i)}},e.prototype._scrollChildrenWithBuckets=function(t,e,i,o){for(var n=Math.max(0,Math.floor(-t/this._bucketWidth)),r=Math.floor((-t+this._parentMeasure.width-1)/this._bucketWidth),a=Math.floor((-e+this._parentMeasure.height-1)/this._bucketHeight),s=Math.max(0,Math.floor(-e/this._bucketHeight));s<=a;){for(var l=n;l<=r;++l){var _=s*this._bucketLen+l,h=this._buckets[_];if(h)for(var c=0;c<h.length;++c){var u=h[c];u._currentMeasure.left=u._customData._origLeft+i,u._currentMeasure.top=u._customData._origTop+o,u._isClipped=!1}}s++}},e.prototype._draw=function(e,i){if(this._freezeControls){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);var o=0|this.leftInPixels,n=0|this.topInPixels;this._useBuckets()&&null!==this._oldLeft&&null!==this._oldTop?(this._scrollChildrenWithBuckets(this._oldLeft,this._oldTop,o,n),this._scrollChildrenWithBuckets(o,n,o,n)):this._scrollChildren(this._children,o,n),this._oldLeft=o,this._oldTop=n;for(var r=0,a=this._children;r<a.length;r++){var s=a[r];s._intersectsRect(this._parentMeasure)&&s._render(e,this._parentMeasure)}}else t.prototype._draw.call(this,e,i)},e.prototype._postMeasure=function(){if(this._freezeControls)t.prototype._postMeasure.call(this);else{for(var e=this.parentClientWidth,i=this.parentClientHeight,o=0,n=this.children;o<n.length;o++){var r=n[o];r.isVisible&&!r.notRenderable&&(r.horizontalAlignment===g.HORIZONTAL_ALIGNMENT_CENTER&&r._offsetLeft(this._currentMeasure.left-r._currentMeasure.left),r.verticalAlignment===g.VERTICAL_ALIGNMENT_CENTER&&r._offsetTop(this._currentMeasure.top-r._currentMeasure.top),e=Math.max(e,r._currentMeasure.left-this._currentMeasure.left+r._currentMeasure.width+r.paddingRightInPixels),i=Math.max(i,r._currentMeasure.top-this._currentMeasure.top+r._currentMeasure.height+r.paddingBottomInPixels))}this._currentMeasure.width!==e&&(this._width.updateInPlace(e,l.UNITMODE_PIXEL),this._currentMeasure.width=e,this._rebuildLayout=!0,this._isDirty=!0),this._currentMeasure.height!==i&&(this._height.updateInPlace(i,l.UNITMODE_PIXEL),this._currentMeasure.height=i,this._rebuildLayout=!0,this._isDirty=!0),t.prototype._postMeasure.call(this)}},e}(m),G=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._background="black",i._borderColor="white",i._tempMeasure=new d(0,0,0,0),i}return r(e,t),Object.defineProperty(e.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"Scrollbar"},e.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._renderLeft,i=this._getThumbPosition();t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),t.fillStyle=this.color,this.isVertical?(this._tempMeasure.left=e-this._effectiveBarOffset,this._tempMeasure.top=this._currentMeasure.top+i,this._tempMeasure.width=this._currentMeasure.width,this._tempMeasure.height=this._effectiveThumbThickness):(this._tempMeasure.left=this._currentMeasure.left+i,this._tempMeasure.top=this._currentMeasure.top,this._tempMeasure.width=this._effectiveThumbThickness,this._tempMeasure.height=this._currentMeasure.height),t.fillRect(this._tempMeasure.left,this._tempMeasure.top,this._tempMeasure.width,this._tempMeasure.height),t.restore()},e.prototype._updateValueFromPointer=function(t,e){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=t,this._originY=e,(t<this._tempMeasure.left||t>this._tempMeasure.left+this._tempMeasure.width||e<this._tempMeasure.top||e>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,o,n,r){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,o,n,r)},a([(0,s.serialize)()],e.prototype,"borderColor",null),a([(0,s.serialize)()],e.prototype,"background",null),e}(N),U=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thumbLength=.5,i._thumbHeight=1,i._barImageHeight=1,i._tempMeasure=new d(0,0,0,0),i.num90RotationInVerticalMode=1,i}return r(e,t),Object.defineProperty(e.prototype,"backgroundImage",{get:function(){return this._backgroundBaseImage},set:function(t){var e=this;this._backgroundBaseImage!==t&&(this._backgroundBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._backgroundImage=t._rotate90(this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(e.num90RotationInVerticalMode,!0);e._backgroundImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._backgroundImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._thumbBaseImage},set:function(t){var e=this;this._thumbBaseImage!==t&&(this._thumbBaseImage=t,this.isVertical&&0!==this.num90RotationInVerticalMode?t.isLoaded?(this._thumbImage=t._rotate90(-this.num90RotationInVerticalMode,!0),this._markAsDirty()):t.onImageLoadedObservable.addOnce((function(){var i=t._rotate90(-e.num90RotationInVerticalMode,!0);e._thumbImage=i,i.isLoaded||i.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),e._markAsDirty()})):(this._thumbImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){e._markAsDirty()})),this._markAsDirty()))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){this._thumbLength!==t&&(this._thumbLength=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){this._thumbLength!==t&&(this._thumbHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){this._barImageHeight!==t&&(this._barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ImageScrollBar"},e.prototype._getThumbThickness=function(){return this._thumbWidth.isPixel?this._thumbWidth.getValue(this._host):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._getThumbPosition(),i=this._renderLeft,o=this._renderTop,n=this._renderWidth,r=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(i,o,n,r),this.isVertical?(this._tempMeasure.copyFromFloats(i+n*(1-this._barImageHeight)*.5,this._currentMeasure.top,n*this._barImageHeight,r),this._tempMeasure.height+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)):(this._tempMeasure.copyFromFloats(this._currentMeasure.left,o+r*(1-this._barImageHeight)*.5,n,r*this._barImageHeight),this._tempMeasure.width+=this._effectiveThumbThickness,this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure)),this._backgroundImage._draw(t)),this.isVertical?this._tempMeasure.copyFromFloats(i-this._effectiveBarOffset+this._currentMeasure.width*(1-this._thumbHeight)*.5,this._currentMeasure.top+e,this._currentMeasure.width*this._thumbHeight,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+e,this._currentMeasure.top+this._currentMeasure.height*(1-this._thumbHeight)*.5,this._effectiveThumbThickness,this._currentMeasure.height*this._thumbHeight),this._thumbImage&&(this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(t)),t.restore()},e.prototype._updateValueFromPointer=function(t,e){0!=this.rotation&&(this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y),this._first&&(this._first=!1,this._originX=t,this._originY=e,(t<this._tempMeasure.left||t>this._tempMeasure.left+this._tempMeasure.width||e<this._tempMeasure.top||e>this._tempMeasure.top+this._tempMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(e-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var i;i=this.isVertical?-(e-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(t-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=i*(this.maximum-this.minimum),this._originX=t,this._originY=e},e.prototype._onPointerDown=function(e,i,o,n,r){return this._first=!0,t.prototype._onPointerDown.call(this,e,i,o,n,r)},a([(0,s.serialize)()],e.prototype,"num90RotationInVerticalMode",void 0),e}(N),j=function(t){function e(e,i){var o=t.call(this,e)||this;return o._barSize=20,o._pointerIsOver=!1,o._wheelPrecision=.05,o._thumbLength=.5,o._thumbHeight=1,o._barImageHeight=1,o._horizontalBarImageHeight=1,o._verticalBarImageHeight=1,o._oldWindowContentsWidth=0,o._oldWindowContentsHeight=0,o._forceHorizontalBar=!1,o._forceVerticalBar=!1,o._useImageBar=i||!1,o.onDirtyObservable.add((function(){o._horizontalBarSpace.color=o.color,o._verticalBarSpace.color=o.color,o._dragSpace.color=o.color})),o.onPointerEnterObservable.add((function(){o._pointerIsOver=!0})),o.onPointerOutObservable.add((function(){o._pointerIsOver=!1})),o._grid=new I,o._useImageBar?(o._horizontalBar=new U,o._verticalBar=new U):(o._horizontalBar=new G,o._verticalBar=new G),o._window=new W("scrollViewer_window"),o._window.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o._window.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,o._grid.addColumnDefinition(1),o._grid.addColumnDefinition(0,!0),o._grid.addRowDefinition(1),o._grid.addRowDefinition(0,!0),t.prototype.addControl.call(o,o._grid),o._grid.addControl(o._window,0,0),o._verticalBarSpace=new v,o._verticalBarSpace.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o._verticalBarSpace.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,o._verticalBarSpace.thickness=1,o._grid.addControl(o._verticalBarSpace,0,1),o._addBar(o._verticalBar,o._verticalBarSpace,!0,Math.PI),o._horizontalBarSpace=new v,o._horizontalBarSpace.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,o._horizontalBarSpace.verticalAlignment=g.VERTICAL_ALIGNMENT_TOP,o._horizontalBarSpace.thickness=1,o._grid.addControl(o._horizontalBarSpace,1,0),o._addBar(o._horizontalBar,o._horizontalBarSpace,!1,0),o._dragSpace=new v,o._dragSpace.thickness=1,o._grid.addControl(o._dragSpace,1,1),o._useImageBar||(o.barColor="grey",o.barBackground="transparent"),o}return r(e,t),Object.defineProperty(e.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!1,configurable:!0}),e.prototype.addControl=function(t){return t?(this._window.addControl(t),this):this},e.prototype.removeControl=function(t){return this._window.removeControl(t),this},Object.defineProperty(e.prototype,"children",{get:function(){return this._window.children},enumerable:!1,configurable:!0}),e.prototype._flagDescendantsAsMatrixDirty=function(){for(var t=0,e=this._children;t<e.length;t++)e[t]._markMatrixAsDirty()},Object.defineProperty(e.prototype,"freezeControls",{get:function(){return this._window.freezeControls},set:function(t){this._window.freezeControls=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketWidth",{get:function(){return this._window.bucketWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bucketHeight",{get:function(){return this._window.bucketHeight},enumerable:!1,configurable:!0}),e.prototype.setBucketSizes=function(t,e){this._window.setBucketSizes(t,e)},Object.defineProperty(e.prototype,"forceHorizontalBar",{get:function(){return this._forceHorizontalBar},set:function(t){this._grid.setRowDefinition(1,t?this._barSize:0,!0),this._horizontalBar.isVisible=t,this._forceHorizontalBar=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forceVerticalBar",{get:function(){return this._forceVerticalBar},set:function(t){this._grid.setColumnDefinition(1,t?this._barSize:0,!0),this._verticalBar.isVisible=t,this._forceVerticalBar=t},enumerable:!1,configurable:!0}),e.prototype.resetWindow=function(){this._window.width="100%",this._window.height="100%"},e.prototype._getTypeName=function(){return"ScrollViewer"},e.prototype._buildClientSizes=function(){var t=this.host.idealRatio;this._window.parentClientWidth=this._currentMeasure.width-(this._verticalBar.isVisible||this.forceVerticalBar?this._barSize*t:0)-2*this.thickness,this._window.parentClientHeight=this._currentMeasure.height-(this._horizontalBar.isVisible||this.forceHorizontalBar?this._barSize*t:0)-2*this.thickness,this._clientWidth=this._window.parentClientWidth,this._clientHeight=this._window.parentClientHeight},e.prototype._additionalProcessing=function(e,i){t.prototype._additionalProcessing.call(this,e,i),this._buildClientSizes()},e.prototype._postMeasure=function(){t.prototype._postMeasure.call(this),this._updateScroller(),this._setWindowPosition(!1)},Object.defineProperty(e.prototype,"wheelPrecision",{get:function(){return this._wheelPrecision},set:function(t){this._wheelPrecision!==t&&(t<0&&(t=0),t>1&&(t=1),this._wheelPrecision=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scrollBackground",{get:function(){return this._horizontalBarSpace.background},set:function(t){this._horizontalBarSpace.background!==t&&(this._horizontalBarSpace.background=t,this._verticalBarSpace.background=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barColor",{get:function(){return this._barColor},set:function(t){this._barColor!==t&&(this._barColor=t,this._horizontalBar.color=t,this._verticalBar.color=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._barImage},set:function(t){if(this._barImage!==t){this._barImage=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbImage=t,i.thumbImage=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalThumbImage",{get:function(){return this._horizontalBarImage},set:function(t){this._horizontalBarImage!==t&&(this._horizontalBarImage=t,this._horizontalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalThumbImage",{get:function(){return this._verticalBarImage},set:function(t){this._verticalBarImage!==t&&(this._verticalBarImage=t,this._verticalBar.thumbImage=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barSize",{get:function(){return this._barSize},set:function(t){this._barSize!==t&&(this._barSize=t,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbLength",{get:function(){return this._thumbLength},set:function(t){if(this._thumbLength!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbLength=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbLength=t,i.thumbLength=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbHeight",{get:function(){return this._thumbHeight},set:function(t){if(this._thumbHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._thumbHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.thumbHeight=t,i.thumbHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImageHeight",{get:function(){return this._barImageHeight},set:function(t){if(this._barImageHeight!==t){t<=0&&(t=.1),t>1&&(t=1),this._barImageHeight=t;var e=this._horizontalBar,i=this._verticalBar;e.barImageHeight=t,i.barImageHeight=t,this._markAsDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImageHeight",{get:function(){return this._horizontalBarImageHeight},set:function(t){this._horizontalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._horizontalBarImageHeight=t,this._horizontalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImageHeight",{get:function(){return this._verticalBarImageHeight},set:function(t){this._verticalBarImageHeight!==t&&(t<=0&&(t=.1),t>1&&(t=1),this._verticalBarImageHeight=t,this._verticalBar.barImageHeight=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barBackground",{get:function(){return this._barBackground},set:function(t){if(this._barBackground!==t){this._barBackground=t;var e=this._horizontalBar,i=this._verticalBar;e.background=t,i.background=t,this._dragSpace.background=t}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"barImage",{get:function(){return this._barBackgroundImage},set:function(t){this._barBackgroundImage=t;var e=this._horizontalBar,i=this._verticalBar;e.backgroundImage=t,i.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"horizontalBarImage",{get:function(){return this._horizontalBarBackgroundImage},set:function(t){this._horizontalBarBackgroundImage=t,this._horizontalBar.backgroundImage=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"verticalBarImage",{get:function(){return this._verticalBarBackgroundImage},set:function(t){this._verticalBarBackgroundImage=t,this._verticalBar.backgroundImage=t},enumerable:!1,configurable:!0}),e.prototype._setWindowPosition=function(t){void 0===t&&(t=!0);var e=this.host.idealRatio,i=this._window._currentMeasure.width,o=this._window._currentMeasure.height;if(t||this._oldWindowContentsWidth!==i||this._oldWindowContentsHeight!==o){this._oldWindowContentsWidth=i,this._oldWindowContentsHeight=o;var n=this._clientWidth-i,r=this._clientHeight-o,a=this._horizontalBar.value/e*n+"px",s=this._verticalBar.value/e*r+"px";a!==this._window.left&&(this._window.left=a,this.freezeControls||(this._rebuildLayout=!0)),s!==this._window.top&&(this._window.top=s,this.freezeControls||(this._rebuildLayout=!0))}},e.prototype._updateScroller=function(){var t=this._window._currentMeasure.width,e=this._window._currentMeasure.height;this._horizontalBar.isVisible&&t<=this._clientWidth&&!this.forceHorizontalBar?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&(t>this._clientWidth||this.forceHorizontalBar)&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&e<=this._clientHeight&&!this.forceVerticalBar?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&(e>this._clientHeight||this.forceVerticalBar)&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes();var i=this.host.idealRatio;this._horizontalBar.thumbWidth=.9*this._thumbLength*(this._clientWidth/i)+"px",this._verticalBar.thumbWidth=.9*this._thumbLength*(this._clientHeight/i)+"px"},e.prototype._link=function(e){t.prototype._link.call(this,e),this._attachWheel()},e.prototype._addBar=function(t,e,i,o){var n=this;t.paddingLeft=0,t.width="100%",t.height="100%",t.barOffset=0,t.value=0,t.maximum=1,t.horizontalAlignment=g.HORIZONTAL_ALIGNMENT_CENTER,t.verticalAlignment=g.VERTICAL_ALIGNMENT_CENTER,t.isVertical=i,t.rotation=o,t.isVisible=!1,e.addControl(t),t.onValueChangedObservable.add((function(){n._setWindowPosition()}))},e.prototype._attachWheel=function(){var t=this;this._host&&!this._onWheelObserver&&(this._onWheelObserver=this.onWheelObservable.add((function(e){t._pointerIsOver&&!t.isReadOnly&&(1==t._verticalBar.isVisible&&(e.y<0&&t._verticalBar.value>0?t._verticalBar.value-=t._wheelPrecision:e.y>0&&t._verticalBar.value<t._verticalBar.maximum&&(t._verticalBar.value+=t._wheelPrecision)),1==t._horizontalBar.isVisible&&(e.x<0&&t._horizontalBar.value<t._horizontalBar.maximum?t._horizontalBar.value+=t._wheelPrecision:e.x>0&&t._horizontalBar.value>0&&(t._horizontalBar.value-=t._wheelPrecision)))})))},e.prototype._renderHighlightSpecific=function(e){this.isHighlighted&&(t.prototype._renderHighlightSpecific.call(this,e),this._grid._renderHighlightSpecific(e),e.restore())},e.prototype.dispose=function(){this.onWheelObservable.remove(this._onWheelObserver),this._onWheelObserver=null,t.prototype.dispose.call(this)},e}(v);(0,s.RegisterClass)("BABYLON.GUI.ScrollViewer",j);var X=function(t){function e(e,i){var o=t.call(this,e)||this;o.name=e,o.onIsActiveChangedObservable=new s.Observable,o.delegatePickingToChildren=!1,o._isActive=!1,o.group=null!=i?i:"",o.thickness=0,o.isPointerBlocker=!0;var n=null;return o.toActiveAnimation=function(){o.thickness=1},o.toInactiveAnimation=function(){o.thickness=0},o.pointerEnterActiveAnimation=function(){n=o.alpha,o.alpha-=.1},o.pointerOutActiveAnimation=function(){null!==n&&(o.alpha=n)},o.pointerDownActiveAnimation=function(){o.scaleX-=.05,o.scaleY-=.05},o.pointerUpActiveAnimation=function(){o.scaleX+=.05,o.scaleY+=.05},o.pointerEnterInactiveAnimation=function(){n=o.alpha,o.alpha-=.1},o.pointerOutInactiveAnimation=function(){null!==n&&(o.alpha=n)},o.pointerDownInactiveAnimation=function(){o.scaleX-=.05,o.scaleY-=.05},o.pointerUpInactiveAnimation=function(){o.scaleX+=.05,o.scaleY+=.05},o}return r(e,t),Object.defineProperty(e.prototype,"group",{get:function(){return this._group},set:function(t){this._group!==t&&(this._group=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isActive",{get:function(){return this._isActive},set:function(t){var e,i,o=this;this._isActive!==t&&(this._isActive=t,this._isActive?null===(e=this.toActiveAnimation)||void 0===e||e.call(this):null===(i=this.toInactiveAnimation)||void 0===i||i.call(this),this._markAsDirty(),this.onIsActiveChangedObservable.notifyObservers(t),this._isActive&&this._host&&this._group&&this._host.executeOnAllControls((function(t){if("ToggleButton"===t.typeName){if(t===o)return;var e=t;e.group===o.group&&(e.isActive=!1)}})))},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ToggleButton"},e.prototype._processPicking=function(e,i,o,n,r,a,s,l){if(!this._isEnabled||!this.isHitTestVisible||!this.isVisible||this.notRenderable)return!1;if(!t.prototype.contains.call(this,e,i))return!1;if(this.delegatePickingToChildren){for(var _=!1,h=this._children.length-1;h>=0;h--){var c=this._children[h];if(c.isEnabled&&c.isHitTestVisible&&c.isVisible&&!c.notRenderable&&c.contains(e,i)){_=!0;break}}if(!_)return!1}return this._processObservables(n,e,i,o,r,a,s,l),!0},e.prototype._onPointerEnter=function(e,i){return!!t.prototype._onPointerEnter.call(this,e,i)&&(this.isReadOnly||(this._isActive?this.pointerEnterActiveAnimation&&this.pointerEnterActiveAnimation():this.pointerEnterInactiveAnimation&&this.pointerEnterInactiveAnimation()),!0)},e.prototype._onPointerOut=function(e,i,o){void 0===o&&(o=!1),this.isReadOnly||(this._isActive?this.pointerOutActiveAnimation&&this.pointerOutActiveAnimation():this.pointerOutInactiveAnimation&&this.pointerOutInactiveAnimation()),t.prototype._onPointerOut.call(this,e,i,o)},e.prototype._onPointerDown=function(e,i,o,n,r){return!!t.prototype._onPointerDown.call(this,e,i,o,n,r)&&(this.isReadOnly||(this._isActive?this.pointerDownActiveAnimation&&this.pointerDownActiveAnimation():this.pointerDownInactiveAnimation&&this.pointerDownInactiveAnimation()),!0)},e.prototype._onPointerUp=function(e,i,o,n,r,a){this.isReadOnly||(this._isActive?this.pointerUpActiveAnimation&&this.pointerUpActiveAnimation():this.pointerUpInactiveAnimation&&this.pointerUpInactiveAnimation()),t.prototype._onPointerUp.call(this,e,i,o,n,r,a)},e}(v);(0,s.RegisterClass)("BABYLON.GUI.ToggleButton",X);var Y=function(){},K=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.onKeyPressObservable=new s.Observable,e.defaultButtonWidth="40px",e.defaultButtonHeight="40px",e.defaultButtonPaddingLeft="2px",e.defaultButtonPaddingRight="2px",e.defaultButtonPaddingTop="2px",e.defaultButtonPaddingBottom="2px",e.defaultButtonColor="#DDD",e.defaultButtonBackground="#070707",e.shiftButtonColor="#7799FF",e.selectedShiftThickness=1,e.shiftState=0,e._currentlyConnectedInputText=null,e._connectedInputTexts=[],e._onKeyPressObserver=null,e}return r(e,t),e.prototype._getTypeName=function(){return"VirtualKeyboard"},e.prototype._createKey=function(t,e){var i=this,o=P.CreateSimpleButton(t,t);return o.width=e&&e.width?e.width:this.defaultButtonWidth,o.height=e&&e.height?e.height:this.defaultButtonHeight,o.color=e&&e.color?e.color:this.defaultButtonColor,o.background=e&&e.background?e.background:this.defaultButtonBackground,o.paddingLeft=e&&e.paddingLeft?e.paddingLeft:this.defaultButtonPaddingLeft,o.paddingRight=e&&e.paddingRight?e.paddingRight:this.defaultButtonPaddingRight,o.paddingTop=e&&e.paddingTop?e.paddingTop:this.defaultButtonPaddingTop,o.paddingBottom=e&&e.paddingBottom?e.paddingBottom:this.defaultButtonPaddingBottom,o.thickness=0,o.isFocusInvisible=!0,o.shadowColor=this.shadowColor,o.shadowBlur=this.shadowBlur,o.shadowOffsetX=this.shadowOffsetX,o.shadowOffsetY=this.shadowOffsetY,o.onPointerUpObservable.add((function(){i.onKeyPressObservable.notifyObservers(t)})),o},e.prototype.addKeysRow=function(t,e){var i=new B;i.isVertical=!1,i.isFocusInvisible=!0;for(var o=null,n=0;n<t.length;n++){var r=null;e&&e.length===t.length&&(r=e[n]);var a=this._createKey(t[n],r);(!o||a.heightInPixels>o.heightInPixels)&&(o=a),i.addControl(a)}i.height=o?o.height:this.defaultButtonHeight,this.addControl(i)},e.prototype.applyShiftState=function(t){if(this.children)for(var e=0;e<this.children.length;e++){var i=this.children[e];if(i&&i.children)for(var o=i,n=0;n<o.children.length;n++){var r=o.children[n];if(r&&r.children[0]){var a=r.children[0];"⇧"===a.text&&(r.color=t?this.shiftButtonColor:this.defaultButtonColor,r.thickness=t>1?this.selectedShiftThickness:0),a.text=t>0?a.text.toUpperCase():a.text.toLowerCase()}}}},Object.defineProperty(e.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!1,configurable:!0}),e.prototype.connect=function(t){var e=this;if(!this._connectedInputTexts.some((function(e){return e.input===t}))){null===this._onKeyPressObserver&&(this._onKeyPressObserver=this.onKeyPressObservable.add((function(t){if(e._currentlyConnectedInputText){switch(e._currentlyConnectedInputText._host.focusedControl=e._currentlyConnectedInputText,t){case"⇧":return e.shiftState++,e.shiftState>2&&(e.shiftState=0),void e.applyShiftState(e.shiftState);case"←":return void e._currentlyConnectedInputText.processKey(8);case"↵":return void e._currentlyConnectedInputText.processKey(13)}e._currentlyConnectedInputText.processKey(-1,e.shiftState?t.toUpperCase():t),1===e.shiftState&&(e.shiftState=0,e.applyShiftState(e.shiftState))}}))),this.isVisible=!1,this._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=this;var i=t.onFocusObservable.add((function(){e._currentlyConnectedInputText=t,t._connectedVirtualKeyboard=e,e.isVisible=!0})),o=t.onBlurObservable.add((function(){t._connectedVirtualKeyboard=null,e._currentlyConnectedInputText=null,e.isVisible=!1}));this._connectedInputTexts.push({input:t,onBlurObserver:o,onFocusObserver:i})}},e.prototype.disconnect=function(t){var e=this;if(t){var i=this._connectedInputTexts.filter((function(e){return e.input===t}));1===i.length&&(this._removeConnectedInputObservables(i[0]),this._connectedInputTexts=this._connectedInputTexts.filter((function(e){return e.input!==t})),this._currentlyConnectedInputText===t&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach((function(t){e._removeConnectedInputObservables(t)})),this._connectedInputTexts=[];0===this._connectedInputTexts.length&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},e.prototype._removeConnectedInputObservables=function(t){t.input._connectedVirtualKeyboard=null,t.input.onFocusObservable.remove(t.onFocusObserver),t.input.onBlurObservable.remove(t.onBlurObserver)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.disconnect()},e.CreateDefaultLayout=function(t){var i=new e(t);return i.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),i.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),i.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),i.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),i.addKeysRow([" "],[{width:"200px"}]),i},e.prototype._parseFromContent=function(e,i){var o=this;t.prototype._parseFromContent.call(this,e,i);for(var n=0,r=this.children;n<r.length;n++){var a=r[n];if("StackPanel"===a.getClassName())for(var s=function(t){"Button"===t.getClassName()&&t.name&&t.onPointerUpObservable.add((function(){o.onKeyPressObservable.notifyObservers(t.name)}))},l=0,_=a.children;l<_.length;l++)s(_[l])}},e}(B);(0,s.RegisterClass)("BABYLON.GUI.VirtualKeyboard",K);var Z=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._cellWidth=20,i._cellHeight=20,i._minorLineTickness=1,i._minorLineColor="DarkGray",i._majorLineTickness=2,i._majorLineColor="White",i._majorLineFrequency=5,i._background="Black",i._displayMajorLines=!0,i._displayMinorLines=!0,i}return r(e,t),Object.defineProperty(e.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(t){this._displayMinorLines!==t&&(this._displayMinorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(t){this._displayMajorLines!==t&&(this._displayMajorLines=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(t){this._minorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(t){this._minorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(t){this._majorLineTickness=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(t){this._majorLineColor=t,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(t){this._majorLineFrequency=t,this._markAsDirty()},enumerable:!1,configurable:!0}),e.prototype._draw=function(t){if(t.save(),this._applyStates(t),this._isEnabled){this._background&&(t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var e=this._currentMeasure.width/this._cellWidth,i=this._currentMeasure.height/this._cellHeight,o=this._currentMeasure.left+this._currentMeasure.width/2,n=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){t.strokeStyle=this._minorLineColor,t.lineWidth=this._minorLineTickness;for(var r=-e/2+1;r<e/2;r++){var a=o+r*this.cellWidth;t.beginPath(),t.moveTo(a,this._currentMeasure.top),t.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),t.stroke()}for(var s=-i/2+1;s<i/2;s++){var l=n+s*this.cellHeight;t.beginPath(),t.moveTo(this._currentMeasure.left,l),t.lineTo(this._currentMeasure.left+this._currentMeasure.width,l),t.stroke()}}if(this._displayMajorLines){for(t.strokeStyle=this._majorLineColor,t.lineWidth=this._majorLineTickness,r=-e/2+this._majorLineFrequency;r<e/2;r+=this._majorLineFrequency)a=o+r*this.cellWidth,t.beginPath(),t.moveTo(a,this._currentMeasure.top),t.lineTo(a,this._currentMeasure.top+this._currentMeasure.height),t.stroke();for(s=-i/2+this._majorLineFrequency;s<i/2;s+=this._majorLineFrequency)l=n+s*this.cellHeight,t.moveTo(this._currentMeasure.left,l),t.lineTo(this._currentMeasure.left+this._currentMeasure.width,l),t.closePath(),t.stroke()}}t.restore()},e.prototype._getTypeName=function(){return"DisplayGrid"},a([(0,s.serialize)()],e.prototype,"displayMinorLines",null),a([(0,s.serialize)()],e.prototype,"displayMajorLines",null),a([(0,s.serialize)()],e.prototype,"background",null),a([(0,s.serialize)()],e.prototype,"cellWidth",null),a([(0,s.serialize)()],e.prototype,"cellHeight",null),a([(0,s.serialize)()],e.prototype,"minorLineTickness",null),a([(0,s.serialize)()],e.prototype,"minorLineColor",null),a([(0,s.serialize)()],e.prototype,"majorLineTickness",null),a([(0,s.serialize)()],e.prototype,"majorLineColor",null),a([(0,s.serialize)()],e.prototype,"majorLineFrequency",null),e}(g);(0,s.RegisterClass)("BABYLON.GUI.DisplayGrid",Z);var q=function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._tempMeasure=new d(0,0,0,0),i}return r(e,t),Object.defineProperty(e.prototype,"displayThumb",{get:function(){return this._displayThumb&&null!=this.thumbImage},set:function(t){this._displayThumb!==t&&(this._displayThumb=t,this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backgroundImage",{get:function(){return this._backgroundImage},set:function(t){var e=this;this._backgroundImage!==t&&(this._backgroundImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueBarImage",{get:function(){return this._valueBarImage},set:function(t){var e=this;this._valueBarImage!==t&&(this._valueBarImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thumbImage",{get:function(){return this._thumbImage},set:function(t){var e=this;this._thumbImage!==t&&(this._thumbImage=t,t&&!t.isLoaded&&t.onImageLoadedObservable.addOnce((function(){return e._markAsDirty()})),this._markAsDirty())},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"ImageBasedSlider"},e.prototype._draw=function(t){t.save(),this._applyStates(t),this._prepareRenderingData("rectangle");var e=this._getThumbPosition(),i=this._renderLeft,o=this._renderTop,n=this._renderWidth,r=this._renderHeight;this._backgroundImage&&(this._tempMeasure.copyFromFloats(i,o,n,r),this.isThumbClamped&&this.displayThumb&&(this.isVertical?this._tempMeasure.height+=this._effectiveThumbThickness:this._tempMeasure.width+=this._effectiveThumbThickness),this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure),this._backgroundImage._draw(t)),this._valueBarImage&&(this.isVertical?this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(i,o+e,n,r-e+this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(i,o+e,n,r-e):this.isThumbClamped&&this.displayThumb?this._tempMeasure.copyFromFloats(i,o,e+this._effectiveThumbThickness/2,r):this._tempMeasure.copyFromFloats(i,o,e,r),this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure),this._valueBarImage._draw(t)),this.displayThumb&&(this.isVertical?this._tempMeasure.copyFromFloats(i-this._effectiveBarOffset,this._currentMeasure.top+e,this._currentMeasure.width,this._effectiveThumbThickness):this._tempMeasure.copyFromFloats(this._currentMeasure.left+e,this._currentMeasure.top,this._effectiveThumbThickness,this._currentMeasure.height),this._thumbImage._currentMeasure.copyFrom(this._tempMeasure),this._thumbImage._draw(t)),t.restore()},e.prototype.serialize=function(e){t.prototype.serialize.call(this,e);var i={},o={},n={};this.backgroundImage.serialize(i),this.thumbImage.serialize(o),this.valueBarImage.serialize(n),e.backgroundImage=i,e.thumbImage=o,e.valueBarImage=n},e.prototype._parseFromContent=function(e,i){t.prototype._parseFromContent.call(this,e,i),this.backgroundImage=x.Parse(e.backgroundImage,i),this.thumbImage=x.Parse(e.thumbImage,i),this.valueBarImage=x.Parse(e.valueBarImage,i)},a([(0,s.serialize)()],e.prototype,"displayThumb",null),e}(N);(0,s.RegisterClass)("BABYLON.GUI.ImageBasedSlider",q);var J="Statics";g.AddHeader=function(t,e,i,o){var n=new B("panel"),r=!o||o.isHorizontal,a=!o||o.controlFirst;n.isVertical=!r;var s=new y("header");return s.text=e,s.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,r?s.width=i:s.height=i,a?(n.addControl(t),n.addControl(s),s.paddingLeft="5px"):(n.addControl(s),n.addControl(t),s.paddingRight="5px"),s.shadowBlur=t.shadowBlur,s.shadowColor=t.shadowColor,s.shadowOffsetX=t.shadowOffsetX,s.shadowOffsetY=t.shadowOffsetY,n};var $=function(){function t(t){this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new l(18,l.UNITMODE_PIXEL,!1),this.onChangedObservable=new s.Observable,this._host=t}return Object.defineProperty(t.prototype,"fontSize",{get:function(){return this._fontSize.toString(this._host)},set:function(t){this._fontSize.toString(this._host)!==t&&this._fontSize.fromString(t)&&this.onChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChangedObservable.notifyObservers(this))},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onChangedObservable.clear()},t}(),tt=function(t){function e(e,i,o,n,r,a,l){void 0===i&&(i=0),void 0===o&&(o=0),void 0===r&&(r=!1),void 0===a&&(a=s.Texture.NEAREST_SAMPLINGMODE),void 0===l&&(l=!0);var _=t.call(this,e,{width:i,height:o},n,r,a,s.Constants.TEXTUREFORMAT_RGBA,l)||this;return _._isDirty=!1,_._rootContainer=new m("root"),_._lastControlOver={},_._lastControlDown={},_._capturingControl={},_._linkedControls=new Array,_._isFullscreen=!1,_._fullscreenViewport=new s.Viewport(0,0,1,1),_._idealWidth=0,_._idealHeight=0,_._useSmallestIdeal=!1,_._renderAtIdealSize=!1,_._blockNextFocusCheck=!1,_._renderScale=1,_._cursorChanged=!1,_._defaultMousePointerId=0,_._numLayoutCalls=0,_._numRenderCalls=0,_._clipboardData="",_.onClipboardObservable=new s.Observable,_.onControlPickedObservable=new s.Observable,_.onBeginLayoutObservable=new s.Observable,_.onEndLayoutObservable=new s.Observable,_.onBeginRenderObservable=new s.Observable,_.onEndRenderObservable=new s.Observable,_.premulAlpha=!1,_.applyYInversionOnUpdate=!0,_.checkPointerEveryFrame=!1,_._useInvalidateRectOptimization=!0,_._invalidatedRectangle=null,_._clearMeasure=new d(0,0,0,0),_._onClipboardCopy=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.COPY,e);_.onClipboardObservable.notifyObservers(i),e.preventDefault()},_._onClipboardCut=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.CUT,e);_.onClipboardObservable.notifyObservers(i),e.preventDefault()},_._onClipboardPaste=function(t){var e=t,i=new s.ClipboardInfo(s.ClipboardEventTypes.PASTE,e);_.onClipboardObservable.notifyObservers(i),e.preventDefault()},(n=_.getScene())&&_._texture?(_.applyYInversionOnUpdate=l,_._rootElement=n.getEngine().getInputElement(),_._renderObserver=n.onBeforeCameraRenderObservable.add((function(t){return _._checkUpdate(t)})),_._preKeyboardObserver=n.onPreKeyboardObservable.add((function(t){_._focusedControl&&(t.type===s.KeyboardEventTypes.KEYDOWN&&_._focusedControl.processKeyboard(t.event),t.skipOnPointerObservable=!0)})),_._rootContainer._link(_),_.hasAlpha=!0,i&&o||(_._resizeObserver=n.getEngine().onResizeObservable.add((function(){return _._onResize()})),_._onResize()),_._texture.isReady=!0,_):_}return r(e,t),Object.defineProperty(e.prototype,"numLayoutCalls",{get:function(){return this._numLayoutCalls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numRenderCalls",{get:function(){return this._numRenderCalls},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderScale",{get:function(){return this._renderScale},set:function(t){t!==this._renderScale&&(this._renderScale=t,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this.markAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(t){this._idealWidth!==t&&(this._idealWidth=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(t){this._idealHeight!==t&&(this._idealHeight=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useSmallestIdeal",{get:function(){return this._useSmallestIdeal},set:function(t){this._useSmallestIdeal!==t&&(this._useSmallestIdeal=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(t){this._renderAtIdealSize!==t&&(this._renderAtIdealSize=t,this._onResize())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idealRatio",{get:function(){var t=0,e=0;return this._idealWidth&&(t=this.getSize().width/this._idealWidth),this._idealHeight&&(e=this.getSize().height/this._idealHeight),this._useSmallestIdeal&&this._idealWidth&&this._idealHeight?window.innerWidth<window.innerHeight?t:e:this._idealWidth?t:this._idealHeight?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),e.prototype.getChildren=function(){return[this._rootContainer]},e.prototype.getDescendants=function(t,e){return this._rootContainer.getDescendants(t,e)},e.prototype.getControlsByType=function(t){return this._rootContainer.getDescendants(!1,(function(e){return e.typeName===t}))},e.prototype.getControlByName=function(t){return this._getControlByKey("name",t)},e.prototype._getControlByKey=function(t,e){return this._rootContainer.getDescendants().find((function(i){return i[t]===e}))||null},Object.defineProperty(e.prototype,"focusedControl",{get:function(){return this._focusedControl},set:function(t){this._focusedControl!=t&&(this._focusedControl&&this._focusedControl.onBlur(),t&&t.onFocus(),this._focusedControl=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isForeground",{get:function(){return!this.layer||!this.layer.isBackground},set:function(t){this.layer&&this.layer.isBackground!==!t&&(this.layer.isBackground=!t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"clipboardData",{get:function(){return this._clipboardData},set:function(t){this._clipboardData=t},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"AdvancedDynamicTexture"},e.prototype.executeOnAllControls=function(t,e){e||(e=this._rootContainer),t(e);for(var i=0,o=e.children;i<o.length;i++){var n=o[i];n.children?this.executeOnAllControls(t,n):t(n)}},Object.defineProperty(e.prototype,"useInvalidateRectOptimization",{get:function(){return this._useInvalidateRectOptimization},set:function(t){this._useInvalidateRectOptimization=t},enumerable:!1,configurable:!0}),e.prototype.invalidateRect=function(t,e,i,o){if(this._useInvalidateRectOptimization)if(this._invalidatedRectangle){var n=Math.ceil(Math.max(this._invalidatedRectangle.left+this._invalidatedRectangle.width-1,i)),r=Math.ceil(Math.max(this._invalidatedRectangle.top+this._invalidatedRectangle.height-1,o));this._invalidatedRectangle.left=Math.floor(Math.min(this._invalidatedRectangle.left,t)),this._invalidatedRectangle.top=Math.floor(Math.min(this._invalidatedRectangle.top,e)),this._invalidatedRectangle.width=n-this._invalidatedRectangle.left+1,this._invalidatedRectangle.height=r-this._invalidatedRectangle.top+1}else this._invalidatedRectangle=new d(t,e,i-t+1,o-e+1)},e.prototype.markAsDirty=function(){this._isDirty=!0},e.prototype.createStyle=function(){return new $(this)},e.prototype.addControl=function(t){return this._rootContainer.addControl(t),this},e.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),this},e.prototype.moveToNonOverlappedPosition=function(t,i,o){var n;if(void 0===i&&(i=1),void 0===o&&(o=1),Array.isArray(t))n=t;else{var r=this.getDescendants(!0);n=void 0===t?r.filter((function(t){return void 0!==t.overlapGroup})):r.filter((function(e){return e.overlapGroup===t}))}n.forEach((function(t){var r,a=s.Vector2.Zero(),l=new s.Vector2(t.centerX,t.centerY);n.forEach((function(i){if(t!==i&&e._Overlaps(t,i)){var n=l.subtract(new s.Vector2(i.centerX,i.centerY)),r=n.length();r>0&&(a=a.add(n.normalize().scale(o/r)))}})),a.length()>0&&(a=a.normalize().scale(i*(null!==(r=t.overlapDeltaMultiplier)&&void 0!==r?r:1)),t.linkOffsetXInPixels+=a.x,t.linkOffsetYInPixels+=a.y)}))},e.prototype.dispose=function(){var e=this.getScene();e&&(this._rootElement=null,e.onBeforeCameraRenderObservable.remove(this._renderObserver),this._resizeObserver&&e.getEngine().onResizeObservable.remove(this._resizeObserver),this._pointerMoveObserver&&e.onPrePointerObservable.remove(this._pointerMoveObserver),this._sceneRenderObserver&&e.onBeforeRenderObservable.remove(this._sceneRenderObserver),this._pointerObserver&&e.onPointerObservable.remove(this._pointerObserver),this._preKeyboardObserver&&e.onPreKeyboardObservable.remove(this._preKeyboardObserver),this._canvasPointerOutObserver&&e.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver),this._canvasBlurObserver&&e.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver),this._layerToDispose&&(this._layerToDispose.texture=null,this._layerToDispose.dispose(),this._layerToDispose=null),this._rootContainer.dispose(),this.onClipboardObservable.clear(),this.onControlPickedObservable.clear(),this.onBeginRenderObservable.clear(),this.onEndRenderObservable.clear(),this.onBeginLayoutObservable.clear(),this.onEndLayoutObservable.clear(),t.prototype.dispose.call(this))},e.prototype._onResize=function(){var t=this.getScene();if(t){var e=t.getEngine(),i=this.getSize(),o=e.getRenderWidth()*this._renderScale,n=e.getRenderHeight()*this._renderScale;this._renderAtIdealSize&&(this._idealWidth?(n=n*this._idealWidth/o,o=this._idealWidth):this._idealHeight&&(o=o*this._idealHeight/n,n=this._idealHeight)),i.width===o&&i.height===n||(this.scaleTo(o,n),this.markAsDirty(),(this._idealWidth||this._idealHeight)&&this._rootContainer._markAllAsDirty()),this.invalidateRect(0,0,i.width-1,i.height-1)}},e.prototype._getGlobalViewport=function(){var t=this.getSize(),e=this._fullscreenViewport.toGlobal(t.width,t.height),i=Math.round(e.width*(1/this.rootContainer.scaleX)),o=Math.round(e.height*(1/this.rootContainer.scaleY));return e.x+=(e.width-i)/2,e.y+=(e.height-o)/2,e.width=i,e.height=o,e},e.prototype.getProjectedPosition=function(t,e){var i=this.getProjectedPositionWithZ(t,e);return new s.Vector2(i.x,i.y)},e.prototype.getProjectedPositionWithZ=function(t,e){var i=this.getScene();if(!i)return s.Vector3.Zero();var o=this._getGlobalViewport(),n=s.Vector3.Project(t,e,i.getTransformMatrix(),o);return new s.Vector3(n.x,n.y,n.z)},e.prototype._checkUpdate=function(t){if(!this._layerToDispose||0!=(t.layerMask&this._layerToDispose.layerMask)){if(this._isFullscreen&&this._linkedControls.length){var i=this.getScene();if(!i)return;for(var o=this._getGlobalViewport(),n=function(t){if(!t.isVisible)return"continue";var e=t._linkedMesh;if(!e||e.isDisposed())return s.Tools.SetImmediate((function(){t.linkWithMesh(null)})),"continue";var n=e.getBoundingInfo?e.getBoundingInfo().boundingSphere.center:s.Vector3.ZeroReadOnly,r=s.Vector3.Project(n,e.getWorldMatrix(),i.getTransformMatrix(),o);if(r.z<0||r.z>1)return t.notRenderable=!0,"continue";t.notRenderable=!1,t._moveToProjectedPosition(r)},r=0,a=this._linkedControls;r<a.length;r++)n(a[r])}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update(this.applyYInversionOnUpdate,this.premulAlpha,e.AllowGPUOptimizations))}},e.prototype._render=function(){var t=this.getSize(),e=t.width,i=t.height,o=this.getContext();o.font="18px Arial",o.strokeStyle="white",this.onBeginLayoutObservable.notifyObservers(this);var n=new d(0,0,e,i);this._numLayoutCalls=0,this._rootContainer._layout(n,o),this.onEndLayoutObservable.notifyObservers(this),this._isDirty=!1,this._invalidatedRectangle?this._clearMeasure.copyFrom(this._invalidatedRectangle):this._clearMeasure.copyFromFloats(0,0,e,i),o.clearRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),this._background&&(o.save(),o.fillStyle=this._background,o.fillRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),o.restore()),this.onBeginRenderObservable.notifyObservers(this),this._numRenderCalls=0,this._rootContainer._render(o,this._invalidatedRectangle),this.onEndRenderObservable.notifyObservers(this),this._invalidatedRectangle=null},e.prototype._changeCursor=function(t){this._rootElement&&(this._rootElement.style.cursor=t,this._cursorChanged=!0)},e.prototype._registerLastControlDown=function(t,e){this._lastControlDown[e]=t,this.onControlPickedObservable.notifyObservers(t)},e.prototype._doPicking=function(t,e,i,o,n,r,a,l){var _=this.getScene();if(_){var h=_.getEngine(),c=this.getSize();if(this._isFullscreen){var u=_.cameraToUseForPointers||_.activeCamera;if(!u)return;var d=u.viewport;t*=c.width/(h.getRenderWidth()*d.width),e*=c.height/(h.getRenderHeight()*d.height)}this._capturingControl[n]?this._capturingControl[n]._processObservables(o,t,e,i,n,r):(this._cursorChanged=!1,this._rootContainer._processPicking(t,e,i,o,n,r,a,l)||(_.doNotHandleCursors||this._changeCursor(""),o===s.PointerEventTypes.POINTERMOVE&&this._lastControlOver[n]&&(this._lastControlOver[n]._onPointerOut(this._lastControlOver[n],i),delete this._lastControlOver[n])),this._cursorChanged||_.doNotHandleCursors||this._changeCursor(""),this._manageFocus())}},e.prototype._cleanControlAfterRemovalFromList=function(t,e){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&t[i]===e&&delete t[i]},e.prototype._cleanControlAfterRemoval=function(t){this._cleanControlAfterRemovalFromList(this._lastControlDown,t),this._cleanControlAfterRemovalFromList(this._lastControlOver,t)},e.prototype._translateToPicking=function(t,e,i){var o=t.cameraToUseForPointers||t.activeCamera,n=t.getEngine(),r=t.cameraToUseForPointers;if(o)if(o.rigCameras.length){var a=new s.Viewport(0,0,1,1);o.rigCameras.forEach((function(i){i.viewport.toGlobalToRef(n.getRenderWidth(),n.getRenderHeight(),a);var o=t.pointerX/n.getHardwareScalingLevel()-a.x,r=t.pointerY/n.getHardwareScalingLevel()-(n.getRenderHeight()-a.y-a.height);o<0||r<0||o>a.width||r>a.height||(t.cameraToUseForPointers=i,e.x=a.x,e.y=a.y,e.width=a.width,e.height=a.height)}))}else o.viewport.toGlobalToRef(n.getRenderWidth(),n.getRenderHeight(),e);else e.x=0,e.y=0,e.width=n.getRenderWidth(),e.height=n.getRenderHeight();var l=t.pointerX/n.getHardwareScalingLevel()-e.x,_=t.pointerY/n.getHardwareScalingLevel()-(n.getRenderHeight()-e.y-e.height);if(this._shouldBlockPointer=!1,i){var h=i.event.pointerId||this._defaultMousePointerId;this._doPicking(l,_,i,i.type,h,i.event.button,i.event.deltaX,i.event.deltaY),(this._shouldBlockPointer||this._capturingControl[h])&&(i.skipOnPointerObservable=!0)}else this._doPicking(l,_,null,s.PointerEventTypes.POINTERMOVE,this._defaultMousePointerId,0);t.cameraToUseForPointers=r},e.prototype.attach=function(){var t=this,e=this.getScene();if(e){var i=new s.Viewport(0,0,0,0);this._pointerMoveObserver=e.onPrePointerObservable.add((function(o){e.isPointerCaptured(o.event.pointerId)||o.type!==s.PointerEventTypes.POINTERMOVE&&o.type!==s.PointerEventTypes.POINTERUP&&o.type!==s.PointerEventTypes.POINTERDOWN&&o.type!==s.PointerEventTypes.POINTERWHEEL||(o.type===s.PointerEventTypes.POINTERMOVE&&o.event.pointerId&&(t._defaultMousePointerId=o.event.pointerId),t._translateToPicking(e,i,o))})),this._attachPickingToSceneRender(e,(function(){return t._translateToPicking(e,i,null)}),!1),this._attachToOnPointerOut(e),this._attachToOnBlur(e)}},e.prototype.registerClipboardEvents=function(){self.addEventListener("copy",this._onClipboardCopy,!1),self.addEventListener("cut",this._onClipboardCut,!1),self.addEventListener("paste",this._onClipboardPaste,!1)},e.prototype.unRegisterClipboardEvents=function(){self.removeEventListener("copy",this._onClipboardCopy),self.removeEventListener("cut",this._onClipboardCut),self.removeEventListener("paste",this._onClipboardPaste)},e.prototype.attachToMesh=function(t,e){var i=this;void 0===e&&(e=!0);var o=this.getScene();o&&(this._pointerObserver=o.onPointerObservable.add((function(e){if(e.type===s.PointerEventTypes.POINTERMOVE||e.type===s.PointerEventTypes.POINTERUP||e.type===s.PointerEventTypes.POINTERDOWN||e.type===s.PointerEventTypes.POINTERWHEEL){e.type===s.PointerEventTypes.POINTERMOVE&&e.event.pointerId&&(i._defaultMousePointerId=e.event.pointerId);var o=e.event.pointerId||i._defaultMousePointerId;if(e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh===t){var n=e.pickInfo.getTextureCoordinates();if(n){var r=i.getSize();i._doPicking(n.x*r.width,(i.applyYInversionOnUpdate?1-n.y:n.y)*r.height,e,e.type,o,e.event.button,e.event.deltaX,e.event.deltaY)}}else if(e.type===s.PointerEventTypes.POINTERUP){if(i._lastControlDown[o]&&i._lastControlDown[o]._forcePointerUp(o),delete i._lastControlDown[o],i.focusedControl){var a=i.focusedControl.keepsFocusWith(),l=!0;if(a)for(var _=0,h=a;_<h.length;_++){var c=h[_];if(i!==c._host){var u=c._host;if(u._lastControlOver[o]&&u._lastControlOver[o].isAscendant(c)){l=!1;break}}}l&&(i.focusedControl=null)}}else e.type===s.PointerEventTypes.POINTERMOVE&&(i._lastControlOver[o]&&i._lastControlOver[o]._onPointerOut(i._lastControlOver[o],e,!0),delete i._lastControlOver[o])}})),t.enablePointerMoveEvents=e,this._attachPickingToSceneRender(o,(function(){var e=i._defaultMousePointerId,n=null==o?void 0:o.pick(o.pointerX,o.pointerY);if(n&&n.hit&&n.pickedMesh===t){var r=n.getTextureCoordinates();if(r){var a=i.getSize();i._doPicking(r.x*a.width,(i.applyYInversionOnUpdate?1-r.y:r.y)*a.height,null,s.PointerEventTypes.POINTERMOVE,e,0)}}else i._lastControlOver[e]&&i._lastControlOver[e]._onPointerOut(i._lastControlOver[e],null,!0),delete i._lastControlOver[e]}),!0),this._attachToOnPointerOut(o),this._attachToOnBlur(o))},e.prototype.moveFocusToControl=function(t){this.focusedControl=t,this._lastPickedControl=t,this._blockNextFocusCheck=!0},e.prototype._manageFocus=function(){if(this._blockNextFocusCheck)return this._blockNextFocusCheck=!1,void(this._lastPickedControl=this._focusedControl);if(this._focusedControl&&this._focusedControl!==this._lastPickedControl){if(this._lastPickedControl.isFocusInvisible)return;this.focusedControl=null}},e.prototype._attachPickingToSceneRender=function(t,e,i){var o=this;this._sceneRenderObserver=t.onBeforeRenderObservable.add((function(){o.checkPointerEveryFrame&&(o._linkedControls.length>0||i)&&e()}))},e.prototype._attachToOnPointerOut=function(t){var e=this;this._canvasPointerOutObserver=t.getEngine().onCanvasPointerOutObservable.add((function(t){e._lastControlOver[t.pointerId]&&e._lastControlOver[t.pointerId]._onPointerOut(e._lastControlOver[t.pointerId],null),delete e._lastControlOver[t.pointerId],e._lastControlDown[t.pointerId]&&e._lastControlDown[t.pointerId]!==e._capturingControl[t.pointerId]&&(e._lastControlDown[t.pointerId]._forcePointerUp(),delete e._lastControlDown[t.pointerId])}))},e.prototype._attachToOnBlur=function(t){var e=this;this._canvasBlurObserver=t.getEngine().onCanvasBlurObservable.add((function(){Object.entries(e._lastControlDown).forEach((function(t){t[1]._onCanvasBlur()})),e.focusedControl=null,e._lastControlDown={}}))},e.prototype.serializeContent=function(){var t=this.getSize(),e={root:{},width:t.width,height:t.height};return this._rootContainer.serialize(e.root),e},e.prototype.parseContent=function(t,e){if(this._rootContainer=g.Parse(t.root,this),e){var i=t.width,o=t.height;"number"==typeof i&&"number"==typeof o&&i>=0&&o>=0?this.scaleTo(i,o):this.scaleTo(1920,1080)}},e.prototype.parseFromSnippetAsync=function(t,i){var o=this;return"_BLANK"===t?Promise.resolve():new Promise((function(n,r){var a=new s.WebRequest;a.addEventListener("readystatechange",(function(){if(4==a.readyState)if(200==a.status){var e=JSON.parse(JSON.parse(a.responseText).jsonPayload),s=JSON.parse(e.gui);o.parseContent(s,i),o.snippetId=t,n()}else r("Unable to load the snippet "+t)})),a.open("GET",e.SnippetUrl+"/"+t.replace(/#/g,"/")),a.send()}))},e.prototype.parseFromURLAsync=function(t,e){var i=this;return""===t?Promise.resolve():new Promise((function(o,n){var r=new s.WebRequest;r.addEventListener("readystatechange",(function(){if(4==r.readyState)if(200==r.status){var t=r.responseText,a=JSON.parse(t);i.parseContent(a,e),o()}else n("Unable to load")})),r.open("GET",t),r.send()}))},e._Overlaps=function(t,e){return!(t.centerX>e.centerX+e.widthInPixels||t.centerX+t.widthInPixels<e.centerX||t.centerY+t.heightInPixels<e.centerY||t.centerY>e.centerY+e.heightInPixels)},e.CreateForMesh=function(t,i,o,n,r,a,l){void 0===i&&(i=1024),void 0===o&&(o=1024),void 0===n&&(n=!0),void 0===r&&(r=!1),void 0===l&&(l=this._CreateMaterial);var _=(0,s.RandomGUID)(),h=new e("AdvancedDynamicTexture for ".concat(t.name," [").concat(_,"]"),i,o,t.getScene(),!0,s.Texture.TRILINEAR_SAMPLINGMODE,a);return l(t,_,h,r),h.attachToMesh(t,n),h},e._CreateMaterial=function(t,e,i,o){var n=(0,s.GetClass)("BABYLON.StandardMaterial");if(!n)throw"StandardMaterial needs to be imported before as it contains a side-effect required by your code.";var r=new n("AdvancedDynamicTextureMaterial for ".concat(t.name," [").concat(e,"]"),t.getScene());r.backFaceCulling=!1,r.diffuseColor=s.Color3.Black(),r.specularColor=s.Color3.Black(),o?(r.diffuseTexture=i,r.emissiveTexture=i,i.hasAlpha=!0):(r.emissiveTexture=i,r.opacityTexture=i),t.material=r},e.CreateForMeshTexture=function(t,i,o,n,r){void 0===i&&(i=1024),void 0===o&&(o=1024),void 0===n&&(n=!0);var a=new e(t.name+" AdvancedDynamicTexture",i,o,t.getScene(),!0,s.Texture.TRILINEAR_SAMPLINGMODE,r);return a.attachToMesh(t,n),a},e.CreateFullscreenUI=function(t,i,o,n,r){void 0===i&&(i=!0),void 0===o&&(o=null),void 0===n&&(n=s.Texture.BILINEAR_SAMPLINGMODE),void 0===r&&(r=!1);var a=new e(t,0,0,o,!1,n),l=a.getScene(),_=new s.Layer(t+"_layer",null,l,!i);if(_.texture=a,a._layerToDispose=_,a._isFullscreen=!0,r&&l){var h=1/l.getEngine().getHardwareScalingLevel();a._rootContainer.scaleX=h,a._rootContainer.scaleY=h}return a.attach(),a},e.prototype.scale=function(e){t.prototype.scale.call(this,e),this.markAsDirty()},e.prototype.scaleTo=function(e,i){t.prototype.scaleTo.call(this,e,i),this.markAsDirty()},e.SnippetUrl="https://snippet.babylonjs.com",e.AllowGPUOptimizations=!0,e}(s.DynamicTexture),et=function(){function t(t){this.texture=t,this._captureRenderTime=!1,this._renderTime=new s.PerfCounter,this._captureLayoutTime=!1,this._layoutTime=new s.PerfCounter,this._onBeginRenderObserver=null,this._onEndRenderObserver=null,this._onBeginLayoutObserver=null,this._onEndLayoutObserver=null}return Object.defineProperty(t.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layoutTimeCounter",{get:function(){return this._layoutTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(t){var e=this;t!==this._captureRenderTime&&(this._captureRenderTime=t,t?(this._onBeginRenderObserver=this.texture.onBeginRenderObservable.add((function(){e._renderTime.beginMonitoring()})),this._onEndRenderObserver=this.texture.onEndRenderObservable.add((function(){e._renderTime.endMonitoring(!0)}))):(this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"captureLayoutTime",{get:function(){return this._captureLayoutTime},set:function(t){var e=this;t!==this._captureLayoutTime&&(this._captureLayoutTime=t,t?(this._onBeginLayoutObserver=this.texture.onBeginLayoutObservable.add((function(){e._layoutTime.beginMonitoring()})),this._onEndLayoutObserver=this.texture.onEndLayoutObservable.add((function(){e._layoutTime.endMonitoring(!0)}))):(this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null))},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver),this._onBeginRenderObserver=null,this.texture.onEndRenderObservable.remove(this._onEndRenderObserver),this._onEndRenderObserver=null,this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver),this._onBeginLayoutObserver=null,this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver),this._onEndLayoutObserver=null,this.texture=null},t}(),it="XmlLoader Exception : XML file is malformed or corrupted.",ot=function(){function t(t){void 0===t&&(t=null),this._nodes={},this._nodeTypes={element:1,attribute:2,text:3},this._isLoaded=!1,this._objectAttributes={textHorizontalAlignment:1,textVerticalAlignment:2,horizontalAlignment:3,verticalAlignment:4,stretch:5},t&&(this._parentClass=t)}return t.prototype._getChainElement=function(t){var e=window;this._parentClass&&(e=this._parentClass);var i=t;i=i.split(".");for(var o=0;o<i.length;o++)e=e[i[o]];return e},t.prototype._getClassAttribute=function(t){var e=t.split(".");return(0,s.GetClass)("BABYLON.GUI."+e[0])[e[1]]},t.prototype._createGuiElement=function(t,e,i){void 0===i&&(i=!0);try{var o=new((0,s.GetClass)("BABYLON.GUI."+t.nodeName));e&&i&&e.addControl(o);for(var n=0;n<t.attributes.length;n++)if(!t.attributes[n].name.toLowerCase().includes("datasource"))if(t.attributes[n].name.toLowerCase().includes("observable")){var r=this._getChainElement(t.attributes[n].value);o[t.attributes[n].name].add(r)}else"linkWithMesh"==t.attributes[n].name?this._parentClass?o.linkWithMesh(this._parentClass[t.attributes[n].value]):o.linkWithMesh(window[t.attributes[n].value]):t.attributes[n].value.startsWith("{{")&&t.attributes[n].value.endsWith("}}")?(r=this._getChainElement(t.attributes[n].value.substring(2,t.attributes[n].value.length-2)),o[t.attributes[n].name]=r):this._objectAttributes[t.attributes[n].name]?o[t.attributes[n].name]=this._getClassAttribute(t.attributes[n].value):"true"==t.attributes[n].value||"false"==t.attributes[n].value?o[t.attributes[n].name]="true"==t.attributes[n].value:o[t.attributes[n].name]=isNaN(Number(t.attributes[n].value))?t.attributes[n].value:Number(t.attributes[n].value);if(!t.attributes.getNamedItem("id"))return this._nodes[t.nodeName+Object.keys(this._nodes).length+"_gen"]=o,o;var a=t.attributes.getNamedItem("id").value;if(a.startsWith("{{")&&a.endsWith("}}")&&(a=this._getChainElement(a.substring(2,a.length-2))),this._nodes[a])throw"XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";return this._nodes[a]=o,o}catch(e){throw"XmlLoader Exception : Error parsing Control "+t.nodeName+","+e+"."}},t.prototype._parseGrid=function(t,e,i){for(var o,n,r,a,s,l=t.children,_=!1,h=-1,c=-1,u=0,d=0;d<l.length;d++)if(l[d].nodeType==this._nodeTypes.element){if("Row"!=l[d].nodeName)throw"XmlLoader Exception : Expecting Row node, received "+l[d].nodeName;if(h+=1,r=l[d].children,!l[d].attributes.getNamedItem("height"))throw"XmlLoader Exception : Height must be defined for grid rows";n=Number(l[d].attributes.getNamedItem("height").nodeValue),_=!!l[d].attributes.getNamedItem("isPixel")&&JSON.parse(l[d].attributes.getNamedItem("isPixel").nodeValue),e.addRowDefinition(n,_);for(var f=0;f<r.length;f++)if(r[f].nodeType==this._nodeTypes.element){if("Column"!=r[f].nodeName)throw"XmlLoader Exception : Expecting Column node, received "+r[f].nodeName;if(c+=1,h>0&&c>u)throw"XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";if(0==h){if(!r[f].attributes.getNamedItem("width"))throw"XmlLoader Exception : Width must be defined for all the grid columns in the first row";o=Number(r[f].attributes.getNamedItem("width").nodeValue),_=!!r[f].attributes.getNamedItem("isPixel")&&JSON.parse(r[f].attributes.getNamedItem("isPixel").nodeValue),e.addColumnDefinition(o,_)}a=r[f].children;for(var p=0;p<a.length;p++)a[p].nodeType==this._nodeTypes.element&&(s=this._createGuiElement(a[p],e,!1),e.addControl(s,h,c),a[p].firstChild&&this._parseXml(a[p].firstChild,s))}0==h&&(u=c),c=-1}t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._parseElement=function(t,e,i){t.firstChild&&this._parseXml(t.firstChild,e),t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._prepareSourceElement=function(t,e,i,o,n){this._parentClass?this._parentClass[i]=o[n]:window[i]=o[n],t.firstChild&&this._parseXml(t.firstChild,e,!0)},t.prototype._parseElementsFromSource=function(t,e,i){var o=t.attributes.getNamedItem("dataSource").value;if(!o.includes(" in "))throw"XmlLoader Exception : Malformed XML, Data Source must include an in";var n=!0,r=o.split(" in ");if(r.length<2)throw"XmlLoader Exception : Malformed XML, Data Source must have an iterator and a source";var a=r[1];if(a.startsWith("{")&&a.endsWith("}")&&(n=!1),(!n||a.startsWith("[")&&a.endsWith("]"))&&(a=a.substring(1,a.length-1)),a=this._parentClass?this._parentClass[a]:window[a],n)for(var s=0;s<a.length;s++)this._prepareSourceElement(t,e,r[0],a,s);else for(var s in a)this._prepareSourceElement(t,e,r[0],a,s);t.nextSibling&&this._parseXml(t.nextSibling,i)},t.prototype._parseXml=function(t,e,i){if(void 0===i&&(i=!1),t.nodeType==this._nodeTypes.element){i&&t.setAttribute("id",e.id+(e._children.length+1));var o=this._createGuiElement(t,e);this._rootNode||(this._rootNode=o),"Grid"==t.nodeName?this._parseGrid(t,o,e):t.attributes.getNamedItem("dataSource")?this._parseElementsFromSource(t,o,e):this._parseElement(t,o,e)}else t.nextSibling&&this._parseXml(t.nextSibling,e,i)},t.prototype.isLoaded=function(){return this._isLoaded},t.prototype.getNodeById=function(t){return this._nodes[t]},t.prototype.getNodes=function(){return this._nodes},t.prototype.dispose=function(){this._rootNode&&(this._rootNode.dispose(),this._rootNode=null,this._nodes={})},t.prototype.loadLayout=function(t,e,i,o){var n=this;void 0===i&&(i=null),void 0===o&&(o=null);var r=new XMLHttpRequest;r.onload=function(){if(4===r.readyState&&200===r.status){if(!r.responseXML){if(o)return void o(it);throw it}var t=r.responseXML.documentElement;n._parseXml(t.firstChild,e),n._isLoaded=!0,i&&i()}},r.onerror=function(){o&&o("an error occurred during loading the layout")},r.open("GET",t,!0),r.send()},t.prototype.loadLayoutAsync=function(t,e){return i=this,o=void 0,r=function(){var i=this;return function(t,e){var i,o,n,r,a={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(r){return function(s){return function(r){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,o&&(n=2&r[0]?o.return:r[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,r[1])).done)return n;switch(o=0,n&&(r=[2&r[0],n.value]),r[0]){case 0:case 1:n=r;break;case 4:return a.label++,{value:r[1],done:!1};case 5:a.label++,o=r[1],r=[0];continue;case 7:r=a.ops.pop(),a.trys.pop();continue;default:if(!((n=(n=a.trys).length>0&&n[n.length-1])||6!==r[0]&&2!==r[0])){a=0;continue}if(3===r[0]&&(!n||r[1]>n[0]&&r[1]<n[3])){a.label=r[1];break}if(6===r[0]&&a.label<n[1]){a.label=n[1],n=r;break}if(n&&a.label<n[2]){a.label=n[2],a.ops.push(r);break}n[2]&&a.ops.pop(),a.trys.pop();continue}r=e.call(t,a)}catch(t){r=[6,t],o=0}finally{i=n=0}if(5&r[0])throw r[1];return{value:r[0]?r[1]:void 0,done:!0}}([r,s])}}}(this,(function(o){return[2,new Promise((function(o,n){i.loadLayout(t,e,o,n)}))]}))},new((n=void 0)||(n=Promise))((function(t,e){function a(t){try{l(r.next(t))}catch(t){e(t)}}function s(t){try{l(r.throw(t))}catch(t){e(t)}}function l(e){var i;e.done?t(e.value):(i=e.value,i instanceof n?i:new n((function(t){t(i)}))).then(a,s)}l((r=r.apply(i,o||[])).next())}));var i,o,n,r},t}(),nt=function(t){function e(e,i){void 0===i&&(i=0);var o=t.call(this,e.x,e.y,e.z)||this;return o.buttonIndex=i,o}return r(e,t),e}(s.Vector3),rt=function(){function t(t){this.name=t,this._downCount=0,this._enterCount=-1,this._downPointerIds={},this._isVisible=!0,this._isScaledByManager=!1,this.onPointerMoveObservable=new s.Observable,this.onPointerOutObservable=new s.Observable,this.onPointerDownObservable=new s.Observable,this.onPointerUpObservable=new s.Observable,this.onPointerClickObservable=new s.Observable,this.onPointerEnterObservable=new s.Observable,this._behaviors=new Array}return Object.defineProperty(t.prototype,"position",{get:function(){return this._node?this._node.position:s.Vector3.Zero()},set:function(t){this._node&&(this._node.position=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._node?this._node.scaling:new s.Vector3(1,1,1)},set:function(t){this._node&&(this._isScaledByManager=!1,this._node.scaling=t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),t.prototype.addBehavior=function(t){var e=this;if(-1!==this._behaviors.indexOf(t))return this;t.init();var i=this._host.scene;return i.isLoading?i.onDataLoadedObservable.addOnce((function(){t.attach(e)})):t.attach(this),this._behaviors.push(t),this},t.prototype.removeBehavior=function(t){var e=this._behaviors.indexOf(t);return-1===e||(this._behaviors[e].detach(),this._behaviors.splice(e,1)),this},t.prototype.getBehaviorByName=function(t){for(var e=0,i=this._behaviors;e<i.length;e++){var o=i[e];if(o.name===t)return o}return null},Object.defineProperty(t.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){if(this._isVisible!==t){this._isVisible=t;var e=this.mesh;e&&e.setEnabled(t)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return this._getTypeName()},t.prototype._getTypeName=function(){return"Control3D"},Object.defineProperty(t.prototype,"node",{get:function(){return this._node},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._node instanceof s.AbstractMesh?this._node:null},enumerable:!1,configurable:!0}),t.prototype.linkToTransformNode=function(t){return this._node&&(this._node.parent=t),this},t.prototype._prepareNode=function(t){if(!this._node){if(this._node=this._createNode(t),!this.node)return;this._injectGUI3DReservedDataStore(this.node).control=this;var e=this.mesh;e&&(e.isPickable=!0,this._affectMaterial(e))}},t.prototype._injectGUI3DReservedDataStore=function(t){var e,i;return t.reservedDataStore=null!==(e=t.reservedDataStore)&&void 0!==e?e:{},t.reservedDataStore.GUI3D=null!==(i=t.reservedDataStore.GUI3D)&&void 0!==i?i:{},t.reservedDataStore.GUI3D},t.prototype._createNode=function(t){return null},t.prototype._affectMaterial=function(t){t.material=null},t.prototype._isTouchButton3D=function(t){return void 0!==t._generatePointerEventType},t.prototype._onPointerMove=function(t,e){this.onPointerMoveObservable.notifyObservers(e,-1,t,this)},t.prototype._onPointerEnter=function(t){return-1===this._enterCount&&(this._enterCount=0),this._enterCount++,!(this._enterCount>1||(this.onPointerEnterObservable.notifyObservers(this,-1,t,this),this.pointerEnterAnimation&&this.pointerEnterAnimation(),0))},t.prototype._onPointerOut=function(t){this._enterCount--,this._enterCount>0||(this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this),this.pointerOutAnimation&&this.pointerOutAnimation())},t.prototype._onPointerDown=function(t,e,i,o){return this._downCount++,this._downPointerIds[i]=this._downPointerIds[i]+1||1,1===this._downCount&&(this.onPointerDownObservable.notifyObservers(new nt(e,o),-1,t,this),this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},t.prototype._onPointerUp=function(t,e,i,o,n){this._downCount--,this._downPointerIds[i]--,this._downPointerIds[i]<=0&&delete this._downPointerIds[i],this._downCount<0?this._downCount=0:0==this._downCount&&(n&&(this._enterCount>0||-1===this._enterCount)&&this.onPointerClickObservable.notifyObservers(new nt(e,o),-1,t,this),this.onPointerUpObservable.notifyObservers(new nt(e,o),-1,t,this),this.pointerUpAnimation&&this.pointerUpAnimation())},t.prototype.forcePointerUp=function(t){if(void 0===t&&(t=null),null!==t)this._onPointerUp(this,s.Vector3.Zero(),t,0,!0);else{for(var e in this._downPointerIds)this._onPointerUp(this,s.Vector3.Zero(),+e,0,!0);this._downCount>0&&(this._downCount=1,this._onPointerUp(this,s.Vector3.Zero(),0,0,!0))}},t.prototype._processObservables=function(t,e,i,o,n){if(this._isTouchButton3D(this)&&i&&(t=this._generatePointerEventType(t,i,this._downCount)),t===s.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,e);var r=this._host._lastControlOver[o];return r&&r!==this&&r._onPointerOut(this),r!==this&&this._onPointerEnter(this),this._host._lastControlOver[o]=this,!0}return t===s.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,e,o,n),this._host._lastControlDown[o]=this,this._host._lastPickedControl=this,!0):(t===s.PointerEventTypes.POINTERUP||t===s.PointerEventTypes.POINTERDOUBLETAP)&&(this._host._lastControlDown[o]&&this._host._lastControlDown[o]._onPointerUp(this,e,o,n,!0),delete this._host._lastControlDown[o],!0)},t.prototype._disposeNode=function(){this._node&&(this._node.dispose(),this._node=null)},t.prototype.dispose=function(){this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._disposeNode();for(var t=0,e=this._behaviors;t<e.length;t++)e[t].detach()},t}(),at=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._contentResolution=512,e._contentScaleRatio=2,e}return r(e,t),Object.defineProperty(e.prototype,"content",{get:function(){return this._content},set:function(t){this._content=t,t&&this._host&&this._host.utilityLayer&&(this._facadeTexture?this._facadeTexture.rootContainer.clearControls():(this._facadeTexture=new tt("Facade",this._contentResolution,this._contentResolution,this._host.utilityLayer.utilityLayerScene,!0,s.Texture.TRILINEAR_SAMPLINGMODE),this._facadeTexture.rootContainer.scaleX=this._contentScaleRatio,this._facadeTexture.rootContainer.scaleY=this._contentScaleRatio,this._facadeTexture.premulAlpha=!0),this._facadeTexture.addControl(t),this._applyFacade(this._facadeTexture))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contentResolution",{get:function(){return this._contentResolution},set:function(t){this._contentResolution!==t&&(this._contentResolution=t,this._resetContent())},enumerable:!1,configurable:!0}),e.prototype._disposeFacadeTexture=function(){this._facadeTexture&&(this._facadeTexture.dispose(),this._facadeTexture=null)},e.prototype._resetContent=function(){this._disposeFacadeTexture(),this.content=this._content},e.prototype._applyFacade=function(t){},e}(rt),st=function(t){function e(e){return t.call(this,e)||this}return r(e,t),e.prototype._getTypeName=function(){return"AbstractButton3D"},e.prototype._createNode=function(t){return new s.TransformNode("button"+this.name,t)},e}(at),lt=function(t){function e(e){var i=t.call(this,e)||this;return i.pointerEnterAnimation=function(){i.mesh&&(i._currentMaterial.emissiveColor=s.Color3.Red())},i.pointerOutAnimation=function(){i._currentMaterial.emissiveColor=s.Color3.Black()},i.pointerDownAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(.95)},i.pointerUpAnimation=function(){i.mesh&&i.mesh.scaling.scaleInPlace(1/.95)},i}return r(e,t),e.prototype._applyFacade=function(t){this._currentMaterial.emissiveTexture=t},e.prototype._getTypeName=function(){return"Button3D"},e.prototype._createNode=function(t){for(var e=new Array(6),i=0;i<6;i++)e[i]=new s.Vector4(0,0,0,0);return t.useRightHandedSystem?e[0].copyFromFloats(1,0,0,1):e[1].copyFromFloats(0,0,1,1),(0,s.CreateBox)(this.name+"_rootMesh",{width:1,height:1,depth:.08,faceUV:e,wrap:!0},t)},e.prototype._affectMaterial=function(t){var e=new s.StandardMaterial(this.name+"Material",t.getScene());e.specularColor=s.Color3.Black(),t.material=e,this._currentMaterial=e,this._resetContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeFacadeTexture(),this._currentMaterial&&this._currentMaterial.dispose()},e}(st),_t=function(t){function e(e){var i=t.call(this,e)||this;return i._blockLayout=!1,i._children=new Array,i}return r(e,t),Object.defineProperty(e.prototype,"children",{get:function(){return this._children},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blockLayout",{get:function(){return this._blockLayout},set:function(t){this._blockLayout!==t&&(this._blockLayout=t,this._blockLayout||this._arrangeChildren())},enumerable:!1,configurable:!0}),e.prototype.updateLayout=function(){return this._arrangeChildren(),this},e.prototype.containsControl=function(t){return-1!==this._children.indexOf(t)},e.prototype.addControl=function(t){return-1!==this._children.indexOf(t)||(t.parent=this,t._host=this._host,this._children.push(t),this._host.utilityLayer&&(t._prepareNode(this._host.utilityLayer.utilityLayerScene),t.node&&(t.node.parent=this.node),this.blockLayout||this._arrangeChildren())),this},e.prototype._arrangeChildren=function(){},e.prototype._createNode=function(t){return new s.TransformNode("ContainerNode",t)},e.prototype.removeControl=function(t){var e=this._children.indexOf(t);return-1!==e&&(this._children.splice(e,1),t.parent=null,t._disposeNode()),this},e.prototype._getTypeName=function(){return"Container3D"},e.prototype.dispose=function(){for(var e=0,i=this._children;e<i.length;e++)i[e].dispose();this._children=[],t.prototype.dispose.call(this)},e.UNSET_ORIENTATION=0,e.FACEORIGIN_ORIENTATION=1,e.FACEORIGINREVERSED_ORIENTATION=2,e.FACEFORWARD_ORIENTATION=3,e.FACEFORWARDREVERSED_ORIENTATION=4,e}(rt),ht=function(t){function e(e){var i=t.call(this,e)||this;return i._columns=10,i._rows=0,i._rowThenColum=!0,i._orientation=_t.FACEORIGIN_ORIENTATION,i.margin=0,i}return r(e,t),Object.defineProperty(e.prototype,"orientation",{get:function(){return this._orientation},set:function(t){var e=this;this._orientation!==t&&(this._orientation=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._columns},set:function(t){var e=this;this._columns!==t&&(this._columns=t,this._rowThenColum=!0,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},set:function(t){var e=this;this._rows!==t&&(this._rows=t,this._rowThenColum=!1,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._arrangeChildren=function(){this._cellWidth=0,this._cellHeight=0;for(var t=0,e=0,i=0,o=s.Matrix.Invert(this.node.computeWorldMatrix(!0)),n=0,r=this._children;n<r.length;n++)if((b=r[n]).mesh){i++,b.mesh.computeWorldMatrix(!0);var a=b.mesh.getHierarchyBoundingVectors(),l=s.TmpVectors.Vector3[0],_=s.TmpVectors.Vector3[1];a.max.subtractToRef(a.min,_),_.scaleInPlace(.5),s.Vector3.TransformNormalToRef(_,o,l),this._cellWidth=Math.max(this._cellWidth,2*l.x),this._cellHeight=Math.max(this._cellHeight,2*l.y)}this._cellWidth+=2*this.margin,this._cellHeight+=2*this.margin,this._rowThenColum?(e=this._columns,t=Math.ceil(i/this._columns)):(t=this._rows,e=Math.ceil(i/this._rows));var h=.5*e*this._cellWidth,c=.5*t*this._cellHeight,u=[],d=0;if(this._rowThenColum)for(var f=0;f<t;f++)for(var p=0;p<e&&(u.push(new s.Vector3(p*this._cellWidth-h+this._cellWidth/2,f*this._cellHeight-c+this._cellHeight/2,0)),!(++d>i));p++);else for(p=0;p<e;p++)for(f=0;f<t&&(u.push(new s.Vector3(p*this._cellWidth-h+this._cellWidth/2,f*this._cellHeight-c+this._cellHeight/2,0)),!(++d>i));f++);d=0;for(var g=0,m=this._children;g<m.length;g++){var b;(b=m[g]).mesh&&(this._mapGridNode(b,u[d]),d++)}this._finalProcessing()},e.prototype._finalProcessing=function(){},e}(_t),ct=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._radius=5,e}return r(e,t),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){var e=this;this._radius!==t&&(this._radius=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){var o=this._cylindricalMapping(e);switch(t.position=o,this.orientation){case _t.FACEORIGIN_ORIENTATION:i.lookAt(new s.Vector3(2*o.x,o.y,2*o.z));break;case _t.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(-o.x,o.y,-o.z));break;case _t.FACEFORWARD_ORIENTATION:break;case _t.FACEFORWARDREVERSED_ORIENTATION:i.rotate(s.Axis.Y,Math.PI,s.Space.LOCAL)}}},e.prototype._cylindricalMapping=function(t){var e=new s.Vector3(0,t.y,this._radius),i=t.x/this._radius;return s.Matrix.RotationYawPitchRollToRef(i,0,0,s.TmpVectors.Matrix[0]),s.Vector3.TransformNormal(e,s.TmpVectors.Matrix[0])},e}(ht);s.ShaderStore.ShadersStore.fluentVertexShader="precision highp float;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth; \nif (abs(normal.x)==1.0) \n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y)==1.0) \n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse \n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n} \n#endif \nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";s.ShaderStore.ShadersStore.fluentPixelShader="precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\nuniform mat4 textureMatrix;\nvec2 finalUV;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nfinalUV=vec2(textureMatrix*vec4(vUV,1.0,0.0));\nalbedo=texture2D(albedoSampler,finalUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER \nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover); \nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y); \n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";var ut=function(t){function e(){var e=t.call(this)||this;return e.INNERGLOW=!1,e.BORDER=!1,e.HOVERLIGHT=!1,e.TEXTURE=!1,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),dt=function(t){function e(e,i){var o=t.call(this,e,i)||this;return o.innerGlowColorIntensity=.5,o.innerGlowColor=new s.Color3(1,1,1),o.albedoColor=new s.Color3(.3,.35,.4),o.renderBorders=!1,o.borderWidth=.5,o.edgeSmoothingValue=.02,o.borderMinValue=.1,o.renderHoverLight=!1,o.hoverRadius=.01,o.hoverColor=new s.Color4(.3,.3,.3,1),o.hoverPosition=s.Vector3.Zero(),o}return r(e,t),e.prototype.needAlphaBlending=function(){return 1!==this.alpha},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new ut);var i=this.getScene(),o=e.materialDefines;if(!this.checkReadyOnEveryCall&&e.effect&&o._renderId===i.getRenderId())return!0;if(o._areTexturesDirty)if(o.INNERGLOW=this.innerGlowColorIntensity>0,o.BORDER=this.renderBorders,o.HOVERLIGHT=this.renderHoverLight,this._albedoTexture){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;o.TEXTURE=!0}else o.TEXTURE=!1;var n=i.getEngine();if(o.isDirty){o.markAsProcessed(),i.resetCachedMaterial();var r=[s.VertexBuffer.PositionKind];r.push(s.VertexBuffer.NormalKind),r.push(s.VertexBuffer.UVKind);var a=["world","viewProjection","innerGlowColor","albedoColor","borderWidth","edgeSmoothingValue","scaleFactor","borderMinValue","hoverColor","hoverPosition","hoverRadius","textureMatrix"],l=["albedoSampler"],_=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:a,uniformBuffersNames:_,samplers:l,defines:o,maxSimultaneousLights:4});var h=o.toString();e.setEffect(i.getEngine().createEffect("fluent",{attributes:r,uniformsNames:a,uniformBuffersNames:_,samplers:l,defines:h,fallbacks:null,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),o,this._materialContext)}return!(!e.effect||!e.effect.isReady()||(o._renderId=i.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){var o=this.getScene(),n=i.materialDefines;if(n){var r=i.effect;if(r){if(this._activeEffect=r,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),this._mustRebind(o,r)&&(this._activeEffect.setColor4("albedoColor",this.albedoColor,this.alpha),n.INNERGLOW&&this._activeEffect.setColor4("innerGlowColor",this.innerGlowColor,this.innerGlowColorIntensity),n.BORDER&&(this._activeEffect.setFloat("borderWidth",this.borderWidth),this._activeEffect.setFloat("edgeSmoothingValue",this.edgeSmoothingValue),this._activeEffect.setFloat("borderMinValue",this.borderMinValue),e.getBoundingInfo().boundingBox.extendSize.multiplyToRef(e.scaling,s.TmpVectors.Vector3[0]),this._activeEffect.setVector3("scaleFactor",s.TmpVectors.Vector3[0])),n.HOVERLIGHT&&(this._activeEffect.setDirectColor4("hoverColor",this.hoverColor),this._activeEffect.setFloat("hoverRadius",this.hoverRadius),this._activeEffect.setVector3("hoverPosition",this.hoverPosition)),n.TEXTURE&&this._albedoTexture)){this._activeEffect.setTexture("albedoSampler",this._albedoTexture);var a=this._albedoTexture.getTextureMatrix();this._activeEffect.setMatrix("textureMatrix",a)}this._afterBind(e,this._activeEffect)}}},e.prototype.getActiveTextures=function(){return t.prototype.getActiveTextures.call(this)},e.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.GUI.FluentMaterial",e},e.prototype.getClassName=function(){return"FluentMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},a([(0,s.serialize)(),(0,s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"innerGlowColorIntensity",void 0),a([(0,s.serializeAsColor3)()],e.prototype,"innerGlowColor",void 0),a([(0,s.serializeAsColor3)()],e.prototype,"albedoColor",void 0),a([(0,s.serialize)(),(0,s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderBorders",void 0),a([(0,s.serialize)()],e.prototype,"borderWidth",void 0),a([(0,s.serialize)()],e.prototype,"edgeSmoothingValue",void 0),a([(0,s.serialize)()],e.prototype,"borderMinValue",void 0),a([(0,s.serialize)(),(0,s.expandToProperty)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"renderHoverLight",void 0),a([(0,s.serialize)()],e.prototype,"hoverRadius",void 0),a([(0,s.serializeAsColor4)()],e.prototype,"hoverColor",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"hoverPosition",void 0),a([(0,s.serializeAsTexture)("albedoTexture")],e.prototype,"_albedoTexture",void 0),a([(0,s.expandToProperty)("_markAllSubMeshesAsTexturesAndMiscDirty")],e.prototype,"albedoTexture",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.FluentMaterial",dt);var ft=function(t){function e(e,i){void 0===i&&(i=!0);var o=t.call(this,e)||this;return o._shareMaterials=!0,o._shareMaterials=i,o.pointerEnterAnimation=function(){o.mesh&&o._frontPlate.setEnabled(!0)},o.pointerOutAnimation=function(){o.mesh&&o._frontPlate.setEnabled(!1)},o}return r(e,t),e.prototype._disposeTooltip=function(){this._tooltipFade=null,this._tooltipTextBlock&&this._tooltipTextBlock.dispose(),this._tooltipTexture&&this._tooltipTexture.dispose(),this._tooltipMesh&&this._tooltipMesh.dispose(),this.onPointerEnterObservable.remove(this._tooltipHoverObserver),this.onPointerOutObservable.remove(this._tooltipOutObserver)},Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._backPlate.renderingGroupId},set:function(t){this._backPlate.renderingGroupId=t,this._textPlate.renderingGroupId=t,this._frontPlate.renderingGroupId=t,this._tooltipMesh&&(this._tooltipMesh.renderingGroupId=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tooltipText",{get:function(){return this._tooltipTextBlock?this._tooltipTextBlock.text:null},set:function(t){var e=this;if(t){if(!this._tooltipFade){var i=this._backPlate._scene.useRightHandedSystem;this._tooltipMesh=(0,s.CreatePlane)("",{size:1},this._backPlate._scene);var o=(0,s.CreatePlane)("",{size:1,sideOrientation:s.Mesh.DOUBLESIDE},this._backPlate._scene),n=new s.StandardMaterial("",this._backPlate._scene);n.diffuseColor=s.Color3.FromHexString("#212121"),o.material=n,o.isPickable=!1,this._tooltipMesh.addChild(o),o.position=s.Vector3.Forward(i).scale(.05),this._tooltipMesh.scaling.y=1/3,this._tooltipMesh.position=s.Vector3.Up().scale(.7).add(s.Vector3.Forward(i).scale(-.15)),this._tooltipMesh.isPickable=!1,this._tooltipMesh.parent=this._backPlate,this._tooltipTexture=tt.CreateForMesh(this._tooltipMesh),this._tooltipTextBlock=new y,this._tooltipTextBlock.scaleY=3,this._tooltipTextBlock.color="white",this._tooltipTextBlock.fontSize=130,this._tooltipTexture.addControl(this._tooltipTextBlock),this._tooltipFade=new s.FadeInOutBehavior,this._tooltipFade.delay=500,this._tooltipMesh.addBehavior(this._tooltipFade),this._tooltipHoverObserver=this.onPointerEnterObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!0)})),this._tooltipOutObserver=this.onPointerOutObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!1)}))}this._tooltipTextBlock&&(this._tooltipTextBlock.text=t)}else this._disposeTooltip()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageUrl",{get:function(){return this._imageUrl},set:function(t){this._imageUrl!==t&&(this._imageUrl=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backMaterial",{get:function(){return this._backMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontMaterial",{get:function(){return this._frontMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plateMaterial",{get:function(){return this._plateMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shareMaterials",{get:function(){return this._shareMaterials},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"HolographicButton"},e.prototype._rebuildContent=function(){this._disposeFacadeTexture();var t=new B;if(t.isVertical=!0,s.DomManagement.IsDocumentAvailable()&&document.createElement&&this._imageUrl){var e=new x;e.source=this._imageUrl,e.paddingTop="40px",e.height="180px",e.width="100px",e.paddingBottom="40px",t.addControl(e)}if(this._text){var i=new y;i.text=this._text,i.color="white",i.height="30px",i.fontSize=24,t.addControl(i)}this._frontPlate&&(this.content=t)},e.prototype._createNode=function(e){return this._backPlate=(0,s.CreateBox)(this.name+"BackMesh",{width:1,height:1,depth:.08},e),this._frontPlate=(0,s.CreateBox)(this.name+"FrontMesh",{width:1,height:1,depth:.08},e),this._frontPlate.parent=this._backPlate,this._frontPlate.position=s.Vector3.Forward(e.useRightHandedSystem).scale(-.08),this._frontPlate.isPickable=!1,this._frontPlate.setEnabled(!1),this._textPlate=t.prototype._createNode.call(this,e),this._textPlate.parent=this._backPlate,this._textPlate.position=s.Vector3.Forward(e.useRightHandedSystem).scale(-.08),this._textPlate.isPickable=!1,this._backPlate},e.prototype._applyFacade=function(t){this._plateMaterial.emissiveTexture=t,this._plateMaterial.opacityTexture=t},e.prototype._createBackMaterial=function(t){var e=this;this._backMaterial=new dt(this.name+"Back Material",t.getScene()),this._backMaterial.renderHoverLight=!0,this._pickedPointObserver=this._host.onPickedPointChangedObservable.add((function(t){t?(e._backMaterial.hoverPosition=t,e._backMaterial.hoverColor.a=1):e._backMaterial.hoverColor.a=0}))},e.prototype._createFrontMaterial=function(t){this._frontMaterial=new dt(this.name+"Front Material",t.getScene()),this._frontMaterial.innerGlowColorIntensity=0,this._frontMaterial.alpha=.5,this._frontMaterial.renderBorders=!0},e.prototype._createPlateMaterial=function(t){this._plateMaterial=new s.StandardMaterial(this.name+"Plate Material",t.getScene()),this._plateMaterial.specularColor=s.Color3.Black()},e.prototype._affectMaterial=function(t){this._shareMaterials?(this._host._sharedMaterials.backFluentMaterial?this._backMaterial=this._host._sharedMaterials.backFluentMaterial:(this._createBackMaterial(t),this._host._sharedMaterials.backFluentMaterial=this._backMaterial),this._host._sharedMaterials.frontFluentMaterial?this._frontMaterial=this._host._sharedMaterials.frontFluentMaterial:(this._createFrontMaterial(t),this._host._sharedMaterials.frontFluentMaterial=this._frontMaterial)):(this._createBackMaterial(t),this._createFrontMaterial(t)),this._createPlateMaterial(t),this._backPlate.material=this._backMaterial,this._frontPlate.material=this._frontMaterial,this._textPlate.material=this._plateMaterial,this._rebuildContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeTooltip(),this.shareMaterials||(this._backMaterial.dispose(),this._frontMaterial.dispose(),this._plateMaterial.dispose(),this._pickedPointObserver&&(this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver),this._pickedPointObserver=null))},e}(lt);s.ShaderStore.ShadersStore.fluentButtonPixelShader="uniform vec3 cameraPosition;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nuniform float _Edge_Width_;\nuniform vec4 _Edge_Color_;\nuniform bool _Relative_Width_;\nuniform float _Proximity_Max_Intensity_;\nuniform float _Proximity_Far_Distance_;\nuniform float _Proximity_Near_Radius_;\nuniform float _Proximity_Anisotropy_;\nuniform float _Selection_Fuzz_;\nuniform float _Selected_;\nuniform float _Selection_Fade_;\nuniform float _Selection_Fade_Size_;\nuniform float _Selected_Distance_;\nuniform float _Selected_Fade_Length_;\nuniform bool _Blob_Enable_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Inner_Fade_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform bool _Blob_Enable_2_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Inner_Fade_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Active_Face_Dir_;\nuniform vec3 _Active_Face_Up_;\nuniform bool Enable_Fade;\nuniform float _Fade_Width_;\nuniform bool _Smooth_Active_Face_;\nuniform bool _Show_Frame_;\nuniform bool _Use_Blob_Texture_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvoid Holo_Edge_Fragment_B35(\nvec4 Edges,\nfloat Edge_Width,\nout float NotEdge)\n{\nvec2 c=vec2(min(Edges.r,Edges.g),min(Edges.b,Edges.a));\nvec2 df=fwidth(c)*Edge_Width;\nvec2 g=clamp(c/df,0.0,1.0);\nNotEdge=g.x*g.y;\n}\nvoid Blob_Fragment_B39(\nvec2 UV,\nvec3 Blob_Info,\nsampler2D Blob_Texture,\nout vec4 Blob_Color)\n{\nfloat k=dot(UV,UV);\nBlob_Color=Blob_Info.y*texture(Blob_Texture,vec2(vec2(sqrt(k),Blob_Info.x).x,1.0-vec2(sqrt(k),Blob_Info.x).y))*(1.0-clamp(k,0.0,1.0));\n}\nvec2 FilterStep(vec2 Edge,vec2 X)\n{\nvec2 dX=max(fwidth(X),vec2(0.00001,0.00001));\nreturn clamp( (X+dX-max(Edge,X-dX))/(dX*2.0),0.0,1.0);\n}\nvoid Wireframe_Fragment_B59(\nvec3 Widths,\nvec2 UV,\nfloat Proximity,\nvec4 Edge_Color,\nout vec4 Wireframe)\n{\nvec2 c=min(UV,vec2(1.0,1.0)-UV);\nvec2 g=FilterStep(Widths.xy*0.5,c); \nWireframe=(1.0-min(g.x,g.y))*Proximity*Edge_Color;\n}\nvoid Proximity_B53(\nvec3 Proximity_Center,\nvec3 Proximity_Center_2,\nfloat Proximity_Max_Intensity,\nfloat Proximity_Near_Radius,\nvec3 Position,\nvec3 Show_Selection,\nvec4 Extra1,\nfloat Dist_To_Face,\nfloat Intensity,\nout float Proximity)\n{\nvec2 delta1=Extra1.xy;\nvec2 delta2=Extra1.zw;\nfloat d2=sqrt(min(dot(delta1,delta1),dot(delta2,delta2))+Dist_To_Face*Dist_To_Face);\nProximity=Intensity*Proximity_Max_Intensity*(1.0-clamp(d2/Proximity_Near_Radius,0.0,1.0))*(1.0-Show_Selection.x)+Show_Selection.x;\n}\nvoid To_XYZ_B46(\nvec3 Vec3,\nout float X,\nout float Y,\nout float Z)\n{\nX=Vec3.x;\nY=Vec3.y;\nZ=Vec3.z;\n}\nvoid main()\n{\nfloat NotEdge_Q35;\n#if ENABLE_FADE\nHolo_Edge_Fragment_B35(vColor,_Fade_Width_,NotEdge_Q35);\n#else\nNotEdge_Q35=1.0;\n#endif\nvec4 Blob_Color_Q39;\nfloat k=dot(vUV,vUV);\nvec2 blobTextureCoord=vec2(vec2(sqrt(k),vTangent.x).x,1.0-vec2(sqrt(k),vTangent.x).y);\nvec4 blobColor=mix(vec4(1.0,1.0,1.0,1.0)*step(1.0-vTangent.x,clamp(sqrt(k)+0.1,0.0,1.0)),texture(_Blob_Texture_,blobTextureCoord),float(_Use_Blob_Texture_));\nBlob_Color_Q39=vTangent.y*blobColor*(1.0-clamp(k,0.0,1.0));\nfloat Is_Quad_Q24;\nIs_Quad_Q24=vNormal.z;\nvec3 Blob_Position_Q41= mix(_Blob_Position_,Global_Left_Index_Tip_Position.xyz,float(Use_Global_Left_Index));\nvec3 Blob_Position_Q42= mix(_Blob_Position_2_,Global_Right_Index_Tip_Position.xyz,float(Use_Global_Right_Index));\nfloat X_Q46;\nfloat Y_Q46;\nfloat Z_Q46;\nTo_XYZ_B46(vBinormal,X_Q46,Y_Q46,Z_Q46);\nfloat Proximity_Q53;\nProximity_B53(Blob_Position_Q41,Blob_Position_Q42,_Proximity_Max_Intensity_,_Proximity_Near_Radius_,vPosition,vBinormal,vExtra1,Y_Q46,Z_Q46,Proximity_Q53);\nvec4 Wireframe_Q59;\nWireframe_Fragment_B59(vNormal,vUV,Proximity_Q53,_Edge_Color_,Wireframe_Q59);\nvec4 Wire_Or_Blob_Q23=mix(Wireframe_Q59,Blob_Color_Q39,Is_Quad_Q24);\nvec4 Result_Q22;\nResult_Q22=mix(Wire_Or_Blob_Q23,vec4(0.3,0.3,0.3,0.3),float(_Show_Frame_));\nvec4 Final_Color_Q37=NotEdge_Q35*Result_Q22;\nvec4 Out_Color=Final_Color_Q37;\nfloat Clip_Threshold=0.0;\nbool To_sRGB=false;\ngl_FragColor=Out_Color;\n}";s.ShaderStore.ShadersStore.fluentButtonVertexShader="uniform mat4 world;\nuniform mat4 viewProjection;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec3 tangent;\nattribute vec4 color;\nuniform float _Edge_Width_;\nuniform vec4 _Edge_Color_;\nuniform float _Proximity_Max_Intensity_;\nuniform float _Proximity_Far_Distance_;\nuniform float _Proximity_Near_Radius_;\nuniform float _Proximity_Anisotropy_;\nuniform float _Selection_Fuzz_;\nuniform float _Selected_;\nuniform float _Selection_Fade_;\nuniform float _Selection_Fade_Size_;\nuniform float _Selected_Distance_;\nuniform float _Selected_Fade_Length_;\nuniform bool _Blob_Enable_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Inner_Fade_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform bool _Blob_Enable_2_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Inner_Fade_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Active_Face_Dir_;\nuniform vec3 _Active_Face_Up_;\nuniform bool _Enable_Fade_;\nuniform float _Fade_Width_;\nuniform bool _Smooth_Active_Face_;\nuniform bool _Show_Frame_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvoid Blob_Vertex_B47(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nvec4 Vx_Color,\nvec2 UV,\nvec3 Face_Center,\nvec2 Face_Size,\nvec2 In_UV,\nfloat Blob_Fade_Length,\nfloat Selection_Fade,\nfloat Selection_Fade_Size,\nfloat Inner_Fade,\nvec3 Active_Face_Center,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nfloat Blob_Enabled,\nout vec3 Out_Position,\nout vec2 Out_UV,\nout vec3 Blob_Info)\n{\nfloat blobSize,fadeIn;\nvec3 Hit_Position;\nBlob_Info=vec3(0.0,0.0,0.0);\nfloat Hit_Distance=dot(Blob_Position-Face_Center,Normal);\nHit_Position=Blob_Position-Hit_Distance*Normal;\nfloat absD=abs(Hit_Distance);\nfloat lerpVal=clamp((absD-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfadeIn=1.0-clamp((absD-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat innerFade=1.0-clamp(-Hit_Distance/Inner_Fade,0.0,1.0);\nfloat farClip=clamp(1.0-step(Blob_Far_Distance+Blob_Fade_Length,absD),0.0,1.0);\nfloat size=mix(Blob_Near_Size,Blob_Far_Size,lerpVal)*farClip;\nblobSize=mix(size,Selection_Fade_Size,Selection_Fade)*innerFade*Blob_Enabled;\nBlob_Info.x=lerpVal*0.5+0.5;\nBlob_Info.y=fadeIn*Intensity*(1.0-Selection_Fade)*Blob_Fade;\nBlob_Info.x*=(1.0-Blob_Pulse);\nvec3 delta=Hit_Position-Face_Center;\nvec2 blobCenterXY=vec2(dot(delta,Tangent),dot(delta,Bitangent));\nvec2 quadUVin=2.0*UV-1.0; \nvec2 blobXY=blobCenterXY+quadUVin*blobSize;\nvec2 blobClipped=clamp(blobXY,-Face_Size*0.5,Face_Size*0.5);\nvec2 blobUV=(blobClipped-blobCenterXY)/max(blobSize,0.0001)*2.0;\nvec3 blobCorner=Face_Center+blobClipped.x*Tangent+blobClipped.y*Bitangent;\nOut_Position=mix(Position,blobCorner,Vx_Color.rrr);\nOut_UV=mix(In_UV,blobUV,Vx_Color.rr);\n}\nvec2 ProjectProximity(\nvec3 blobPosition,\nvec3 position,\nvec3 center,\nvec3 dir,\nvec3 xdir,\nvec3 ydir,\nout float vdistance\n)\n{\nvec3 delta=blobPosition-position;\nvec2 xy=vec2(dot(delta,xdir),dot(delta,ydir));\nvdistance=abs(dot(delta,dir));\nreturn xy;\n}\nvoid Proximity_Vertex_B66(\nvec3 Blob_Position,\nvec3 Blob_Position_2,\nvec3 Active_Face_Center,\nvec3 Active_Face_Dir,\nvec3 Position,\nfloat Proximity_Far_Distance,\nfloat Relative_Scale,\nfloat Proximity_Anisotropy,\nvec3 Up,\nout vec4 Extra1,\nout float Distance_To_Face,\nout float Intensity)\n{\nvec3 Active_Face_Dir_X=normalize(cross(Active_Face_Dir,Up));\nvec3 Active_Face_Dir_Y=cross(Active_Face_Dir,Active_Face_Dir_X);\nfloat distz1,distz2;\nExtra1.xy=ProjectProximity(Blob_Position,Position,Active_Face_Center,Active_Face_Dir,Active_Face_Dir_X*Proximity_Anisotropy,Active_Face_Dir_Y,distz1)/Relative_Scale;\nExtra1.zw=ProjectProximity(Blob_Position_2,Position,Active_Face_Center,Active_Face_Dir,Active_Face_Dir_X*Proximity_Anisotropy,Active_Face_Dir_Y,distz2)/Relative_Scale;\nDistance_To_Face=dot(Active_Face_Dir,Position-Active_Face_Center);\nIntensity=1.0-clamp(min(distz1,distz2)/Proximity_Far_Distance,0.0,1.0);\n}\nvoid Holo_Edge_Vertex_B44(\nvec3 Incident,\nvec3 Normal,\nvec2 UV,\nvec3 Tangent,\nvec3 Bitangent,\nbool Smooth_Active_Face,\nfloat Active,\nout vec4 Holo_Edges)\n{\nfloat NdotI=dot(Incident,Normal);\nvec2 flip=(UV-vec2(0.5,0.5));\nfloat udot=dot(Incident,Tangent)*flip.x*NdotI;\nfloat uval=1.0-float(udot>0.0);\nfloat vdot=-dot(Incident,Bitangent)*flip.y*NdotI;\nfloat vval=1.0-float(vdot>0.0);\nfloat Smooth_And_Active=step(1.0,float(Smooth_Active_Face && Active>0.0));\nuval=mix(uval,max(1.0,uval),Smooth_And_Active); \nvval=mix(vval,max(1.0,vval),Smooth_And_Active);\nHolo_Edges=vec4(1.0,1.0,1.0,1.0)-vec4(uval*UV.x,uval*(1.0-UV.x),vval*UV.y,vval*(1.0-UV.y));\n}\nvoid Object_To_World_Pos_B13(\nvec3 Pos_Object,\nout vec3 Pos_World)\n{\nPos_World=(world*vec4(Pos_Object,1.0)).xyz;\n}\nvoid Choose_Blob_B38(\nvec4 Vx_Color,\nvec3 Position1,\nvec3 Position2,\nbool Blob_Enable_1,\nbool Blob_Enable_2,\nfloat Near_Size_1,\nfloat Near_Size_2,\nfloat Blob_Inner_Fade_1,\nfloat Blob_Inner_Fade_2,\nfloat Blob_Pulse_1,\nfloat Blob_Pulse_2,\nfloat Blob_Fade_1,\nfloat Blob_Fade_2,\nout vec3 Position,\nout float Near_Size,\nout float Inner_Fade,\nout float Blob_Enable,\nout float Fade,\nout float Pulse)\n{\nPosition=Position1*(1.0-Vx_Color.g)+Vx_Color.g*Position2;\nfloat b1=float(Blob_Enable_1);\nfloat b2=float(Blob_Enable_2);\nBlob_Enable=b1+(b2-b1)*Vx_Color.g;\nPulse=Blob_Pulse_1*(1.0-Vx_Color.g)+Vx_Color.g*Blob_Pulse_2;\nFade=Blob_Fade_1*(1.0-Vx_Color.g)+Vx_Color.g*Blob_Fade_2;\nNear_Size=Near_Size_1*(1.0-Vx_Color.g)+Vx_Color.g*Near_Size_2;\nInner_Fade=Blob_Inner_Fade_1*(1.0-Vx_Color.g)+Vx_Color.g*Blob_Inner_Fade_2;\n}\nvoid Wireframe_Vertex_B51(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nfloat Edge_Width,\nvec2 Face_Size,\nout vec3 Wire_Vx_Pos,\nout vec2 UV,\nout vec2 Widths)\n{\nWidths.xy=Edge_Width/Face_Size;\nfloat x=dot(Position,Tangent);\nfloat y=dot(Position,Bitangent);\nfloat dx=0.5-abs(x);\nfloat newx=(0.5-dx*Widths.x*2.0)*sign(x);\nfloat dy=0.5-abs(y);\nfloat newy=(0.5-dy*Widths.y*2.0)*sign(y);\nWire_Vx_Pos=Normal*0.5+newx*Tangent+newy*Bitangent;\nUV.x=dot(Wire_Vx_Pos,Tangent)+0.5;\nUV.y=dot(Wire_Vx_Pos,Bitangent)+0.5;\n}\nvec2 ramp2(vec2 start,vec2 end,vec2 x)\n{\nreturn clamp((x-start)/(end-start),vec2(0.0,0.0),vec2(1.0,1.0));\n}\nfloat computeSelection(\nvec3 blobPosition,\nvec3 normal,\nvec3 tangent,\nvec3 bitangent,\nvec3 faceCenter,\nvec2 faceSize,\nfloat selectionFuzz,\nfloat farDistance,\nfloat fadeLength\n)\n{\nvec3 delta=blobPosition-faceCenter;\nfloat absD=abs(dot(delta,normal));\nfloat fadeIn=1.0-clamp((absD-farDistance)/fadeLength,0.0,1.0);\nvec2 blobCenterXY=vec2(dot(delta,tangent),dot(delta,bitangent));\nvec2 innerFace=faceSize*(1.0-selectionFuzz)*0.5;\nvec2 selectPulse=ramp2(-faceSize*0.5,-innerFace,blobCenterXY)-ramp2(innerFace,faceSize*0.5,blobCenterXY);\nreturn selectPulse.x*selectPulse.y*fadeIn;\n}\nvoid Selection_Vertex_B48(\nvec3 Blob_Position,\nvec3 Blob_Position_2,\nvec3 Face_Center,\nvec2 Face_Size,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nfloat Selection_Fuzz,\nfloat Selected,\nfloat Far_Distance,\nfloat Fade_Length,\nvec3 Active_Face_Dir,\nout float Show_Selection)\n{\nfloat select1=computeSelection(Blob_Position,Normal,Tangent,Bitangent,Face_Center,Face_Size,Selection_Fuzz,Far_Distance,Fade_Length);\nfloat select2=computeSelection(Blob_Position_2,Normal,Tangent,Bitangent,Face_Center,Face_Size,Selection_Fuzz,Far_Distance,Fade_Length);\nfloat Active=max(0.0,dot(Active_Face_Dir,Normal));\nShow_Selection=mix(max(select1,select2),1.0,Selected)*Active;\n}\nvoid Proximity_Visibility_B54(\nfloat Selection,\nvec3 Proximity_Center,\nvec3 Proximity_Center_2,\nfloat Input_Width,\nfloat Proximity_Far_Distance,\nfloat Proximity_Radius,\nvec3 Active_Face_Center,\nvec3 Active_Face_Dir,\nout float Width)\n{\nvec3 boxEdges=(world*vec4(vec3(0.5,0.5,0.5),0.0)).xyz;\nfloat boxMaxSize=length(boxEdges);\nfloat d1=dot(Proximity_Center-Active_Face_Center,Active_Face_Dir);\nvec3 blob1=Proximity_Center-d1*Active_Face_Dir;\nfloat d2=dot(Proximity_Center_2-Active_Face_Center,Active_Face_Dir);\nvec3 blob2=Proximity_Center_2-d2*Active_Face_Dir;\nvec3 delta1=blob1-Active_Face_Center;\nvec3 delta2=blob2-Active_Face_Center;\nfloat dist1=dot(delta1,delta1);\nfloat dist2=dot(delta2,delta2);\nfloat nearestProxDist=sqrt(min(dist1,dist2));\nWidth=Input_Width*(1.0-step(boxMaxSize+Proximity_Radius,nearestProxDist))*(1.0-step(Proximity_Far_Distance,min(d1,d2))*(1.0-step(0.0001,Selection)));\n}\nvoid Object_To_World_Dir_B67(\nvec3 Dir_Object,\nout vec3 Dir_World)\n{\nDir_World=(world*vec4(Dir_Object,0.0)).xyz;\n}\nvoid main()\n{\nvec3 Active_Face_Center_Q49;\nActive_Face_Center_Q49=(world*vec4(_Active_Face_Dir_*0.5,1.0)).xyz;\nvec3 Blob_Position_Q41= mix(_Blob_Position_,Global_Left_Index_Tip_Position.xyz,float(Use_Global_Left_Index));\nvec3 Blob_Position_Q42= mix(_Blob_Position_2_,Global_Right_Index_Tip_Position.xyz,float(Use_Global_Right_Index));\nvec3 Active_Face_Dir_Q64=normalize((world*vec4(_Active_Face_Dir_,0.0)).xyz);\nfloat Relative_Scale_Q57;\n#if RELATIVE_WIDTH\nRelative_Scale_Q57=length((world*vec4(vec3(0,1,0),0.0)).xyz);\n#else\nRelative_Scale_Q57=1.0;\n#endif\nvec3 Tangent_World_Q30;\nTangent_World_Q30=(world*vec4(tangent,0.0)).xyz;\nvec3 Binormal_World_Q31;\nBinormal_World_Q31=(world*vec4((cross(normal,tangent)),0.0)).xyz;\nvec3 Normal_World_Q60;\nNormal_World_Q60=(world*vec4(normal,0.0)).xyz;\nvec3 Result_Q18=0.5*normal;\nvec3 Dir_World_Q67;\nObject_To_World_Dir_B67(_Active_Face_Up_,Dir_World_Q67);\nfloat Product_Q56=_Edge_Width_*Relative_Scale_Q57;\nvec3 Normal_World_N_Q29=normalize(Normal_World_Q60);\nvec3 Tangent_World_N_Q28=normalize(Tangent_World_Q30);\nvec3 Binormal_World_N_Q32=normalize(Binormal_World_Q31);\nvec3 Position_Q38;\nfloat Near_Size_Q38;\nfloat Inner_Fade_Q38;\nfloat Blob_Enable_Q38;\nfloat Fade_Q38;\nfloat Pulse_Q38;\nChoose_Blob_B38(color,Blob_Position_Q41,Blob_Position_Q42,_Blob_Enable_,_Blob_Enable_2_,_Blob_Near_Size_,_Blob_Near_Size_2_,_Blob_Inner_Fade_,_Blob_Inner_Fade_2_,_Blob_Pulse_,_Blob_Pulse_2_,_Blob_Fade_,_Blob_Fade_2_,Position_Q38,Near_Size_Q38,Inner_Fade_Q38,Blob_Enable_Q38,Fade_Q38,Pulse_Q38);\nvec3 Face_Center_Q33;\nFace_Center_Q33=(world*vec4(Result_Q18,1.0)).xyz;\nvec2 Face_Size_Q50=vec2(length(Tangent_World_Q30),length(Binormal_World_Q31));\nfloat Show_Selection_Q48;\nSelection_Vertex_B48(Blob_Position_Q41,Blob_Position_Q42,Face_Center_Q33,Face_Size_Q50,Normal_World_N_Q29,Tangent_World_N_Q28,Binormal_World_N_Q32,_Selection_Fuzz_,_Selected_,_Selected_Distance_,_Selected_Fade_Length_,Active_Face_Dir_Q64,Show_Selection_Q48);\nvec3 Normalized_Q72=normalize(Dir_World_Q67);\nfloat Active_Q34=max(0.0,dot(Active_Face_Dir_Q64,Normal_World_N_Q29));\nfloat Width_Q54;\nProximity_Visibility_B54(Show_Selection_Q48,Blob_Position_Q41,Blob_Position_Q42,Product_Q56,_Proximity_Far_Distance_,_Proximity_Near_Radius_,Active_Face_Center_Q49,Active_Face_Dir_Q64,Width_Q54);\nvec3 Wire_Vx_Pos_Q51;\nvec2 UV_Q51;\nvec2 Widths_Q51;\nWireframe_Vertex_B51(position,normal,tangent,(cross(normal,tangent)),Width_Q54,Face_Size_Q50,Wire_Vx_Pos_Q51,UV_Q51,Widths_Q51);\nvec3 Vec3_Q27=vec3(Widths_Q51.x,Widths_Q51.y,color.r);\nvec3 Pos_World_Q13;\nObject_To_World_Pos_B13(Wire_Vx_Pos_Q51,Pos_World_Q13);\nvec3 Incident_Q36=normalize(Pos_World_Q13-cameraPosition);\nvec3 Out_Position_Q47;\nvec2 Out_UV_Q47;\nvec3 Blob_Info_Q47;\nBlob_Vertex_B47(Pos_World_Q13,Normal_World_N_Q29,Tangent_World_N_Q28,Binormal_World_N_Q32,Position_Q38,_Blob_Intensity_,Near_Size_Q38,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,color,uv,Face_Center_Q33,Face_Size_Q50,UV_Q51,_Blob_Fade_Length_,_Selection_Fade_,_Selection_Fade_Size_,Inner_Fade_Q38,Active_Face_Center_Q49,Pulse_Q38,Fade_Q38,Blob_Enable_Q38,Out_Position_Q47,Out_UV_Q47,Blob_Info_Q47);\nvec4 Extra1_Q66;\nfloat Distance_To_Face_Q66;\nfloat Intensity_Q66;\nProximity_Vertex_B66(Blob_Position_Q41,Blob_Position_Q42,Active_Face_Center_Q49,Active_Face_Dir_Q64,Pos_World_Q13,_Proximity_Far_Distance_,Relative_Scale_Q57,_Proximity_Anisotropy_,Normalized_Q72,Extra1_Q66,Distance_To_Face_Q66,Intensity_Q66);\nvec4 Holo_Edges_Q44;\nHolo_Edge_Vertex_B44(Incident_Q36,Normal_World_N_Q29,uv,Tangent_World_Q30,Binormal_World_Q31,_Smooth_Active_Face_,Active_Q34,Holo_Edges_Q44);\nvec3 Vec3_Q19=vec3(Show_Selection_Q48,Distance_To_Face_Q66,Intensity_Q66);\nvec3 Position=Out_Position_Q47;\nvec2 UV=Out_UV_Q47;\nvec3 Tangent=Blob_Info_Q47;\nvec3 Binormal=Vec3_Q19;\nvec3 Normal=Vec3_Q27;\nvec4 Extra1=Extra1_Q66;\nvec4 Color=Holo_Edges_Q44;\ngl_Position=viewProjection*vec4(Position,1);\nvPosition=Position;\nvNormal=Normal;\nvUV=UV;\nvTangent=Tangent;\nvBinormal=Binormal;\nvColor=Color;\nvExtra1=Extra1;\n}";var pt=function(t){function e(){var e=t.call(this)||this;return e.RELATIVE_WIDTH=!0,e.ENABLE_FADE=!0,e._needNormals=!0,e._needUVs=!0,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),gt=function(t){function e(i,o){var n=t.call(this,i,o)||this;return n.edgeWidth=.04,n.edgeColor=new s.Color4(.592157,.592157,.592157,1),n.proximityMaxIntensity=.45,n.proximityFarDistance=.16,n.proximityNearRadius=1.5,n.proximityAnisotropy=1,n.selectionFuzz=.5,n.selected=0,n.selectionFade=0,n.selectionFadeSize=.3,n.selectedDistance=.08,n.selectedFadeLength=.08,n.blobIntensity=.5,n.blobFarSize=.05,n.blobNearDistance=0,n.blobFarDistance=.08,n.blobFadeLength=.08,n.leftBlobEnable=!0,n.leftBlobNearSize=.025,n.leftBlobPulse=0,n.leftBlobFade=1,n.leftBlobInnerFade=.01,n.rightBlobEnable=!0,n.rightBlobNearSize=.025,n.rightBlobPulse=0,n.rightBlobFade=1,n.rightBlobInnerFade=.01,n.activeFaceDir=new s.Vector3(0,0,-1),n.activeFaceUp=new s.Vector3(0,1,0),n.enableFade=!0,n.fadeWidth=1.5,n.smoothActiveFace=!0,n.showFrame=!1,n.useBlobTexture=!0,n.globalLeftIndexTipPosition=s.Vector3.Zero(),n.globalRightIndexTipPosition=s.Vector3.Zero(),n.alphaMode=s.Constants.ALPHA_ADD,n.disableDepthWrite=!0,n.backFaceCulling=!1,n._blobTexture=new s.Texture(e.BLOB_TEXTURE_URL,n.getScene(),!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n}return r(e,t),e.prototype.needAlphaBlending=function(){return!0},e.prototype.needAlphaTesting=function(){return!0},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new pt);var i=e.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(e))return!0;var n=o.getEngine();if(s.MaterialHelper.PrepareDefinesForAttributes(t,i,!0,!1),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var r=new s.EffectFallbacks;i.FOG&&r.addFallback(1,"FOG"),s.MaterialHelper.HandleFallbacksForShadows(i,r),i.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var a=[s.VertexBuffer.PositionKind];i.NORMAL&&a.push(s.VertexBuffer.NormalKind),i.UV1&&a.push(s.VertexBuffer.UVKind),i.UV2&&a.push(s.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&a.push(s.VertexBuffer.ColorKind),i.TANGENT&&a.push(s.VertexBuffer.TangentKind),s.MaterialHelper.PrepareAttributesForInstances(a,i);var l=i.toString(),_=["world","viewProjection","cameraPosition","_Edge_Width_","_Edge_Color_","_Relative_Width_","_Proximity_Max_Intensity_","_Proximity_Far_Distance_","_Proximity_Near_Radius_","_Proximity_Anisotropy_","_Selection_Fuzz_","_Selected_","_Selection_Fade_","_Selection_Fade_Size_","_Selected_Distance_","_Selected_Fade_Length_","_Blob_Enable_","_Blob_Position_","_Blob_Intensity_","_Blob_Near_Size_","_Blob_Far_Size_","_Blob_Near_Distance_","_Blob_Far_Distance_","_Blob_Fade_Length_","_Blob_Inner_Fade_","_Blob_Pulse_","_Blob_Fade_","_Blob_Texture_","_Blob_Enable_2_","_Blob_Position_2_","_Blob_Near_Size_2_","_Blob_Inner_Fade_2_","_Blob_Pulse_2_","_Blob_Fade_2_","_Active_Face_Dir_","_Active_Face_Up_","_Enable_Fade_","_Fade_Width_","_Smooth_Active_Face_","_Show_Frame_","_Use_Blob_Texture_","Use_Global_Left_Index","Use_Global_Right_Index","Global_Left_Index_Tip_Position","Global_Right_Index_Tip_Position","Global_Left_Thumb_Tip_Position","Global_Right_Thumb_Tip_Position","Global_Left_Index_Tip_Proximity","Global_Right_Index_Tip_Proximity"],h=["_Blob_Texture_"],c=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:i,maxSimultaneousLights:4}),e.setEffect(o.getEngine().createEffect("fluentButton",{attributes:a,uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:l,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),i,this._materialContext)}return!(!e.effect||!e.effect.isReady()||(i._renderId=o.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){var o=this.getScene();if(i.materialDefines){var n=i.effect;n&&(this._activeEffect=n,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",o.getTransformMatrix()),this._activeEffect.setVector3("cameraPosition",o.activeCamera.position),this._activeEffect.setTexture("_Blob_Texture_",this._blobTexture),this._activeEffect.setFloat("_Edge_Width_",this.edgeWidth),this._activeEffect.setColor4("_Edge_Color_",new s.Color3(this.edgeColor.r,this.edgeColor.g,this.edgeColor.b),this.edgeColor.a),this._activeEffect.setFloat("_Proximity_Max_Intensity_",this.proximityMaxIntensity),this._activeEffect.setFloat("_Proximity_Far_Distance_",this.proximityFarDistance),this._activeEffect.setFloat("_Proximity_Near_Radius_",this.proximityNearRadius),this._activeEffect.setFloat("_Proximity_Anisotropy_",this.proximityAnisotropy),this._activeEffect.setFloat("_Selection_Fuzz_",this.selectionFuzz),this._activeEffect.setFloat("_Selected_",this.selected),this._activeEffect.setFloat("_Selection_Fade_",this.selectionFade),this._activeEffect.setFloat("_Selection_Fade_Size_",this.selectionFadeSize),this._activeEffect.setFloat("_Selected_Distance_",this.selectedDistance),this._activeEffect.setFloat("_Selected_Fade_Length_",this.selectedFadeLength),this._activeEffect.setFloat("_Blob_Enable_",this.leftBlobEnable?1:0),this._activeEffect.setFloat("_Blob_Intensity_",this.blobIntensity),this._activeEffect.setFloat("_Blob_Near_Size_",this.leftBlobNearSize),this._activeEffect.setFloat("_Blob_Far_Size_",this.blobFarSize),this._activeEffect.setFloat("_Blob_Near_Distance_",this.blobNearDistance),this._activeEffect.setFloat("_Blob_Far_Distance_",this.blobFarDistance),this._activeEffect.setFloat("_Blob_Fade_Length_",this.blobFadeLength),this._activeEffect.setFloat("_Blob_Inner_Fade_",this.leftBlobInnerFade),this._activeEffect.setFloat("_Blob_Pulse_",this.leftBlobPulse),this._activeEffect.setFloat("_Blob_Fade_",this.leftBlobFade),this._activeEffect.setFloat("_Blob_Enable_2_",this.rightBlobEnable?1:0),this._activeEffect.setFloat("_Blob_Near_Size_2_",this.rightBlobNearSize),this._activeEffect.setFloat("_Blob_Inner_Fade_2_",this.rightBlobInnerFade),this._activeEffect.setFloat("_Blob_Pulse_2_",this.rightBlobPulse),this._activeEffect.setFloat("_Blob_Fade_2_",this.rightBlobFade),this._activeEffect.setVector3("_Active_Face_Dir_",this.activeFaceDir),this._activeEffect.setVector3("_Active_Face_Up_",this.activeFaceUp),this._activeEffect.setFloat("_Fade_Width_",this.fadeWidth),this._activeEffect.setFloat("_Smooth_Active_Face_",this.smoothActiveFace?1:0),this._activeEffect.setFloat("_Show_Frame_",this.showFrame?1:0),this._activeEffect.setFloat("_Use_Blob_Texture_",this.useBlobTexture?1:0),this._activeEffect.setFloat("Use_Global_Left_Index",1),this._activeEffect.setFloat("Use_Global_Right_Index",1),this._activeEffect.setVector4("Global_Left_Index_Tip_Position",new s.Vector4(this.globalLeftIndexTipPosition.x,this.globalLeftIndexTipPosition.y,this.globalLeftIndexTipPosition.z,1)),this._activeEffect.setVector4("Global_Right_Index_Tip_Position",new s.Vector4(this.globalRightIndexTipPosition.x,this.globalRightIndexTipPosition.y,this.globalRightIndexTipPosition.z,1)),this._afterBind(e,this._activeEffect))}},e.prototype.getAnimatables=function(){return[]},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.FluentButtonMaterial",e},e.prototype.getClassName=function(){return"FluentButtonMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},e.BLOB_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/mrtk-fluent-button-blob.png",a([(0,s.serialize)()],e.prototype,"edgeWidth",void 0),a([(0,s.serializeAsColor4)()],e.prototype,"edgeColor",void 0),a([(0,s.serialize)()],e.prototype,"proximityMaxIntensity",void 0),a([(0,s.serialize)()],e.prototype,"proximityFarDistance",void 0),a([(0,s.serialize)()],e.prototype,"proximityNearRadius",void 0),a([(0,s.serialize)()],e.prototype,"proximityAnisotropy",void 0),a([(0,s.serialize)()],e.prototype,"selectionFuzz",void 0),a([(0,s.serialize)()],e.prototype,"selected",void 0),a([(0,s.serialize)()],e.prototype,"selectionFade",void 0),a([(0,s.serialize)()],e.prototype,"selectionFadeSize",void 0),a([(0,s.serialize)()],e.prototype,"selectedDistance",void 0),a([(0,s.serialize)()],e.prototype,"selectedFadeLength",void 0),a([(0,s.serialize)()],e.prototype,"blobIntensity",void 0),a([(0,s.serialize)()],e.prototype,"blobFarSize",void 0),a([(0,s.serialize)()],e.prototype,"blobNearDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFarDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFadeLength",void 0),a([(0,s.serialize)()],e.prototype,"leftBlobEnable",void 0),a([(0,s.serialize)()],e.prototype,"leftBlobNearSize",void 0),a([(0,s.serialize)()],e.prototype,"leftBlobPulse",void 0),a([(0,s.serialize)()],e.prototype,"leftBlobFade",void 0),a([(0,s.serialize)()],e.prototype,"leftBlobInnerFade",void 0),a([(0,s.serialize)()],e.prototype,"rightBlobEnable",void 0),a([(0,s.serialize)()],e.prototype,"rightBlobNearSize",void 0),a([(0,s.serialize)()],e.prototype,"rightBlobPulse",void 0),a([(0,s.serialize)()],e.prototype,"rightBlobFade",void 0),a([(0,s.serialize)()],e.prototype,"rightBlobInnerFade",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"activeFaceDir",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"activeFaceUp",void 0),a([(0,s.serialize)()],e.prototype,"enableFade",void 0),a([(0,s.serialize)()],e.prototype,"fadeWidth",void 0),a([(0,s.serialize)()],e.prototype,"smoothActiveFace",void 0),a([(0,s.serialize)()],e.prototype,"showFrame",void 0),a([(0,s.serialize)()],e.prototype,"useBlobTexture",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"globalLeftIndexTipPosition",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"globalRightIndexTipPosition",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.FluentButtonMaterial",gt);var mt=function(t){function e(e,i){var o=t.call(this,e)||this;return o._isNearPressed=!1,o._interactionSurfaceHeight=0,o._isToggleButton=!1,o._toggleState=!1,o._toggleButtonCallback=function(){o._onToggle(!o._toggleState)},o.onToggleObservable=new s.Observable,o.collidableFrontDirection=s.Vector3.Zero(),i&&(o.collisionMesh=i),o}return r(e,t),Object.defineProperty(e.prototype,"isActiveNearInteraction",{get:function(){return this._isNearPressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"collidableFrontDirection",{get:function(){if(this._collisionMesh){var t=s.TmpVectors.Vector3[0];return s.Vector3.TransformNormalToRef(this._collidableFrontDirection,this._collisionMesh.getWorldMatrix(),t),t.normalize()}return this._collidableFrontDirection},set:function(t){if(this._collidableFrontDirection=t.normalize(),this._collisionMesh){var e=s.TmpVectors.Matrix[0];e.copyFrom(this._collisionMesh.getWorldMatrix()),e.invert(),s.Vector3.TransformNormalToRef(this._collidableFrontDirection,e,this._collidableFrontDirection),this._collidableFrontDirection.normalize()}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"collisionMesh",{set:function(t){var e,i=this;this._collisionMesh&&(this._collisionMesh.isNearPickable=!1,(null===(e=this._collisionMesh.reservedDataStore)||void 0===e?void 0:e.GUI3D)&&(this._collisionMesh.reservedDataStore.GUI3D={}),this._collisionMesh.getChildMeshes().forEach((function(t){var e;t.isNearPickable=!1,(null===(e=t.reservedDataStore)||void 0===e?void 0:e.GUI3D)&&(t.reservedDataStore.GUI3D={})}))),this._collisionMesh=t,this._injectGUI3DReservedDataStore(this._collisionMesh).control=this,this._collisionMesh.isNearPickable=!0,this._collisionMesh.getChildMeshes().forEach((function(t){i._injectGUI3DReservedDataStore(t).control=i,t.isNearPickable=!0})),this.collidableFrontDirection=t.forward},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isToggleButton",{get:function(){return this._isToggleButton},set:function(t){t!==this._isToggleButton&&(this._isToggleButton=t,t?this.onPointerUpObservable.add(this._toggleButtonCallback):(this.onPointerUpObservable.removeCallback(this._toggleButtonCallback),this._toggleState&&this._onToggle(!1)))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isToggled",{get:function(){return this._toggleState},set:function(t){this._isToggleButton&&this._toggleState!==t&&this._onToggle(t)},enumerable:!1,configurable:!0}),e.prototype._onToggle=function(t){this._toggleState=t,this.onToggleObservable.notifyObservers(t)},e.prototype._isInteractionInFrontOfButton=function(t){return this._getInteractionHeight(t,this._collisionMesh.getAbsolutePosition())>0},e.prototype.getPressDepth=function(t){if(!this._isNearPressed)return 0;var e=this._getInteractionHeight(t,this._collisionMesh.getAbsolutePosition());return this._interactionSurfaceHeight-e},e.prototype._getInteractionHeight=function(t,e){var i=this.collidableFrontDirection;if(0===i.length())return s.Vector3.Distance(t,e);var o=s.Vector3.Dot(e,i);return s.Vector3.Dot(t,i)-o},e.prototype._generatePointerEventType=function(t,e,i){if(t===s.PointerEventTypes.POINTERDOWN){if(!this._isInteractionInFrontOfButton(e))return s.PointerEventTypes.POINTERMOVE;this._isNearPressed=!0,this._interactionSurfaceHeight=this._getInteractionHeight(e,this._collisionMesh.getAbsolutePosition())}if(t===s.PointerEventTypes.POINTERUP){if(0==i)return s.PointerEventTypes.POINTERMOVE;this._isNearPressed=!1}return t},e.prototype._getTypeName=function(){return"TouchButton3D"},e.prototype._createNode=function(e){return t.prototype._createNode.call(this,e)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.onPointerUpObservable.removeCallback(this._toggleButtonCallback),this.onToggleObservable.clear(),this._collisionMesh&&this._collisionMesh.dispose()},e}(lt),bt=function(t){function e(e,i){void 0===i&&(i=!0);var o=t.call(this,e)||this;return o._shareMaterials=!0,o._isBackplateVisible=!0,o._frontPlateDepth=.5,o._backPlateDepth=.04,o._backplateColor=new s.Color3(.08,.15,.55),o._backplateToggledColor=new s.Color3(.25,.4,.95),o._shareMaterials=i,o.pointerEnterAnimation=function(){o._frontMaterial.leftBlobEnable=!0,o._frontMaterial.rightBlobEnable=!0},o.pointerOutAnimation=function(){o._frontMaterial.leftBlobEnable=!1,o._frontMaterial.rightBlobEnable=!1},o.pointerDownAnimation=function(){o._frontPlate&&!o.isActiveNearInteraction&&(o._frontPlate.scaling.z=.2*o._frontPlateDepth,o._frontPlate.position=s.Vector3.Forward(o._frontPlate._scene.useRightHandedSystem).scale((o._frontPlateDepth-.2*o._frontPlateDepth)/2),o._textPlate.position=s.Vector3.Forward(o._textPlate._scene.useRightHandedSystem).scale(-(o._backPlateDepth+.2*o._frontPlateDepth)/2))},o.pointerUpAnimation=function(){o._frontPlate&&(o._frontPlate.scaling.z=o._frontPlateDepth,o._frontPlate.position=s.Vector3.Forward(o._frontPlate._scene.useRightHandedSystem).scale((o._frontPlateDepth-o._frontPlateDepth)/2),o._textPlate.position=s.Vector3.Forward(o._textPlate._scene.useRightHandedSystem).scale(-(o._backPlateDepth+o._frontPlateDepth)/2))},o.onPointerMoveObservable.add((function(t){if(o._frontPlate&&o.isActiveNearInteraction){var e=s.Vector3.Zero();if(o._backPlate.getWorldMatrix().decompose(e,void 0,void 0)){var i=o._getInteractionHeight(t,o._backPlate.getAbsolutePosition())/e.z;i=s.Scalar.Clamp(i-o._backPlateDepth/2,.2*o._frontPlateDepth,o._frontPlateDepth),o._frontPlate.scaling.z=i,o._frontPlate.position=s.Vector3.Forward(o._frontPlate._scene.useRightHandedSystem).scale((o._frontPlateDepth-i)/2),o._textPlate.position=s.Vector3.Forward(o._textPlate._scene.useRightHandedSystem).scale(-(o._backPlateDepth+i)/2)}}})),o._pointerHoverObserver=o.onPointerMoveObservable.add((function(t){o._frontMaterial.globalLeftIndexTipPosition=t})),o}return r(e,t),e.prototype._disposeTooltip=function(){this._tooltipFade=null,this._tooltipTextBlock&&this._tooltipTextBlock.dispose(),this._tooltipTexture&&this._tooltipTexture.dispose(),this._tooltipMesh&&this._tooltipMesh.dispose(),this.onPointerEnterObservable.remove(this._tooltipHoverObserver),this.onPointerOutObservable.remove(this._tooltipOutObserver)},Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._backPlate.renderingGroupId},set:function(t){this._backPlate.renderingGroupId=t,this._textPlate.renderingGroupId=t,this._frontPlate.renderingGroupId=t,this._tooltipMesh&&(this._tooltipMesh.renderingGroupId=t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{get:function(){return this._backPlate},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"tooltipText",{get:function(){return this._tooltipTextBlock?this._tooltipTextBlock.text:null},set:function(t){var e=this;if(t){if(!this._tooltipFade){var i=this._backPlate._scene.useRightHandedSystem;this._tooltipMesh=(0,s.CreatePlane)("",{size:1},this._backPlate._scene);var o=(0,s.CreatePlane)("",{size:1,sideOrientation:s.Mesh.DOUBLESIDE},this._backPlate._scene),n=new s.StandardMaterial("",this._backPlate._scene);n.diffuseColor=s.Color3.FromHexString("#212121"),o.material=n,o.isPickable=!1,this._tooltipMesh.addChild(o),o.position=s.Vector3.Forward(i).scale(.05),this._tooltipMesh.scaling.y=1/3,this._tooltipMesh.position=s.Vector3.Up().scale(.7).add(s.Vector3.Forward(i).scale(-.15)),this._tooltipMesh.isPickable=!1,this._tooltipMesh.parent=this._backPlate,this._tooltipTexture=tt.CreateForMesh(this._tooltipMesh),this._tooltipTextBlock=new y,this._tooltipTextBlock.scaleY=3,this._tooltipTextBlock.color="white",this._tooltipTextBlock.fontSize=130,this._tooltipTexture.addControl(this._tooltipTextBlock),this._tooltipFade=new s.FadeInOutBehavior,this._tooltipFade.delay=500,this._tooltipMesh.addBehavior(this._tooltipFade),this._tooltipHoverObserver=this.onPointerEnterObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!0)})),this._tooltipOutObserver=this.onPointerOutObservable.add((function(){e._tooltipFade&&e._tooltipFade.fadeIn(!1)}))}this._tooltipTextBlock&&(this._tooltipTextBlock.text=t)}else this._disposeTooltip()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageUrl",{get:function(){return this._imageUrl},set:function(t){this._imageUrl!==t&&(this._imageUrl=t,this._rebuildContent())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backMaterial",{get:function(){return this._backMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontMaterial",{get:function(){return this._frontMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"plateMaterial",{get:function(){return this._plateMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shareMaterials",{get:function(){return this._shareMaterials},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isBackplateVisible",{set:function(t){this.mesh&&this._backMaterial&&(t&&!this._isBackplateVisible?this._backPlate.visibility=1:!t&&this._isBackplateVisible&&(this._backPlate.visibility=0)),this._isBackplateVisible=t},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"TouchHolographicButton"},e.prototype._rebuildContent=function(){this._disposeFacadeTexture();var t=new B;if(t.isVertical=!0,s.DomManagement.IsDocumentAvailable()&&document.createElement&&this._imageUrl){var e=new x;e.source=this._imageUrl,e.paddingTop="40px",e.height="180px",e.width="100px",e.paddingBottom="40px",t.addControl(e)}if(this._text){var i=new y;i.text=this._text,i.color="white",i.height="30px",i.fontSize=24,t.addControl(i)}this.content=t},e.prototype._createNode=function(i){var o,n=this;this.name=null!==(o=this.name)&&void 0!==o?o:"TouchHolographicButton";var r=(0,s.CreateBox)("".concat(this.name,"_collisionMesh"),{width:1,height:1,depth:this._frontPlateDepth},i);r.isPickable=!0,r.isNearPickable=!0,r.visibility=0,r.position=s.Vector3.Forward(i.useRightHandedSystem).scale(-this._frontPlateDepth/2),s.SceneLoader.ImportMeshAsync(void 0,e.MODEL_BASE_URL,e.MODEL_FILENAME,i).then((function(t){var e=(0,s.CreateBox)("${this.name}_alphaMesh",{width:1,height:1,depth:1},i);e.isPickable=!1,e.material=new s.StandardMaterial("${this.name}_alphaMesh_material",i),e.material.alpha=.15;var o=t.meshes[1];o.name="".concat(n.name,"_frontPlate"),o.isPickable=!1,o.scaling.z=n._frontPlateDepth,e.parent=o,o.parent=r,n._frontMaterial&&(o.material=n._frontMaterial),n._frontPlate=o})),this._backPlate=(0,s.CreateBox)("".concat(this.name,"_backPlate"),{width:1,height:1,depth:this._backPlateDepth},i),this._backPlate.position=s.Vector3.Forward(i.useRightHandedSystem).scale(this._backPlateDepth/2),this._backPlate.isPickable=!1,this._textPlate=t.prototype._createNode.call(this,i),this._textPlate.name="".concat(this.name,"_textPlate"),this._textPlate.isPickable=!1,this._textPlate.position=s.Vector3.Forward(i.useRightHandedSystem).scale(-this._frontPlateDepth/2),this._backPlate.addChild(r),this._backPlate.addChild(this._textPlate);var a=new s.TransformNode("{this.name}_root",i);return this._backPlate.setParent(a),this.collisionMesh=r,this.collidableFrontDirection=this._backPlate.forward.negate(),a},e.prototype._applyFacade=function(t){this._plateMaterial.emissiveTexture=t,this._plateMaterial.opacityTexture=t,this._plateMaterial.diffuseColor=new s.Color3(.4,.4,.4)},e.prototype._createBackMaterial=function(t){this._backMaterial=new dt(this.name+"backPlateMaterial",t.getScene()),this._backMaterial.albedoColor=this._backplateColor,this._backMaterial.renderBorders=!0,this._backMaterial.renderHoverLight=!1},e.prototype._createFrontMaterial=function(t){this._frontMaterial=new gt(this.name+"Front Material",t.getScene())},e.prototype._createPlateMaterial=function(t){this._plateMaterial=new s.StandardMaterial(this.name+"Plate Material",t.getScene()),this._plateMaterial.specularColor=s.Color3.Black()},e.prototype._onToggle=function(e){this._backMaterial&&(this._backMaterial.albedoColor=e?this._backplateToggledColor:this._backplateColor),t.prototype._onToggle.call(this,e)},e.prototype._affectMaterial=function(t){this._shareMaterials?(this._host._touchSharedMaterials.backFluentMaterial?this._backMaterial=this._host._touchSharedMaterials.backFluentMaterial:(this._createBackMaterial(t),this._host._touchSharedMaterials.backFluentMaterial=this._backMaterial),this._host._touchSharedMaterials.frontFluentMaterial?this._frontMaterial=this._host._touchSharedMaterials.frontFluentMaterial:(this._createFrontMaterial(t),this._host._touchSharedMaterials.frontFluentMaterial=this._frontMaterial)):(this._createBackMaterial(t),this._createFrontMaterial(t)),this._createPlateMaterial(t),this._backPlate.material=this._backMaterial,this._textPlate.material=this._plateMaterial,this._isBackplateVisible||(this._backPlate.visibility=0),this._frontPlate&&(this._frontPlate.material=this._frontMaterial),this._rebuildContent()},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._disposeTooltip(),this.onPointerMoveObservable.remove(this._pointerHoverObserver),this.shareMaterials||(this._backMaterial.dispose(),this._frontMaterial.dispose(),this._plateMaterial.dispose(),this._pickedPointObserver&&(this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver),this._pickedPointObserver=null))},e.MODEL_BASE_URL="https://assets.babylonjs.com/meshes/MRTK/",e.MODEL_FILENAME="mrtk-fluent-button.glb",e}(mt),vt=function(){function t(){this.followBehaviorEnabled=!1,this.sixDofDragBehaviorEnabled=!0,this.surfaceMagnetismBehaviorEnabled=!0,this._followBehavior=new s.FollowBehavior,this._sixDofDragBehavior=new s.SixDofDragBehavior,this._surfaceMagnetismBehavior=new s.SurfaceMagnetismBehavior}return Object.defineProperty(t.prototype,"name",{get:function(){return"Default"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"followBehavior",{get:function(){return this._followBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sixDofDragBehavior",{get:function(){return this._sixDofDragBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surfaceMagnetismBehavior",{get:function(){return this._surfaceMagnetismBehavior},enumerable:!1,configurable:!0}),t.prototype.init=function(){},t.prototype.attach=function(t,e,i){this._scene=t.getScene(),this.attachedNode=t,this._addObservables(),this._followBehavior.attach(t),this._sixDofDragBehavior.attach(t),this._sixDofDragBehavior.draggableMeshes=e||null,this._sixDofDragBehavior.faceCameraOnDragStart=!0,this._surfaceMagnetismBehavior.attach(t,this._scene),i&&(this._surfaceMagnetismBehavior.meshes=i),this._surfaceMagnetismBehavior.enabled=!1},t.prototype.detach=function(){this.attachedNode=null,this._removeObservables(),this._followBehavior.detach(),this._sixDofDragBehavior.detach(),this._surfaceMagnetismBehavior.detach()},t.prototype._addObservables=function(){var t=this;this._onBeforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){t._followBehavior._enabled=!t._sixDofDragBehavior.isMoving&&t.followBehaviorEnabled})),this._onDragObserver=this._sixDofDragBehavior.onDragObservable.add((function(e){t._sixDofDragBehavior.disableMovement=t._surfaceMagnetismBehavior.findAndUpdateTarget(e.pickInfo)}))},t.prototype._removeObservables=function(){this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._sixDofDragBehavior.onDragObservable.remove(this._onDragObserver)},t}();s.ShaderStore.ShadersStore.handleVertexShader="precision highp float;\nattribute vec3 position;\nuniform vec3 positionOffset;\nuniform mat4 worldViewProjection;\nuniform float scale;\nvoid main(void) {\nvec4 vPos=vec4((vec3(position)+positionOffset)*scale,1.0);\ngl_Position=worldViewProjection*vPos;\n}";s.ShaderStore.ShadersStore.handlePixelShader="uniform vec3 color;\nvoid main(void) {\ngl_FragColor=vec4(color,1.0);\n}";var yt,xt=function(t){function e(e,i){var o=t.call(this,e,i,"handle",{attributes:["position"],uniforms:["worldViewProjection","color","scale","positionOffset"],needAlphaBlending:!1,needAlphaTesting:!1})||this;return o._hover=!1,o._drag=!1,o._color=new s.Color3,o._scale=1,o._lastTick=-1,o.animationLength=100,o.hoverColor=new s.Color3(0,.467,.84),o.baseColor=new s.Color3(1,1,1),o.hoverScale=.75,o.baseScale=.35,o.dragScale=.55,o._positionOffset=s.Vector3.Zero(),o._updateInterpolationTarget(),o._lastTick=Date.now(),o._onBeforeRender=o.getScene().onBeforeRenderObservable.add((function(){var t=Date.now(),e=t-o._lastTick,i=o._targetScale-o._scale,n=s.TmpColors.Color3[0].copyFrom(o._targetColor).subtractToRef(o._color,s.TmpColors.Color3[0]);o._scale=o._scale+i*e/o.animationLength,n.scaleToRef(e/o.animationLength,n),o._color.addToRef(n,o._color),o.setColor3("color",o._color),o.setFloat("scale",o._scale),o.setVector3("positionOffset",o._positionOffset),o._lastTick=t})),o}return r(e,t),Object.defineProperty(e.prototype,"hover",{get:function(){return this._hover},set:function(t){this._hover=t,this._updateInterpolationTarget()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"drag",{get:function(){return this._drag},set:function(t){this._drag=t,this._updateInterpolationTarget()},enumerable:!1,configurable:!0}),e.prototype._updateInterpolationTarget=function(){this.drag?(this._targetColor=this.hoverColor,this._targetScale=this.dragScale):this.hover?(this._targetColor=this.hoverColor,this._targetScale=this.hoverScale):(this._targetColor=this.baseColor,this._targetScale=this.baseScale)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.getScene().onBeforeRenderObservable.remove(this._onBeforeRender)},e}(s.ShaderMaterial);!function(t){t[t.IDLE=0]="IDLE",t[t.HOVER=1]="HOVER",t[t.DRAG=2]="DRAG"}(yt||(yt={}));var Pt=function(){function t(t,e){this._state=yt.IDLE,this._materials=[],this._scene=e,this._gizmo=t,this.node=this.createNode(),this.node.reservedDataStore={handle:this}}return Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gizmo",{get:function(){return this._gizmo},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hover",{set:function(t){t?this._state|=yt.HOVER:this._state&=~yt.HOVER,this._updateMaterial()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"drag",{set:function(t){t?this._state|=yt.DRAG:this._state&=~yt.DRAG,this._updateMaterial()},enumerable:!1,configurable:!0}),t.prototype._createMaterial=function(t){var e=new xt("handle",this._scene);return t&&(e._positionOffset=t),e},t.prototype._updateMaterial=function(){for(var t=this._state,e=0,i=this._materials;e<i.length;e++)(s=i[e]).hover=!1,s.drag=!1;if(t&yt.DRAG)for(var o=0,n=this._materials;o<n.length;o++)(s=n[o]).drag=!0;else if(t&yt.HOVER)for(var r=0,a=this._materials;r<a.length;r++){var s;(s=a[r]).hover=!0}},t.prototype.setDragBehavior=function(t,e,i){var o=new s.BaseSixDofDragBehavior;this._dragBehavior=o,this._dragStartObserver=o.onDragStartObservable.add(t),this._draggingObserver=o.onDragObservable.add(e),this._dragEndObserver=o.onDragEndObservable.add(i),this._dragBehavior.attach(this.node)},t.prototype.dispose=function(){this._dragBehavior.onDragStartObservable.remove(this._dragStartObserver),this._dragBehavior.onDragObservable.remove(this._draggingObserver),this._dragBehavior.onDragEndObservable.remove(this._dragEndObserver),this._dragBehavior.detach();for(var t=0,e=this._materials;t<e.length;t++)e[t].dispose();this.node.dispose()},t}(),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.createNode=function(){var t=(0,s.CreateBox)("sideVert",{width:1,height:10,depth:.1},this._scene),e=new s.TransformNode("side",this._scene);t.parent=e;var i=this._createMaterial();return t.material=i,t.isNearGrabbable=!0,this._materials.push(i),e},e}(Pt),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.createNode=function(){var t=(0,s.CreateBox)("angleHor",{width:3,height:1,depth:.1},this._scene),e=(0,s.CreateBox)("angleVert",{width:1,height:3,depth:.1},this._scene),i=new s.TransformNode("angle",this._scene);return t.parent=i,e.parent=i,t.material=this._createMaterial(new s.Vector3(1,0,0)),e.material=this._createMaterial(new s.Vector3(0,1,0)),e.isNearGrabbable=!0,t.isNearGrabbable=!0,this._materials.push(t.material),this._materials.push(e.material),i},e}(Pt),Tt=function(t){function e(e){var i=t.call(this,e)||this;return i._boundingDimensions=new s.Vector3(0,0,0),i._renderObserver=null,i._tmpQuaternion=new s.Quaternion,i._tmpVector=new s.Vector3(0,0,0),i._corners=[],i._sides=[],i._boundingBoxGizmo={min:new s.Vector3,max:new s.Vector3},i._margin=.35,i._handleSize=.075,i._attachedSlate=null,i._existingSlateScale=new s.Vector3,i.fixedScreenSize=!1,i.fixedScreenSizeDistanceFactor=10,i._createNode(),i.updateScale=!1,i._renderObserver=i.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){i.attachedMesh&&!i._existingSlateScale.equals(i.attachedMesh.scaling)&&i.updateBoundingBox()})),i}return r(e,t),Object.defineProperty(e.prototype,"attachedSlate",{get:function(){return this._attachedSlate},set:function(t){var e=this;t?(this.attachedMesh=t.mesh,this.updateBoundingBox(),this._pickedPointObserver=t._host.onPickingObservable.add((function(t){if(!e._handleHovered||t&&t.parent===e._handleHovered.node||(e._handleHovered.hover=!1,e._handleHovered=null),t&&t.parent&&t.parent.reservedDataStore&&t.parent.reservedDataStore.handle){var i=t.parent.reservedDataStore.handle;i.gizmo===e&&(e._handleHovered=i,e._handleHovered.hover=!0)}}))):this._attachedSlate&&this._attachedSlate._host.onPickingObservable.remove(this._pickedPointObserver),this._attachedSlate=t},enumerable:!1,configurable:!0}),e.prototype._createNode=function(){var t=this;this._handlesParent=new s.TransformNode("handlesParent",this.gizmoLayer.utilityLayerScene),this._handlesParent.rotationQuaternion=s.Quaternion.Identity();for(var e=[{dimensions:new s.Vector3(-1,-1,0),origin:new s.Vector3(1,0,0)},{dimensions:new s.Vector3(1,-1,0),origin:new s.Vector3(0,0,0)},{dimensions:new s.Vector3(1,1,0),origin:new s.Vector3(0,1,0)},{dimensions:new s.Vector3(-1,1,0),origin:new s.Vector3(1,1,0)}],i=0;i<4;i++){var o=new Ct(this,this.gizmoLayer.utilityLayerScene);this._corners.push(o),o.node.rotation.z=Math.PI/2*i,o.node.parent=this._handlesParent,this._assignDragBehaviorCorners(o,(function(e,i,o,n){return t._moveHandle(e,i,o,n,!0)}),e[i])}for(i=0;i<4;i++){var n=new Bt(this,this.gizmoLayer.utilityLayerScene);this._sides.push(n),n.node.rotation.z=Math.PI/2*i,n.node.parent=this._handlesParent,this._assignDragBehaviorSides(n,i%2==0?new s.Vector3(0,1,0):new s.Vector3(1,0,0))}this._handlesParent.parent=this._rootMesh},e.prototype._keepAspectRatio=function(t,e,i){void 0===i&&(i=!1);var o=s.TmpVectors.Vector3[0];o.copyFromFloats(e,1,0).normalize(),i&&(o.y*=-1);var n=s.Vector3.Dot(t,o);t.copyFrom(o).scaleInPlace(n)},e.prototype._clampDimensions=function(t,e,i,o){void 0===o&&(o=!1);var n=s.TmpVectors.Vector3[0];n.copyFrom(t).multiplyInPlace(i);var r=s.TmpVectors.Vector3[1];if(r.copyFromFloats(Math.max(this._attachedSlate.minDimensions.x,n.x+e.x),Math.max(this._attachedSlate.minDimensions.y,n.y+e.y),0),o){var a=e.x/e.y;r.x=Math.max(r.x,r.y*a),r.y=Math.max(r.y,r.x/a)}n.copyFrom(r).subtractInPlace(e),t.x=Math.sign(t.x)*Math.abs(n.x),t.y=Math.sign(t.y)*Math.abs(n.y)},e.prototype._moveHandle=function(t,e,i,o,n){if(this._attachedSlate){if(n){var r=e.x/e.y;this._keepAspectRatio(i,r,o.dimensions.x*o.dimensions.y<0)}this._clampDimensions(i,e,o.dimensions,n);var a=s.TmpVectors.Vector3[0],l=s.TmpVectors.Vector3[1];a.copyFrom(i).multiplyInPlace(o.origin),l.copyFrom(i).multiplyInPlace(o.dimensions),this._attachedSlate.origin.copyFrom(t).addInPlace(a),this._attachedSlate.dimensions.set(e.x+l.x,e.y+l.y)}},e.prototype._assignDragBehaviorCorners=function(t,e,i){var o=this,n=new s.Vector3,r=new s.Vector3,a=new s.Vector3,l=new s.Matrix,_=new s.Vector3;t.setDragBehavior((function(t){o.attachedSlate&&o.attachedMesh&&(n.set(o.attachedSlate.dimensions.x,o.attachedSlate.dimensions.y,s.Epsilon),r.copyFrom(o.attachedSlate.origin),a.copyFrom(t.position),l.copyFrom(o.attachedMesh.computeWorldMatrix(!0)),l.invert(),o.attachedSlate._followButton.isToggled=!1,s.Vector3.TransformNormalToRef(s.Vector3.Forward(),o.attachedMesh.getWorldMatrix(),_),_.normalize(),o._handleHovered&&(o._handleDragged=o._handleHovered,o._handleDragged.drag=!0))}),(function(t){o.attachedSlate&&o.attachedMesh&&(function(t,e,i,o){t.subtractToRef(i,s.TmpVectors.Vector3[0]);var n=s.Vector3.Dot(s.TmpVectors.Vector3[0],e);s.TmpVectors.Vector3[1].copyFrom(e).scaleInPlace(n),s.TmpVectors.Vector3[0].subtractInPlace(s.TmpVectors.Vector3[1]),s.TmpVectors.Vector3[0].addToRef(i,o)}(t.position,_,a,o._tmpVector),o._tmpVector.subtractInPlace(a),s.Vector3.TransformNormalToRef(o._tmpVector,l,o._tmpVector),e(r,n,o._tmpVector,i),o.attachedSlate._positionElements(),o.updateBoundingBox())}),(function(){o.attachedSlate&&o.attachedNode&&(o.attachedSlate._updatePivot(),o._handleDragged&&(o._handleDragged.drag=!1,o._handleDragged=null))}))},e.prototype._assignDragBehaviorSides=function(t,e){var i=this,o=new s.Quaternion,n=new s.Vector3,r=new s.Vector3,a=new s.Vector3,l=new s.Vector3;t.setDragBehavior((function(t){i.attachedSlate&&i.attachedMesh&&(o.copyFrom(i.attachedMesh.rotationQuaternion),n.copyFrom(t.position),a.copyFrom(i.attachedMesh.getAbsolutePivotPoint()),r.copyFrom(n).subtractInPlace(a).normalize(),i.attachedSlate._followButton.isToggled=!1,s.Vector3.TransformNormalToRef(e,i.attachedMesh.getWorldMatrix(),l),l.normalize(),i._handleHovered&&(i._handleDragged=i._handleHovered,i._handleDragged.drag=!0))}),(function(t){if(i.attachedSlate&&i.attachedMesh){i._tmpVector.copyFrom(t.position),i._tmpVector.subtractInPlace(a),i._tmpVector.normalize();var n=-s.Vector3.GetAngleBetweenVectorsOnPlane(i._tmpVector,r,l);s.Quaternion.RotationAxisToRef(e,n,i._tmpQuaternion),o.multiplyToRef(i._tmpQuaternion,i.attachedMesh.rotationQuaternion)}}),(function(){i.attachedSlate&&i.attachedNode&&(i.attachedSlate._updatePivot(),i._handleDragged&&(i._handleDragged.drag=!1,i._handleDragged=null))}))},e.prototype._attachedNodeChanged=function(t){t&&this.updateBoundingBox()},e.prototype.updateBoundingBox=function(){if(this.attachedMesh){s.PivotTools._RemoveAndStorePivotPoint(this.attachedMesh);var t=this.attachedMesh.parent;this.attachedMesh.setParent(null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=s.Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var e=this.attachedMesh.getHierarchyBoundingVectors();e.max.subtractToRef(e.min,this._boundingDimensions),this._boundingBoxGizmo.min=e.min,this._boundingBoxGizmo.max=e.max,this._updateHandlesPosition(),this._updateHandlesScaling(),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),s.PivotTools._RestorePivotPoint(this.attachedMesh),this.attachedMesh.setParent(t),this.attachedMesh.computeWorldMatrix(!0),this._existingSlateScale.copyFrom(this.attachedMesh.scaling)}},e.prototype._updateHandlesPosition=function(){var t=this._boundingBoxGizmo.min.clone(),e=this._boundingBoxGizmo.max.clone(),i=this._corners[0].node.scaling.length();t.x-=this._margin*i,t.y-=this._margin*i,e.x+=this._margin*i,e.y+=this._margin*i;var o=t.add(e).scaleInPlace(.5);this._corners[0].node.position.copyFromFloats(t.x,t.y,0),this._corners[1].node.position.copyFromFloats(e.x,t.y,0),this._corners[2].node.position.copyFromFloats(e.x,e.y,0),this._corners[3].node.position.copyFromFloats(t.x,e.y,0),this._sides[0].node.position.copyFromFloats(t.x,o.y,0),this._sides[1].node.position.copyFromFloats(o.x,t.y,0),this._sides[2].node.position.copyFromFloats(e.x,o.y,0),this._sides[3].node.position.copyFromFloats(o.x,e.y,0)},e.prototype._updateHandlesScaling=function(){if(this._attachedSlate&&this._attachedSlate.mesh){for(var t=this._attachedSlate.mesh.scaling.x*this._attachedSlate.dimensions.x,e=this._attachedSlate.mesh.scaling.y*this._attachedSlate.dimensions.y,i=Math.min(t,e)*this._handleSize,o=0;o<this._corners.length;o++)this._corners[o].node.scaling.setAll(i);for(o=0;o<this._sides.length;o++)this._sides[o].node.scaling.setAll(i)}},e.prototype._update=function(){if(t.prototype._update.call(this),this.gizmoLayer.utilityLayerScene.activeCamera&&this._attachedSlate&&this._attachedSlate.mesh){if(this.fixedScreenSize){this._attachedSlate.mesh.absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);for(var e=this._handleSize*this._tmpVector.length()/this.fixedScreenSizeDistanceFactor,i=0;i<this._corners.length;i++)this._corners[i].node.scaling.set(e,e,e);for(i=0;i<this._sides.length;i++)this._sides[i].node.scaling.set(e,e,e)}this._updateHandlesPosition()}},e.prototype.dispose=function(){this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),t.prototype.dispose.call(this);for(var e=0,i=this._corners;e<i.length;e++)i[e].dispose();for(var o=0,n=this._sides;o<n.length;o++)n[o].dispose()},e}(s.Gizmo);s.ShaderStore.ShadersStore.fluentBackplatePixelShader="uniform vec3 cameraPosition;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nuniform float _Radius_;\nuniform float _Line_Width_;\nuniform bool _Absolute_Sizes_;\nuniform float _Filter_Width_;\nuniform vec4 _Base_Color_;\nuniform vec4 _Line_Color_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform float _Rate_;\nuniform vec4 _Highlight_Color_;\nuniform float _Highlight_Width_;\nuniform vec4 _Highlight_Transform_;\nuniform float _Highlight_;\nuniform float _Iridescence_Intensity_;\nuniform float _Iridescence_Edge_Intensity_;\nuniform float _Angle_;\nuniform float _Fade_Out_;\nuniform bool _Reflected_;\nuniform float _Frequency_;\nuniform float _Vertical_Offset_;\nuniform sampler2D _Iridescent_Map_;\nuniform bool _Use_Global_Left_Index_;\nuniform bool _Use_Global_Right_Index_;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nvoid Round_Rect_Fragment_B31(\nfloat Radius,\nfloat Line_Width,\nvec4 Line_Color,\nfloat Filter_Width,\nvec2 UV,\nfloat Line_Visibility,\nvec4 Rect_Parms,\nvec4 Fill_Color,\nout vec4 Color)\n{\nfloat d=length(max(abs(UV)-Rect_Parms.xy,0.0));\nfloat dx=max(fwidth(d)*Filter_Width,0.00001);\nfloat g=min(Rect_Parms.z,Rect_Parms.w);\nfloat dgrad=max(fwidth(g)*Filter_Width,0.00001);\nfloat Inside_Rect=clamp(g/dgrad,0.0,1.0);\nfloat inner=clamp((d+dx*0.5-max(Radius-Line_Width,d-dx*0.5))/dx,0.0,1.0);\nColor=clamp(mix(Fill_Color,Line_Color,inner),0.0,1.0)*Inside_Rect;\n}\nvoid Blob_Fragment_B71(\nsampler2D Blob_Texture,\nvec4 Blob_Info1,\nvec4 Blob_Info2,\nout vec4 Blob_Color)\n{\nfloat k1=dot(Blob_Info1.xy,Blob_Info1.xy);\nfloat k2=dot(Blob_Info2.xy,Blob_Info2.xy);\nvec3 closer=k1<k2 ? vec3(k1,Blob_Info1.z,Blob_Info1.w) : vec3(k2,Blob_Info2.z,Blob_Info2.w);\nBlob_Color=closer.z*texture(Blob_Texture,vec2(vec2(sqrt(closer.x),closer.y).x,1.0-vec2(sqrt(closer.x),closer.y).y))*clamp(1.0-closer.x,0.0,1.0);\n}\nvoid Line_Fragment_B48(\nvec4 Base_Color,\nvec4 Highlight_Color,\nfloat Highlight_Width,\nvec3 Line_Vertex,\nfloat Highlight,\nout vec4 Line_Color)\n{\nfloat k2=1.0-clamp(abs(Line_Vertex.y/Highlight_Width),0.0,1.0);\nLine_Color=mix(Base_Color,Highlight_Color,Highlight*k2);\n}\nvoid Scale_RGB_B54(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=vec4(Scalar,Scalar,Scalar,1)*Color;\n}\nvoid Conditional_Float_B38(\nbool Which,\nfloat If_True,\nfloat If_False,\nout float Result)\n{\nResult=Which ? If_True : If_False;\n}\nvoid main()\n{\nfloat R_Q72;\nfloat G_Q72;\nfloat B_Q72;\nfloat A_Q72;\nR_Q72=vColor.r; G_Q72=vColor.g; B_Q72=vColor.b; A_Q72=vColor.a;\nvec4 Blob_Color_Q71;\n#if BLOB_ENABLE\nfloat k1=dot(vExtra2.xy,vExtra2.xy);\nfloat k2=dot(vExtra3.xy,vExtra3.xy);\nvec3 closer=k1<k2 ? vec3(k1,vExtra2.z,vExtra2.w) : vec3(k2,vExtra3.z,vExtra3.w);\nBlob_Color_Q71=closer.z*texture(_Blob_Texture_,vec2(vec2(sqrt(closer.x),closer.y).x,1.0-vec2(sqrt(closer.x),closer.y).y))*clamp(1.0-closer.x,0.0,1.0);\n#else\nBlob_Color_Q71=vec4(0,0,0,0);\n#endif\nvec4 Line_Color_Q48;\nLine_Fragment_B48(_Line_Color_,_Highlight_Color_,_Highlight_Width_,vTangent,_Highlight_,Line_Color_Q48);\nfloat X_Q67;\nfloat Y_Q67;\nX_Q67=vUV.x;\nY_Q67=vUV.y;\nvec3 Incident_Q66=normalize(vPosition-cameraPosition);\nvec3 Reflected_Q60=reflect(Incident_Q66,vBinormal);\nfloat Product_Q63=Y_Q67*_Vertical_Offset_;\nfloat Dot_Q68=dot(Incident_Q66, Reflected_Q60);\nfloat Dot_Q57=dot(vNormal, Incident_Q66);\nfloat Result_Q38;\nConditional_Float_B38(_Reflected_,Dot_Q68,Dot_Q57,Result_Q38);\nfloat Product_Q64=Result_Q38*_Frequency_;\nfloat Sum_Q69=Product_Q64+1.0;\nfloat Product_Q70=Sum_Q69*0.5;\nfloat Sum_Q62=Product_Q63+Product_Q70;\nfloat FractF_Q59=fract(Sum_Q62);\nvec2 Vec2_Q65=vec2(FractF_Q59,0.5);\nvec4 Color_Q58;\n#if IRIDESCENT_MAP_ENABLE\nColor_Q58=texture(_Iridescent_Map_,Vec2_Q65);\n#else\nColor_Q58=vec4(0,0,0,0);\n#endif\nvec4 Result_Q54;\nScale_RGB_B54(Color_Q58,_Iridescence_Edge_Intensity_,Result_Q54);\nvec4 Result_Q55;\nScale_RGB_B54(Color_Q58,_Iridescence_Intensity_,Result_Q55);\nvec4 Base_And_Iridescent_Q53;\nBase_And_Iridescent_Q53=Line_Color_Q48+vec4(Result_Q54.rgb,0.0);\nvec4 Base_And_Iridescent_Q56;\nBase_And_Iridescent_Q56=_Base_Color_+vec4(Result_Q55.rgb,0.0);\nvec4 Result_Q52=Base_And_Iridescent_Q53; Result_Q52.a=1.0;\nvec4 Result_Q35=Blob_Color_Q71+(1.0-Blob_Color_Q71.a)*Base_And_Iridescent_Q56;\nvec4 Color_Q31;\nRound_Rect_Fragment_B31(R_Q72,G_Q72,Result_Q52,_Filter_Width_,vUV,1.0,vExtra1,Result_Q35,Color_Q31);\nvec4 Result_Q47=_Fade_Out_*Color_Q31;\nvec4 Out_Color=Result_Q47;\nfloat Clip_Threshold=0.001;\nbool To_sRGB=false;\ngl_FragColor=Out_Color;\n}";s.ShaderStore.ShadersStore.fluentBackplateVertexShader="uniform mat4 world;\nuniform mat4 viewProjection;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef TANGENT\nattribute vec3 tangent;\n#else\nconst vec3 tangent=vec3(0.);\n#endif\nuniform float _Radius_;\nuniform float _Line_Width_;\nuniform bool _Absolute_Sizes_;\nuniform float _Filter_Width_;\nuniform vec4 _Base_Color_;\nuniform vec4 _Line_Color_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform float _Rate_;\nuniform vec4 _Highlight_Color_;\nuniform float _Highlight_Width_;\nuniform vec4 _Highlight_Transform_;\nuniform float _Highlight_;\nuniform float _Iridescence_Intensity_;\nuniform float _Iridescence_Edge_Intensity_;\nuniform float _Angle_;\nuniform float _Fade_Out_;\nuniform bool _Reflected_;\nuniform float _Frequency_;\nuniform float _Vertical_Offset_;\nuniform sampler2D _Iridescent_Map_;\nuniform bool _Use_Global_Left_Index_;\nuniform bool _Use_Global_Right_Index_;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nvoid Object_To_World_Pos_B115(\nvec3 Pos_Object,\nout vec3 Pos_World)\n{\nPos_World=(world*vec4(Pos_Object,1.0)).xyz;\n}\nvoid PickDir_B140(\nfloat Degrees,\nvec3 DirX,\nvec3 DirY,\nout vec3 Dir)\n{\nfloat a=Degrees*3.14159/180.0;\nDir=cos(a)*DirX+sin(a)*DirY;\n}\nvoid Round_Rect_Vertex_B139(\nvec2 UV,\nfloat Radius,\nfloat Margin,\nfloat Anisotropy,\nfloat Gradient1,\nfloat Gradient2,\nout vec2 Rect_UV,\nout vec4 Rect_Parms,\nout vec2 Scale_XY,\nout vec2 Line_UV)\n{\nScale_XY=vec2(Anisotropy,1.0);\nLine_UV=(UV-vec2(0.5,0.5));\nRect_UV=Line_UV*Scale_XY;\nRect_Parms.xy=Scale_XY*0.5-vec2(Radius,Radius)-vec2(Margin,Margin);\nRect_Parms.z=Gradient1; \nRect_Parms.w=Gradient2;\n}\nvoid Line_Vertex_B135(\nvec2 Scale_XY,\nvec2 UV,\nfloat Time,\nfloat Rate,\nvec4 Highlight_Transform,\nout vec3 Line_Vertex)\n{\nfloat angle2=(Rate*Time)*2.0*3.1416;\nfloat sinAngle2=sin(angle2);\nfloat cosAngle2=cos(angle2);\nvec2 xformUV=UV*Highlight_Transform.xy+Highlight_Transform.zw;\nLine_Vertex.x=0.0;\nLine_Vertex.y=cosAngle2*xformUV.x-sinAngle2*xformUV.y;\nLine_Vertex.z=0.0; \n}\nvoid Blob_Vertex_B180(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nfloat Blob_Fade_Length,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nout vec4 Blob_Info)\n{\nvec3 blob=Blob_Position;\nvec3 delta=blob-Position;\nfloat dist=dot(Normal,delta);\nfloat lerpValue=clamp((abs(dist)-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfloat fadeValue=1.0-clamp((abs(dist)-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat size=Blob_Near_Size+(Blob_Far_Size-Blob_Near_Size)*lerpValue;\nvec2 blobXY=vec2(dot(delta,Tangent),dot(delta,Bitangent))/(0.0001+size);\nfloat Fade=fadeValue*Intensity*Blob_Fade;\nfloat Distance=(lerpValue*0.5+0.5)*(1.0-Blob_Pulse);\nBlob_Info=vec4(blobXY.x,blobXY.y,Distance,Fade);\n}\nvoid Move_Verts_B129(\nfloat Anisotropy,\nvec3 P,\nfloat Radius,\nout vec3 New_P,\nout vec2 New_UV,\nout float Radial_Gradient,\nout vec3 Radial_Dir)\n{\nvec2 UV=P.xy*2.0+0.5;\nvec2 center=clamp(UV,0.0,1.0);\nvec2 delta=UV-center;\nvec2 r2=2.0*vec2(Radius/Anisotropy,Radius);\nNew_UV=center+r2*(UV-2.0*center+0.5);\nNew_P=vec3(New_UV-0.5,P.z);\nRadial_Gradient=1.0-length(delta)*2.0;\nRadial_Dir=vec3(delta*r2,0.0);\n}\nvoid Object_To_World_Dir_B132(\nvec3 Dir_Object,\nout vec3 Binormal_World,\nout vec3 Binormal_World_N,\nout float Binormal_Length)\n{\nBinormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nBinormal_Length=length(Binormal_World);\nBinormal_World_N=Binormal_World/Binormal_Length;\n}\nvoid RelativeOrAbsoluteDetail_B147(\nfloat Nominal_Radius,\nfloat Nominal_LineWidth,\nbool Absolute_Measurements,\nfloat Height,\nout float Radius,\nout float Line_Width)\n{\nfloat scale=Absolute_Measurements ? 1.0/Height : 1.0;\nRadius=Nominal_Radius*scale;\nLine_Width=Nominal_LineWidth*scale;\n}\nvoid Edge_AA_Vertex_B130(\nvec3 Position_World,\nvec3 Position_Object,\nvec3 Normal_Object,\nvec3 Eye,\nfloat Radial_Gradient,\nvec3 Radial_Dir,\nvec3 Tangent,\nout float Gradient1,\nout float Gradient2)\n{\nvec3 I=(Eye-Position_World);\nvec3 T=(world* vec4(Tangent,0.0)).xyz;\nfloat g=(dot(T,I)<0.0) ? 0.0 : 1.0;\nif (Normal_Object.z==0.0) { \nGradient1=Position_Object.z>0.0 ? g : 1.0;\nGradient2=Position_Object.z>0.0 ? 1.0 : g;\n} else {\nGradient1=g+(1.0-g)*(Radial_Gradient);\nGradient2=1.0;\n}\n}\nvoid Pick_Radius_B144(\nfloat Radius,\nfloat Radius_Top_Left,\nfloat Radius_Top_Right,\nfloat Radius_Bottom_Left,\nfloat Radius_Bottom_Right,\nvec3 Position,\nout float Result)\n{\nbool whichY=Position.y>0.0;\nResult=Position.x<0.0 ? (whichY ? Radius_Top_Left : Radius_Bottom_Left) : (whichY ? Radius_Top_Right : Radius_Bottom_Right);\nResult*=Radius;\n}\nvoid main()\n{\nvec3 Nrm_World_Q128;\nNrm_World_Q128=normalize((world*vec4(normal,0.0)).xyz);\nvec3 Tangent_World_Q131;\nvec3 Tangent_World_N_Q131;\nfloat Tangent_Length_Q131;\nTangent_World_Q131=(world*vec4(vec3(1,0,0),0.0)).xyz;\nTangent_Length_Q131=length(Tangent_World_Q131);\nTangent_World_N_Q131=Tangent_World_Q131/Tangent_Length_Q131;\nvec3 Binormal_World_Q132;\nvec3 Binormal_World_N_Q132;\nfloat Binormal_Length_Q132;\nObject_To_World_Dir_B132(vec3(0,1,0),Binormal_World_Q132,Binormal_World_N_Q132,Binormal_Length_Q132);\nfloat Anisotropy_Q133=Tangent_Length_Q131/Binormal_Length_Q132;\nvec3 Result_Q177;\nResult_Q177=mix(_Blob_Position_,Global_Left_Index_Tip_Position.xyz,float(_Use_Global_Left_Index_));\nvec3 Result_Q178;\nResult_Q178=mix(_Blob_Position_2_,Global_Right_Index_Tip_Position.xyz,float(_Use_Global_Right_Index_));\nfloat Result_Q144;\nPick_Radius_B144(_Radius_,_Radius_Top_Left_,_Radius_Top_Right_,_Radius_Bottom_Left_,_Radius_Bottom_Right_,position,Result_Q144);\nvec3 Dir_Q140;\nPickDir_B140(_Angle_,Tangent_World_N_Q131,Binormal_World_N_Q132,Dir_Q140);\nfloat Radius_Q147;\nfloat Line_Width_Q147;\nRelativeOrAbsoluteDetail_B147(Result_Q144,_Line_Width_,_Absolute_Sizes_,Binormal_Length_Q132,Radius_Q147,Line_Width_Q147);\nvec4 Out_Color_Q145=vec4(Radius_Q147,Line_Width_Q147,0,1);\nvec3 New_P_Q129;\nvec2 New_UV_Q129;\nfloat Radial_Gradient_Q129;\nvec3 Radial_Dir_Q129;\nMove_Verts_B129(Anisotropy_Q133,position,Radius_Q147,New_P_Q129,New_UV_Q129,Radial_Gradient_Q129,Radial_Dir_Q129);\nvec3 Pos_World_Q115;\nObject_To_World_Pos_B115(New_P_Q129,Pos_World_Q115);\nvec4 Blob_Info_Q180;\n#if BLOB_ENABLE\nBlob_Vertex_B180(Pos_World_Q115,Nrm_World_Q128,Tangent_World_N_Q131,Binormal_World_N_Q132,Result_Q177,_Blob_Intensity_,_Blob_Near_Size_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_,_Blob_Fade_,Blob_Info_Q180);\n#else\nBlob_Info_Q180=vec4(0,0,0,0);\n#endif\nvec4 Blob_Info_Q181;\n#if BLOB_ENABLE_2\nBlob_Vertex_B180(Pos_World_Q115,Nrm_World_Q128,Tangent_World_N_Q131,Binormal_World_N_Q132,Result_Q178,_Blob_Intensity_,_Blob_Near_Size_2_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_2_,_Blob_Fade_2_,Blob_Info_Q181);\n#else\nBlob_Info_Q181=vec4(0,0,0,0);\n#endif\nfloat Gradient1_Q130;\nfloat Gradient2_Q130;\n#if SMOOTH_EDGES\nEdge_AA_Vertex_B130(Pos_World_Q115,position,normal,cameraPosition,Radial_Gradient_Q129,Radial_Dir_Q129,tangent,Gradient1_Q130,Gradient2_Q130);\n#else\nGradient1_Q130=1.0;\nGradient2_Q130=1.0;\n#endif\nvec2 Rect_UV_Q139;\nvec4 Rect_Parms_Q139;\nvec2 Scale_XY_Q139;\nvec2 Line_UV_Q139;\nRound_Rect_Vertex_B139(New_UV_Q129,Radius_Q147,0.0,Anisotropy_Q133,Gradient1_Q130,Gradient2_Q130,Rect_UV_Q139,Rect_Parms_Q139,Scale_XY_Q139,Line_UV_Q139);\nvec3 Line_Vertex_Q135;\nLine_Vertex_B135(Scale_XY_Q139,Line_UV_Q139,0.0,_Rate_,_Highlight_Transform_,Line_Vertex_Q135);\nvec3 Position=Pos_World_Q115;\nvec3 Normal=Dir_Q140;\nvec2 UV=Rect_UV_Q139;\nvec3 Tangent=Line_Vertex_Q135;\nvec3 Binormal=Nrm_World_Q128;\nvec4 Color=Out_Color_Q145;\nvec4 Extra1=Rect_Parms_Q139;\nvec4 Extra2=Blob_Info_Q180;\nvec4 Extra3=Blob_Info_Q181;\ngl_Position=viewProjection*vec4(Position,1);\nvPosition=Position;\nvNormal=Normal;\nvUV=UV;\nvTangent=Tangent;\nvBinormal=Binormal;\nvColor=Color;\nvExtra1=Extra1;\nvExtra2=Extra2;\nvExtra3=Extra3;\n}";var Ot=function(t){function e(){var e=t.call(this)||this;return e.BLOB_ENABLE=!0,e.BLOB_ENABLE_2=!0,e.SMOOTH_EDGES=!0,e.IRIDESCENT_MAP_ENABLE=!0,e._needNormals=!0,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),It=function(t){function e(i,o){var n=t.call(this,i,o)||this;return n.radius=.03,n.lineWidth=.01,n.absoluteSizes=!1,n._filterWidth=1,n.baseColor=new s.Color4(.0392157,.0666667,.207843,1),n.lineColor=new s.Color4(.14902,.133333,.384314,1),n.blobIntensity=.98,n.blobFarSize=.04,n.blobNearDistance=0,n.blobFarDistance=.08,n.blobFadeLength=.08,n.blobNearSize=.22,n.blobPulse=0,n.blobFade=0,n.blobNearSize2=.22,n.blobPulse2=0,n.blobFade2=0,n._rate=.135,n.highlightColor=new s.Color4(.98,.98,.98,1),n.highlightWidth=.25,n._highlightTransform=new s.Vector4(1,1,0,0),n._highlight=1,n.iridescenceIntensity=0,n.iridescenceEdgeIntensity=1,n._angle=-45,n.fadeOut=1,n._reflected=!0,n._frequency=1,n._verticalOffset=0,n.globalLeftIndexTipPosition=s.Vector3.Zero(),n._globalLeftIndexTipPosition4=s.Vector4.Zero(),n.globalRightIndexTipPosition=s.Vector3.Zero(),n._globalRightIndexTipPosition4=s.Vector4.Zero(),n.alphaMode=s.Constants.ALPHA_DISABLE,n.backFaceCulling=!1,n._blobTexture=new s.Texture(e.BLOB_TEXTURE_URL,n.getScene(),!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n._iridescentMap=new s.Texture(e.IM_TEXTURE_URL,n.getScene(),!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n}return r(e,t),e.prototype.needAlphaBlending=function(){return!1},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new Ot);var i=e.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(e))return!0;var n=o.getEngine();if(s.MaterialHelper.PrepareDefinesForAttributes(t,i,!1,!1),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var r=new s.EffectFallbacks;i.FOG&&r.addFallback(1,"FOG"),s.MaterialHelper.HandleFallbacksForShadows(i,r),i.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var a=[s.VertexBuffer.PositionKind];i.NORMAL&&a.push(s.VertexBuffer.NormalKind),i.UV1&&a.push(s.VertexBuffer.UVKind),i.UV2&&a.push(s.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&a.push(s.VertexBuffer.ColorKind),i.TANGENT&&a.push(s.VertexBuffer.TangentKind),s.MaterialHelper.PrepareAttributesForInstances(a,i);var l=i.toString(),_=["world","viewProjection","cameraPosition","_Radius_","_Line_Width_","_Absolute_Sizes_","_Filter_Width_","_Base_Color_","_Line_Color_","_Radius_Top_Left_","_Radius_Top_Right_","_Radius_Bottom_Left_","_Radius_Bottom_Right_","_Blob_Position_","_Blob_Intensity_","_Blob_Near_Size_","_Blob_Far_Size_","_Blob_Near_Distance_","_Blob_Far_Distance_","_Blob_Fade_Length_","_Blob_Pulse_","_Blob_Fade_","_Blob_Texture_","_Blob_Position_2_","_Blob_Near_Size_2_","_Blob_Pulse_2_","_Blob_Fade_2_","_Rate_","_Highlight_Color_","_Highlight_Width_","_Highlight_Transform_","_Highlight_","_Iridescence_Intensity_","_Iridescence_Edge_Intensity_","_Angle_","_Fade_Out_","_Reflected_","_Frequency_","_Vertical_Offset_","_Iridescent_Map_","_Use_Global_Left_Index_","_Use_Global_Right_Index_","Global_Left_Index_Tip_Position","Global_Right_Index_Tip_Position"],h=["_Blob_Texture_","_Iridescent_Map_"],c=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:i,maxSimultaneousLights:4}),e.setEffect(o.getEngine().createEffect("fluentBackplate",{attributes:a,uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:l,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),i,this._materialContext)}return!(!e.effect||!e.effect.isReady()||(i._renderId=o.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){var o,n;if(i.materialDefines){var r=i.effect;r&&(this._activeEffect=r,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._activeEffect.setVector3("cameraPosition",null!==(n=null===(o=this.getScene().activeCamera)||void 0===o?void 0:o.position)&&void 0!==n?n:s.Vector3.ZeroReadOnly),this._activeEffect.setFloat("_Radius_",this.radius),this._activeEffect.setFloat("_Line_Width_",this.lineWidth),this._activeEffect.setFloat("_Absolute_Sizes_",this.absoluteSizes?1:0),this._activeEffect.setFloat("_Filter_Width_",this._filterWidth),this._activeEffect.setDirectColor4("_Base_Color_",this.baseColor),this._activeEffect.setDirectColor4("_Line_Color_",this.lineColor),this._activeEffect.setFloat("_Radius_Top_Left_",1),this._activeEffect.setFloat("_Radius_Top_Right_",1),this._activeEffect.setFloat("_Radius_Bottom_Left_",1),this._activeEffect.setFloat("_Radius_Bottom_Right_",1),this._activeEffect.setFloat("_Blob_Intensity_",this.blobIntensity),this._activeEffect.setFloat("_Blob_Near_Size_",this.blobNearSize),this._activeEffect.setFloat("_Blob_Far_Size_",this.blobFarSize),this._activeEffect.setFloat("_Blob_Near_Distance_",this.blobNearDistance),this._activeEffect.setFloat("_Blob_Far_Distance_",this.blobFarDistance),this._activeEffect.setFloat("_Blob_Fade_Length_",this.blobFadeLength),this._activeEffect.setFloat("_Blob_Pulse_",this.blobPulse),this._activeEffect.setFloat("_Blob_Fade_",this.blobFade),this._activeEffect.setTexture("_Blob_Texture_",this._blobTexture),this._activeEffect.setFloat("_Blob_Near_Size_2_",this.blobNearSize2),this._activeEffect.setFloat("_Blob_Pulse_2_",this.blobPulse2),this._activeEffect.setFloat("_Blob_Fade_2_",this.blobFade2),this._activeEffect.setFloat("_Rate_",this._rate),this._activeEffect.setDirectColor4("_Highlight_Color_",this.highlightColor),this._activeEffect.setFloat("_Highlight_Width_",this.highlightWidth),this._activeEffect.setVector4("_Highlight_Transform_",this._highlightTransform),this._activeEffect.setFloat("_Highlight_",this._highlight),this._activeEffect.setFloat("_Iridescence_Intensity_",this.iridescenceIntensity),this._activeEffect.setFloat("_Iridescence_Edge_Intensity_",this.iridescenceEdgeIntensity),this._activeEffect.setFloat("_Angle_",this._angle),this._activeEffect.setFloat("_Fade_Out_",this.fadeOut),this._activeEffect.setFloat("_Reflected_",this._reflected?1:0),this._activeEffect.setFloat("_Frequency_",this._frequency),this._activeEffect.setFloat("_Vertical_Offset_",this._verticalOffset),this._activeEffect.setTexture("_Iridescent_Map_",this._iridescentMap),this._activeEffect.setFloat("_Use_Global_Left_Index_",1),this._activeEffect.setFloat("_Use_Global_Right_Index_",1),this._globalLeftIndexTipPosition4.set(this.globalLeftIndexTipPosition.x,this.globalLeftIndexTipPosition.y,this.globalLeftIndexTipPosition.z,1),this._activeEffect.setVector4("Global_Left_Index_Tip_Position",this._globalLeftIndexTipPosition4),this._globalRightIndexTipPosition4.set(this.globalRightIndexTipPosition.x,this.globalRightIndexTipPosition.y,this.globalRightIndexTipPosition.z,1),this._activeEffect.setVector4("Global_Right_Index_Tip_Position",this._globalRightIndexTipPosition4),this._afterBind(e,this._activeEffect))}},e.prototype.getAnimatables=function(){return[]},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e),this._blobTexture.dispose(),this._iridescentMap.dispose()},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.FluentBackplateMaterial",e},e.prototype.getClassName=function(){return"FluentBackplateMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},e.BLOB_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/mrtk-fluent-backplate-blob.png",e.IM_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/mrtk-fluent-backplate-iridescence.png",a([(0,s.serialize)()],e.prototype,"radius",void 0),a([(0,s.serialize)()],e.prototype,"lineWidth",void 0),a([(0,s.serialize)()],e.prototype,"absoluteSizes",void 0),a([(0,s.serialize)()],e.prototype,"baseColor",void 0),a([(0,s.serialize)()],e.prototype,"lineColor",void 0),a([(0,s.serialize)()],e.prototype,"blobIntensity",void 0),a([(0,s.serialize)()],e.prototype,"blobFarSize",void 0),a([(0,s.serialize)()],e.prototype,"blobNearDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFarDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFadeLength",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse",void 0),a([(0,s.serialize)()],e.prototype,"blobFade",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize2",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse2",void 0),a([(0,s.serialize)()],e.prototype,"blobFade2",void 0),a([(0,s.serialize)()],e.prototype,"highlightColor",void 0),a([(0,s.serialize)()],e.prototype,"highlightWidth",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceIntensity",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceEdgeIntensity",void 0),a([(0,s.serialize)()],e.prototype,"fadeOut",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"globalLeftIndexTipPosition",void 0),a([(0,s.serializeAsVector3)()],e.prototype,"globalRightIndexTipPosition",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.FluentBackplateMaterial",It);var Rt=function(t){function e(e){var i=t.call(this,e)||this;return i.titleBarMargin=.005,i.origin=new s.Vector3(0,0,0),i._dimensions=new s.Vector2(21.875,12.5),i._titleBarHeight=.625,i._titleText="",i._contentScaleRatio=1,i.minDimensions=new s.Vector2(15.625,6.25),i.defaultDimensions=i._dimensions.clone(),i._followButton=new bt("followButton"+i.name),i._followButton.isToggleButton=!0,i._closeButton=new bt("closeButton"+i.name),i._contentViewport=new s.Viewport(0,0,1,1),i._contentDragBehavior=new s.PointerDragBehavior({dragPlaneNormal:new s.Vector3(0,0,-1)}),i}return r(e,t),Object.defineProperty(e.prototype,"defaultBehavior",{get:function(){return this._defaultBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dimensions",{get:function(){return this._dimensions},set:function(t){var e=1;if(t.x<this.minDimensions.x||t.y<this.minDimensions.y){var i=t.x/t.y;e=this.minDimensions.x/this.minDimensions.y>i?this.minDimensions.x/t.x:this.minDimensions.y/t.y}this._dimensions.copyFrom(t).scaleInPlace(e),this._updatePivot(),this._positionElements()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"titleBarHeight",{get:function(){return this._titleBarHeight},set:function(t){this._titleBarHeight=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._titleBar.renderingGroupId},set:function(t){this._titleBar.renderingGroupId=t,this._titleBarTitle.renderingGroupId=t,this._contentPlate.renderingGroupId=t,this._backPlate.renderingGroupId=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"title",{get:function(){return this._titleText},set:function(t){this._titleText=t,this._titleTextComponent&&(this._titleTextComponent.text=t)},enumerable:!1,configurable:!0}),e.prototype._applyFacade=function(t){this._contentMaterial.albedoTexture=t,this._resetContentPositionAndZoom(),this._applyContentViewport(),t.attachToMesh(this._contentPlate,!0)},e.prototype._addControl=function(t){t._host=this._host,this._host.utilityLayer&&t._prepareNode(this._host.utilityLayer.utilityLayerScene)},e.prototype._getTypeName=function(){return"HolographicSlate"},e.prototype._positionElements=function(){var t=this._followButton,i=this._closeButton,o=this._titleBar,n=this._titleBarTitle,r=this._contentPlate,a=this._backPlate;if(t&&i&&o){i.scaling.setAll(this.titleBarHeight),t.scaling.setAll(this.titleBarHeight),i.position.copyFromFloats(this.dimensions.x-this.titleBarHeight/2,-this.titleBarHeight/2,0).addInPlace(this.origin),t.position.copyFromFloats(this.dimensions.x-3*this.titleBarHeight/2,-this.titleBarHeight/2,0).addInPlace(this.origin);var l=this.dimensions.y-this.titleBarHeight-this.titleBarMargin,_=r.getScene().useRightHandedSystem;o.scaling.set(this.dimensions.x,this.titleBarHeight,s.Epsilon),n.scaling.set(this.dimensions.x-2*this.titleBarHeight,this.titleBarHeight,s.Epsilon),r.scaling.copyFromFloats(this.dimensions.x,l,s.Epsilon),a.scaling.copyFromFloats(this.dimensions.x,l,s.Epsilon),o.position.copyFromFloats(this.dimensions.x/2,-this.titleBarHeight/2,0).addInPlace(this.origin),n.position.copyFromFloats(this.dimensions.x/2-this.titleBarHeight,-this.titleBarHeight/2,_?s.Epsilon:-s.Epsilon).addInPlace(this.origin),r.position.copyFromFloats(this.dimensions.x/2,-(this.titleBarHeight+this.titleBarMargin+l/2),0).addInPlace(this.origin),a.position.copyFromFloats(this.dimensions.x/2,-(this.titleBarHeight+this.titleBarMargin+l/2),_?-s.Epsilon:s.Epsilon).addInPlace(this.origin),this._titleTextComponent.host.scaleTo(e._DEFAULT_TEXT_RESOLUTION_Y*n.scaling.x/n.scaling.y,e._DEFAULT_TEXT_RESOLUTION_Y);var h=this.dimensions.x/l;this._contentViewport.width=this._contentScaleRatio,this._contentViewport.height=this._contentScaleRatio/h,this._applyContentViewport(),this._gizmo&&this._gizmo.updateBoundingBox()}},e.prototype._applyContentViewport=function(){var t;if((null===(t=this._contentPlate)||void 0===t?void 0:t.material)&&this._contentPlate.material.albedoTexture){var e=this._contentPlate.material.albedoTexture;e.uScale=this._contentScaleRatio,e.vScale=this._contentScaleRatio/this._contentViewport.width*this._contentViewport.height,e.uOffset=this._contentViewport.x,e.vOffset=this._contentViewport.y}},e.prototype._resetContentPositionAndZoom=function(){this._contentViewport.x=0,this._contentViewport.y=1-this._contentViewport.height/this._contentViewport.width,this._contentScaleRatio=1},e.prototype._updatePivot=function(){if(this.mesh){var t=new s.Vector3(.5*this.dimensions.x,.5*-this.dimensions.y,s.Epsilon);t.addInPlace(this.origin),t.z=0;var e=new s.Vector3(0,0,0);s.Vector3.TransformCoordinatesToRef(e,this.mesh.computeWorldMatrix(!0),e),this.mesh.setPivotPoint(t);var i=new s.Vector3(0,0,0);s.Vector3.TransformCoordinatesToRef(i,this.mesh.computeWorldMatrix(!0),i),this.mesh.position.addInPlace(e).subtractInPlace(i)}},e.prototype._createNode=function(t){var i=this,o=new s.Mesh("slate_"+this.name,t);this._titleBar=(0,s.CreateBox)("titleBar_"+this.name,{size:1},t),this._titleBarTitle=(0,s.CreatePlane)("titleText_"+this.name,{size:1},t),this._titleBarTitle.parent=o,this._titleBarTitle.isPickable=!1;var n=tt.CreateForMesh(this._titleBarTitle);if(this._titleTextComponent=new y("titleText_"+this.name,this._titleText),this._titleTextComponent.textWrapping=b.Ellipsis,this._titleTextComponent.textHorizontalAlignment=g.HORIZONTAL_ALIGNMENT_LEFT,this._titleTextComponent.color="white",this._titleTextComponent.fontSize=e._DEFAULT_TEXT_RESOLUTION_Y/2,this._titleTextComponent.paddingLeft=e._DEFAULT_TEXT_RESOLUTION_Y/4,n.addControl(this._titleTextComponent),t.useRightHandedSystem){var r=new s.Vector4(0,0,1,1);this._contentPlate=(0,s.CreatePlane)("contentPlate_"+this.name,{size:1,sideOrientation:s.VertexData.BACKSIDE,frontUVs:r},t),this._backPlate=(0,s.CreatePlane)("backPlate_"+this.name,{size:1,sideOrientation:s.VertexData.FRONTSIDE},t)}else r=new s.Vector4(0,0,1,1),this._contentPlate=(0,s.CreatePlane)("contentPlate_"+this.name,{size:1,sideOrientation:s.VertexData.FRONTSIDE,frontUVs:r},t),this._backPlate=(0,s.CreatePlane)("backPlate_"+this.name,{size:1,sideOrientation:s.VertexData.BACKSIDE},t);this._titleBar.parent=o,this._titleBar.isNearGrabbable=!0,this._contentPlate.parent=o,this._backPlate.parent=o,this._attachContentPlateBehavior(),this._addControl(this._followButton),this._addControl(this._closeButton);var a=this._followButton,l=this._closeButton;return a.node.parent=o,l.node.parent=o,this._positionElements(),this._followButton.imageUrl=e.ASSETS_BASE_URL+e.FOLLOW_ICON_FILENAME,this._closeButton.imageUrl=e.ASSETS_BASE_URL+e.CLOSE_ICON_FILENAME,this._followButton.isBackplateVisible=!1,this._closeButton.isBackplateVisible=!1,this._followButton.onToggleObservable.add((function(t){i._defaultBehavior.followBehaviorEnabled=t,i._defaultBehavior.followBehaviorEnabled&&i._defaultBehavior.followBehavior.recenter()})),this._closeButton.onPointerClickObservable.add((function(){i.dispose()})),o.rotationQuaternion=s.Quaternion.Identity(),o.isVisible=!1,o},e.prototype._attachContentPlateBehavior=function(){var t=this;this._contentDragBehavior.attach(this._contentPlate),this._contentDragBehavior.moveAttached=!1,this._contentDragBehavior.useObjectOrientationForDragging=!0,this._contentDragBehavior.updateDragPlane=!1;var e,i,o=new s.Vector3,n=new s.Vector3,r=new s.Vector3,a=new s.Vector3,l=new s.Vector2;this._contentDragBehavior.onDragStartObservable.add((function(l){t.node&&(e=t._contentViewport.clone(),i=t.node.computeWorldMatrix(!0),o.copyFrom(l.dragPlanePoint),n.set(t.dimensions.x,t.dimensions.y,s.Epsilon),n.y-=t.titleBarHeight+t.titleBarMargin,s.Vector3.TransformNormalToRef(n,i,n),r.copyFromFloats(0,1,0),s.Vector3.TransformNormalToRef(r,i,r),a.copyFromFloats(1,0,0),s.Vector3.TransformNormalToRef(a,i,a),r.normalize(),r.scaleInPlace(1/s.Vector3.Dot(r,n)),a.normalize(),a.scaleInPlace(1/s.Vector3.Dot(a,n)))}));var _=new s.Vector3;this._contentDragBehavior.onDragObservable.add((function(i){_.copyFrom(i.dragPlanePoint),_.subtractInPlace(o),l.copyFromFloats(s.Vector3.Dot(_,a),s.Vector3.Dot(_,r)),t._contentViewport.x=s.Scalar.Clamp(e.x-_.x,0,1-t._contentViewport.width*t._contentScaleRatio),t._contentViewport.y=s.Scalar.Clamp(e.y-_.y,0,1-t._contentViewport.height*t._contentScaleRatio),t._applyContentViewport()}))},e.prototype._affectMaterial=function(t){this._titleBarMaterial=new It("".concat(this.name," plateMaterial"),t.getScene()),this._contentMaterial=new dt("".concat(this.name," contentMaterial"),t.getScene()),this._contentMaterial.renderBorders=!0,this._backMaterial=new It("".concat(this.name," backPlate"),t.getScene()),this._backMaterial.lineWidth=s.Epsilon,this._backMaterial.radius=.005,this._backMaterial.backFaceCulling=!0,this._titleBar.material=this._titleBarMaterial,this._contentPlate.material=this._contentMaterial,this._backPlate.material=this._backMaterial,this._resetContent(),this._applyContentViewport()},e.prototype._prepareNode=function(e){var i=this;t.prototype._prepareNode.call(this,e),this._gizmo=new Tt(this._host.utilityLayer),this._gizmo.attachedSlate=this,this._defaultBehavior=new vt,this._defaultBehavior.attach(this.node,[this._titleBar]),this._defaultBehavior.sixDofDragBehavior.onDragStartObservable.add((function(){i._followButton.isToggled=!1})),this._positionChangedObserver=this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.add((function(){i._gizmo.updateBoundingBox()})),this._updatePivot(),this.resetDefaultAspectAndPose(!1)},e.prototype.resetDefaultAspectAndPose=function(t){if(void 0===t&&(t=!0),this._host&&this._host.utilityLayer&&this.node){var e=this._host.utilityLayer.utilityLayerScene,i=e.activeCamera;if(i){var o=i.getWorldMatrix(),n=s.Vector3.TransformNormal(s.Vector3.Backward(e.useRightHandedSystem),o);this.origin.setAll(0),this._gizmo.updateBoundingBox();var r=this.node.getAbsolutePivotPoint();this.node.position.copyFrom(i.position).subtractInPlace(n).subtractInPlace(r),this.node.rotationQuaternion=s.Quaternion.FromLookDirectionLH(n,new s.Vector3(0,1,0)),t&&(this.dimensions=this.defaultDimensions)}}},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._titleBarMaterial.dispose(),this._contentMaterial.dispose(),this._titleBar.dispose(),this._titleBarTitle.dispose(),this._contentPlate.dispose(),this._backPlate.dispose(),this._followButton.dispose(),this._closeButton.dispose(),this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver),this._defaultBehavior.sixDofDragBehavior.onPositionChangedObservable.remove(this._positionChangedObserver),this._defaultBehavior.detach(),this._gizmo.dispose(),this._contentDragBehavior.detach()},e.ASSETS_BASE_URL="https://assets.babylonjs.com/meshes/MRTK/",e.CLOSE_ICON_FILENAME="IconClose.png",e.FOLLOW_ICON_FILENAME="IconFollowMe.png",e._DEFAULT_TEXT_RESOLUTION_Y=102.4,e}(at),St=function(t){function e(e){var i=t.call(this,e)||this;return i._backPlateMargin=1.25,i}return r(e,t),Object.defineProperty(e.prototype,"backPlateMargin",{get:function(){return this._backPlateMargin},set:function(t){var e=this;this._backPlateMargin=t,this._children.length>=1&&(this.children.forEach((function(t){e._updateCurrentMinMax(t.position)})),this._updateMargins())},enumerable:!1,configurable:!0}),e.prototype._createNode=function(t){var e=new s.Mesh("menu_".concat(this.name),t);return this._backPlate=(0,s.CreateBox)("backPlate"+this.name,{size:1},t),this._backPlate.parent=e,e},e.prototype._affectMaterial=function(t){var e=this;this._backPlateMaterial=new dt(this.name+"backPlateMaterial",t.getScene()),this._backPlateMaterial.albedoColor=new s.Color3(.08,.15,.55),this._backPlateMaterial.renderBorders=!0,this._backPlateMaterial.renderHoverLight=!0,this._pickedPointObserver=this._host.onPickedPointChangedObservable.add((function(t){t?(e._backPlateMaterial.hoverPosition=t,e._backPlateMaterial.hoverColor.a=1):e._backPlateMaterial.hoverColor.a=0})),this._backPlate.material=this._backPlateMaterial},e.prototype._mapGridNode=function(t,e){t.mesh&&(t.position=e.clone(),this._updateCurrentMinMax(e))},e.prototype._finalProcessing=function(){this._updateMargins()},e.prototype._updateCurrentMinMax=function(t){this._currentMin||(this._currentMin=t.clone(),this._currentMax=t.clone()),this._currentMin.minimizeInPlace(t),this._currentMax.maximizeInPlace(t)},e.prototype._updateMargins=function(){if(this._children.length>0){this._currentMin.addInPlaceFromFloats(-this._cellWidth/2,-this._cellHeight/2,0),this._currentMax.addInPlaceFromFloats(this._cellWidth/2,this._cellHeight/2,0);var t=this._currentMax.subtract(this._currentMin);this._backPlate.scaling.x=t.x+this._cellWidth*this.backPlateMargin,this._backPlate.scaling.y=t.y+this._cellHeight*this.backPlateMargin,this._backPlate.scaling.z=.001;for(var e=0;e<this._children.length;e++)this._children[e].position.subtractInPlace(this._currentMin).subtractInPlace(t.scale(.5)),this._children[e].position.z-=.01}this._currentMin=null,this._currentMax=null},e.prototype.addButton=function(i){var o=this.blockLayout;return o||(this.blockLayout=!0),t.prototype.addControl.call(this,i),i.isBackplateVisible=!1,i.scaling.scaleInPlace(e.MENU_BUTTON_SCALE),o||(this.blockLayout=!1),this},e.prototype.addControl=function(t){return s.Logger.Warn("TouchHolographicMenu can only contain buttons. Please use the method `addButton` instead."),this},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver)},e.MENU_BUTTON_SCALE=1,e}(ht),wt=function(t){function e(e,i){var o=t.call(this,i)||this;return o._handConstraintBehavior=new s.HandConstraintBehavior,o._handConstraintBehavior.linkToXRExperience(e),o.backPlateMargin=.15,o.rows=3,o}return r(e,t),Object.defineProperty(e.prototype,"handConstraintBehavior",{get:function(){return this._handConstraintBehavior},enumerable:!1,configurable:!0}),e.prototype._createNode=function(e){var i=t.prototype._createNode.call(this,e);return this._handConstraintBehavior.attach(i),i},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._handConstraintBehavior.detach()},e}(St),Mt=function(t){function e(e,i){var o=t.call(this,i)||this;return o._currentMesh=e,o.pointerEnterAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1.1)},o.pointerOutAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1/1.1)},o.pointerDownAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(.95)},o.pointerUpAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1/.95)},o}return r(e,t),e.prototype._getTypeName=function(){return"MeshButton3D"},e.prototype._createNode=function(t){var e=this;return this._currentMesh.getChildMeshes().forEach((function(t){e._injectGUI3DReservedDataStore(t).control=e})),this._currentMesh},e.prototype._affectMaterial=function(t){},e}(lt),Et=function(t){function e(e){var i=t.call(this,e)||this;return i._isPinned=!1,i._defaultBehavior=new vt,i._dragObserver=i._defaultBehavior.sixDofDragBehavior.onDragObservable.add((function(){i.isPinned=!0})),i.backPlateMargin=1,i}return r(e,t),Object.defineProperty(e.prototype,"defaultBehavior",{get:function(){return this._defaultBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPinned",{get:function(){return this._isPinned},set:function(t){this._pinButton.isToggled===t?(this._isPinned=t,this._defaultBehavior.followBehaviorEnabled=!t):this._pinButton.isToggled=t},enumerable:!1,configurable:!0}),e.prototype._createPinButton=function(t){var i=this,o=new bt("pin"+this.name,!1);return o.imageUrl=e._ASSETS_BASE_URL+e._PIN_ICON_FILENAME,o.parent=this,o._host=this._host,o.isToggleButton=!0,o.onToggleObservable.add((function(t){i.isPinned=t})),this._host.utilityLayer&&(o._prepareNode(this._host.utilityLayer.utilityLayerScene),o.scaling.scaleInPlace(St.MENU_BUTTON_SCALE),o.node&&(o.node.parent=t)),o},e.prototype._createNode=function(e){var i=t.prototype._createNode.call(this,e);return this._pinButton=this._createPinButton(i),this.isPinned=!1,this._defaultBehavior.attach(i,[this._backPlate]),this._defaultBehavior.followBehavior.ignoreCameraPitchAndRoll=!0,this._defaultBehavior.followBehavior.pitchOffset=-15,this._defaultBehavior.followBehavior.minimumDistance=.3,this._defaultBehavior.followBehavior.defaultDistance=.4,this._defaultBehavior.followBehavior.maximumDistance=.6,this._backPlate.isNearGrabbable=!0,i.isVisible=!1,i},e.prototype._finalProcessing=function(){t.prototype._finalProcessing.call(this),this._pinButton.position.copyFromFloats((this._backPlate.scaling.x+St.MENU_BUTTON_SCALE)/2,this._backPlate.scaling.y/2,0)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._defaultBehavior.sixDofDragBehavior.onDragObservable.remove(this._dragObserver),this._defaultBehavior.detach()},e._ASSETS_BASE_URL="https://assets.babylonjs.com/meshes/MRTK/",e._PIN_ICON_FILENAME="IconPin.png",e}(St),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){t.position=e.clone();var o=s.TmpVectors.Vector3[0];switch(o.copyFrom(e),this.orientation){case _t.FACEORIGIN_ORIENTATION:case _t.FACEFORWARD_ORIENTATION:o.addInPlace(new s.Vector3(0,0,1)),i.lookAt(o);break;case _t.FACEFORWARDREVERSED_ORIENTATION:case _t.FACEORIGINREVERSED_ORIENTATION:o.addInPlace(new s.Vector3(0,0,-1)),i.lookAt(o)}}},e}(ht),Ft=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._iteration=100,e}return r(e,t),Object.defineProperty(e.prototype,"iteration",{get:function(){return this._iteration},set:function(t){var e=this;this._iteration!==t&&(this._iteration=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh,o=this._scatterMapping(e);if(i){switch(this.orientation){case _t.FACEORIGIN_ORIENTATION:case _t.FACEFORWARD_ORIENTATION:i.lookAt(new s.Vector3(0,0,1));break;case _t.FACEFORWARDREVERSED_ORIENTATION:case _t.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(0,0,-1))}t.position=o}},e.prototype._scatterMapping=function(t){return t.x=(1-2*Math.random())*this._cellWidth,t.y=(1-2*Math.random())*this._cellHeight,t},e.prototype._finalProcessing=function(){for(var t=[],e=0,i=this._children;e<i.length;e++){var o=i[e];o.mesh&&t.push(o.mesh)}for(var n=0;n<this._iteration;n++){t.sort((function(t,e){var i=t.position.lengthSquared(),o=e.position.lengthSquared();return i<o?1:i>o?-1:0}));for(var r=Math.pow(this.margin,2),a=Math.max(this._cellWidth,this._cellHeight),l=s.TmpVectors.Vector2[0],_=s.TmpVectors.Vector3[0],h=0;h<t.length-1;h++)for(var c=h+1;c<t.length;c++)if(h!=c){t[c].position.subtractToRef(t[h].position,_),l.x=_.x,l.y=_.y;var u=a,d=l.lengthSquared()-r;(d-=Math.min(d,r))<Math.pow(u,2)&&(l.normalize(),_.scaleInPlace(.5*(u-Math.sqrt(d))),t[c].position.addInPlace(_),t[h].position.subtractInPlace(_))}}},e}(ht);s.ShaderStore.ShadersStore.mrdlSliderBarPixelShader="uniform vec3 cameraPosition;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nuniform float _Radius_;\nuniform float _Bevel_Front_;\nuniform float _Bevel_Front_Stretch_;\nuniform float _Bevel_Back_;\nuniform float _Bevel_Back_Stretch_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform bool _Bulge_Enabled_;\nuniform float _Bulge_Height_;\nuniform float _Bulge_Radius_;\nuniform float _Sun_Intensity_;\nuniform float _Sun_Theta_;\nuniform float _Sun_Phi_;\nuniform float _Indirect_Diffuse_;\nuniform vec4 _Albedo_;\nuniform float _Specular_;\nuniform float _Shininess_;\nuniform float _Sharpness_;\nuniform float _Subsurface_;\nuniform vec4 _Left_Color_;\nuniform vec4 _Right_Color_;\nuniform float _Reflection_;\nuniform float _Front_Reflect_;\nuniform float _Edge_Reflect_;\nuniform float _Power_;\nuniform vec4 _Sky_Color_;\nuniform vec4 _Horizon_Color_;\nuniform vec4 _Ground_Color_;\nuniform float _Horizon_Power_;\nuniform sampler2D _Reflection_Map_;\nuniform sampler2D _Indirect_Environment_;\nuniform float _Width_;\nuniform float _Fuzz_;\nuniform float _Min_Fuzz_;\nuniform float _Clip_Fade_;\nuniform float _Hue_Shift_;\nuniform float _Saturation_Shift_;\nuniform float _Value_Shift_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Left_Index_Pos_;\nuniform vec3 _Right_Index_Pos_;\nuniform vec3 _Left_Index_Middle_Pos_;\nuniform vec3 _Right_Index_Middle_Pos_;\nuniform sampler2D _Decal_;\nuniform vec2 _Decal_Scale_XY_;\nuniform bool _Decal_Front_Only_;\nuniform float _Rim_Intensity_;\nuniform sampler2D _Rim_Texture_;\nuniform float _Rim_Hue_Shift_;\nuniform float _Rim_Saturation_Shift_;\nuniform float _Rim_Value_Shift_;\nuniform float _Iridescence_Intensity_;\nuniform sampler2D _Iridescence_Texture_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform vec4 Global_Left_Index_Middle_Position;\nuniform vec4 Global_Right_Index_Middle_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvoid Blob_Fragment_B30(\nsampler2D Blob_Texture,\nvec4 Blob_Info1,\nvec4 Blob_Info2,\nout vec4 Blob_Color)\n{\nfloat k1=dot(Blob_Info1.xy,Blob_Info1.xy);\nfloat k2=dot(Blob_Info2.xy,Blob_Info2.xy);\nvec3 closer=k1<k2 ? vec3(k1,Blob_Info1.z,Blob_Info1.w) : vec3(k2,Blob_Info2.z,Blob_Info2.w);\nBlob_Color=closer.z*texture(Blob_Texture,vec2(vec2(sqrt(closer.x),closer.y).x,1.0-vec2(sqrt(closer.x),closer.y).y))*clamp(1.0-closer.x,0.0,1.0);\n}\nvoid FastLinearTosRGB_B42(\nvec4 Linear,\nout vec4 sRGB)\n{\nsRGB.rgb=sqrt(clamp(Linear.rgb,0.0,1.0));\nsRGB.a=Linear.a;\n}\nvoid Scale_RGB_B59(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=vec4(Scalar,Scalar,Scalar,1)*Color;\n}\nvoid Fragment_Main_B121(\nfloat Sun_Intensity,\nfloat Sun_Theta,\nfloat Sun_Phi,\nvec3 Normal,\nvec4 Albedo,\nfloat Fresnel_Reflect,\nfloat Shininess,\nvec3 Incident,\nvec4 Horizon_Color,\nvec4 Sky_Color,\nvec4 Ground_Color,\nfloat Indirect_Diffuse,\nfloat Specular,\nfloat Horizon_Power,\nfloat Reflection,\nvec4 Reflection_Sample,\nvec4 Indirect_Sample,\nfloat Sharpness,\nfloat SSS,\nfloat Subsurface,\nvec4 Translucence,\nvec4 Rim_Light,\nvec4 Iridescence,\nout vec4 Result)\n{\nfloat theta=Sun_Theta*2.0*3.14159;\nfloat phi=Sun_Phi*3.14159;\nvec3 lightDir= vec3(cos(phi)*cos(theta),sin(phi),cos(phi)*sin(theta));\nfloat NdotL=max(dot(lightDir,Normal),0.0);\nvec3 R=reflect(Incident,Normal);\nfloat RdotL=max(0.0,dot(R,lightDir));\nfloat specular=pow(RdotL,Shininess);\nspecular=mix(specular,smoothstep(0.495*Sharpness,1.0-0.495*Sharpness,specular),Sharpness);\nvec4 gi=mix(Ground_Color,Sky_Color,Normal.y*0.5+0.5);\nResult=((Sun_Intensity*NdotL+Indirect_Sample*Indirect_Diffuse+Translucence)*(1.0+SSS*Subsurface))*Albedo*(1.0-Fresnel_Reflect)+(Sun_Intensity*specular*Specular+Fresnel_Reflect*Reflection*Reflection_Sample)+Fresnel_Reflect*Rim_Light+Iridescence;\n}\nvoid Bulge_B79(\nbool Enabled,\nvec3 Normal,\nvec3 Tangent,\nfloat Bulge_Height,\nvec4 UV,\nfloat Bulge_Radius,\nvec3 ButtonN,\nout vec3 New_Normal)\n{\nvec2 xy=clamp(UV.xy*2.0,vec2(-1,-1),vec2(1,1));\nvec3 B=(cross(Normal,Tangent));\nfloat k=-clamp(1.0-length(xy)/Bulge_Radius,0.0,1.0)*Bulge_Height;\nk=sin(k*3.14159*0.5);\nk*=smoothstep(0.9998,0.9999,abs(dot(ButtonN,Normal)));\nNew_Normal=Normal*sqrt(1.0-k*k)+(xy.x*Tangent+xy.y*B)*k;\nNew_Normal=Enabled ? New_Normal : Normal;\n}\nvoid SSS_B77(\nvec3 ButtonN,\nvec3 Normal,\nvec3 Incident,\nout float Result)\n{\nfloat NdotI=abs(dot(Normal,Incident));\nfloat BdotI=abs(dot(ButtonN,Incident));\nResult=(abs(NdotI-BdotI)); \n}\nvoid FingerOcclusion_B67(\nfloat Width,\nfloat DistToCenter,\nfloat Fuzz,\nfloat Min_Fuzz,\nvec3 Position,\nvec3 Forward,\nvec3 Nearest,\nfloat Fade_Out,\nout float NotInShadow)\n{\nfloat d=dot((Nearest-Position),Forward);\nfloat sh=smoothstep(Width*0.5,Width*0.5+Fuzz*max(d,0.0)+Min_Fuzz,DistToCenter);\nNotInShadow=1.0-(1.0-sh)*smoothstep(-Fade_Out,0.0,d);\n}\nvoid FingerOcclusion_B68(\nfloat Width,\nfloat DistToCenter,\nfloat Fuzz,\nfloat Min_Fuzz,\nvec3 Position,\nvec3 Forward,\nvec3 Nearest,\nfloat Fade_Out,\nout float NotInShadow)\n{\nfloat d=dot((Nearest-Position),Forward);\nfloat sh=smoothstep(Width*0.5,Width*0.5+Fuzz*max(d,0.0)+Min_Fuzz,DistToCenter);\nNotInShadow=1.0-(1.0-sh)*smoothstep(-Fade_Out,0.0,d);\n}\nvoid Scale_Color_B91(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=Scalar*Color;\n}\nvoid From_HSV_B73(\nfloat Hue,\nfloat Saturation,\nfloat Value,\nfloat Alpha,\nout vec4 Color)\n{\nvec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);\nvec3 p=abs(fract(vec3(Hue,Hue,Hue)+K.xyz)*6.0-K.www);\nColor.rgb=Value*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),Saturation);\nColor.a=Alpha;\n}\nvoid Fast_Fresnel_B122(\nfloat Front_Reflect,\nfloat Edge_Reflect,\nfloat Power,\nvec3 Normal,\nvec3 Incident,\nout float Transmit,\nout float Reflect)\n{\nfloat d=max(-dot(Incident,Normal),0.0);\nReflect=Front_Reflect+(Edge_Reflect-Front_Reflect)*pow(.01-d,Power);\nTransmit=1.0-Reflect;\n}\nvoid Mapped_Environment_B51(\nsampler2D Reflected_Environment,\nsampler2D Indirect_Environment,\nvec3 Dir,\nout vec4 Reflected_Color,\nout vec4 Indirect_Diffuse)\n{\nReflected_Color=texture(Reflected_Environment,vec2(atan(Dir.z,Dir.x)/3.14159*0.5,asin(Dir.y)/3.14159+0.5));\nIndirect_Diffuse=texture(Indirect_Environment,vec2(atan(Dir.z,Dir.x)/3.14159*0.5,asin(Dir.y)/3.14159+0.5));\n}\nvec4 SampleEnv_Bid50(vec3 D,vec4 S,vec4 H,vec4 G,float exponent)\n{\nfloat k=pow(abs(D.y),exponent);\nvec4 C;\nif (D.y>0.0) {\nC=mix(H,S,k);\n} else {\nC=mix(H,G,k); \n}\nreturn C;\n}\nvoid Sky_Environment_B50(\nvec3 Normal,\nvec3 Reflected,\nvec4 Sky_Color,\nvec4 Horizon_Color,\nvec4 Ground_Color,\nfloat Horizon_Power,\nout vec4 Reflected_Color,\nout vec4 Indirect_Color)\n{\nReflected_Color=SampleEnv_Bid50(Reflected,Sky_Color,Horizon_Color,Ground_Color,Horizon_Power);\nIndirect_Color=mix(Ground_Color,Sky_Color,Normal.y*0.5+0.5);\n}\nvoid Min_Segment_Distance_B65(\nvec3 P0,\nvec3 P1,\nvec3 Q0,\nvec3 Q1,\nout vec3 NearP,\nout vec3 NearQ,\nout float Distance)\n{\nvec3 u=P1-P0;\nvec3 v=Q1-Q0;\nvec3 w=P0-Q0;\nfloat a=dot(u,u);\nfloat b=dot(u,v);\nfloat c=dot(v,v);\nfloat d=dot(u,w);\nfloat e=dot(v,w);\nfloat D=a*c-b*b;\nfloat sD=D;\nfloat tD=D;\nfloat sc,sN,tc,tN;\nif (D<0.00001) {\nsN=0.0;\nsD=1.0;\ntN=e;\ntD=c;\n} else {\nsN=(b*e-c*d);\ntN=(a*e-b*d);\nif (sN<0.0) {\nsN=0.0;\ntN=e;\ntD=c;\n} else if (sN>sD) {\nsN=sD;\ntN=e+b;\ntD=c;\n}\n}\nif (tN<0.0) {\ntN=0.0;\nif (-d<0.0) {\nsN=0.0;\n} else if (-d>a) {\nsN=sD;\n} else {\nsN=-d;\nsD=a;\n}\n} else if (tN>tD) {\ntN=tD;\nif ((-d+b)<0.0) {\nsN=0.0;\n} else if ((-d+b)>a) {\nsN=sD;\n} else {\nsN=(-d+b);\nsD=a;\n}\n}\nsc=abs(sN)<0.000001 ? 0.0 : sN/sD;\ntc=abs(tN)<0.000001 ? 0.0 : tN/tD;\nNearP=P0+sc*u;\nNearQ=Q0+tc*v;\nDistance=distance(NearP,NearQ);\n}\nvoid To_XYZ_B74(\nvec3 Vec3,\nout float X,\nout float Y,\nout float Z)\n{\nX=Vec3.x;\nY=Vec3.y;\nZ=Vec3.z;\n}\nvoid Finger_Positions_B64(\nvec3 Left_Index_Pos,\nvec3 Right_Index_Pos,\nvec3 Left_Index_Middle_Pos,\nvec3 Right_Index_Middle_Pos,\nout vec3 Left_Index,\nout vec3 Right_Index,\nout vec3 Left_Index_Middle,\nout vec3 Right_Index_Middle)\n{\nLeft_Index= (Use_Global_Left_Index ? Global_Left_Index_Tip_Position.xyz : Left_Index_Pos);\nRight_Index= (Use_Global_Right_Index ? Global_Right_Index_Tip_Position.xyz : Right_Index_Pos);\nLeft_Index_Middle= (Use_Global_Left_Index ? Global_Left_Index_Middle_Position.xyz : Left_Index_Middle_Pos);\nRight_Index_Middle= (Use_Global_Right_Index ? Global_Right_Index_Middle_Position.xyz : Right_Index_Middle_Pos);\n}\nvoid VaryHSV_B108(\nvec3 HSV_In,\nfloat Hue_Shift,\nfloat Saturation_Shift,\nfloat Value_Shift,\nout vec3 HSV_Out)\n{\nHSV_Out=vec3(fract(HSV_In.x+Hue_Shift),clamp(HSV_In.y+Saturation_Shift,0.0,1.0),clamp(HSV_In.z+Value_Shift,0.0,1.0));\n}\nvoid Remap_Range_B114(\nfloat In_Min,\nfloat In_Max,\nfloat Out_Min,\nfloat Out_Max,\nfloat In,\nout float Out)\n{\nOut=mix(Out_Min,Out_Max,clamp((In-In_Min)/(In_Max-In_Min),0.0,1.0));\n}\nvoid To_HSV_B75(\nvec4 Color,\nout float Hue,\nout float Saturation,\nout float Value,\nout float Alpha,\nout vec3 HSV)\n{\nvec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);\nvec4 p=Color.g<Color.b ? vec4(Color.bg,K.wz) : vec4(Color.gb,K.xy);\nvec4 q=Color.r<p.x ? vec4(p.xyw,Color.r) : vec4(Color.r,p.yzx);\nfloat d=q.x-min(q.w,q.y);\nfloat e=1.0e-10;\nHue=abs(q.z+(q.w-q.y)/(6.0*d+e));\nSaturation=d/(q.x+e);\nValue=q.x;\nAlpha=Color.a;\nHSV=vec3(Hue,Saturation,Value);\n}\nvoid Code_B110(\nfloat X,\nout float Result)\n{\nResult=(acos(X)/3.14159-0.5)*2.0;\n}\nvoid Rim_Light_B132(\nvec3 Front,\nvec3 Normal,\nvec3 Incident,\nfloat Rim_Intensity,\nsampler2D Texture,\nout vec4 Result)\n{\nvec3 R=reflect(Incident,Normal);\nfloat RdotF=dot(R,Front);\nfloat RdotL=sqrt(1.0-RdotF*RdotF);\nvec2 UV=vec2(R.y*0.5+0.5,0.5);\nvec4 Color=texture(Texture,UV);\nResult=Color;\n}\nvoid main()\n{\nvec4 Blob_Color_Q30;\n#if BLOB_ENABLE\nBlob_Fragment_B30(_Blob_Texture_,vExtra2,vExtra3,Blob_Color_Q30);\n#else\nBlob_Color_Q30=vec4(0,0,0,0);\n#endif\nvec3 Incident_Q39=normalize(vPosition-cameraPosition);\nvec3 Normalized_Q38=normalize(vNormal);\nvec3 Normalized_Q71=normalize(vTangent);\nvec4 Color_Q83;\n#if DECAL_ENABLE\nColor_Q83=texture(_Decal_,vUV);\n#else\nColor_Q83=vec4(0,0,0,0);\n#endif\nfloat X_Q90;\nfloat Y_Q90;\nfloat Z_Q90;\nfloat W_Q90;\nX_Q90=vExtra1.x;\nY_Q90=vExtra1.y;\nZ_Q90=vExtra1.z;\nW_Q90=vExtra1.w;\nvec4 Linear_Q43;\nLinear_Q43.rgb=clamp(_Sky_Color_.rgb*_Sky_Color_.rgb,0.0,1.0);\nLinear_Q43.a=_Sky_Color_.a;\nvec4 Linear_Q44;\nLinear_Q44.rgb=clamp(_Horizon_Color_.rgb*_Horizon_Color_.rgb,0.0,1.0);\nLinear_Q44.a=_Horizon_Color_.a;\nvec4 Linear_Q45;\nLinear_Q45.rgb=clamp(_Ground_Color_.rgb*_Ground_Color_.rgb,0.0,1.0);\nLinear_Q45.a=_Ground_Color_.a;\nvec3 Left_Index_Q64;\nvec3 Right_Index_Q64;\nvec3 Left_Index_Middle_Q64;\nvec3 Right_Index_Middle_Q64;\nFinger_Positions_B64(_Left_Index_Pos_,_Right_Index_Pos_,_Left_Index_Middle_Pos_,_Right_Index_Middle_Pos_,Left_Index_Q64,Right_Index_Q64,Left_Index_Middle_Q64,Right_Index_Middle_Q64);\nvec4 Linear_Q46;\nLinear_Q46.rgb=clamp(_Albedo_.rgb*_Albedo_.rgb,0.0,1.0);\nLinear_Q46.a=_Albedo_.a;\nvec3 Normalized_Q107=normalize(vBinormal);\nvec3 Incident_Q70=normalize(vPosition-cameraPosition);\nvec3 New_Normal_Q79;\nBulge_B79(_Bulge_Enabled_,Normalized_Q38,Normalized_Q71,_Bulge_Height_,vColor,_Bulge_Radius_,vBinormal,New_Normal_Q79);\nfloat Result_Q77;\nSSS_B77(vBinormal,New_Normal_Q79,Incident_Q39,Result_Q77);\nvec4 Result_Q91;\nScale_Color_B91(Color_Q83,X_Q90,Result_Q91);\nfloat Transmit_Q122;\nfloat Reflect_Q122;\nFast_Fresnel_B122(_Front_Reflect_,_Edge_Reflect_,_Power_,New_Normal_Q79,Incident_Q39,Transmit_Q122,Reflect_Q122);\nfloat Product_Q125=Y_Q90*Y_Q90;\nvec3 NearP_Q65;\nvec3 NearQ_Q65;\nfloat Distance_Q65;\nMin_Segment_Distance_B65(Left_Index_Q64,Left_Index_Middle_Q64,vPosition,cameraPosition,NearP_Q65,NearQ_Q65,Distance_Q65);\nvec3 NearP_Q63;\nvec3 NearQ_Q63;\nfloat Distance_Q63;\nMin_Segment_Distance_B65(Right_Index_Q64,Right_Index_Middle_Q64,vPosition,cameraPosition,NearP_Q63,NearQ_Q63,Distance_Q63);\nvec3 Reflected_Q47=reflect(Incident_Q39,New_Normal_Q79);\nvec4 Product_Q103=Linear_Q46*vec4(1,1,1,1);\nvec4 Result_Q132;\nRim_Light_B132(Normalized_Q107,Normalized_Q38,Incident_Q70,_Rim_Intensity_,_Rim_Texture_,Result_Q132);\nfloat Dot_Q72=dot(Incident_Q70, Normalized_Q71);\nfloat MaxAB_Q123=max(Reflect_Q122,Product_Q125);\nfloat NotInShadow_Q67;\n#if OCCLUSION_ENABLED\nFingerOcclusion_B67(_Width_,Distance_Q65,_Fuzz_,_Min_Fuzz_,vPosition,vBinormal,NearP_Q65,_Clip_Fade_,NotInShadow_Q67);\n#else\nNotInShadow_Q67=1.0;\n#endif\nfloat NotInShadow_Q68;\n#if OCCLUSION_ENABLED\nFingerOcclusion_B68(_Width_,Distance_Q63,_Fuzz_,_Min_Fuzz_,vPosition,vBinormal,NearP_Q63,_Clip_Fade_,NotInShadow_Q68);\n#else\nNotInShadow_Q68=1.0;\n#endif\nvec4 Reflected_Color_Q51;\nvec4 Indirect_Diffuse_Q51;\n#if ENV_ENABLE\nMapped_Environment_B51(_Reflection_Map_,_Indirect_Environment_,Reflected_Q47,Reflected_Color_Q51,Indirect_Diffuse_Q51);\n#else\nReflected_Color_Q51=vec4(0,0,0,1);\nIndirect_Diffuse_Q51=vec4(0,0,0,1);\n#endif\nvec4 Reflected_Color_Q50;\nvec4 Indirect_Color_Q50;\n#if SKY_ENABLED\nSky_Environment_B50(New_Normal_Q79,Reflected_Q47,Linear_Q43,Linear_Q44,Linear_Q45,_Horizon_Power_,Reflected_Color_Q50,Indirect_Color_Q50);\n#else\nReflected_Color_Q50=vec4(0,0,0,1);\nIndirect_Color_Q50=vec4(0,0,0,1);\n#endif\nfloat Hue_Q75;\nfloat Saturation_Q75;\nfloat Value_Q75;\nfloat Alpha_Q75;\nvec3 HSV_Q75;\nTo_HSV_B75(Product_Q103,Hue_Q75,Saturation_Q75,Value_Q75,Alpha_Q75,HSV_Q75);\nfloat Hue_Q127;\nfloat Saturation_Q127;\nfloat Value_Q127;\nfloat Alpha_Q127;\nvec3 HSV_Q127;\nTo_HSV_B75(Result_Q132,Hue_Q127,Saturation_Q127,Value_Q127,Alpha_Q127,HSV_Q127);\nfloat Result_Q110;\nCode_B110(Dot_Q72,Result_Q110);\nfloat AbsA_Q76=abs(Result_Q110);\nfloat MinAB_Q58=min(NotInShadow_Q67,NotInShadow_Q68);\nvec4 Sum_Q48=Reflected_Color_Q51+Reflected_Color_Q50;\nvec4 Sum_Q49=Indirect_Diffuse_Q51+Indirect_Color_Q50;\nvec3 HSV_Out_Q126;\nVaryHSV_B108(HSV_Q127,_Rim_Hue_Shift_,_Rim_Saturation_Shift_,_Rim_Value_Shift_,HSV_Out_Q126);\nfloat Out_Q114;\nRemap_Range_B114(-1.0,1.0,0.0,1.0,Result_Q110,Out_Q114);\nfloat Product_Q106;\nProduct_Q106=AbsA_Q76*_Hue_Shift_;\nfloat X_Q128;\nfloat Y_Q128;\nfloat Z_Q128;\nTo_XYZ_B74(HSV_Out_Q126,X_Q128,Y_Q128,Z_Q128);\nvec2 Vec2_Q112=vec2(Out_Q114,0.5);\nvec3 HSV_Out_Q108;\nVaryHSV_B108(HSV_Q75,Product_Q106,_Saturation_Shift_,_Value_Shift_,HSV_Out_Q108);\nvec4 Color_Q129;\nFrom_HSV_B73(X_Q128,Y_Q128,Z_Q128,0.0,Color_Q129);\nvec4 Color_Q111;\n#if IRIDESCENCE_ENABLED\nColor_Q111=texture(_Iridescence_Texture_,Vec2_Q112);\n#else\nColor_Q111=vec4(0,0,0,0);\n#endif\nfloat X_Q74;\nfloat Y_Q74;\nfloat Z_Q74;\nTo_XYZ_B74(HSV_Out_Q108,X_Q74,Y_Q74,Z_Q74);\nvec4 Result_Q131=_Rim_Intensity_*Color_Q129;\nvec4 Result_Q113=_Iridescence_Intensity_*Color_Q111;\nvec4 Color_Q73;\nFrom_HSV_B73(X_Q74,Y_Q74,Z_Q74,0.0,Color_Q73);\nvec4 Result_Q84=Result_Q91+(1.0-Result_Q91.a)*Color_Q73;\nvec4 Result_Q121;\nFragment_Main_B121(_Sun_Intensity_,_Sun_Theta_,_Sun_Phi_,New_Normal_Q79,Result_Q84,MaxAB_Q123,_Shininess_,Incident_Q39,_Horizon_Color_,_Sky_Color_,_Ground_Color_,_Indirect_Diffuse_,_Specular_,_Horizon_Power_,_Reflection_,Sum_Q48,Sum_Q49,_Sharpness_,Result_Q77,_Subsurface_,vec4(0,0,0,0),Result_Q131,Result_Q113,Result_Q121);\nvec4 Result_Q59;\nScale_RGB_B59(Result_Q121,MinAB_Q58,Result_Q59);\nvec4 sRGB_Q42;\nFastLinearTosRGB_B42(Result_Q59,sRGB_Q42);\nvec4 Result_Q31=Blob_Color_Q30+(1.0-Blob_Color_Q30.a)*sRGB_Q42;\nvec4 Result_Q40=Result_Q31; Result_Q40.a=1.0;\nvec4 Out_Color=Result_Q40;\nfloat Clip_Threshold=0.001;\nbool To_sRGB=false;\ngl_FragColor=Out_Color;\n}";s.ShaderStore.ShadersStore.mrdlSliderBarVertexShader="uniform mat4 world;\nuniform mat4 viewProjection;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n#ifdef TANGENT\nattribute vec3 tangent;\n#else\nconst vec3 tangent=vec3(0.);\n#endif\nuniform float _Radius_;\nuniform float _Bevel_Front_;\nuniform float _Bevel_Front_Stretch_;\nuniform float _Bevel_Back_;\nuniform float _Bevel_Back_Stretch_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform bool _Bulge_Enabled_;\nuniform float _Bulge_Height_;\nuniform float _Bulge_Radius_;\nuniform float _Sun_Intensity_;\nuniform float _Sun_Theta_;\nuniform float _Sun_Phi_;\nuniform float _Indirect_Diffuse_;\nuniform vec4 _Albedo_;\nuniform float _Specular_;\nuniform float _Shininess_;\nuniform float _Sharpness_;\nuniform float _Subsurface_;\nuniform vec4 _Left_Color_;\nuniform vec4 _Right_Color_;\nuniform float _Reflection_;\nuniform float _Front_Reflect_;\nuniform float _Edge_Reflect_;\nuniform float _Power_;\nuniform vec4 _Sky_Color_;\nuniform vec4 _Horizon_Color_;\nuniform vec4 _Ground_Color_;\nuniform float _Horizon_Power_;\nuniform sampler2D _Reflection_Map_;\nuniform sampler2D _Indirect_Environment_;\nuniform float _Width_;\nuniform float _Fuzz_;\nuniform float _Min_Fuzz_;\nuniform float _Clip_Fade_;\nuniform float _Hue_Shift_;\nuniform float _Saturation_Shift_;\nuniform float _Value_Shift_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Left_Index_Pos_;\nuniform vec3 _Right_Index_Pos_;\nuniform vec3 _Left_Index_Middle_Pos_;\nuniform vec3 _Right_Index_Middle_Pos_;\nuniform sampler2D _Decal_;\nuniform vec2 _Decal_Scale_XY_;\nuniform bool _Decal_Front_Only_;\nuniform float _Rim_Intensity_;\nuniform sampler2D _Rim_Texture_;\nuniform float _Rim_Hue_Shift_;\nuniform float _Rim_Saturation_Shift_;\nuniform float _Rim_Value_Shift_;\nuniform float _Iridescence_Intensity_;\nuniform sampler2D _Iridescence_Texture_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nvoid Object_To_World_Pos_B12(\nvec3 Pos_Object,\nout vec3 Pos_World)\n{\nPos_World=(world*vec4(Pos_Object,1.0)).xyz;\n}\nvoid Object_To_World_Normal_B32(\nvec3 Nrm_Object,\nout vec3 Nrm_World)\n{\nNrm_World=(vec4(Nrm_Object,0.0)).xyz;\n}\nvoid Blob_Vertex_B23(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nfloat Blob_Fade_Length,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nout vec4 Blob_Info)\n{\nvec3 blob= (Use_Global_Left_Index ? Global_Left_Index_Tip_Position.xyz : Blob_Position);\nvec3 delta=blob-Position;\nfloat dist=dot(Normal,delta);\nfloat lerpValue=clamp((abs(dist)-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfloat fadeValue=1.0-clamp((abs(dist)-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat size=Blob_Near_Size+(Blob_Far_Size-Blob_Near_Size)*lerpValue;\nvec2 blobXY=vec2(dot(delta,Tangent),dot(delta,Bitangent))/(0.0001+size);\nfloat Fade=fadeValue*Intensity*Blob_Fade;\nfloat Distance=(lerpValue*0.5+0.5)*(1.0-Blob_Pulse);\nBlob_Info=vec4(blobXY.x,blobXY.y,Distance,Fade);\n}\nvoid Blob_Vertex_B24(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nfloat Blob_Fade_Length,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nout vec4 Blob_Info)\n{\nvec3 blob= (Use_Global_Right_Index ? Global_Right_Index_Tip_Position.xyz : Blob_Position);\nvec3 delta=blob-Position;\nfloat dist=dot(Normal,delta);\nfloat lerpValue=clamp((abs(dist)-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfloat fadeValue=1.0-clamp((abs(dist)-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat size=Blob_Near_Size+(Blob_Far_Size-Blob_Near_Size)*lerpValue;\nvec2 blobXY=vec2(dot(delta,Tangent),dot(delta,Bitangent))/(0.0001+size);\nfloat Fade=fadeValue*Intensity*Blob_Fade;\nfloat Distance=(lerpValue*0.5+0.5)*(1.0-Blob_Pulse);\nBlob_Info=vec4(blobXY.x,blobXY.y,Distance,Fade);\n}\nvoid Move_Verts_B130(\nfloat Anisotropy,\nvec3 P,\nfloat Radius,\nfloat Bevel,\nvec3 Normal_Object,\nfloat ScaleZ,\nfloat Stretch,\nout vec3 New_P,\nout vec2 New_UV,\nout float Radial_Gradient,\nout vec3 Radial_Dir,\nout vec3 New_Normal)\n{\nvec2 UV=P.xy*2.0+0.5;\nvec2 center=clamp(UV,0.0,1.0);\nvec2 delta=UV-center;\nfloat deltad=(length(delta)*2.0);\nfloat f=(Bevel+(Radius-Bevel)*Stretch)/Radius;\nfloat innerd=clamp(deltad*2.0,0.0,1.0);\nfloat outerd=clamp(deltad*2.0-1.0,0.0,1.0);\nfloat bevelAngle=outerd*3.14159*0.5;\nfloat sinb=sin(bevelAngle);\nfloat cosb=cos(bevelAngle);\nfloat beveld=(1.0-f)*innerd+f*sinb;\nfloat br=outerd;\nvec2 r2=2.0*vec2(Radius/Anisotropy,Radius);\nfloat dir=P.z<0.0001 ? 1.0 : -1.0;\nNew_UV=center+r2*((0.5-center)+normalize(delta+vec2(0.0,0.000001))*beveld*0.5);\nNew_P=vec3(New_UV-0.5,P.z+dir*(1.0-cosb)*Bevel*ScaleZ);\nRadial_Gradient=clamp((deltad-0.5)*2.0,0.0,1.0);\nRadial_Dir=vec3(delta*r2,0.0);\nvec3 beveledNormal=cosb*Normal_Object+sinb*vec3(delta.x,delta.y,0.0);\nNew_Normal=Normal_Object.z==0.0 ? Normal_Object : beveledNormal;\n}\nvoid Object_To_World_Dir_B60(\nvec3 Dir_Object,\nout vec3 Normal_World,\nout vec3 Normal_World_N,\nout float Normal_Length)\n{\nNormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nNormal_Length=length(Normal_World);\nNormal_World_N=Normal_World/Normal_Length;\n}\nvoid To_XYZ_B78(\nvec3 Vec3,\nout float X,\nout float Y,\nout float Z)\n{\nX=Vec3.x;\nY=Vec3.y;\nZ=Vec3.z;\n}\nvoid Conditional_Float_B93(\nbool Which,\nfloat If_True,\nfloat If_False,\nout float Result)\n{\nResult=Which ? If_True : If_False;\n}\nvoid Object_To_World_Dir_B28(\nvec3 Dir_Object,\nout vec3 Binormal_World,\nout vec3 Binormal_World_N,\nout float Binormal_Length)\n{\nBinormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nBinormal_Length=length(Binormal_World);\nBinormal_World_N=Binormal_World/Binormal_Length;\n}\nvoid Pick_Radius_B69(\nfloat Radius,\nfloat Radius_Top_Left,\nfloat Radius_Top_Right,\nfloat Radius_Bottom_Left,\nfloat Radius_Bottom_Right,\nvec3 Position,\nout float Result)\n{\nbool whichY=Position.y>0.0;\nResult=Position.x<0.0 ? (whichY ? Radius_Top_Left : Radius_Bottom_Left) : (whichY ? Radius_Top_Right : Radius_Bottom_Right);\nResult*=Radius;\n}\nvoid Conditional_Float_B36(\nbool Which,\nfloat If_True,\nfloat If_False,\nout float Result)\n{\nResult=Which ? If_True : If_False;\n}\nvoid Greater_Than_B37(\nfloat Left,\nfloat Right,\nout bool Not_Greater_Than,\nout bool Greater_Than)\n{\nGreater_Than=Left>Right;\nNot_Greater_Than=!Greater_Than;\n}\nvoid Remap_Range_B105(\nfloat In_Min,\nfloat In_Max,\nfloat Out_Min,\nfloat Out_Max,\nfloat In,\nout float Out)\n{\nOut=mix(Out_Min,Out_Max,clamp((In-In_Min)/(In_Max-In_Min),0.0,1.0));\n}\nvoid main()\n{\nvec2 XY_Q85;\nXY_Q85=(uv-vec2(0.5,0.5))*_Decal_Scale_XY_+vec2(0.5,0.5);\nvec3 Tangent_World_Q27;\nvec3 Tangent_World_N_Q27;\nfloat Tangent_Length_Q27;\nTangent_World_Q27=(world*vec4(vec3(1,0,0),0.0)).xyz;\nTangent_Length_Q27=length(Tangent_World_Q27);\nTangent_World_N_Q27=Tangent_World_Q27/Tangent_Length_Q27;\nvec3 Normal_World_Q60;\nvec3 Normal_World_N_Q60;\nfloat Normal_Length_Q60;\nObject_To_World_Dir_B60(vec3(0,0,1),Normal_World_Q60,Normal_World_N_Q60,Normal_Length_Q60);\nfloat X_Q78;\nfloat Y_Q78;\nfloat Z_Q78;\nTo_XYZ_B78(position,X_Q78,Y_Q78,Z_Q78);\nvec3 Nrm_World_Q26;\nNrm_World_Q26=normalize((world*vec4(normal,0.0)).xyz);\nvec3 Binormal_World_Q28;\nvec3 Binormal_World_N_Q28;\nfloat Binormal_Length_Q28;\nObject_To_World_Dir_B28(vec3(0,1,0),Binormal_World_Q28,Binormal_World_N_Q28,Binormal_Length_Q28);\nfloat Anisotropy_Q29=Tangent_Length_Q27/Binormal_Length_Q28;\nfloat Result_Q69;\nPick_Radius_B69(_Radius_,_Radius_Top_Left_,_Radius_Top_Right_,_Radius_Bottom_Left_,_Radius_Bottom_Right_,position,Result_Q69);\nfloat Anisotropy_Q53=Binormal_Length_Q28/Normal_Length_Q60;\nbool Not_Greater_Than_Q37;\nbool Greater_Than_Q37;\nGreater_Than_B37(Z_Q78,0.0,Not_Greater_Than_Q37,Greater_Than_Q37);\nvec4 Linear_Q101;\nLinear_Q101.rgb=clamp(_Left_Color_.rgb*_Left_Color_.rgb,0.0,1.0);\nLinear_Q101.a=_Left_Color_.a;\nvec4 Linear_Q102;\nLinear_Q102.rgb=clamp(_Right_Color_.rgb*_Right_Color_.rgb,0.0,1.0);\nLinear_Q102.a=_Right_Color_.a;\nvec3 Difference_Q61=vec3(0,0,0)-Normal_World_N_Q60;\nvec4 Out_Color_Q34=vec4(X_Q78,Y_Q78,Z_Q78,1);\nfloat Result_Q36;\nConditional_Float_B36(Greater_Than_Q37,_Bevel_Back_,_Bevel_Front_,Result_Q36);\nfloat Result_Q94;\nConditional_Float_B36(Greater_Than_Q37,_Bevel_Back_Stretch_,_Bevel_Front_Stretch_,Result_Q94);\nvec3 New_P_Q130;\nvec2 New_UV_Q130;\nfloat Radial_Gradient_Q130;\nvec3 Radial_Dir_Q130;\nvec3 New_Normal_Q130;\nMove_Verts_B130(Anisotropy_Q29,position,Result_Q69,Result_Q36,normal,Anisotropy_Q53,Result_Q94,New_P_Q130,New_UV_Q130,Radial_Gradient_Q130,Radial_Dir_Q130,New_Normal_Q130);\nfloat X_Q98;\nfloat Y_Q98;\nX_Q98=New_UV_Q130.x;\nY_Q98=New_UV_Q130.y;\nvec3 Pos_World_Q12;\nObject_To_World_Pos_B12(New_P_Q130,Pos_World_Q12);\nvec3 Nrm_World_Q32;\nObject_To_World_Normal_B32(New_Normal_Q130,Nrm_World_Q32);\nvec4 Blob_Info_Q23;\n#if BLOB_ENABLE\nBlob_Vertex_B23(Pos_World_Q12,Nrm_World_Q26,Tangent_World_N_Q27,Binormal_World_N_Q28,_Blob_Position_,_Blob_Intensity_,_Blob_Near_Size_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_,_Blob_Fade_,Blob_Info_Q23);\n#else\nBlob_Info_Q23=vec4(0,0,0,0);\n#endif\nvec4 Blob_Info_Q24;\n#if BLOB_ENABLE_2\nBlob_Vertex_B24(Pos_World_Q12,Nrm_World_Q26,Tangent_World_N_Q27,Binormal_World_N_Q28,_Blob_Position_2_,_Blob_Intensity_,_Blob_Near_Size_2_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_2_,_Blob_Fade_2_,Blob_Info_Q24);\n#else\nBlob_Info_Q24=vec4(0,0,0,0);\n#endif\nfloat Out_Q105;\nRemap_Range_B105(0.0,1.0,0.0,1.0,X_Q98,Out_Q105);\nfloat X_Q86;\nfloat Y_Q86;\nfloat Z_Q86;\nTo_XYZ_B78(Nrm_World_Q32,X_Q86,Y_Q86,Z_Q86);\nvec4 Color_At_T_Q97=mix(Linear_Q101,Linear_Q102,Out_Q105);\nfloat Minus_F_Q87=-Z_Q86;\nfloat R_Q99;\nfloat G_Q99;\nfloat B_Q99;\nfloat A_Q99;\nR_Q99=Color_At_T_Q97.r; G_Q99=Color_At_T_Q97.g; B_Q99=Color_At_T_Q97.b; A_Q99=Color_At_T_Q97.a;\nfloat ClampF_Q88=clamp(0.0,Minus_F_Q87,1.0);\nfloat Result_Q93;\nConditional_Float_B93(_Decal_Front_Only_,ClampF_Q88,1.0,Result_Q93);\nvec4 Vec4_Q89=vec4(Result_Q93,Radial_Gradient_Q130,G_Q99,B_Q99);\nvec3 Position=Pos_World_Q12;\nvec3 Normal=Nrm_World_Q32;\nvec2 UV=XY_Q85;\nvec3 Tangent=Tangent_World_N_Q27;\nvec3 Binormal=Difference_Q61;\nvec4 Color=Out_Color_Q34;\nvec4 Extra1=Vec4_Q89;\nvec4 Extra2=Blob_Info_Q23;\nvec4 Extra3=Blob_Info_Q24;\ngl_Position=viewProjection*vec4(Position,1);\nvPosition=Position;\nvNormal=Normal;\nvUV=UV;\nvTangent=Tangent;\nvBinormal=Binormal;\nvColor=Color;\nvExtra1=Extra1;\nvExtra2=Extra2;\nvExtra3=Extra3;\n}";var Lt=function(t){function e(){var e=t.call(this)||this;return e.SKY_ENABLED=!0,e.BLOB_ENABLE_2=!0,e.IRIDESCENCE_ENABLED=!0,e._needNormals=!0,e._needUVs=!0,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),Nt=function(t){function e(i,o){var n=t.call(this,i,o)||this;return n.radius=.6,n.bevelFront=.6,n.bevelFrontStretch=.077,n.bevelBack=0,n.bevelBackStretch=0,n.radiusTopLeft=1,n.radiusTopRight=1,n.radiusBottomLeft=1,n.radiusBottomRight=1,n.bulgeEnabled=!1,n.bulgeHeight=-.323,n.bulgeRadius=.73,n.sunIntensity=1.102,n.sunTheta=.76,n.sunPhi=.526,n.indirectDiffuse=.658,n.albedo=new s.Color4(.0117647,.505882,.996078,1),n.specular=0,n.shininess=10,n.sharpness=0,n.subsurface=0,n.leftGradientColor=new s.Color4(.0117647,.505882,.996078,1),n.rightGradientColor=new s.Color4(.0117647,.505882,.996078,1),n.reflection=.749,n.frontReflect=0,n.edgeReflect=.09,n.power=8.13,n.skyColor=new s.Color4(.0117647,.964706,.996078,1),n.horizonColor=new s.Color4(.0117647,.333333,.996078,1),n.groundColor=new s.Color4(0,.254902,.996078,1),n.horizonPower=1,n.width=.02,n.fuzz=.5,n.minFuzz=.001,n.clipFade=.01,n.hueShift=0,n.saturationShift=0,n.valueShift=0,n.blobPosition=new s.Vector3(0,0,.1),n.blobIntensity=.5,n.blobNearSize=.01,n.blobFarSize=.03,n.blobNearDistance=0,n.blobFarDistance=.08,n.blobFadeLength=.576,n.blobPulse=0,n.blobFade=1,n.blobPosition2=new s.Vector3(.2,0,.1),n.blobNearSize2=.01,n.blobPulse2=0,n.blobFade2=1,n.blobTexture=new s.Texture("",n.getScene()),n.leftIndexPosition=new s.Vector3(0,0,1),n.rightIndexPosition=new s.Vector3(-1,-1,-1),n.leftIndexMiddlePosition=new s.Vector3(0,0,0),n.rightIndexMiddlePosition=new s.Vector3(0,0,0),n.decalScaleXY=new s.Vector2(1.5,1.5),n.decalFrontOnly=!0,n.rimIntensity=.287,n.rimHueShift=0,n.rimSaturationShift=0,n.rimValueShift=-1,n.iridescenceIntensity=0,n.useGlobalLeftIndex=1,n.useGlobalRightIndex=1,n.globalLeftIndexTipProximity=0,n.globalRightIndexTipProximity=0,n.globalLeftIndexTipPosition=new s.Vector4(.5,0,-.55,1),n.globaRightIndexTipPosition=new s.Vector4(0,0,0,1),n.globalLeftThumbTipPosition=new s.Vector4(.5,0,-.55,1),n.globalRightThumbTipPosition=new s.Vector4(0,0,0,1),n.globalLeftIndexMiddlePosition=new s.Vector4(.5,0,-.55,1),n.globalRightIndexMiddlePosition=new s.Vector4(0,0,0,1),n.alphaMode=s.Constants.ALPHA_DISABLE,n.backFaceCulling=!1,n._blueGradientTexture=new s.Texture(e.BLUE_GRADIENT_TEXTURE_URL,n.getScene(),!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n}return r(e,t),e.prototype.needAlphaBlending=function(){return!1},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new Lt);var i=e.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(e))return!0;var n=o.getEngine();if(s.MaterialHelper.PrepareDefinesForAttributes(t,i,!1,!1),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var r=new s.EffectFallbacks;i.FOG&&r.addFallback(1,"FOG"),s.MaterialHelper.HandleFallbacksForShadows(i,r),i.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var a=[s.VertexBuffer.PositionKind];i.NORMAL&&a.push(s.VertexBuffer.NormalKind),i.UV1&&a.push(s.VertexBuffer.UVKind),i.UV2&&a.push(s.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&a.push(s.VertexBuffer.ColorKind),i.TANGENT&&a.push(s.VertexBuffer.TangentKind),s.MaterialHelper.PrepareAttributesForInstances(a,i);var l=i.toString(),_=["world","viewProjection","cameraPosition","_Radius_","_Bevel_Front_","_Bevel_Front_Stretch_","_Bevel_Back_","_Bevel_Back_Stretch_","_Radius_Top_Left_","_Radius_Top_Right_","_Radius_Bottom_Left_","_Radius_Bottom_Right_","_Bulge_Enabled_","_Bulge_Height_","_Bulge_Radius_","_Sun_Intensity_","_Sun_Theta_","_Sun_Phi_","_Indirect_Diffuse_","_Albedo_","_Specular_","_Shininess_","_Sharpness_","_Subsurface_","_Left_Color_","_Right_Color_","_Reflection_","_Front_Reflect_","_Edge_Reflect_","_Power_","_Sky_Color_","_Horizon_Color_","_Ground_Color_","_Horizon_Power_","_Reflection_Map_","_Indirect_Environment_","_Width_","_Fuzz_","_Min_Fuzz_","_Clip_Fade_","_Hue_Shift_","_Saturation_Shift_","_Value_Shift_","_Blob_Position_","_Blob_Intensity_","_Blob_Near_Size_","_Blob_Far_Size_","_Blob_Near_Distance_","_Blob_Far_Distance_","_Blob_Fade_Length_","_Blob_Pulse_","_Blob_Fade_","_Blob_Texture_","_Blob_Position_2_","_Blob_Near_Size_2_","_Blob_Pulse_2_","_Blob_Fade_2_","_Left_Index_Pos_","_Right_Index_Pos_","_Left_Index_Middle_Pos_","_Right_Index_Middle_Pos_","_Decal_","_Decal_Scale_XY_","_Decal_Front_Only_","_Rim_Intensity_","_Rim_Texture_","_Rim_Hue_Shift_","_Rim_Saturation_Shift_","_Rim_Value_Shift_","_Iridescence_Intensity_","_Iridescence_Texture_","Use_Global_Left_Index","Use_Global_Right_Index","Global_Left_Index_Tip_Position","Global_Right_Index_Tip_Position","Global_Left_Thumb_Tip_Position","Global_Right_Thumb_Tip_Position","Global_Left_Index_Middle_Position;","Global_Right_Index_Middle_Position","Global_Left_Index_Tip_Proximity","Global_Right_Index_Tip_Proximity"],h=["_Rim_Texture_","_Iridescence_Texture_"],c=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:i,maxSimultaneousLights:4}),e.setEffect(o.getEngine().createEffect("mrdlSliderBar",{attributes:a,uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:l,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),i,this._materialContext)}return!(!e.effect||!e.effect.isReady()||(i._renderId=o.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){if(i.materialDefines){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._activeEffect.setVector3("cameraPosition",this.getScene().activeCamera.position),this._activeEffect.setFloat("_Radius_",this.radius),this._activeEffect.setFloat("_Bevel_Front_",this.bevelFront),this._activeEffect.setFloat("_Bevel_Front_Stretch_",this.bevelFrontStretch),this._activeEffect.setFloat("_Bevel_Back_",this.bevelBack),this._activeEffect.setFloat("_Bevel_Back_Stretch_",this.bevelBackStretch),this._activeEffect.setFloat("_Radius_Top_Left_",this.radiusTopLeft),this._activeEffect.setFloat("_Radius_Top_Right_",this.radiusTopRight),this._activeEffect.setFloat("_Radius_Bottom_Left_",this.radiusBottomLeft),this._activeEffect.setFloat("_Radius_Bottom_Right_",this.radiusBottomRight),this._activeEffect.setFloat("_Bulge_Enabled_",this.bulgeEnabled?1:0),this._activeEffect.setFloat("_Bulge_Height_",this.bulgeHeight),this._activeEffect.setFloat("_Bulge_Radius_",this.bulgeRadius),this._activeEffect.setFloat("_Sun_Intensity_",this.sunIntensity),this._activeEffect.setFloat("_Sun_Theta_",this.sunTheta),this._activeEffect.setFloat("_Sun_Phi_",this.sunPhi),this._activeEffect.setFloat("_Indirect_Diffuse_",this.indirectDiffuse),this._activeEffect.setDirectColor4("_Albedo_",this.albedo),this._activeEffect.setFloat("_Specular_",this.specular),this._activeEffect.setFloat("_Shininess_",this.shininess),this._activeEffect.setFloat("_Sharpness_",this.sharpness),this._activeEffect.setFloat("_Subsurface_",this.subsurface),this._activeEffect.setDirectColor4("_Left_Color_",this.leftGradientColor),this._activeEffect.setDirectColor4("_Right_Color_",this.rightGradientColor),this._activeEffect.setFloat("_Reflection_",this.reflection),this._activeEffect.setFloat("_Front_Reflect_",this.frontReflect),this._activeEffect.setFloat("_Edge_Reflect_",this.edgeReflect),this._activeEffect.setFloat("_Power_",this.power),this._activeEffect.setDirectColor4("_Sky_Color_",this.skyColor),this._activeEffect.setDirectColor4("_Horizon_Color_",this.horizonColor),this._activeEffect.setDirectColor4("_Ground_Color_",this.groundColor),this._activeEffect.setFloat("_Horizon_Power_",this.horizonPower),this._activeEffect.setTexture("_Reflection_Map_",new s.Texture("",this.getScene())),this._activeEffect.setTexture("_Indirect_Environment_",new s.Texture("",this.getScene())),this._activeEffect.setFloat("_Width_",this.width),this._activeEffect.setFloat("_Fuzz_",this.fuzz),this._activeEffect.setFloat("_Min_Fuzz_",this.minFuzz),this._activeEffect.setFloat("_Clip_Fade_",this.clipFade),this._activeEffect.setFloat("_Hue_Shift_",this.hueShift),this._activeEffect.setFloat("_Saturation_Shift_",this.saturationShift),this._activeEffect.setFloat("_Value_Shift_",this.valueShift),this._activeEffect.setVector3("_Blob_Position_",this.blobPosition),this._activeEffect.setFloat("_Blob_Intensity_",this.blobIntensity),this._activeEffect.setFloat("_Blob_Near_Size_",this.blobNearSize),this._activeEffect.setFloat("_Blob_Far_Size_",this.blobFarSize),this._activeEffect.setFloat("_Blob_Near_Distance_",this.blobNearDistance),this._activeEffect.setFloat("_Blob_Far_Distance_",this.blobFarDistance),this._activeEffect.setFloat("_Blob_Fade_Length_",this.blobFadeLength),this._activeEffect.setFloat("_Blob_Pulse_",this.blobPulse),this._activeEffect.setFloat("_Blob_Fade_",this.blobFade),this._activeEffect.setTexture("_Blob_Texture_",this.blobTexture),this._activeEffect.setVector3("_Blob_Position_2_",this.blobPosition2),this._activeEffect.setFloat("_Blob_Near_Size_2_",this.blobNearSize2),this._activeEffect.setFloat("_Blob_Pulse_2_",this.blobPulse2),this._activeEffect.setFloat("_Blob_Fade_2_",this.blobFade2),this._activeEffect.setVector3("_Left_Index_Pos_",this.leftIndexPosition),this._activeEffect.setVector3("_Right_Index_Pos_",this.rightIndexPosition),this._activeEffect.setVector3("_Left_Index_Middle_Pos_",this.leftIndexMiddlePosition),this._activeEffect.setVector3("_Right_Index_Middle_Pos_",this.rightIndexMiddlePosition),this._activeEffect.setTexture("_Decal_",new s.Texture("",this.getScene())),this._activeEffect.setVector2("_Decal_Scale_XY_",this.decalScaleXY),this._activeEffect.setFloat("_Decal_Front_Only_",this.decalFrontOnly?1:0),this._activeEffect.setFloat("_Rim_Intensity_",this.rimIntensity),this._activeEffect.setTexture("_Rim_Texture_",this._blueGradientTexture),this._activeEffect.setFloat("_Rim_Hue_Shift_",this.rimHueShift),this._activeEffect.setFloat("_Rim_Saturation_Shift_",this.rimSaturationShift),this._activeEffect.setFloat("_Rim_Value_Shift_",this.rimValueShift),this._activeEffect.setFloat("_Iridescence_Intensity_",this.iridescenceIntensity),this._activeEffect.setTexture("_Iridescence_Texture_",this._blueGradientTexture),this._activeEffect.setFloat("Use_Global_Left_Index",this.useGlobalLeftIndex),this._activeEffect.setFloat("Use_Global_Right_Index",this.useGlobalRightIndex),this._activeEffect.setVector4("Global_Left_Index_Tip_Position",this.globalLeftIndexTipPosition),this._activeEffect.setVector4("Global_Right_Index_Tip_Position",this.globaRightIndexTipPosition),this._activeEffect.setVector4("Global_Left_Thumb_Tip_Position",this.globalLeftThumbTipPosition),this._activeEffect.setVector4("Global_Right_Thumb_Tip_Position",this.globalRightThumbTipPosition),this._activeEffect.setVector4("Global_Left_Index_Middle_Position",this.globalLeftIndexMiddlePosition),this._activeEffect.setVector4("Global_Right_Index_Middle_Position",this.globalRightIndexMiddlePosition),this._activeEffect.setFloat("Global_Left_Index_Tip_Proximity",this.globalLeftIndexTipProximity),this._activeEffect.setFloat("Global_Right_Index_Tip_Proximity",this.globalRightIndexTipProximity),this._afterBind(e,this._activeEffect))}},e.prototype.getAnimatables=function(){return[]},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.MRDLSliderBarMaterial",e},e.prototype.getClassName=function(){return"MRDLSliderBarMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},e.BLUE_GRADIENT_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/MRDL/mrtk-mrdl-blue-gradient.png",a([(0,s.serialize)()],e.prototype,"radius",void 0),a([(0,s.serialize)()],e.prototype,"bevelFront",void 0),a([(0,s.serialize)()],e.prototype,"bevelFrontStretch",void 0),a([(0,s.serialize)()],e.prototype,"bevelBack",void 0),a([(0,s.serialize)()],e.prototype,"bevelBackStretch",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopRight",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomRight",void 0),a([(0,s.serialize)()],e.prototype,"bulgeEnabled",void 0),a([(0,s.serialize)()],e.prototype,"bulgeHeight",void 0),a([(0,s.serialize)()],e.prototype,"bulgeRadius",void 0),a([(0,s.serialize)()],e.prototype,"sunIntensity",void 0),a([(0,s.serialize)()],e.prototype,"sunTheta",void 0),a([(0,s.serialize)()],e.prototype,"sunPhi",void 0),a([(0,s.serialize)()],e.prototype,"indirectDiffuse",void 0),a([(0,s.serialize)()],e.prototype,"albedo",void 0),a([(0,s.serialize)()],e.prototype,"specular",void 0),a([(0,s.serialize)()],e.prototype,"shininess",void 0),a([(0,s.serialize)()],e.prototype,"sharpness",void 0),a([(0,s.serialize)()],e.prototype,"subsurface",void 0),a([(0,s.serialize)()],e.prototype,"leftGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"rightGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"reflection",void 0),a([(0,s.serialize)()],e.prototype,"frontReflect",void 0),a([(0,s.serialize)()],e.prototype,"edgeReflect",void 0),a([(0,s.serialize)()],e.prototype,"power",void 0),a([(0,s.serialize)()],e.prototype,"skyColor",void 0),a([(0,s.serialize)()],e.prototype,"horizonColor",void 0),a([(0,s.serialize)()],e.prototype,"groundColor",void 0),a([(0,s.serialize)()],e.prototype,"horizonPower",void 0),a([(0,s.serialize)()],e.prototype,"width",void 0),a([(0,s.serialize)()],e.prototype,"fuzz",void 0),a([(0,s.serialize)()],e.prototype,"minFuzz",void 0),a([(0,s.serialize)()],e.prototype,"clipFade",void 0),a([(0,s.serialize)()],e.prototype,"hueShift",void 0),a([(0,s.serialize)()],e.prototype,"saturationShift",void 0),a([(0,s.serialize)()],e.prototype,"valueShift",void 0),a([(0,s.serialize)()],e.prototype,"blobPosition",void 0),a([(0,s.serialize)()],e.prototype,"blobIntensity",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize",void 0),a([(0,s.serialize)()],e.prototype,"blobFarSize",void 0),a([(0,s.serialize)()],e.prototype,"blobNearDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFarDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFadeLength",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse",void 0),a([(0,s.serialize)()],e.prototype,"blobFade",void 0),a([(0,s.serialize)()],e.prototype,"blobPosition2",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize2",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse2",void 0),a([(0,s.serialize)()],e.prototype,"blobFade2",void 0),a([(0,s.serialize)()],e.prototype,"blobTexture",void 0),a([(0,s.serialize)()],e.prototype,"leftIndexPosition",void 0),a([(0,s.serialize)()],e.prototype,"rightIndexPosition",void 0),a([(0,s.serialize)()],e.prototype,"leftIndexMiddlePosition",void 0),a([(0,s.serialize)()],e.prototype,"rightIndexMiddlePosition",void 0),a([(0,s.serialize)()],e.prototype,"decalScaleXY",void 0),a([(0,s.serialize)()],e.prototype,"decalFrontOnly",void 0),a([(0,s.serialize)()],e.prototype,"rimIntensity",void 0),a([(0,s.serialize)()],e.prototype,"rimHueShift",void 0),a([(0,s.serialize)()],e.prototype,"rimSaturationShift",void 0),a([(0,s.serialize)()],e.prototype,"rimValueShift",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceIntensity",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.MRDLSliderBarMaterial",Nt);s.ShaderStore.ShadersStore.mrdlSliderThumbPixelShader="uniform vec3 cameraPosition;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nuniform float _Radius_;\nuniform float _Bevel_Front_;\nuniform float _Bevel_Front_Stretch_;\nuniform float _Bevel_Back_;\nuniform float _Bevel_Back_Stretch_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform bool _Bulge_Enabled_;\nuniform float _Bulge_Height_;\nuniform float _Bulge_Radius_;\nuniform float _Sun_Intensity_;\nuniform float _Sun_Theta_;\nuniform float _Sun_Phi_;\nuniform float _Indirect_Diffuse_;\nuniform vec4 _Albedo_;\nuniform float _Specular_;\nuniform float _Shininess_;\nuniform float _Sharpness_;\nuniform float _Subsurface_;\nuniform vec4 _Left_Color_;\nuniform vec4 _Right_Color_;\nuniform float _Reflection_;\nuniform float _Front_Reflect_;\nuniform float _Edge_Reflect_;\nuniform float _Power_;\nuniform vec4 _Sky_Color_;\nuniform vec4 _Horizon_Color_;\nuniform vec4 _Ground_Color_;\nuniform float _Horizon_Power_;\nuniform sampler2D _Reflection_Map_;\nuniform sampler2D _Indirect_Environment_;\nuniform float _Width_;\nuniform float _Fuzz_;\nuniform float _Min_Fuzz_;\nuniform float _Clip_Fade_;\nuniform float _Hue_Shift_;\nuniform float _Saturation_Shift_;\nuniform float _Value_Shift_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Left_Index_Pos_;\nuniform vec3 _Right_Index_Pos_;\nuniform vec3 _Left_Index_Middle_Pos_;\nuniform vec3 _Right_Index_Middle_Pos_;\nuniform sampler2D _Decal_;\nuniform vec2 _Decal_Scale_XY_;\nuniform bool _Decal_Front_Only_;\nuniform float _Rim_Intensity_;\nuniform sampler2D _Rim_Texture_;\nuniform float _Rim_Hue_Shift_;\nuniform float _Rim_Saturation_Shift_;\nuniform float _Rim_Value_Shift_;\nuniform float _Iridescence_Intensity_;\nuniform sampler2D _Iridescence_Texture_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform vec4 Global_Left_Index_Middle_Position;\nuniform vec4 Global_Right_Index_Middle_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvoid Blob_Fragment_B180(\nsampler2D Blob_Texture,\nvec4 Blob_Info1,\nvec4 Blob_Info2,\nout vec4 Blob_Color)\n{\nfloat k1=dot(Blob_Info1.xy,Blob_Info1.xy);\nfloat k2=dot(Blob_Info2.xy,Blob_Info2.xy);\nvec3 closer=k1<k2 ? vec3(k1,Blob_Info1.z,Blob_Info1.w) : vec3(k2,Blob_Info2.z,Blob_Info2.w);\nBlob_Color=closer.z*texture(Blob_Texture,vec2(vec2(sqrt(closer.x),closer.y).x,1.0-vec2(sqrt(closer.x),closer.y).y))*clamp(1.0-closer.x,0.0,1.0);\n}\nvoid FastLinearTosRGB_B192(\nvec4 Linear,\nout vec4 sRGB)\n{\nsRGB.rgb=sqrt(clamp(Linear.rgb,0.0,1.0));\nsRGB.a=Linear.a;\n}\nvoid Scale_RGB_B209(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=vec4(Scalar,Scalar,Scalar,1)*Color;\n}\nvoid Fragment_Main_B271(\nfloat Sun_Intensity,\nfloat Sun_Theta,\nfloat Sun_Phi,\nvec3 Normal,\nvec4 Albedo,\nfloat Fresnel_Reflect,\nfloat Shininess,\nvec3 Incident,\nvec4 Horizon_Color,\nvec4 Sky_Color,\nvec4 Ground_Color,\nfloat Indirect_Diffuse,\nfloat Specular,\nfloat Horizon_Power,\nfloat Reflection,\nvec4 Reflection_Sample,\nvec4 Indirect_Sample,\nfloat Sharpness,\nfloat SSS,\nfloat Subsurface,\nvec4 Translucence,\nvec4 Rim_Light,\nvec4 Iridescence,\nout vec4 Result)\n{\nfloat theta=Sun_Theta*2.0*3.14159;\nfloat phi=Sun_Phi*3.14159;\nvec3 lightDir= vec3(cos(phi)*cos(theta),sin(phi),cos(phi)*sin(theta));\nfloat NdotL=max(dot(lightDir,Normal),0.0);\nvec3 R=reflect(Incident,Normal);\nfloat RdotL=max(0.0,dot(R,lightDir));\nfloat specular=pow(RdotL,Shininess);\nspecular=mix(specular,smoothstep(0.495*Sharpness,1.0-0.495*Sharpness,specular),Sharpness);\nvec4 gi=mix(Ground_Color,Sky_Color,Normal.y*0.5+0.5);\nResult=((Sun_Intensity*NdotL+Indirect_Sample*Indirect_Diffuse+Translucence)*(1.0+SSS*Subsurface))*Albedo*(1.0-Fresnel_Reflect)+(Sun_Intensity*specular*Specular+Fresnel_Reflect*Reflection*Reflection_Sample)+Fresnel_Reflect*Rim_Light+Iridescence;\n}\nvoid Bulge_B229(\nbool Enabled,\nvec3 Normal,\nvec3 Tangent,\nfloat Bulge_Height,\nvec4 UV,\nfloat Bulge_Radius,\nvec3 ButtonN,\nout vec3 New_Normal)\n{\nvec2 xy=clamp(UV.xy*2.0,vec2(-1,-1),vec2(1,1));\nvec3 B=(cross(Normal,Tangent));\nfloat k=-clamp(1.0-length(xy)/Bulge_Radius,0.0,1.0)*Bulge_Height;\nk=sin(k*3.14159*0.5);\nk*=smoothstep(0.9998,0.9999,abs(dot(ButtonN,Normal)));\nNew_Normal=Normal*sqrt(1.0-k*k)+(xy.x*Tangent+xy.y*B)*k;\nNew_Normal=Enabled ? New_Normal : Normal;\n}\nvoid SSS_B227(\nvec3 ButtonN,\nvec3 Normal,\nvec3 Incident,\nout float Result)\n{\nfloat NdotI=abs(dot(Normal,Incident));\nfloat BdotI=abs(dot(ButtonN,Incident));\nResult=(abs(NdotI-BdotI)); \n}\nvoid FingerOcclusion_B217(\nfloat Width,\nfloat DistToCenter,\nfloat Fuzz,\nfloat Min_Fuzz,\nvec3 Position,\nvec3 Forward,\nvec3 Nearest,\nfloat Fade_Out,\nout float NotInShadow)\n{\nfloat d=dot((Nearest-Position),Forward);\nfloat sh=smoothstep(Width*0.5,Width*0.5+Fuzz*max(d,0.0)+Min_Fuzz,DistToCenter);\nNotInShadow=1.0-(1.0-sh)*smoothstep(-Fade_Out,0.0,d);\n}\nvoid FingerOcclusion_B218(\nfloat Width,\nfloat DistToCenter,\nfloat Fuzz,\nfloat Min_Fuzz,\nvec3 Position,\nvec3 Forward,\nvec3 Nearest,\nfloat Fade_Out,\nout float NotInShadow)\n{\nfloat d=dot((Nearest-Position),Forward);\nfloat sh=smoothstep(Width*0.5,Width*0.5+Fuzz*max(d,0.0)+Min_Fuzz,DistToCenter);\nNotInShadow=1.0-(1.0-sh)*smoothstep(-Fade_Out,0.0,d);\n}\nvoid Scale_Color_B241(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=Scalar*Color;\n}\nvoid From_HSV_B223(\nfloat Hue,\nfloat Saturation,\nfloat Value,\nfloat Alpha,\nout vec4 Color)\n{\nvec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);\nvec3 p=abs(fract(vec3(Hue,Hue,Hue)+K.xyz)*6.0-K.www);\nColor.rgb=Value*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),Saturation);\nColor.a=Alpha;\n}\nvoid Fast_Fresnel_B272(\nfloat Front_Reflect,\nfloat Edge_Reflect,\nfloat Power,\nvec3 Normal,\nvec3 Incident,\nout float Transmit,\nout float Reflect)\n{\nfloat d=max(-dot(Incident,Normal),0.0);\nReflect=Front_Reflect+(Edge_Reflect-Front_Reflect)*pow(1.0-d,Power);\nTransmit=1.0-Reflect;\n}\nvoid Mapped_Environment_B201(\nsampler2D Reflected_Environment,\nsampler2D Indirect_Environment,\nvec3 Dir,\nout vec4 Reflected_Color,\nout vec4 Indirect_Diffuse)\n{\nReflected_Color=texture(Reflected_Environment,vec2(atan(Dir.z,Dir.x)/3.14159*0.5,asin(Dir.y)/3.14159+0.5));\nIndirect_Diffuse=texture(Indirect_Environment,vec2(atan(Dir.z,Dir.x)/3.14159*0.5,asin(Dir.y)/3.14159+0.5));\n}\nvec4 SampleEnv_Bid200(vec3 D,vec4 S,vec4 H,vec4 G,float exponent)\n{\nfloat k=pow(abs(D.y),exponent);\nvec4 C;\nif (D.y>0.0) {\nC=mix(H,S,k);\n} else {\nC=mix(H,G,k); \n}\nreturn C;\n}\nvoid Sky_Environment_B200(\nvec3 Normal,\nvec3 Reflected,\nvec4 Sky_Color,\nvec4 Horizon_Color,\nvec4 Ground_Color,\nfloat Horizon_Power,\nout vec4 Reflected_Color,\nout vec4 Indirect_Color)\n{\nReflected_Color=SampleEnv_Bid200(Reflected,Sky_Color,Horizon_Color,Ground_Color,Horizon_Power);\nIndirect_Color=mix(Ground_Color,Sky_Color,Normal.y*0.5+0.5);\n}\nvoid Min_Segment_Distance_B215(\nvec3 P0,\nvec3 P1,\nvec3 Q0,\nvec3 Q1,\nout vec3 NearP,\nout vec3 NearQ,\nout float Distance)\n{\nvec3 u=P1-P0;\nvec3 v=Q1-Q0;\nvec3 w=P0-Q0;\nfloat a=dot(u,u);\nfloat b=dot(u,v);\nfloat c=dot(v,v);\nfloat d=dot(u,w);\nfloat e=dot(v,w);\nfloat D=a*c-b*b;\nfloat sD=D;\nfloat tD=D;\nfloat sc,sN,tc,tN;\nif (D<0.00001) {\nsN=0.0;\nsD=1.0;\ntN=e;\ntD=c;\n} else {\nsN=(b*e-c*d);\ntN=(a*e-b*d);\nif (sN<0.0) {\nsN=0.0;\ntN=e;\ntD=c;\n} else if (sN>sD) {\nsN=sD;\ntN=e+b;\ntD=c;\n}\n}\nif (tN<0.0) {\ntN=0.0;\nif (-d<0.0) {\nsN=0.0;\n} else if (-d>a) {\nsN=sD;\n} else {\nsN=-d;\nsD=a;\n}\n} else if (tN>tD) {\ntN=tD;\nif ((-d+b)<0.0) {\nsN=0.0;\n} else if ((-d+b)>a) {\nsN=sD;\n} else {\nsN=(-d+b);\nsD=a;\n}\n}\nsc=abs(sN)<0.000001 ? 0.0 : sN/sD;\ntc=abs(tN)<0.000001 ? 0.0 : tN/tD;\nNearP=P0+sc*u;\nNearQ=Q0+tc*v;\nDistance=distance(NearP,NearQ);\n}\nvoid To_XYZ_B224(\nvec3 Vec3,\nout float X,\nout float Y,\nout float Z)\n{\nX=Vec3.x;\nY=Vec3.y;\nZ=Vec3.z;\n}\nvoid Finger_Positions_B214(\nvec3 Left_Index_Pos,\nvec3 Right_Index_Pos,\nvec3 Left_Index_Middle_Pos,\nvec3 Right_Index_Middle_Pos,\nout vec3 Left_Index,\nout vec3 Right_Index,\nout vec3 Left_Index_Middle,\nout vec3 Right_Index_Middle)\n{\nLeft_Index= (Use_Global_Left_Index ? Global_Left_Index_Tip_Position.xyz : Left_Index_Pos);\nRight_Index= (Use_Global_Right_Index ? Global_Right_Index_Tip_Position.xyz : Right_Index_Pos);\nLeft_Index_Middle= (Use_Global_Left_Index ? Global_Left_Index_Middle_Position.xyz : Left_Index_Middle_Pos);\nRight_Index_Middle= (Use_Global_Right_Index ? Global_Right_Index_Middle_Position.xyz : Right_Index_Middle_Pos);\n}\nvoid VaryHSV_B258(\nvec3 HSV_In,\nfloat Hue_Shift,\nfloat Saturation_Shift,\nfloat Value_Shift,\nout vec3 HSV_Out)\n{\nHSV_Out=vec3(fract(HSV_In.x+Hue_Shift),clamp(HSV_In.y+Saturation_Shift,0.0,1.0),clamp(HSV_In.z+Value_Shift,0.0,1.0));\n}\nvoid Remap_Range_B264(\nfloat In_Min,\nfloat In_Max,\nfloat Out_Min,\nfloat Out_Max,\nfloat In,\nout float Out)\n{\nOut=mix(Out_Min,Out_Max,clamp((In-In_Min)/(In_Max-In_Min),0.0,1.0));\n}\nvoid To_HSV_B225(\nvec4 Color,\nout float Hue,\nout float Saturation,\nout float Value,\nout float Alpha,\nout vec3 HSV)\n{\nvec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);\nvec4 p=Color.g<Color.b ? vec4(Color.bg,K.wz) : vec4(Color.gb,K.xy);\nvec4 q=Color.r<p.x ? vec4(p.xyw,Color.r) : vec4(Color.r,p.yzx);\nfloat d=q.x-min(q.w,q.y);\nfloat e=1.0e-10;\nHue=abs(q.z+(q.w-q.y)/(6.0*d+e));\nSaturation=d/(q.x+e);\nValue=q.x;\nAlpha=Color.a;\nHSV=vec3(Hue,Saturation,Value);\n}\nvoid Code_B260(\nfloat X,\nout float Result)\n{\nResult=(acos(X)/3.14159-0.5)*2.0;\n}\nvoid Rim_Light_B282(\nvec3 Front,\nvec3 Normal,\nvec3 Incident,\nfloat Rim_Intensity,\nsampler2D Texture,\nout vec4 Result)\n{\nvec3 R=reflect(Incident,Normal);\nfloat RdotF=dot(R,Front);\nfloat RdotL=sqrt(1.0-RdotF*RdotF);\nvec2 UV=vec2(R.y*0.5+0.5,0.5);\nvec4 Color=texture(Texture,UV);\nResult=Color;\n}\nvoid main()\n{\nvec4 Blob_Color_Q180;\n#if BLOB_ENABLE\nBlob_Fragment_B180(_Blob_Texture_,vExtra2,vExtra3,Blob_Color_Q180);\n#else\nBlob_Color_Q180=vec4(0,0,0,0);\n#endif\nvec3 Incident_Q189=normalize(vPosition-cameraPosition);\nvec3 Normalized_Q188=normalize(vNormal);\nvec3 Normalized_Q221=normalize(vTangent);\nvec4 Color_Q233;\n#if DECAL_ENABLE\nColor_Q233=texture(_Decal_,vUV);\n#else\nColor_Q233=vec4(0,0,0,0);\n#endif\nfloat X_Q240;\nfloat Y_Q240;\nfloat Z_Q240;\nfloat W_Q240;\nX_Q240=vExtra1.x;\nY_Q240=vExtra1.y;\nZ_Q240=vExtra1.z;\nW_Q240=vExtra1.w;\nvec4 Linear_Q193;\nLinear_Q193.rgb=clamp(_Sky_Color_.rgb*_Sky_Color_.rgb,0.0,1.0);\nLinear_Q193.a=_Sky_Color_.a;\nvec4 Linear_Q194;\nLinear_Q194.rgb=clamp(_Horizon_Color_.rgb*_Horizon_Color_.rgb,0.0,1.0);\nLinear_Q194.a=_Horizon_Color_.a;\nvec4 Linear_Q195;\nLinear_Q195.rgb=clamp(_Ground_Color_.rgb*_Ground_Color_.rgb,0.0,1.0);\nLinear_Q195.a=_Ground_Color_.a;\nvec3 Left_Index_Q214;\nvec3 Right_Index_Q214;\nvec3 Left_Index_Middle_Q214;\nvec3 Right_Index_Middle_Q214;\nFinger_Positions_B214(_Left_Index_Pos_,_Right_Index_Pos_,_Left_Index_Middle_Pos_,_Right_Index_Middle_Pos_,Left_Index_Q214,Right_Index_Q214,Left_Index_Middle_Q214,Right_Index_Middle_Q214);\nvec4 Linear_Q196;\nLinear_Q196.rgb=clamp(_Albedo_.rgb*_Albedo_.rgb,0.0,1.0);\nLinear_Q196.a=_Albedo_.a;\nvec3 Normalized_Q257=normalize(vBinormal);\nvec3 Incident_Q220=normalize(vPosition-cameraPosition);\nvec3 New_Normal_Q229;\nBulge_B229(_Bulge_Enabled_,Normalized_Q188,Normalized_Q221,_Bulge_Height_,vColor,_Bulge_Radius_,vBinormal,New_Normal_Q229);\nfloat Result_Q227;\nSSS_B227(vBinormal,New_Normal_Q229,Incident_Q189,Result_Q227);\nvec4 Result_Q241;\nScale_Color_B241(Color_Q233,X_Q240,Result_Q241);\nfloat Transmit_Q272;\nfloat Reflect_Q272;\nFast_Fresnel_B272(_Front_Reflect_,_Edge_Reflect_,_Power_,New_Normal_Q229,Incident_Q189,Transmit_Q272,Reflect_Q272);\nfloat Product_Q275=Y_Q240*Y_Q240;\nvec3 NearP_Q215;\nvec3 NearQ_Q215;\nfloat Distance_Q215;\nMin_Segment_Distance_B215(Left_Index_Q214,Left_Index_Middle_Q214,vPosition,cameraPosition,NearP_Q215,NearQ_Q215,Distance_Q215);\nvec3 NearP_Q213;\nvec3 NearQ_Q213;\nfloat Distance_Q213;\nMin_Segment_Distance_B215(Right_Index_Q214,Right_Index_Middle_Q214,vPosition,cameraPosition,NearP_Q213,NearQ_Q213,Distance_Q213);\nvec3 Reflected_Q197=reflect(Incident_Q189,New_Normal_Q229);\nvec4 Product_Q253=Linear_Q196*vec4(1,1,1,1);\nvec4 Result_Q282;\nRim_Light_B282(Normalized_Q257,Normalized_Q188,Incident_Q220,_Rim_Intensity_,_Rim_Texture_,Result_Q282);\nfloat Dot_Q222=dot(Incident_Q220, Normalized_Q221);\nfloat MaxAB_Q273=max(Reflect_Q272,Product_Q275);\nfloat NotInShadow_Q217;\n#if OCCLUSION_ENABLED\nFingerOcclusion_B217(_Width_,Distance_Q215,_Fuzz_,_Min_Fuzz_,vPosition,vBinormal,NearP_Q215,_Clip_Fade_,NotInShadow_Q217);\n#else\nNotInShadow_Q217=1.0;\n#endif\nfloat NotInShadow_Q218;\n#if OCCLUSION_ENABLED\nFingerOcclusion_B218(_Width_,Distance_Q213,_Fuzz_,_Min_Fuzz_,vPosition,vBinormal,NearP_Q213,_Clip_Fade_,NotInShadow_Q218);\n#else\nNotInShadow_Q218=1.0;\n#endif\nvec4 Reflected_Color_Q201;\nvec4 Indirect_Diffuse_Q201;\n#if ENV_ENABLE\nMapped_Environment_B201(_Reflection_Map_,_Indirect_Environment_,Reflected_Q197,Reflected_Color_Q201,Indirect_Diffuse_Q201);\n#else\nReflected_Color_Q201=vec4(0,0,0,1);\nIndirect_Diffuse_Q201=vec4(0,0,0,1);\n#endif\nvec4 Reflected_Color_Q200;\nvec4 Indirect_Color_Q200;\n#if SKY_ENABLED\nSky_Environment_B200(New_Normal_Q229,Reflected_Q197,Linear_Q193,Linear_Q194,Linear_Q195,_Horizon_Power_,Reflected_Color_Q200,Indirect_Color_Q200);\n#else\nReflected_Color_Q200=vec4(0,0,0,1);\nIndirect_Color_Q200=vec4(0,0,0,1);\n#endif\nfloat Hue_Q225;\nfloat Saturation_Q225;\nfloat Value_Q225;\nfloat Alpha_Q225;\nvec3 HSV_Q225;\nTo_HSV_B225(Product_Q253,Hue_Q225,Saturation_Q225,Value_Q225,Alpha_Q225,HSV_Q225);\nfloat Hue_Q277;\nfloat Saturation_Q277;\nfloat Value_Q277;\nfloat Alpha_Q277;\nvec3 HSV_Q277;\nTo_HSV_B225(Result_Q282,Hue_Q277,Saturation_Q277,Value_Q277,Alpha_Q277,HSV_Q277);\nfloat Result_Q260;\nCode_B260(Dot_Q222,Result_Q260);\nfloat AbsA_Q226=abs(Result_Q260);\nfloat MinAB_Q208=min(NotInShadow_Q217,NotInShadow_Q218);\nvec4 Sum_Q198=Reflected_Color_Q201+Reflected_Color_Q200;\nvec4 Sum_Q199=Indirect_Diffuse_Q201+Indirect_Color_Q200;\nvec3 HSV_Out_Q276;\nVaryHSV_B258(HSV_Q277,_Rim_Hue_Shift_,_Rim_Saturation_Shift_,_Rim_Value_Shift_,HSV_Out_Q276);\nfloat Out_Q264;\nRemap_Range_B264(-1.0,1.0,0.0,1.0,Result_Q260,Out_Q264);\nfloat Product_Q256;\nProduct_Q256=AbsA_Q226*_Hue_Shift_;\nfloat X_Q278;\nfloat Y_Q278;\nfloat Z_Q278;\nTo_XYZ_B224(HSV_Out_Q276,X_Q278,Y_Q278,Z_Q278);\nvec2 Vec2_Q262=vec2(Out_Q264,0.5);\nvec3 HSV_Out_Q258;\nVaryHSV_B258(HSV_Q225,Product_Q256,_Saturation_Shift_,_Value_Shift_,HSV_Out_Q258);\nvec4 Color_Q279;\nFrom_HSV_B223(X_Q278,Y_Q278,Z_Q278,0.0,Color_Q279);\nvec4 Color_Q261;\n#if IRIDESCENCE_ENABLED\nColor_Q261=texture(_Iridescence_Texture_,Vec2_Q262);\n#else\nColor_Q261=vec4(0,0,0,0);\n#endif\nfloat X_Q224;\nfloat Y_Q224;\nfloat Z_Q224;\nTo_XYZ_B224(HSV_Out_Q258,X_Q224,Y_Q224,Z_Q224);\nvec4 Result_Q281=_Rim_Intensity_*Color_Q279;\nvec4 Result_Q263=_Iridescence_Intensity_*Color_Q261;\nvec4 Color_Q223;\nFrom_HSV_B223(X_Q224,Y_Q224,Z_Q224,0.0,Color_Q223);\nvec4 Result_Q234=Result_Q241+(1.0-Result_Q241.a)*Color_Q223;\nvec4 Result_Q271;\nFragment_Main_B271(_Sun_Intensity_,_Sun_Theta_,_Sun_Phi_,New_Normal_Q229,Result_Q234,MaxAB_Q273,_Shininess_,Incident_Q189,_Horizon_Color_,_Sky_Color_,_Ground_Color_,_Indirect_Diffuse_,_Specular_,_Horizon_Power_,_Reflection_,Sum_Q198,Sum_Q199,_Sharpness_,Result_Q227,_Subsurface_,vec4(0,0,0,0),Result_Q281,Result_Q263,Result_Q271);\nvec4 Result_Q209;\nScale_RGB_B209(Result_Q271,MinAB_Q208,Result_Q209);\nvec4 sRGB_Q192;\nFastLinearTosRGB_B192(Result_Q209,sRGB_Q192);\nvec4 Result_Q181=Blob_Color_Q180+(1.0-Blob_Color_Q180.a)*sRGB_Q192;\nvec4 Result_Q190=Result_Q181; Result_Q190.a=1.0;\nvec4 Out_Color=Result_Q190;\nfloat Clip_Threshold=0.001;\nbool To_sRGB=false;\ngl_FragColor=Out_Color;\n}";s.ShaderStore.ShadersStore.mrdlSliderThumbVertexShader="uniform mat4 world;\nuniform mat4 viewProjection;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n#ifdef TANGENT\nattribute vec3 tangent;\n#else\nconst vec3 tangent=vec3(0.);\n#endif\nuniform float _Radius_;\nuniform float _Bevel_Front_;\nuniform float _Bevel_Front_Stretch_;\nuniform float _Bevel_Back_;\nuniform float _Bevel_Back_Stretch_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform bool _Bulge_Enabled_;\nuniform float _Bulge_Height_;\nuniform float _Bulge_Radius_;\nuniform float _Sun_Intensity_;\nuniform float _Sun_Theta_;\nuniform float _Sun_Phi_;\nuniform float _Indirect_Diffuse_;\nuniform vec4 _Albedo_;\nuniform float _Specular_;\nuniform float _Shininess_;\nuniform float _Sharpness_;\nuniform float _Subsurface_;\nuniform vec4 _Left_Color_;\nuniform vec4 _Right_Color_;\nuniform float _Reflection_;\nuniform float _Front_Reflect_;\nuniform float _Edge_Reflect_;\nuniform float _Power_;\nuniform vec4 _Sky_Color_;\nuniform vec4 _Horizon_Color_;\nuniform vec4 _Ground_Color_;\nuniform float _Horizon_Power_;\nuniform sampler2D _Reflection_Map_;\nuniform sampler2D _Indirect_Environment_;\nuniform float _Width_;\nuniform float _Fuzz_;\nuniform float _Min_Fuzz_;\nuniform float _Clip_Fade_;\nuniform float _Hue_Shift_;\nuniform float _Saturation_Shift_;\nuniform float _Value_Shift_;\nuniform vec3 _Blob_Position_;\nuniform float _Blob_Intensity_;\nuniform float _Blob_Near_Size_;\nuniform float _Blob_Far_Size_;\nuniform float _Blob_Near_Distance_;\nuniform float _Blob_Far_Distance_;\nuniform float _Blob_Fade_Length_;\nuniform float _Blob_Pulse_;\nuniform float _Blob_Fade_;\nuniform sampler2D _Blob_Texture_;\nuniform vec3 _Blob_Position_2_;\nuniform float _Blob_Near_Size_2_;\nuniform float _Blob_Pulse_2_;\nuniform float _Blob_Fade_2_;\nuniform vec3 _Left_Index_Pos_;\nuniform vec3 _Right_Index_Pos_;\nuniform vec3 _Left_Index_Middle_Pos_;\nuniform vec3 _Right_Index_Middle_Pos_;\nuniform sampler2D _Decal_;\nuniform vec2 _Decal_Scale_XY_;\nuniform bool _Decal_Front_Only_;\nuniform float _Rim_Intensity_;\nuniform sampler2D _Rim_Texture_;\nuniform float _Rim_Hue_Shift_;\nuniform float _Rim_Saturation_Shift_;\nuniform float _Rim_Value_Shift_;\nuniform float _Iridescence_Intensity_;\nuniform sampler2D _Iridescence_Texture_;\nuniform bool Use_Global_Left_Index;\nuniform bool Use_Global_Right_Index;\nuniform vec4 Global_Left_Index_Tip_Position;\nuniform vec4 Global_Right_Index_Tip_Position;\nuniform vec4 Global_Left_Thumb_Tip_Position;\nuniform vec4 Global_Right_Thumb_Tip_Position;\nuniform float Global_Left_Index_Tip_Proximity;\nuniform float Global_Right_Index_Tip_Proximity;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vColor;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvarying vec4 vExtra3;\nvoid Object_To_World_Pos_B162(\nvec3 Pos_Object,\nout vec3 Pos_World)\n{\nPos_World=(world*vec4(Pos_Object,1.0)).xyz;\n}\nvoid Object_To_World_Normal_B182(\nvec3 Nrm_Object,\nout vec3 Nrm_World)\n{\nNrm_World=(vec4(Nrm_Object,0.0)).xyz;\n}\nvoid Blob_Vertex_B173(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nfloat Blob_Fade_Length,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nout vec4 Blob_Info)\n{\nvec3 blob= (Use_Global_Left_Index ? Global_Left_Index_Tip_Position.xyz : Blob_Position);\nvec3 delta=blob-Position;\nfloat dist=dot(Normal,delta);\nfloat lerpValue=clamp((abs(dist)-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfloat fadeValue=1.0-clamp((abs(dist)-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat size=Blob_Near_Size+(Blob_Far_Size-Blob_Near_Size)*lerpValue;\nvec2 blobXY=vec2(dot(delta,Tangent),dot(delta,Bitangent))/(0.0001+size);\nfloat Fade=fadeValue*Intensity*Blob_Fade;\nfloat Distance=(lerpValue*0.5+0.5)*(1.0-Blob_Pulse);\nBlob_Info=vec4(blobXY.x,blobXY.y,Distance,Fade);\n}\nvoid Blob_Vertex_B174(\nvec3 Position,\nvec3 Normal,\nvec3 Tangent,\nvec3 Bitangent,\nvec3 Blob_Position,\nfloat Intensity,\nfloat Blob_Near_Size,\nfloat Blob_Far_Size,\nfloat Blob_Near_Distance,\nfloat Blob_Far_Distance,\nfloat Blob_Fade_Length,\nfloat Blob_Pulse,\nfloat Blob_Fade,\nout vec4 Blob_Info)\n{\nvec3 blob= (Use_Global_Right_Index ? Global_Right_Index_Tip_Position.xyz : Blob_Position);\nvec3 delta=blob-Position;\nfloat dist=dot(Normal,delta);\nfloat lerpValue=clamp((abs(dist)-Blob_Near_Distance)/(Blob_Far_Distance-Blob_Near_Distance),0.0,1.0);\nfloat fadeValue=1.0-clamp((abs(dist)-Blob_Far_Distance)/Blob_Fade_Length,0.0,1.0);\nfloat size=Blob_Near_Size+(Blob_Far_Size-Blob_Near_Size)*lerpValue;\nvec2 blobXY=vec2(dot(delta,Tangent),dot(delta,Bitangent))/(0.0001+size);\nfloat Fade=fadeValue*Intensity*Blob_Fade;\nfloat Distance=(lerpValue*0.5+0.5)*(1.0-Blob_Pulse);\nBlob_Info=vec4(blobXY.x,blobXY.y,Distance,Fade);\n}\nvoid Move_Verts_B280(\nfloat Anisotropy,\nvec3 P,\nfloat Radius,\nfloat Bevel,\nvec3 Normal_Object,\nfloat ScaleZ,\nfloat Stretch,\nout vec3 New_P,\nout vec2 New_UV,\nout float Radial_Gradient,\nout vec3 Radial_Dir,\nout vec3 New_Normal)\n{\nvec2 UV=P.xy*2.0+0.5;\nvec2 center=clamp(UV,0.0,1.0);\nvec2 delta=UV-center;\nfloat deltad=(length(delta)*2.0);\nfloat f=(Bevel+(Radius-Bevel)*Stretch)/Radius;\nfloat innerd=clamp(deltad*2.0,0.0,1.0);\nfloat outerd=clamp(deltad*2.0-1.0,0.0,1.0);\nfloat bevelAngle=outerd*3.14159*0.5;\nfloat sinb=sin(bevelAngle);\nfloat cosb=cos(bevelAngle);\nfloat beveld=(1.0-f)*innerd+f*sinb;\nfloat br=outerd;\nvec2 r2=2.0*vec2(Radius/Anisotropy,Radius);\nfloat dir=P.z<0.0001 ? 1.0 : -1.0;\nNew_UV=center+r2*((0.5-center)+normalize(delta+vec2(0.0,0.000001))*beveld*0.5);\nNew_P=vec3(New_UV-0.5,P.z+dir*(1.0-cosb)*Bevel*ScaleZ);\nRadial_Gradient=clamp((deltad-0.5)*2.0,0.0,1.0);\nRadial_Dir=vec3(delta*r2,0.0);\nvec3 beveledNormal=cosb*Normal_Object+sinb*vec3(delta.x,delta.y,0.0);\nNew_Normal=Normal_Object.z==0.0 ? Normal_Object : beveledNormal;\n}\nvoid Object_To_World_Dir_B210(\nvec3 Dir_Object,\nout vec3 Normal_World,\nout vec3 Normal_World_N,\nout float Normal_Length)\n{\nNormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nNormal_Length=length(Normal_World);\nNormal_World_N=Normal_World/Normal_Length;\n}\nvoid To_XYZ_B228(\nvec3 Vec3,\nout float X,\nout float Y,\nout float Z)\n{\nX=Vec3.x;\nY=Vec3.y;\nZ=Vec3.z;\n}\nvoid Conditional_Float_B243(\nbool Which,\nfloat If_True,\nfloat If_False,\nout float Result)\n{\nResult=Which ? If_True : If_False;\n}\nvoid Object_To_World_Dir_B178(\nvec3 Dir_Object,\nout vec3 Binormal_World,\nout vec3 Binormal_World_N,\nout float Binormal_Length)\n{\nBinormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nBinormal_Length=length(Binormal_World);\nBinormal_World_N=Binormal_World/Binormal_Length;\n}\nvoid Pick_Radius_B219(\nfloat Radius,\nfloat Radius_Top_Left,\nfloat Radius_Top_Right,\nfloat Radius_Bottom_Left,\nfloat Radius_Bottom_Right,\nvec3 Position,\nout float Result)\n{\nbool whichY=Position.y>0.0;\nResult=Position.x<0.0 ? (whichY ? Radius_Top_Left : Radius_Bottom_Left) : (whichY ? Radius_Top_Right : Radius_Bottom_Right);\nResult*=Radius;\n}\nvoid Conditional_Float_B186(\nbool Which,\nfloat If_True,\nfloat If_False,\nout float Result)\n{\nResult=Which ? If_True : If_False;\n}\nvoid Greater_Than_B187(\nfloat Left,\nfloat Right,\nout bool Not_Greater_Than,\nout bool Greater_Than)\n{\nGreater_Than=Left>Right;\nNot_Greater_Than=!Greater_Than;\n}\nvoid Remap_Range_B255(\nfloat In_Min,\nfloat In_Max,\nfloat Out_Min,\nfloat Out_Max,\nfloat In,\nout float Out)\n{\nOut=mix(Out_Min,Out_Max,clamp((In-In_Min)/(In_Max-In_Min),0.0,1.0));\n}\nvoid main()\n{\nvec2 XY_Q235;\nXY_Q235=(uv-vec2(0.5,0.5))*_Decal_Scale_XY_+vec2(0.5,0.5);\nvec3 Tangent_World_Q177;\nvec3 Tangent_World_N_Q177;\nfloat Tangent_Length_Q177;\nTangent_World_Q177=(world*vec4(vec3(1,0,0),0.0)).xyz;\nTangent_Length_Q177=length(Tangent_World_Q177);\nTangent_World_N_Q177=Tangent_World_Q177/Tangent_Length_Q177;\nvec3 Normal_World_Q210;\nvec3 Normal_World_N_Q210;\nfloat Normal_Length_Q210;\nObject_To_World_Dir_B210(vec3(0,0,1),Normal_World_Q210,Normal_World_N_Q210,Normal_Length_Q210);\nfloat X_Q228;\nfloat Y_Q228;\nfloat Z_Q228;\nTo_XYZ_B228(position,X_Q228,Y_Q228,Z_Q228);\nvec3 Nrm_World_Q176;\nNrm_World_Q176=normalize((world*vec4(normal,0.0)).xyz);\nvec3 Binormal_World_Q178;\nvec3 Binormal_World_N_Q178;\nfloat Binormal_Length_Q178;\nObject_To_World_Dir_B178(vec3(0,1,0),Binormal_World_Q178,Binormal_World_N_Q178,Binormal_Length_Q178);\nfloat Anisotropy_Q179=Tangent_Length_Q177/Binormal_Length_Q178;\nfloat Result_Q219;\nPick_Radius_B219(_Radius_,_Radius_Top_Left_,_Radius_Top_Right_,_Radius_Bottom_Left_,_Radius_Bottom_Right_,position,Result_Q219);\nfloat Anisotropy_Q203=Binormal_Length_Q178/Normal_Length_Q210;\nbool Not_Greater_Than_Q187;\nbool Greater_Than_Q187;\nGreater_Than_B187(Z_Q228,0.0,Not_Greater_Than_Q187,Greater_Than_Q187);\nvec4 Linear_Q251;\nLinear_Q251.rgb=clamp(_Left_Color_.rgb*_Left_Color_.rgb,0.0,1.0);\nLinear_Q251.a=_Left_Color_.a;\nvec4 Linear_Q252;\nLinear_Q252.rgb=clamp(_Right_Color_.rgb*_Right_Color_.rgb,0.0,1.0);\nLinear_Q252.a=_Right_Color_.a;\nvec3 Difference_Q211=vec3(0,0,0)-Normal_World_N_Q210;\nvec4 Out_Color_Q184=vec4(X_Q228,Y_Q228,Z_Q228,1);\nfloat Result_Q186;\nConditional_Float_B186(Greater_Than_Q187,_Bevel_Back_,_Bevel_Front_,Result_Q186);\nfloat Result_Q244;\nConditional_Float_B186(Greater_Than_Q187,_Bevel_Back_Stretch_,_Bevel_Front_Stretch_,Result_Q244);\nvec3 New_P_Q280;\nvec2 New_UV_Q280;\nfloat Radial_Gradient_Q280;\nvec3 Radial_Dir_Q280;\nvec3 New_Normal_Q280;\nMove_Verts_B280(Anisotropy_Q179,position,Result_Q219,Result_Q186,normal,Anisotropy_Q203,Result_Q244,New_P_Q280,New_UV_Q280,Radial_Gradient_Q280,Radial_Dir_Q280,New_Normal_Q280);\nfloat X_Q248;\nfloat Y_Q248;\nX_Q248=New_UV_Q280.x;\nY_Q248=New_UV_Q280.y;\nvec3 Pos_World_Q162;\nObject_To_World_Pos_B162(New_P_Q280,Pos_World_Q162);\nvec3 Nrm_World_Q182;\nObject_To_World_Normal_B182(New_Normal_Q280,Nrm_World_Q182);\nvec4 Blob_Info_Q173;\n#if BLOB_ENABLE\nBlob_Vertex_B173(Pos_World_Q162,Nrm_World_Q176,Tangent_World_N_Q177,Binormal_World_N_Q178,_Blob_Position_,_Blob_Intensity_,_Blob_Near_Size_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_,_Blob_Fade_,Blob_Info_Q173);\n#else\nBlob_Info_Q173=vec4(0,0,0,0);\n#endif\nvec4 Blob_Info_Q174;\n#if BLOB_ENABLE_2\nBlob_Vertex_B174(Pos_World_Q162,Nrm_World_Q176,Tangent_World_N_Q177,Binormal_World_N_Q178,_Blob_Position_2_,_Blob_Intensity_,_Blob_Near_Size_2_,_Blob_Far_Size_,_Blob_Near_Distance_,_Blob_Far_Distance_,_Blob_Fade_Length_,_Blob_Pulse_2_,_Blob_Fade_2_,Blob_Info_Q174);\n#else\nBlob_Info_Q174=vec4(0,0,0,0);\n#endif\nfloat Out_Q255;\nRemap_Range_B255(0.0,1.0,0.0,1.0,X_Q248,Out_Q255);\nfloat X_Q236;\nfloat Y_Q236;\nfloat Z_Q236;\nTo_XYZ_B228(Nrm_World_Q182,X_Q236,Y_Q236,Z_Q236);\nvec4 Color_At_T_Q247=mix(Linear_Q251,Linear_Q252,Out_Q255);\nfloat Minus_F_Q237=-Z_Q236;\nfloat R_Q249;\nfloat G_Q249;\nfloat B_Q249;\nfloat A_Q249;\nR_Q249=Color_At_T_Q247.r; G_Q249=Color_At_T_Q247.g; B_Q249=Color_At_T_Q247.b; A_Q249=Color_At_T_Q247.a;\nfloat ClampF_Q238=clamp(0.0,Minus_F_Q237,1.0);\nfloat Result_Q243;\nConditional_Float_B243(_Decal_Front_Only_,ClampF_Q238,1.0,Result_Q243);\nvec4 Vec4_Q239=vec4(Result_Q243,Radial_Gradient_Q280,G_Q249,B_Q249);\nvec3 Position=Pos_World_Q162;\nvec3 Normal=Nrm_World_Q182;\nvec2 UV=XY_Q235;\nvec3 Tangent=Tangent_World_N_Q177;\nvec3 Binormal=Difference_Q211;\nvec4 Color=Out_Color_Q184;\nvec4 Extra1=Vec4_Q239;\nvec4 Extra2=Blob_Info_Q173;\nvec4 Extra3=Blob_Info_Q174;\ngl_Position=viewProjection*vec4(Position,1);\nvPosition=Position;\nvNormal=Normal;\nvUV=UV;\nvTangent=Tangent;\nvBinormal=Binormal;\nvColor=Color;\nvExtra1=Extra1;\nvExtra2=Extra2;\nvExtra3=Extra3;\n}";var kt=function(t){function e(){var e=t.call(this)||this;return e.SKY_ENABLED=!0,e.BLOB_ENABLE_2=!0,e.IRIDESCENCE_ENABLED=!0,e._needNormals=!0,e._needUVs=!0,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),At=function(t){function e(i,o){var n=t.call(this,i,o)||this;return n.radius=.157,n.bevelFront=.065,n.bevelFrontStretch=.077,n.bevelBack=.031,n.bevelBackStretch=0,n.radiusTopLeft=1,n.radiusTopRight=1,n.radiusBottomLeft=1,n.radiusBottomRight=1,n.bulgeEnabled=!1,n.bulgeHeight=-.323,n.bulgeRadius=.73,n.sunIntensity=2,n.sunTheta=.937,n.sunPhi=.555,n.indirectDiffuse=1,n.albedo=new s.Color4(.0117647,.505882,.996078,1),n.specular=0,n.shininess=10,n.sharpness=0,n.subsurface=.31,n.leftGradientColor=new s.Color4(.0117647,.505882,.996078,1),n.rightGradientColor=new s.Color4(.0117647,.505882,.996078,1),n.reflection=.749,n.frontReflect=0,n.edgeReflect=.09,n.power=8.1,n.skyColor=new s.Color4(.0117647,.960784,.996078,1),n.horizonColor=new s.Color4(.0117647,.333333,.996078,1),n.groundColor=new s.Color4(0,.254902,.996078,1),n.horizonPower=1,n.width=.02,n.fuzz=.5,n.minFuzz=.001,n.clipFade=.01,n.hueShift=0,n.saturationShift=0,n.valueShift=0,n.blobPosition=new s.Vector3(0,0,.1),n.blobIntensity=.5,n.blobNearSize=.01,n.blobFarSize=.03,n.blobNearDistance=0,n.blobFarDistance=.08,n.blobFadeLength=.576,n.blobPulse=0,n.blobFade=1,n.blobPosition2=new s.Vector3(.2,0,.1),n.blobNearSize2=.01,n.blobPulse2=0,n.blobFade2=1,n.blobTexture=new s.Texture("",n.getScene()),n.leftIndexPosition=new s.Vector3(0,0,1),n.rightIndexPosition=new s.Vector3(-1,-1,-1),n.leftIndexMiddlePosition=new s.Vector3(0,0,0),n.rightIndexMiddlePosition=new s.Vector3(0,0,0),n.decalScaleXY=new s.Vector2(1.5,1.5),n.decalFrontOnly=!0,n.rimIntensity=.287,n.rimHueShift=0,n.rimSaturationShift=0,n.rimValueShift=-1,n.iridescenceIntensity=0,n.useGlobalLeftIndex=1,n.useGlobalRightIndex=1,n.globalLeftIndexTipProximity=0,n.globalRightIndexTipProximity=0,n.globalLeftIndexTipPosition=new s.Vector4(.5,0,-.55,1),n.globaRightIndexTipPosition=new s.Vector4(0,0,0,1),n.globalLeftThumbTipPosition=new s.Vector4(.5,0,-.55,1),n.globalRightThumbTipPosition=new s.Vector4(0,0,0,1),n.globalLeftIndexMiddlePosition=new s.Vector4(.5,0,-.55,1),n.globalRightIndexMiddlePosition=new s.Vector4(0,0,0,1),n.alphaMode=s.Constants.ALPHA_DISABLE,n.backFaceCulling=!1,n._blueGradientTexture=new s.Texture(e.BLUE_GRADIENT_TEXTURE_URL,o,!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n}return r(e,t),e.prototype.needAlphaBlending=function(){return!1},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new kt);var i=e.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(e))return!0;var n=o.getEngine();if(s.MaterialHelper.PrepareDefinesForAttributes(t,i,!1,!1),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var r=new s.EffectFallbacks;i.FOG&&r.addFallback(1,"FOG"),s.MaterialHelper.HandleFallbacksForShadows(i,r),i.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var a=[s.VertexBuffer.PositionKind];i.NORMAL&&a.push(s.VertexBuffer.NormalKind),i.UV1&&a.push(s.VertexBuffer.UVKind),i.UV2&&a.push(s.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&a.push(s.VertexBuffer.ColorKind),i.TANGENT&&a.push(s.VertexBuffer.TangentKind),s.MaterialHelper.PrepareAttributesForInstances(a,i);var l=i.toString(),_=["world","viewProjection","cameraPosition","_Radius_","_Bevel_Front_","_Bevel_Front_Stretch_","_Bevel_Back_","_Bevel_Back_Stretch_","_Radius_Top_Left_","_Radius_Top_Right_","_Radius_Bottom_Left_","_Radius_Bottom_Right_","_Bulge_Enabled_","_Bulge_Height_","_Bulge_Radius_","_Sun_Intensity_","_Sun_Theta_","_Sun_Phi_","_Indirect_Diffuse_","_Albedo_","_Specular_","_Shininess_","_Sharpness_","_Subsurface_","_Left_Color_","_Right_Color_","_Reflection_","_Front_Reflect_","_Edge_Reflect_","_Power_","_Sky_Color_","_Horizon_Color_","_Ground_Color_","_Horizon_Power_","_Reflection_Map_","_Indirect_Environment_","_Width_","_Fuzz_","_Min_Fuzz_","_Clip_Fade_","_Hue_Shift_","_Saturation_Shift_","_Value_Shift_","_Blob_Position_","_Blob_Intensity_","_Blob_Near_Size_","_Blob_Far_Size_","_Blob_Near_Distance_","_Blob_Far_Distance_","_Blob_Fade_Length_","_Blob_Pulse_","_Blob_Fade_","_Blob_Texture_","_Blob_Position_2_","_Blob_Near_Size_2_","_Blob_Pulse_2_","_Blob_Fade_2_","_Left_Index_Pos_","_Right_Index_Pos_","_Left_Index_Middle_Pos_","_Right_Index_Middle_Pos_","_Decal_","_Decal_Scale_XY_","_Decal_Front_Only_","_Rim_Intensity_","_Rim_Texture_","_Rim_Hue_Shift_","_Rim_Saturation_Shift_","_Rim_Value_Shift_","_Iridescence_Intensity_","_Iridescence_Texture_","Use_Global_Left_Index","Use_Global_Right_Index","Global_Left_Index_Tip_Position","Global_Right_Index_Tip_Position","Global_Left_Thumb_Tip_Position","Global_Right_Thumb_Tip_Position","Global_Left_Index_Middle_Position;","Global_Right_Index_Middle_Position","Global_Left_Index_Tip_Proximity","Global_Right_Index_Tip_Proximity"],h=["_Rim_Texture_","_Iridescence_Texture_"],c=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:i,maxSimultaneousLights:4}),e.setEffect(o.getEngine().createEffect("mrdlSliderThumb",{attributes:a,uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:l,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),i)}return!(!e.effect||!e.effect.isReady()||(i._renderId=o.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){if(i.materialDefines){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._activeEffect.setVector3("cameraPosition",this.getScene().activeCamera.position),this._activeEffect.setFloat("_Radius_",this.radius),this._activeEffect.setFloat("_Bevel_Front_",this.bevelFront),this._activeEffect.setFloat("_Bevel_Front_Stretch_",this.bevelFrontStretch),this._activeEffect.setFloat("_Bevel_Back_",this.bevelBack),this._activeEffect.setFloat("_Bevel_Back_Stretch_",this.bevelBackStretch),this._activeEffect.setFloat("_Radius_Top_Left_",this.radiusTopLeft),this._activeEffect.setFloat("_Radius_Top_Right_",this.radiusTopRight),this._activeEffect.setFloat("_Radius_Bottom_Left_",this.radiusBottomLeft),this._activeEffect.setFloat("_Radius_Bottom_Right_",this.radiusBottomRight),this._activeEffect.setFloat("_Bulge_Enabled_",this.bulgeEnabled?1:0),this._activeEffect.setFloat("_Bulge_Height_",this.bulgeHeight),this._activeEffect.setFloat("_Bulge_Radius_",this.bulgeRadius),this._activeEffect.setFloat("_Sun_Intensity_",this.sunIntensity),this._activeEffect.setFloat("_Sun_Theta_",this.sunTheta),this._activeEffect.setFloat("_Sun_Phi_",this.sunPhi),this._activeEffect.setFloat("_Indirect_Diffuse_",this.indirectDiffuse),this._activeEffect.setDirectColor4("_Albedo_",this.albedo),this._activeEffect.setFloat("_Specular_",this.specular),this._activeEffect.setFloat("_Shininess_",this.shininess),this._activeEffect.setFloat("_Sharpness_",this.sharpness),this._activeEffect.setFloat("_Subsurface_",this.subsurface),this._activeEffect.setDirectColor4("_Left_Color_",this.leftGradientColor),this._activeEffect.setDirectColor4("_Right_Color_",this.rightGradientColor),this._activeEffect.setFloat("_Reflection_",this.reflection),this._activeEffect.setFloat("_Front_Reflect_",this.frontReflect),this._activeEffect.setFloat("_Edge_Reflect_",this.edgeReflect),this._activeEffect.setFloat("_Power_",this.power),this._activeEffect.setDirectColor4("_Sky_Color_",this.skyColor),this._activeEffect.setDirectColor4("_Horizon_Color_",this.horizonColor),this._activeEffect.setDirectColor4("_Ground_Color_",this.groundColor),this._activeEffect.setFloat("_Horizon_Power_",this.horizonPower),this._activeEffect.setTexture("_Reflection_Map_",new s.Texture("",this.getScene())),this._activeEffect.setTexture("_Indirect_Environment_",new s.Texture("",this.getScene())),this._activeEffect.setFloat("_Width_",this.width),this._activeEffect.setFloat("_Fuzz_",this.fuzz),this._activeEffect.setFloat("_Min_Fuzz_",this.minFuzz),this._activeEffect.setFloat("_Clip_Fade_",this.clipFade),this._activeEffect.setFloat("_Hue_Shift_",this.hueShift),this._activeEffect.setFloat("_Saturation_Shift_",this.saturationShift),this._activeEffect.setFloat("_Value_Shift_",this.valueShift),this._activeEffect.setVector3("_Blob_Position_",this.blobPosition),this._activeEffect.setFloat("_Blob_Intensity_",this.blobIntensity),this._activeEffect.setFloat("_Blob_Near_Size_",this.blobNearSize),this._activeEffect.setFloat("_Blob_Far_Size_",this.blobFarSize),this._activeEffect.setFloat("_Blob_Near_Distance_",this.blobNearDistance),this._activeEffect.setFloat("_Blob_Far_Distance_",this.blobFarDistance),this._activeEffect.setFloat("_Blob_Fade_Length_",this.blobFadeLength),this._activeEffect.setFloat("_Blob_Pulse_",this.blobPulse),this._activeEffect.setFloat("_Blob_Fade_",this.blobFade),this._activeEffect.setTexture("_Blob_Texture_",this.blobTexture),this._activeEffect.setVector3("_Blob_Position_2_",this.blobPosition2),this._activeEffect.setFloat("_Blob_Near_Size_2_",this.blobNearSize2),this._activeEffect.setFloat("_Blob_Pulse_2_",this.blobPulse2),this._activeEffect.setFloat("_Blob_Fade_2_",this.blobFade2),this._activeEffect.setVector3("_Left_Index_Pos_",this.leftIndexPosition),this._activeEffect.setVector3("_Right_Index_Pos_",this.rightIndexPosition),this._activeEffect.setVector3("_Left_Index_Middle_Pos_",this.leftIndexMiddlePosition),this._activeEffect.setVector3("_Right_Index_Middle_Pos_",this.rightIndexMiddlePosition),this._activeEffect.setTexture("_Decal_",new s.Texture("",this.getScene())),this._activeEffect.setVector2("_Decal_Scale_XY_",this.decalScaleXY),this._activeEffect.setFloat("_Decal_Front_Only_",this.decalFrontOnly?1:0),this._activeEffect.setFloat("_Rim_Intensity_",this.rimIntensity),this._activeEffect.setTexture("_Rim_Texture_",this._blueGradientTexture),this._activeEffect.setFloat("_Rim_Hue_Shift_",this.rimHueShift),this._activeEffect.setFloat("_Rim_Saturation_Shift_",this.rimSaturationShift),this._activeEffect.setFloat("_Rim_Value_Shift_",this.rimValueShift),this._activeEffect.setFloat("_Iridescence_Intensity_",this.iridescenceIntensity),this._activeEffect.setTexture("_Iridescence_Texture_",this._blueGradientTexture),this._activeEffect.setFloat("Use_Global_Left_Index",this.useGlobalLeftIndex),this._activeEffect.setFloat("Use_Global_Right_Index",this.useGlobalRightIndex),this._activeEffect.setVector4("Global_Left_Index_Tip_Position",this.globalLeftIndexTipPosition),this._activeEffect.setVector4("Global_Right_Index_Tip_Position",this.globaRightIndexTipPosition),this._activeEffect.setVector4("Global_Left_Thumb_Tip_Position",this.globalLeftThumbTipPosition),this._activeEffect.setVector4("Global_Right_Thumb_Tip_Position",this.globalRightThumbTipPosition),this._activeEffect.setVector4("Global_Left_Index_Middle_Position",this.globalLeftIndexMiddlePosition),this._activeEffect.setVector4("Global_Right_Index_Middle_Position",this.globalRightIndexMiddlePosition),this._activeEffect.setFloat("Global_Left_Index_Tip_Proximity",this.globalLeftIndexTipProximity),this._activeEffect.setFloat("Global_Right_Index_Tip_Proximity",this.globalRightIndexTipProximity),this._afterBind(e,this._activeEffect))}},e.prototype.getAnimatables=function(){return[]},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.MRDLSliderThumbMaterial",e},e.prototype.getClassName=function(){return"MRDLSliderThumbMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},e.BLUE_GRADIENT_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/MRDL/mrtk-mrdl-blue-gradient.png",a([(0,s.serialize)()],e.prototype,"radius",void 0),a([(0,s.serialize)()],e.prototype,"bevelFront",void 0),a([(0,s.serialize)()],e.prototype,"bevelFrontStretch",void 0),a([(0,s.serialize)()],e.prototype,"bevelBack",void 0),a([(0,s.serialize)()],e.prototype,"bevelBackStretch",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopRight",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomRight",void 0),a([(0,s.serialize)()],e.prototype,"bulgeEnabled",void 0),a([(0,s.serialize)()],e.prototype,"bulgeHeight",void 0),a([(0,s.serialize)()],e.prototype,"bulgeRadius",void 0),a([(0,s.serialize)()],e.prototype,"sunIntensity",void 0),a([(0,s.serialize)()],e.prototype,"sunTheta",void 0),a([(0,s.serialize)()],e.prototype,"sunPhi",void 0),a([(0,s.serialize)()],e.prototype,"indirectDiffuse",void 0),a([(0,s.serialize)()],e.prototype,"albedo",void 0),a([(0,s.serialize)()],e.prototype,"specular",void 0),a([(0,s.serialize)()],e.prototype,"shininess",void 0),a([(0,s.serialize)()],e.prototype,"sharpness",void 0),a([(0,s.serialize)()],e.prototype,"subsurface",void 0),a([(0,s.serialize)()],e.prototype,"leftGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"rightGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"reflection",void 0),a([(0,s.serialize)()],e.prototype,"frontReflect",void 0),a([(0,s.serialize)()],e.prototype,"edgeReflect",void 0),a([(0,s.serialize)()],e.prototype,"power",void 0),a([(0,s.serialize)()],e.prototype,"skyColor",void 0),a([(0,s.serialize)()],e.prototype,"horizonColor",void 0),a([(0,s.serialize)()],e.prototype,"groundColor",void 0),a([(0,s.serialize)()],e.prototype,"horizonPower",void 0),a([(0,s.serialize)()],e.prototype,"width",void 0),a([(0,s.serialize)()],e.prototype,"fuzz",void 0),a([(0,s.serialize)()],e.prototype,"minFuzz",void 0),a([(0,s.serialize)()],e.prototype,"clipFade",void 0),a([(0,s.serialize)()],e.prototype,"hueShift",void 0),a([(0,s.serialize)()],e.prototype,"saturationShift",void 0),a([(0,s.serialize)()],e.prototype,"valueShift",void 0),a([(0,s.serialize)()],e.prototype,"blobPosition",void 0),a([(0,s.serialize)()],e.prototype,"blobIntensity",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize",void 0),a([(0,s.serialize)()],e.prototype,"blobFarSize",void 0),a([(0,s.serialize)()],e.prototype,"blobNearDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFarDistance",void 0),a([(0,s.serialize)()],e.prototype,"blobFadeLength",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse",void 0),a([(0,s.serialize)()],e.prototype,"blobFade",void 0),a([(0,s.serialize)()],e.prototype,"blobPosition2",void 0),a([(0,s.serialize)()],e.prototype,"blobNearSize2",void 0),a([(0,s.serialize)()],e.prototype,"blobPulse2",void 0),a([(0,s.serialize)()],e.prototype,"blobFade2",void 0),a([(0,s.serialize)()],e.prototype,"blobTexture",void 0),a([(0,s.serialize)()],e.prototype,"leftIndexPosition",void 0),a([(0,s.serialize)()],e.prototype,"rightIndexPosition",void 0),a([(0,s.serialize)()],e.prototype,"leftIndexMiddlePosition",void 0),a([(0,s.serialize)()],e.prototype,"rightIndexMiddlePosition",void 0),a([(0,s.serialize)()],e.prototype,"decalScaleXY",void 0),a([(0,s.serialize)()],e.prototype,"decalFrontOnly",void 0),a([(0,s.serialize)()],e.prototype,"rimIntensity",void 0),a([(0,s.serialize)()],e.prototype,"rimHueShift",void 0),a([(0,s.serialize)()],e.prototype,"rimSaturationShift",void 0),a([(0,s.serialize)()],e.prototype,"rimValueShift",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceIntensity",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.MRDLSliderThumbMaterial",At);s.ShaderStore.ShadersStore.mrdlBackplatePixelShader="uniform vec3 cameraPosition;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nuniform float _Radius_;\nuniform float _Line_Width_;\nuniform bool _Absolute_Sizes_;\nuniform float _Filter_Width_;\nuniform vec4 _Base_Color_;\nuniform vec4 _Line_Color_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform float _Rate_;\nuniform vec4 _Highlight_Color_;\nuniform float _Highlight_Width_;\nuniform vec4 _Highlight_Transform_;\nuniform float _Highlight_;\nuniform float _Iridescence_Intensity_;\nuniform float _Iridescence_Edge_Intensity_;\nuniform vec4 _Iridescence_Tint_;\nuniform sampler2D _Iridescent_Map_;\nuniform float _Angle_;\nuniform bool _Reflected_;\nuniform float _Frequency_;\nuniform float _Vertical_Offset_;\nuniform vec4 _Gradient_Color_;\nuniform vec4 _Top_Left_;\nuniform vec4 _Top_Right_;\nuniform vec4 _Bottom_Left_;\nuniform vec4 _Bottom_Right_;\nuniform float _Edge_Width_;\nuniform float _Edge_Power_;\nuniform float _Line_Gradient_Blend_;\nuniform float _Fade_Out_;\nvoid FastLinearTosRGB_B353(\nvec4 Linear,\nout vec4 sRGB)\n{\nsRGB.rgb=sqrt(clamp(Linear.rgb,0.0,1.0));\nsRGB.a=Linear.a;\n}\nvoid Round_Rect_Fragment_B332(\nfloat Radius,\nfloat Line_Width,\nvec4 Line_Color,\nfloat Filter_Width,\nvec2 UV,\nfloat Line_Visibility,\nvec4 Rect_Parms,\nvec4 Fill_Color,\nout vec4 Color)\n{\nfloat d=length(max(abs(UV)-Rect_Parms.xy,0.0));\nfloat dx=max(fwidth(d)*Filter_Width,0.00001);\nfloat g=min(Rect_Parms.z,Rect_Parms.w);\nfloat dgrad=max(fwidth(g)*Filter_Width,0.00001);\nfloat Inside_Rect=clamp(g/dgrad,0.0,1.0);\nfloat inner=clamp((d+dx*0.5-max(Radius-Line_Width,d-dx*0.5))/dx,0.0,1.0);\nColor=clamp(mix(Fill_Color,Line_Color,inner),0.0,1.0)*Inside_Rect;\n}\nvoid Iridescence_B343(\nvec3 Position,\nvec3 Normal,\nvec2 UV,\nvec3 Axis,\nvec3 Eye,\nvec4 Tint,\nsampler2D Texture,\nbool Reflected,\nfloat Frequency,\nfloat Vertical_Offset,\nout vec4 Color)\n{\nvec3 i=normalize(Position-Eye);\nvec3 r=reflect(i,Normal);\nfloat idota=dot(i,Axis);\nfloat idotr=dot(i,r);\nfloat x=Reflected ? idotr : idota;\nvec2 xy;\nxy.x=fract((x*Frequency+1.0)*0.5+UV.y*Vertical_Offset);\nxy.y=0.5;\nColor=texture(Texture,xy);\nColor.rgb*=Tint.rgb;\n}\nvoid Scale_RGB_B346(\nvec4 Color,\nfloat Scalar,\nout vec4 Result)\n{\nResult=vec4(Scalar,Scalar,Scalar,1)*Color;\n}\nvoid Scale_RGB_B344(\nfloat Scalar,\nvec4 Color,\nout vec4 Result)\n{\nResult=vec4(Scalar,Scalar,Scalar,1)*Color;\n}\nvoid Line_Fragment_B362(\nvec4 Base_Color,\nvec4 Highlight_Color,\nfloat Highlight_Width,\nvec3 Line_Vertex,\nfloat Highlight,\nout vec4 Line_Color)\n{\nfloat k2=1.0-clamp(abs(Line_Vertex.y/Highlight_Width),0.0,1.0);\nLine_Color=mix(Base_Color,Highlight_Color,Highlight*k2);\n}\nvoid Edge_B356(\nvec4 RectParms,\nfloat Radius,\nfloat Line_Width,\nvec2 UV,\nfloat Edge_Width,\nfloat Edge_Power,\nout float Result)\n{\nfloat d=length(max(abs(UV)-RectParms.xy,0.0));\nfloat edge=1.0-clamp((1.0-d/(Radius-Line_Width))/Edge_Width,0.0,1.0);\nResult=pow(edge,Edge_Power);\n}\nvoid Gradient_B355(\nvec4 Gradient_Color,\nvec4 Top_Left,\nvec4 Top_Right,\nvec4 Bottom_Left,\nvec4 Bottom_Right,\nvec2 UV,\nout vec4 Result)\n{\nvec3 top=Top_Left.rgb+(Top_Right.rgb-Top_Left.rgb)*UV.x;\nvec3 bottom=Bottom_Left.rgb+(Bottom_Right.rgb-Bottom_Left.rgb)*UV.x;\nResult.rgb=Gradient_Color.rgb*(bottom+(top-bottom)*UV.y);\nResult.a=1.0;\n}\nvoid main()\n{\nfloat X_Q338;\nfloat Y_Q338;\nfloat Z_Q338;\nfloat W_Q338;\nX_Q338=vExtra2.x;\nY_Q338=vExtra2.y;\nZ_Q338=vExtra2.z;\nW_Q338=vExtra2.w;\nvec4 Color_Q343;\n#if IRIDESCENCE_ENABLE\nIridescence_B343(vPosition,vNormal,vUV,vBinormal,cameraPosition,_Iridescence_Tint_,_Iridescent_Map_,_Reflected_,_Frequency_,_Vertical_Offset_,Color_Q343);\n#else\nColor_Q343=vec4(0,0,0,0);\n#endif\nvec4 Result_Q344;\nScale_RGB_B344(_Iridescence_Intensity_,Color_Q343,Result_Q344);\nvec4 Line_Color_Q362;\nLine_Fragment_B362(_Line_Color_,_Highlight_Color_,_Highlight_Width_,vTangent,_Highlight_,Line_Color_Q362);\nfloat Result_Q356;\n#if EDGE_ONLY\nEdge_B356(vExtra1,Z_Q338,W_Q338,vUV,_Edge_Width_,_Edge_Power_,Result_Q356);\n#else\nResult_Q356=1.0;\n#endif\nvec2 Vec2_Q339=vec2(X_Q338,Y_Q338);\nvec4 Result_Q355;\nGradient_B355(_Gradient_Color_,_Top_Left_,_Top_Right_,_Bottom_Left_,_Bottom_Right_,Vec2_Q339,Result_Q355);\nvec4 Linear_Q348;\nLinear_Q348.rgb=clamp(Result_Q355.rgb*Result_Q355.rgb,0.0,1.0);\nLinear_Q348.a=Result_Q355.a;\nvec4 Result_Q346;\nScale_RGB_B346(Linear_Q348,Result_Q356,Result_Q346);\nvec4 Sum_Q345=Result_Q346+Result_Q344;\nvec4 Color_At_T_Q347=mix(Line_Color_Q362,Result_Q346,_Line_Gradient_Blend_);\nvec4 Base_And_Iridescent_Q350;\nBase_And_Iridescent_Q350=_Base_Color_+vec4(Sum_Q345.rgb,0.0);\nvec4 Sum_Q349=Color_At_T_Q347+_Iridescence_Edge_Intensity_*Color_Q343;\nvec4 Result_Q351=Sum_Q349; Result_Q351.a=1.0;\nvec4 Color_Q332;\nRound_Rect_Fragment_B332(Z_Q338,W_Q338,Result_Q351,_Filter_Width_,vUV,1.0,vExtra1,Base_And_Iridescent_Q350,Color_Q332);\nvec4 Result_Q354=_Fade_Out_*Color_Q332;\nvec4 sRGB_Q353;\nFastLinearTosRGB_B353(Result_Q354,sRGB_Q353);\nvec4 Out_Color=sRGB_Q353;\nfloat Clip_Threshold=0.001;\nbool To_sRGB=false;\ngl_FragColor=Out_Color;\n}";s.ShaderStore.ShadersStore.mrdlBackplateVertexShader="uniform mat4 world;\nuniform mat4 viewProjection;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 tangent;\nuniform float _Radius_;\nuniform float _Line_Width_;\nuniform bool _Absolute_Sizes_;\nuniform float _Filter_Width_;\nuniform vec4 _Base_Color_;\nuniform vec4 _Line_Color_;\nuniform float _Radius_Top_Left_;\nuniform float _Radius_Top_Right_;\nuniform float _Radius_Bottom_Left_;\nuniform float _Radius_Bottom_Right_;\nuniform float _Rate_;\nuniform vec4 _Highlight_Color_;\nuniform float _Highlight_Width_;\nuniform vec4 _Highlight_Transform_;\nuniform float _Highlight_;\nuniform float _Iridescence_Intensity_;\nuniform float _Iridescence_Edge_Intensity_;\nuniform vec4 _Iridescence_Tint_;\nuniform sampler2D _Iridescent_Map_;\nuniform float _Angle_;\nuniform bool _Reflected_;\nuniform float _Frequency_;\nuniform float _Vertical_Offset_;\nuniform vec4 _Gradient_Color_;\nuniform vec4 _Top_Left_;\nuniform vec4 _Top_Right_;\nuniform vec4 _Bottom_Left_;\nuniform vec4 _Bottom_Right_;\nuniform float _Edge_Width_;\nuniform float _Edge_Power_;\nuniform float _Line_Gradient_Blend_;\nuniform float _Fade_Out_;\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying vec2 vUV;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec4 vExtra1;\nvarying vec4 vExtra2;\nvoid Object_To_World_Pos_B314(\nvec3 Pos_Object,\nout vec3 Pos_World)\n{\nPos_World=(world*vec4(Pos_Object,1.0)).xyz;\n}\nvoid Round_Rect_Vertex_B357(\nvec2 UV,\nfloat Radius,\nfloat Margin,\nfloat Anisotropy,\nfloat Gradient1,\nfloat Gradient2,\nvec3 Normal,\nvec4 Color_Scale_Translate,\nout vec2 Rect_UV,\nout vec4 Rect_Parms,\nout vec2 Scale_XY,\nout vec2 Line_UV,\nout vec2 Color_UV_Info)\n{\nScale_XY=vec2(Anisotropy,1.0);\nLine_UV=(UV-vec2(0.5,0.5));\nRect_UV=Line_UV*Scale_XY;\nRect_Parms.xy=Scale_XY*0.5-vec2(Radius,Radius)-vec2(Margin,Margin);\nRect_Parms.z=Gradient1; \nRect_Parms.w=Gradient2;\nColor_UV_Info=(Line_UV+vec2(0.5,0.5))*Color_Scale_Translate.xy+Color_Scale_Translate.zw;\n}\nvoid Line_Vertex_B333(\nvec2 Scale_XY,\nvec2 UV,\nfloat Time,\nfloat Rate,\nvec4 Highlight_Transform,\nout vec3 Line_Vertex)\n{\nfloat angle2=(Rate*Time)*2.0*3.1416;\nfloat sinAngle2=sin(angle2);\nfloat cosAngle2=cos(angle2);\nvec2 xformUV=UV*Highlight_Transform.xy+Highlight_Transform.zw;\nLine_Vertex.x=0.0;\nLine_Vertex.y=cosAngle2*xformUV.x-sinAngle2*xformUV.y;\nLine_Vertex.z=0.0; \n}\nvoid PickDir_B334(\nfloat Degrees,\nvec3 DirX,\nvec3 DirY,\nout vec3 Dir)\n{\nfloat a=Degrees*3.14159/180.0;\nDir=cos(a)*DirX+sin(a)*DirY;\n}\nvoid Move_Verts_B327(\nfloat Anisotropy,\nvec3 P,\nfloat Radius,\nout vec3 New_P,\nout vec2 New_UV,\nout float Radial_Gradient,\nout vec3 Radial_Dir)\n{\nvec2 UV=P.xy*2.0+0.5;\nvec2 center=clamp(UV,0.0,1.0);\nvec2 delta=UV-center;\nvec2 r2=2.0*vec2(Radius/Anisotropy,Radius);\nNew_UV=center+r2*(UV-2.0*center+0.5);\nNew_P=vec3(New_UV-0.5,P.z);\nRadial_Gradient=1.0-length(delta)*2.0;\nRadial_Dir=vec3(delta*r2,0.0);\n}\nvoid Pick_Radius_B336(\nfloat Radius,\nfloat Radius_Top_Left,\nfloat Radius_Top_Right,\nfloat Radius_Bottom_Left,\nfloat Radius_Bottom_Right,\nvec3 Position,\nout float Result)\n{\nbool whichY=Position.y>0.0;\nResult=Position.x<0.0 ? (whichY ? Radius_Top_Left : Radius_Bottom_Left) : (whichY ? Radius_Top_Right : Radius_Bottom_Right);\nResult*=Radius;\n}\nvoid Edge_AA_Vertex_B328(\nvec3 Position_World,\nvec3 Position_Object,\nvec3 Normal_Object,\nvec3 Eye,\nfloat Radial_Gradient,\nvec3 Radial_Dir,\nvec3 Tangent,\nout float Gradient1,\nout float Gradient2)\n{\nvec3 I=(Eye-Position_World);\nvec3 T=(vec4(Tangent,0.0)).xyz;\nfloat g=(dot(T,I)<0.0) ? 0.0 : 1.0;\nif (Normal_Object.z==0.0) { \nGradient1=Position_Object.z>0.0 ? g : 1.0;\nGradient2=Position_Object.z>0.0 ? 1.0 : g;\n} else {\nGradient1=g+(1.0-g)*(Radial_Gradient);\nGradient2=1.0;\n}\n}\nvoid Object_To_World_Dir_B330(\nvec3 Dir_Object,\nout vec3 Binormal_World,\nout vec3 Binormal_World_N,\nout float Binormal_Length)\n{\nBinormal_World=(world*vec4(Dir_Object,0.0)).xyz;\nBinormal_Length=length(Binormal_World);\nBinormal_World_N=Binormal_World/Binormal_Length;\n}\nvoid RelativeOrAbsoluteDetail_B341(\nfloat Nominal_Radius,\nfloat Nominal_LineWidth,\nbool Absolute_Measurements,\nfloat Height,\nout float Radius,\nout float Line_Width)\n{\nfloat scale=Absolute_Measurements ? 1.0/Height : 1.0;\nRadius=Nominal_Radius*scale;\nLine_Width=Nominal_LineWidth*scale;\n}\nvoid main()\n{\nvec3 Nrm_World_Q326;\nNrm_World_Q326=normalize((world*vec4(normal,0.0)).xyz);\nvec3 Tangent_World_Q329;\nvec3 Tangent_World_N_Q329;\nfloat Tangent_Length_Q329;\nTangent_World_Q329=(world*vec4(vec3(1,0,0),0.0)).xyz;\nTangent_Length_Q329=length(Tangent_World_Q329);\nTangent_World_N_Q329=Tangent_World_Q329/Tangent_Length_Q329;\nvec3 Binormal_World_Q330;\nvec3 Binormal_World_N_Q330;\nfloat Binormal_Length_Q330;\nObject_To_World_Dir_B330(vec3(0,1,0),Binormal_World_Q330,Binormal_World_N_Q330,Binormal_Length_Q330);\nfloat Radius_Q341;\nfloat Line_Width_Q341;\nRelativeOrAbsoluteDetail_B341(_Radius_,_Line_Width_,_Absolute_Sizes_,Binormal_Length_Q330,Radius_Q341,Line_Width_Q341);\nvec3 Dir_Q334;\nPickDir_B334(_Angle_,Tangent_World_N_Q329,Binormal_World_N_Q330,Dir_Q334);\nfloat Result_Q336;\nPick_Radius_B336(Radius_Q341,_Radius_Top_Left_,_Radius_Top_Right_,_Radius_Bottom_Left_,_Radius_Bottom_Right_,position,Result_Q336);\nfloat Anisotropy_Q331=Tangent_Length_Q329/Binormal_Length_Q330;\nvec4 Out_Color_Q337=vec4(Result_Q336,Line_Width_Q341,0,1);\nvec3 New_P_Q327;\nvec2 New_UV_Q327;\nfloat Radial_Gradient_Q327;\nvec3 Radial_Dir_Q327;\nMove_Verts_B327(Anisotropy_Q331,position,Result_Q336,New_P_Q327,New_UV_Q327,Radial_Gradient_Q327,Radial_Dir_Q327);\nvec3 Pos_World_Q314;\nObject_To_World_Pos_B314(New_P_Q327,Pos_World_Q314);\nfloat Gradient1_Q328;\nfloat Gradient2_Q328;\n#if SMOOTH_EDGES\nEdge_AA_Vertex_B328(Pos_World_Q314,position,normal,cameraPosition,Radial_Gradient_Q327,Radial_Dir_Q327,tangent,Gradient1_Q328,Gradient2_Q328);\n#else\nGradient1_Q328=1.0;\nGradient2_Q328=1.0;\n#endif\nvec2 Rect_UV_Q357;\nvec4 Rect_Parms_Q357;\nvec2 Scale_XY_Q357;\nvec2 Line_UV_Q357;\nvec2 Color_UV_Info_Q357;\nRound_Rect_Vertex_B357(New_UV_Q327,Result_Q336,0.0,Anisotropy_Q331,Gradient1_Q328,Gradient2_Q328,normal,vec4(1,1,0,0),Rect_UV_Q357,Rect_Parms_Q357,Scale_XY_Q357,Line_UV_Q357,Color_UV_Info_Q357);\nvec3 Line_Vertex_Q333;\nLine_Vertex_B333(Scale_XY_Q357,Line_UV_Q357,(20.0),_Rate_,_Highlight_Transform_,Line_Vertex_Q333);\nfloat X_Q359;\nfloat Y_Q359;\nX_Q359=Color_UV_Info_Q357.x;\nY_Q359=Color_UV_Info_Q357.y;\nvec4 Vec4_Q358=vec4(X_Q359,Y_Q359,Result_Q336,Line_Width_Q341);\nvec3 Position=Pos_World_Q314;\nvec3 Normal=Nrm_World_Q326;\nvec2 UV=Rect_UV_Q357;\nvec3 Tangent=Line_Vertex_Q333;\nvec3 Binormal=Dir_Q334;\nvec4 Color=Out_Color_Q337;\nvec4 Extra1=Rect_Parms_Q357;\nvec4 Extra2=Vec4_Q358;\nvec4 Extra3=vec4(0,0,0,0);\ngl_Position=viewProjection*vec4(Position,1);\nvPosition=Position;\nvNormal=Normal;\nvUV=UV;\nvTangent=Tangent;\nvBinormal=Binormal;\nvExtra1=Extra1;\nvExtra2=Extra2;\n}";var zt=function(t){function e(){var e=t.call(this)||this;return e.IRIDESCENCE_ENABLED=!0,e.SMOOTH_EDGES=!0,e._needNormals=!0,e.rebuild(),e}return r(e,t),e}(s.MaterialDefines),Qt=function(t){function e(i,o){var n=t.call(this,i,o)||this;return n.radius=.3,n.lineWidth=.003,n.absoluteSizes=!1,n._filterWidth=1,n.baseColor=new s.Color4(0,0,0,1),n.lineColor=new s.Color4(.2,.262745,.4,1),n.radiusTopLeft=1,n.radiusTopRight=1,n.radiusBottomLeft=1,n.radiusBottomRight=1,n._rate=0,n.highlightColor=new s.Color4(.239216,.435294,.827451,1),n.highlightWidth=0,n._highlightTransform=new s.Vector4(1,1,0,0),n._highlight=1,n.iridescenceIntensity=.45,n.iridescenceEdgeIntensity=1,n.iridescenceTint=new s.Color4(1,1,1,1),n._angle=-45,n.fadeOut=1,n._reflected=!0,n._frequency=1,n._verticalOffset=0,n.gradientColor=new s.Color4(.74902,.74902,.74902,1),n.topLeftGradientColor=new s.Color4(.00784314,.294118,.580392,1),n.topRightGradientColor=new s.Color4(.305882,0,1,1),n.bottomLeftGradientColor=new s.Color4(.133333,.258824,.992157,1),n.bottomRightGradientColor=new s.Color4(.176471,.176471,.619608,1),n.edgeWidth=.5,n.edgePower=1,n.edgeLineGradientBlend=.5,n.alphaMode=s.Constants.ALPHA_DISABLE,n.backFaceCulling=!1,n._iridescentMapTexture=new s.Texture(e.IRIDESCENT_MAP_TEXTURE_URL,n.getScene(),!0,!1,s.Texture.NEAREST_SAMPLINGMODE),n}return r(e,t),e.prototype.needAlphaBlending=function(){return!1},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.isReadyForSubMesh=function(t,e){if(this.isFrozen&&e.effect&&e.effect._wasPreviouslyReady)return!0;e.materialDefines||(e.materialDefines=new zt);var i=e.materialDefines,o=this.getScene();if(this._isReadyForSubMesh(e))return!0;var n=o.getEngine();if(s.MaterialHelper.PrepareDefinesForAttributes(t,i,!1,!1),i.isDirty){i.markAsProcessed(),o.resetCachedMaterial();var r=new s.EffectFallbacks;i.FOG&&r.addFallback(1,"FOG"),s.MaterialHelper.HandleFallbacksForShadows(i,r),i.IMAGEPROCESSINGPOSTPROCESS=o.imageProcessingConfiguration.applyByPostProcess;var a=[s.VertexBuffer.PositionKind];i.NORMAL&&a.push(s.VertexBuffer.NormalKind),i.UV1&&a.push(s.VertexBuffer.UVKind),i.UV2&&a.push(s.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&a.push(s.VertexBuffer.ColorKind),i.TANGENT&&a.push(s.VertexBuffer.TangentKind),s.MaterialHelper.PrepareAttributesForInstances(a,i);var l=i.toString(),_=["world","viewProjection","cameraPosition","_Radius_","_Line_Width_","_Absolute_Sizes_","_Filter_Width_","_Base_Color_","_Line_Color_","_Radius_Top_Left_","_Radius_Top_Right_","_Radius_Bottom_Left_","_Radius_Bottom_Right_","_Rate_","_Highlight_Color_","_Highlight_Width_","_Highlight_Transform_","_Highlight_","_Iridescence_Intensity_","_Iridescence_Edge_Intensity_","_Iridescence_Tint_","_Iridescent_Map_","_Angle_","_Reflected_","_Frequency_","_Vertical_Offset_","_Gradient_Color_","_Top_Left_","_Top_Right_","_Bottom_Left_","_Bottom_Right_","_Edge_Width_","_Edge_Power_","_Line_Gradient_Blend_","_Fade_Out_"],h=[],c=new Array;s.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:i,maxSimultaneousLights:4}),e.setEffect(o.getEngine().createEffect("mrdlBackplate",{attributes:a,uniformsNames:_,uniformBuffersNames:c,samplers:h,defines:l,fallbacks:r,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},n),i)}return!(!e.effect||!e.effect.isReady()||(i._renderId=o.getRenderId(),e.effect._wasPreviouslyReady=!0,0))},e.prototype.bindForSubMesh=function(t,e,i){if(i.materialDefines){var o=i.effect;o&&(this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._activeEffect.setVector3("cameraPosition",this.getScene().activeCamera.position),this._activeEffect.setFloat("_Radius_",this.radius),this._activeEffect.setFloat("_Line_Width_",this.lineWidth),this._activeEffect.setFloat("_Absolute_Sizes_",this.absoluteSizes?1:0),this._activeEffect.setFloat("_Filter_Width_",this._filterWidth),this._activeEffect.setDirectColor4("_Base_Color_",this.baseColor),this._activeEffect.setDirectColor4("_Line_Color_",this.lineColor),this._activeEffect.setFloat("_Radius_Top_Left_",this.radiusTopLeft),this._activeEffect.setFloat("_Radius_Top_Right_",this.radiusTopRight),this._activeEffect.setFloat("_Radius_Bottom_Left_",this.radiusBottomLeft),this._activeEffect.setFloat("_Radius_Bottom_Right_",this.radiusBottomRight),this._activeEffect.setFloat("_Rate_",this._rate),this._activeEffect.setDirectColor4("_Highlight_Color_",this.highlightColor),this._activeEffect.setFloat("_Highlight_Width_",this.highlightWidth),this._activeEffect.setVector4("_Highlight_Transform_",this._highlightTransform),this._activeEffect.setFloat("_Highlight_",this._highlight),this._activeEffect.setFloat("_Iridescence_Intensity_",this.iridescenceIntensity),this._activeEffect.setFloat("_Iridescence_Edge_Intensity_",this.iridescenceEdgeIntensity),this._activeEffect.setDirectColor4("_Iridescence_Tint_",this.iridescenceTint),this._activeEffect.setTexture("_Iridescent_Map_",this._iridescentMapTexture),this._activeEffect.setFloat("_Angle_",this._angle),this._activeEffect.setFloat("_Reflected_",this._reflected?1:0),this._activeEffect.setFloat("_Frequency_",this._frequency),this._activeEffect.setFloat("_Vertical_Offset_",this._verticalOffset),this._activeEffect.setDirectColor4("_Gradient_Color_",this.gradientColor),this._activeEffect.setDirectColor4("_Top_Left_",this.topLeftGradientColor),this._activeEffect.setDirectColor4("_Top_Right_",this.topRightGradientColor),this._activeEffect.setDirectColor4("_Bottom_Left_",this.bottomLeftGradientColor),this._activeEffect.setDirectColor4("_Bottom_Right_",this.bottomRightGradientColor),this._activeEffect.setFloat("_Edge_Width_",this.edgeWidth),this._activeEffect.setFloat("_Edge_Power_",this.edgePower),this._activeEffect.setFloat("_Line_Gradient_Blend_",this.edgeLineGradientBlend),this._activeEffect.setFloat("_Fade_Out_",this.fadeOut),this._afterBind(e,this._activeEffect))}},e.prototype.getAnimatables=function(){return[]},e.prototype.dispose=function(e){t.prototype.dispose.call(this,e)},e.prototype.clone=function(t){var i=this;return s.SerializationHelper.Clone((function(){return new e(t,i.getScene())}),this)},e.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.customType="BABYLON.MRDLBackplateMaterial",e},e.prototype.getClassName=function(){return"MRDLBackplateMaterial"},e.Parse=function(t,i,o){return s.SerializationHelper.Parse((function(){return new e(t.name,i)}),t,i,o)},e.IRIDESCENT_MAP_TEXTURE_URL="https://assets.babylonjs.com/meshes/MRTK/MRDL/mrtk-mrdl-backplate-iridescence.png",a([(0,s.serialize)()],e.prototype,"radius",void 0),a([(0,s.serialize)()],e.prototype,"lineWidth",void 0),a([(0,s.serialize)()],e.prototype,"absoluteSizes",void 0),a([(0,s.serialize)()],e.prototype,"baseColor",void 0),a([(0,s.serialize)()],e.prototype,"lineColor",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusTopRight",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomLeft",void 0),a([(0,s.serialize)()],e.prototype,"radiusBottomRight",void 0),a([(0,s.serialize)()],e.prototype,"highlightColor",void 0),a([(0,s.serialize)()],e.prototype,"highlightWidth",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceIntensity",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceEdgeIntensity",void 0),a([(0,s.serialize)()],e.prototype,"iridescenceTint",void 0),a([(0,s.serialize)()],e.prototype,"fadeOut",void 0),a([(0,s.serialize)()],e.prototype,"gradientColor",void 0),a([(0,s.serialize)()],e.prototype,"topLeftGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"topRightGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"bottomLeftGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"bottomRightGradientColor",void 0),a([(0,s.serialize)()],e.prototype,"edgeWidth",void 0),a([(0,s.serialize)()],e.prototype,"edgePower",void 0),a([(0,s.serialize)()],e.prototype,"edgeLineGradientBlend",void 0),e}(s.PushMaterial);(0,s.RegisterClass)("BABYLON.GUI.MRDLBackplateMaterial",Qt);var Vt=function(t){function e(e,i){var o=t.call(this,e)||this;return o.onValueChangedObservable=new s.Observable,o._sliderBackplateVisible=i||!1,o._minimum=0,o._maximum=100,o._step=0,o._value=50,o}return r(e,t),Object.defineProperty(e.prototype,"mesh",{get:function(){return this.node?this._sliderThumb:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minimum",{get:function(){return this._minimum},set:function(t){this._minimum!==t&&(this._minimum=Math.max(t,0),this._value=Math.max(Math.min(this._value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this._maximum},set:function(t){this._maximum!==t&&(this._maximum=Math.max(t,this._minimum),this._value=Math.max(Math.min(this._value,this._maximum),this._minimum))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"step",{get:function(){return this._step},set:function(t){this._step!==t&&(this._step=Math.max(Math.min(t,this._maximum-this._minimum),0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._value},set:function(t){this._value!==t&&(this._value=Math.max(Math.min(t,this._maximum),this._minimum),this._sliderThumb&&(this._sliderThumb.position.x=this._convertToPosition(this.value)),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"start",{get:function(){return this.node?this._sliderBar.position.x-this._sliderBar.scaling.x/2:-.5},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"end",{get:function(){return this.node?this._sliderBar.position.x+this._sliderBar.scaling.x/2:.5},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliderBarMaterial",{get:function(){return this._sliderBarMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliderThumbMaterial",{get:function(){return this._sliderThumbMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sliderBackplateMaterial",{get:function(){return this._sliderBackplateMaterial},enumerable:!1,configurable:!0}),e.prototype._createNode=function(t){var i=this,o=(0,s.CreateBox)("".concat(this.name,"_sliderbackplate"),{width:1,height:1,depth:1},t);return o.isPickable=!1,o.visibility=0,o.scaling=new s.Vector3(1,.5,.8),s.SceneLoader.ImportMeshAsync(void 0,e.MODEL_BASE_URL,e.MODEL_FILENAME,t).then((function(t){var e=t.meshes[1],n=t.meshes[1].clone("".concat(i.name,"_sliderbar"),o),r=t.meshes[1].clone("".concat(i.name,"_sliderthumb"),o);e.visibility=0,i._sliderBackplateVisible&&(e.visibility=1,e.name="".concat(i.name,"_sliderbackplate"),e.isPickable=!1,e.scaling.x=1,e.scaling.z=.2,e.parent=o,i._sliderBackplateMaterial&&(e.material=i._sliderBackplateMaterial),i._sliderBackplate=e),n&&(n.parent=o,n.position.z=-.1,n.scaling=new s.Vector3(.8,.04,.3),n.isPickable=!1,i._sliderBarMaterial&&(n.material=i._sliderBarMaterial),i._sliderBar=n),r&&(r.parent=o,r.isPickable=!0,r.position.z=-.115,r.scaling=new s.Vector3(.025,.3,.6),r.position.x=i._convertToPosition(i.value),r.addBehavior(i._createBehavior()),i._sliderThumbMaterial&&(r.material=i._sliderThumbMaterial),i._sliderThumb=r)})),this._affectMaterial(o),o},e.prototype._affectMaterial=function(t){var e,i,o;this._sliderBackplateMaterial=null!==(e=this._sliderBackplateMaterial)&&void 0!==e?e:new Qt("".concat(this.name,"_sliderbackplate_material"),t.getScene()),this._sliderBarMaterial=null!==(i=this._sliderBarMaterial)&&void 0!==i?i:new Nt("".concat(this.name,"_sliderbar_material"),t.getScene()),this._sliderThumbMaterial=null!==(o=this._sliderThumbMaterial)&&void 0!==o?o:new At("".concat(this.name,"_sliderthumb_material"),t.getScene())},e.prototype._createBehavior=function(){var t=this,e=new s.PointerDragBehavior({dragAxis:s.Vector3.Right()});return e.moveAttached=!1,e.onDragStartObservable.add((function(){t._draggedPosition=t._sliderThumb.position.x})),e.onDragObservable.add((function(e){t._draggedPosition+=e.dragDistance/t.scaling.x,t.value=t._convertToValue(t._draggedPosition)})),e},e.prototype._convertToPosition=function(t){var e=(t-this.minimum)/(this.maximum-this.minimum)*(this.end-this.start)+this.start;return Math.min(Math.max(e,this.start),this.end)},e.prototype._convertToValue=function(t){var e=(t-this.start)/(this.end-this.start)*(this.maximum-this.minimum);return e=this.step?Math.round(e/this.step)*this.step:e,Math.max(Math.min(this.minimum+e,this._maximum),this._minimum)},e.prototype.dispose=function(){var e,i,o,n,r,a;t.prototype.dispose.call(this),null===(e=this._sliderBar)||void 0===e||e.dispose(),null===(i=this._sliderThumb)||void 0===i||i.dispose(),null===(o=this._sliderBarMaterial)||void 0===o||o.dispose(),null===(n=this._sliderThumbMaterial)||void 0===n||n.dispose(),null===(r=this._sliderBackplate)||void 0===r||r.dispose(),null===(a=this._sliderBackplateMaterial)||void 0===a||a.dispose()},e.MODEL_BASE_URL="https://assets.babylonjs.com/meshes/MRTK/",e.MODEL_FILENAME="mrtk-fluent-backplate.glb",e}(rt),Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._radius=5,e}return r(e,t),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){var e=this;this._radius!==t&&(this._radius=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._mapGridNode=function(t,e){var i=t.mesh;if(i){var o=this._sphericalMapping(e);switch(t.position=o,this.orientation){case _t.FACEORIGIN_ORIENTATION:i.lookAt(new s.Vector3(2*o.x,2*o.y,2*o.z));break;case _t.FACEORIGINREVERSED_ORIENTATION:i.lookAt(new s.Vector3(-o.x,-o.y,-o.z));break;case _t.FACEFORWARD_ORIENTATION:break;case _t.FACEFORWARDREVERSED_ORIENTATION:i.rotate(s.Axis.Y,Math.PI,s.Space.LOCAL)}}},e.prototype._sphericalMapping=function(t){var e=new s.Vector3(0,0,this._radius),i=t.y/this._radius,o=-t.x/this._radius;return s.Matrix.RotationYawPitchRollToRef(o,i,0,s.TmpVectors.Matrix[0]),s.Vector3.TransformNormal(e,s.TmpVectors.Matrix[0])},e}(ht),Wt=function(t){function e(e){void 0===e&&(e=!1);var i=t.call(this)||this;return i._isVertical=!1,i.margin=.1,i._isVertical=e,i}return r(e,t),Object.defineProperty(e.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){var e=this;this._isVertical!==t&&(this._isVertical=t,s.Tools.SetImmediate((function(){e._arrangeChildren()})))},enumerable:!1,configurable:!0}),e.prototype._arrangeChildren=function(){for(var t,e=0,i=0,o=0,n=[],r=s.Matrix.Invert(this.node.computeWorldMatrix(!0)),a=0,l=this._children;a<l.length;a++)if((f=l[a]).mesh){o++,f.mesh.computeWorldMatrix(!0),f.mesh.getWorldMatrix().multiplyToRef(r,s.TmpVectors.Matrix[0]);var _=f.mesh.getBoundingInfo().boundingBox,h=s.Vector3.TransformNormal(_.extendSize,s.TmpVectors.Matrix[0]);n.push(h),this._isVertical?i+=h.y:e+=h.x}this._isVertical?i+=(o-1)*this.margin/2:e+=(o-1)*this.margin/2,t=this._isVertical?-i:-e;for(var c=0,u=0,d=this._children;u<d.length;u++){var f;(f=d[u]).mesh&&(o--,h=n[c++],this._isVertical?(f.position.y=t+h.y,f.position.x=0,t+=2*h.y):(f.position.x=t+h.x,f.position.y=0,t+=2*h.x),t+=o>0?this.margin:0)}},e}(_t),Gt=function(t){function e(e,i){var o=t.call(this,i,e)||this;return o._currentMesh=e,o.pointerEnterAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1.1)},o.pointerOutAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1/1.1)},o.pointerDownAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(.95)},o.pointerUpAnimation=function(){o.mesh&&o.mesh.scaling.scaleInPlace(1/.95)},o}return r(e,t),e.prototype._getTypeName=function(){return"TouchMeshButton3D"},e.prototype._createNode=function(){var t=this;return this._currentMesh.getChildMeshes().forEach((function(e){t._injectGUI3DReservedDataStore(e).control=t})),this._currentMesh},e.prototype._affectMaterial=function(t){},e}(mt),Ut=function(t){function e(e,i){void 0===i&&(i=!0);var o=t.call(this,e)||this;return o._shareMaterials=i,o}return r(e,t),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._model.renderingGroupId},set:function(t){this._model.renderingGroupId=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shareMaterials",{get:function(){return this._shareMaterials},enumerable:!1,configurable:!0}),e.prototype._getTypeName=function(){return"HolographicBackplate"},e.prototype._createNode=function(t){var i,o=this,n=(0,s.CreateBox)((null!==(i=this.name)&&void 0!==i?i:"HolographicBackplate")+"_CollisionMesh",{width:1,height:1,depth:1},t);return n.isPickable=!0,n.visibility=0,s.SceneLoader.ImportMeshAsync(void 0,e.MODEL_BASE_URL,e.MODEL_FILENAME,t).then((function(t){var e=t.meshes[1];e.name="".concat(o.name,"_frontPlate"),e.isPickable=!1,e.parent=n,o._material&&(e.material=o._material),o._model=e})),n},e.prototype._createMaterial=function(t){this._material=new It(this.name+" Material",t.getScene())},e.prototype._affectMaterial=function(t){this._shareMaterials?this._host._touchSharedMaterials.fluentBackplateMaterial?this._material=this._host._touchSharedMaterials.fluentBackplateMaterial:(this._createMaterial(t),this._host._touchSharedMaterials.fluentBackplateMaterial=this._material):this._createMaterial(t)},e.prototype.dispose=function(){t.prototype.dispose.call(this),this.shareMaterials||this._material.dispose(),this._model.dispose()},e.MODEL_BASE_URL="https://assets.babylonjs.com/meshes/MRTK/",e.MODEL_FILENAME="mrtk-fluent-backplate.glb",e}(rt),jt=function(){function t(t){var e=this;this._customControlScaling=1,this._lastControlOver={},this._lastControlDown={},this.onPickedPointChangedObservable=new s.Observable,this.onPickingObservable=new s.Observable,this._sharedMaterials={},this._touchSharedMaterials={},this._scene=t||s.EngineStore.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add((function(){e._sceneDisposeObserver=null,e._utilityLayer=null,e.dispose()})),this._utilityLayer=s.UtilityLayerRenderer._CreateDefaultUtilityLayerFromScene(this._scene),this._utilityLayer.onlyCheckPointerDownEvents=!1,this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.mainSceneTrackerPredicate=function(t){var e,i,o;return t&&(null===(o=null===(i=null===(e=t.reservedDataStore)||void 0===e?void 0:e.GUI3D)||void 0===i?void 0:i.control)||void 0===o?void 0:o._node)},this._rootContainer=new _t("RootContainer"),this._rootContainer._host=this;var i=this._utilityLayer.utilityLayerScene;this._pointerOutObserver=this._utilityLayer.onPointerOutObservable.add((function(t){e._handlePointerOut(t,!0)})),this._pointerObserver=i.onPointerObservable.add((function(t){e._doPicking(t)})),this._utilityLayer.utilityLayerScene.autoClear=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,new s.HemisphericLight("hemi",s.Vector3.Up(),this._utilityLayer.utilityLayerScene)}return Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"controlScaling",{get:function(){return this._customControlScaling},set:function(t){if(this._customControlScaling!==t&&t>0){var e=t/this._customControlScaling;this._customControlScaling=t,this._rootContainer.children.forEach((function(i){i.scaling.scaleInPlace(e),1!==t&&(i._isScaledByManager=!0)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useRealisticScaling",{get:function(){return this.controlScaling===t.MRTK_REALISTIC_SCALING},set:function(e){this.controlScaling=e?t.MRTK_REALISTIC_SCALING:1},enumerable:!1,configurable:!0}),t.prototype._handlePointerOut=function(t,e){var i=this._lastControlOver[t];i&&(i._onPointerOut(i),delete this._lastControlOver[t]),e&&this._lastControlDown[t]&&(this._lastControlDown[t].forcePointerUp(),delete this._lastControlDown[t]),this.onPickedPointChangedObservable.notifyObservers(null)},t.prototype._doPicking=function(t){var e,i,o;if(!this._utilityLayer||!this._utilityLayer.shouldRender||!this._utilityLayer.utilityLayerScene.activeCamera)return!1;var n=t.event,r=n.pointerId||0,a=n.button,l=t.pickInfo;if(l&&this.onPickingObservable.notifyObservers(l.pickedMesh),!l||!l.hit)return this._handlePointerOut(r,t.type===s.PointerEventTypes.POINTERUP),!1;l.pickedPoint&&this.onPickedPointChangedObservable.notifyObservers(l.pickedPoint);var _=null===(i=null===(e=l.pickedMesh.reservedDataStore)||void 0===e?void 0:e.GUI3D)||void 0===i?void 0:i.control;return _&&!_._processObservables(t.type,l.pickedPoint,(null===(o=l.originMesh)||void 0===o?void 0:o.position)||null,r,a)&&t.type===s.PointerEventTypes.POINTERMOVE&&(this._lastControlOver[r]&&this._lastControlOver[r]._onPointerOut(this._lastControlOver[r]),delete this._lastControlOver[r]),t.type===s.PointerEventTypes.POINTERUP&&(this._lastControlDown[n.pointerId]&&(this._lastControlDown[n.pointerId].forcePointerUp(),delete this._lastControlDown[n.pointerId]),"touch"===n.pointerType&&this._handlePointerOut(r,!1)),!0},Object.defineProperty(t.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!1,configurable:!0}),t.prototype.containsControl=function(t){return this._rootContainer.containsControl(t)},t.prototype.addControl=function(t){return this._rootContainer.addControl(t),1!==this._customControlScaling&&(t.scaling.scaleInPlace(this._customControlScaling),t._isScaledByManager=!0),this},t.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),t._isScaledByManager&&(t.scaling.scaleInPlace(1/this._customControlScaling),t._isScaledByManager=!1),this},t.prototype.dispose=function(){for(var t in this._rootContainer.dispose(),this._sharedMaterials)Object.prototype.hasOwnProperty.call(this._sharedMaterials,t)&&this._sharedMaterials[t].dispose();for(var t in this._sharedMaterials={},this._touchSharedMaterials)Object.prototype.hasOwnProperty.call(this._touchSharedMaterials,t)&&this._touchSharedMaterials[t].dispose();this._touchSharedMaterials={},this._pointerOutObserver&&this._utilityLayer&&(this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver),this._pointerOutObserver=null),this.onPickedPointChangedObservable.clear(),this.onPickingObservable.clear();var e=this._utilityLayer?this._utilityLayer.utilityLayerScene:null;e&&this._pointerObserver&&(e.onPointerObservable.remove(this._pointerObserver),this._pointerObserver=null),this._scene&&this._sceneDisposeObserver&&(this._scene.onDisposeObservable.remove(this._sceneDisposeObserver),this._sceneDisposeObserver=null),this._utilityLayer&&this._utilityLayer.dispose()},t.MRTK_REALISTIC_SCALING=.032,t}(),Xt=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;void 0!==Xt&&(Xt.BABYLON=Xt.BABYLON||{},Xt.BABYLON.GUI=t);const Yt=e})(),n.default})()}));
7
+ //# sourceMappingURL=babylon.gui.min.js.map