!(function(t,e){var i=[],r=t.BABYLON||this.BABYLON;"object"==typeof exports&&"object"==typeof module?(r=r||require("babylonjs"),module.exports=e(r)):"function"==typeof define&&define.amd?(i.push("babylonjs"),define("babylonjs-gui",i,e)):"object"==typeof exports?(r=r||require("babylonjs"),exports["babylonjs-gui"]=e(r)):t.BABYLON.GUI=e(r)})(this,(function(t){t=t||this.BABYLON;var e=this&&this.__decorate||function(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 h=t.length-1;h>=0;h--)(n=t[h])&&(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},i=this&&this.__extends||(function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function r(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}})();t.Effect.ShadersStore.fluentVertexShader="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",t.Effect.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\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\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}";var t;!(function(t){!(function(e){var i=(function(){function i(i){this._fontFamily="Arial",this._fontStyle="",this._fontWeight="",this._fontSize=new e.ValueAndUnit(18,e.ValueAndUnit.UNITMODE_PIXEL,!1),this.onChangedObservable=new t.Observable,this._host=i}return Object.defineProperty(i.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:!0,configurable:!0}),Object.defineProperty(i.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this.onChangedObservable.notifyObservers(this))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fontStyle",{get:function(){return this._fontStyle},set:function(t){this._fontStyle!==t&&(this._fontStyle=t,this.onChangedObservable.notifyObservers(this))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(t){this._fontWeight!==t&&(this._fontWeight=t,this.onChangedObservable.notifyObservers(this))},enumerable:!0,configurable:!0}),i.prototype.dispose=function(){this.onChangedObservable.clear()},i})();e.Style=i})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(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}return Object.defineProperty(t.prototype,"isPercentage",{get:function(){return this.unit===t.UNITMODE_PERCENTAGE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isPixel",{get:function(){return this.unit===t.UNITMODE_PIXEL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"internalValue",{get:function(){return this._value},enumerable:!0,configurable:!0}),t.prototype.getValueInPixel=function(t,e){return this.isPixel?this.getValue(t):this.getValue(t)*e},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.innerWidth1?s.notRenderable=!0:(s.notRenderable=!1,l.scaleInPlace(this.renderScale),s._moveToProjectedPosition(l))}else t.Tools.SetImmediate((function(){s.linkWithMesh(null)}))}}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update(!0,this.premulAlpha))}},n.prototype._render=function(){var t=this.getSize(),i=t.width,r=t.height,n=this.getContext();n.clearRect(0,0,i,r),this._background&&(n.save(),n.fillStyle=this._background,n.fillRect(0,0,i,r),n.restore()),n.font="18px Arial",n.strokeStyle="white";var o=new e.Measure(0,0,i,r);this._rootContainer._draw(o,n)},n.prototype._doPicking=function(e,i,r,n,o){var s=this.getScene();if(s){var h=s.getEngine(),a=this.getSize();if(this._isFullscreen&&(e*=a.width/h.getRenderWidth(),i*=a.height/h.getRenderHeight()),this._capturingControl[n])return void this._capturingControl[n]._processObservables(r,e,i,n,o);this._rootContainer._processPicking(e,i,r,n,o)||r===t.PointerEventTypes.POINTERMOVE&&(this._lastControlOver[n]&&this._lastControlOver[n]._onPointerOut(this._lastControlOver[n]),delete this._lastControlOver[n]),this._manageFocus()}},n.prototype._cleanControlAfterRemovalFromList=function(t,e){for(var i in t)if(t.hasOwnProperty(i)){var r=t[i];r===e&&delete t[i]}},n.prototype._cleanControlAfterRemoval=function(t){this._cleanControlAfterRemovalFromList(this._lastControlDown,t),this._cleanControlAfterRemovalFromList(this._lastControlOver,t)},n.prototype.attach=function(){var e=this,i=this.getScene();i&&(this._pointerMoveObserver=i.onPrePointerObservable.add((function(r,n){if(!i.isPointerCaptured(r.event.pointerId)&&(r.type===t.PointerEventTypes.POINTERMOVE||r.type===t.PointerEventTypes.POINTERUP||r.type===t.PointerEventTypes.POINTERDOWN)&&i){var o=i.cameraToUseForPointers||i.activeCamera;if(o){var s=i.getEngine(),h=o.viewport,a=(i.pointerX/s.getHardwareScalingLevel()-h.x*s.getRenderWidth())/h.width,l=(i.pointerY/s.getHardwareScalingLevel()-h.y*s.getRenderHeight())/h.height;e._shouldBlockPointer=!1,e._doPicking(a,l,r.type,r.event.pointerId||0,r.event.button),r.skipOnPointerObservable=e._shouldBlockPointer}}})),this._attachToOnPointerOut(i))},n.prototype.attachToMesh=function(e,i){var r=this;void 0===i&&(i=!0);var n=this.getScene();n&&(this._pointerObserver=n.onPointerObservable.add((function(i,n){if(i.type===t.PointerEventTypes.POINTERMOVE||i.type===t.PointerEventTypes.POINTERUP||i.type===t.PointerEventTypes.POINTERDOWN){var o=i.event.pointerId||0;if(i.pickInfo&&i.pickInfo.hit&&i.pickInfo.pickedMesh===e){var s=i.pickInfo.getTextureCoordinates();if(s){var h=r.getSize();r._doPicking(s.x*h.width,(1-s.y)*h.height,i.type,o,i.event.button)}}else i.type===t.PointerEventTypes.POINTERUP?(r._lastControlDown[o]&&r._lastControlDown[o]._forcePointerUp(o),delete r._lastControlDown[o],r.focusedControl=null):i.type===t.PointerEventTypes.POINTERMOVE&&(r._lastControlOver[o]&&r._lastControlOver[o]._onPointerOut(r._lastControlOver[o]),delete r._lastControlOver[o])}})),e.enablePointerMoveEvents=i,this._attachToOnPointerOut(n))},n.prototype.moveFocusToControl=function(t){this.focusedControl=t,this._lastPickedControl=t,this._blockNextFocusCheck=!0},n.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}},n.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]),delete e._lastControlOver[t.pointerId],e._lastControlDown[t.pointerId]&&e._lastControlDown[t.pointerId]._forcePointerUp(),delete e._lastControlDown[t.pointerId]}))},n.CreateForMesh=function(e,i,r,o){void 0===i&&(i=1024),void 0===r&&(r=1024),void 0===o&&(o=!0);var s=new n(e.name+" AdvancedDynamicTexture",i,r,e.getScene(),!0,t.Texture.TRILINEAR_SAMPLINGMODE),h=new t.StandardMaterial("AdvancedDynamicTextureMaterial",e.getScene());return h.backFaceCulling=!1,h.diffuseColor=t.Color3.Black(),h.specularColor=t.Color3.Black(),h.emissiveTexture=s,h.opacityTexture=s,e.material=h,s.attachToMesh(e,o),s},n.CreateFullscreenUI=function(e,i,r,o){void 0===i&&(i=!0),void 0===r&&(r=null),void 0===o&&(o=t.Texture.BILINEAR_SAMPLINGMODE);var s=new n(e,0,0,r,!1,o),h=new t.Layer(e+"_layer",null,r,!i);return h.texture=s,s._layerToDispose=h,s._isFullscreen=!0,s.attach(),s},n})(t.DynamicTexture);e.AdvancedDynamicTexture=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(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.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})();t.Measure=e})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(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 i(e,t),e})(t.Vector2);e.Vector2WithInfo=r;var n=(function(){function e(t,e,i,r,n,o){this.m=new Float32Array(6),this.fromValues(t,e,i,r,n,o)}return e.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},e.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},e.prototype.invertToRef=function(e){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],s=this.m[4],h=this.m[5],a=this.determinant();if(a1)return void(this.notRenderable=!0);this.notRenderable=!1},i.prototype.linkWithMesh=function(e){if(!this._host||this._root&&this._root!==this._host._rootContainer)return void(e&&t.Tools.Error("Cannot link a control to a mesh if the control is not at root level"));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.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._onlyMeasureMode=!0,this._host._linkedControls.push(this))},i.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},i.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._markAsDirty()},i.prototype._markAsDirty=function(){this._isDirty=!0,this._host&&this._host.markAsDirty()},i.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},i.prototype._link=function(t,e){this._root=t,this._host=e},i.prototype._transform=function(t){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var i=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,r=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;t.translate(i,r),t.rotate(this._rotation),t.scale(this._scaleX,this._scaleY),t.translate(-i,-r),(this._isMatrixDirty||this._cachedOffsetX!==i||this._cachedOffsetY!==r)&&(this._cachedOffsetX=i,this._cachedOffsetY=r,this._isMatrixDirty=!1,e.Matrix2D.ComposeToRef(-i,-r,this._rotation,this._scaleX,this._scaleY,this._root?this._root._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},i.prototype._applyStates=function(t){this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),this._alphaSet&&(t.globalAlpha=this._alpha)},i.prototype._processMeasures=function(t,e){return!this._isDirty&&this._cachedParentMeasure.isEqualsTo(t)||(this._isDirty=!1,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)),!(this._currentMeasure.left>t.left+t.width)&&(!(this._currentMeasure.left+this._currentMeasure.widtht.top+t.height)&&(!(this._currentMeasure.top+this._currentMeasure.heightthis._currentMeasure.left+this._currentMeasure.width)&&(!(ethis._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},i.prototype._processPicking=function(t,e,i,r,n){return!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(t,e)&&(this._processObservables(i,t,e,r,n),!0))},i.prototype._onPointerMove=function(t,e){this.onPointerMoveObservable.notifyObservers(e,-1,t,this)&&null!=this.parent&&this.parent._onPointerMove(t,e)},i.prototype._onPointerEnter=function(t){return!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this)&&null!=this.parent&&this.parent._onPointerEnter(t),!0)},i.prototype._onPointerOut=function(t){this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this)&&null!=this.parent&&this.parent._onPointerOut(t)},i.prototype._onPointerDown=function(t,i,r,n){return 0===this._downCount&&(this._downCount++,this._downPointerIds[r]=!0,this.onPointerDownObservable.notifyObservers(new e.Vector2WithInfo(i,n),-1,t,this)&&null!=this.parent&&this.parent._onPointerDown(t,i,r,n),!0)},i.prototype._onPointerUp=function(t,i,r,n,o){this._downCount=0,delete this._downPointerIds[r];var s=o;o&&(this._enterCount>0||-1===this._enterCount)&&(s=this.onPointerClickObservable.notifyObservers(new e.Vector2WithInfo(i,n),-1,t,this)),this.onPointerUpObservable.notifyObservers(new e.Vector2WithInfo(i,n),-1,t,this)&&null!=this.parent&&this.parent._onPointerUp(t,i,r,n,s)},i.prototype._forcePointerUp=function(e){if(void 0===e&&(e=null),null!==e)this._onPointerUp(this,t.Vector2.Zero(),e,0,!0);else for(var i in this._downPointerIds)this._onPointerUp(this,t.Vector2.Zero(),+i,0,!0)},i.prototype._processObservables=function(e,i,r,n,o){if(this._dummyVector2.copyFromFloats(i,r),e===t.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,this._dummyVector2);var s=this._host._lastControlOver[n];return s&&s!==this&&s._onPointerOut(this),s!==this&&this._onPointerEnter(this),this._host._lastControlOver[n]=this,!0}return e===t.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,n,o),this._host._lastControlDown[n]=this,this._host._lastPickedControl=this,!0):e===t.PointerEventTypes.POINTERUP&&(this._host._lastControlDown[n]&&this._host._lastControlDown[n]._onPointerUp(this,this._dummyVector2,n,o,!0),delete this._host._lastControlDown[n],!0)},i.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=(this._style.fontWeight?this._style.fontWeight:this._style.fontStyle)+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=(this._fontWeight?this._fontWeight:this._fontStyle)+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=i._GetFontOffset(this._font))},i.prototype.dispose=function(){this.onDirtyObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this._root&&(this._root.removeControl(this),this._root=null),this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null)},Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return i._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return i._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return i._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_TOP",{get:function(){return i._VERTICAL_ALIGNMENT_TOP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return i._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return i._VERTICAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),i._GetFontOffset=function(t){if(i._FontHeightSizes[t])return i._FontHeightSizes[t];var e=document.createElement("span");e.innerHTML="Hg",e.style.font=t;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.appendChild(e),n.appendChild(r),document.body.appendChild(n);var o=0,s=0;try{s=r.getBoundingClientRect().top-e.getBoundingClientRect().top,r.style.verticalAlign="baseline",o=r.getBoundingClientRect().top-e.getBoundingClientRect().top}finally{document.body.removeChild(n)}var h={ascent:o,height:s,descent:s-o};return i._FontHeightSizes[t]=h,h},i.AddHeader=function(e,r,n,o){var s=new t.GUI.StackPanel("panel"),h=!o||o.isHorizontal,a=!o||o.controlFirst;s.isVertical=!h;var l=new t.GUI.TextBlock("header");return l.text=r,l.textHorizontalAlignment=i.HORIZONTAL_ALIGNMENT_LEFT,h?l.width=n:l.height=n,a?(s.addControl(e),s.addControl(l),l.paddingLeft="5px"):(s.addControl(l),s.addControl(e),l.paddingRight="5px"),l.shadowBlur=e.shadowBlur,l.shadowColor=e.shadowColor,l.shadowOffsetX=e.shadowOffsetX,l.shadowOffsetY=e.shadowOffsetY,s},i.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)},i._HORIZONTAL_ALIGNMENT_LEFT=0,i._HORIZONTAL_ALIGNMENT_RIGHT=1,i._HORIZONTAL_ALIGNMENT_CENTER=2,i._VERTICAL_ALIGNMENT_TOP=0,i._VERTICAL_ALIGNMENT_BOTTOM=1,i._VERTICAL_ALIGNMENT_CENTER=2,i._FontHeightSizes={},i})();e.Control=i})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(function(e){function r(i){var r=e.call(this,i)||this;return r.name=i,r._children=new Array,r._measureForChildren=t.Measure.Empty(),r._adaptWidthToChildren=!1,r._adaptHeightToChildren=!1,r}return i(r,e),Object.defineProperty(r.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(t){this._adaptHeightToChildren!==t&&(this._adaptHeightToChildren=t,t&&(this.height="100%"),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(t){this._adaptWidthToChildren!==t&&(this._adaptWidthToChildren=t,t&&(this.width="100%"),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"Container"},r.prototype.getChildByName=function(t){for(var e=0,i=this.children;et.zIndex)return void this._children.splice(e,0,t);this._children.push(t),t.parent=this,this._markAsDirty()},r.prototype._markMatrixAsDirty=function(){e.prototype._markMatrixAsDirty.call(this);for(var t=0;t=0&&(this.width=i+"px"),this.adaptHeightToChildren&&r>=0&&(this.height=r+"px")}e.restore(),this.onAfterDrawObservable.hasObservers()&&this.onAfterDrawObservable.notifyObservers(this)}},r.prototype._processPicking=function(t,i,r,n,o){if(!this.isVisible||this.notRenderable)return!1;if(!e.prototype.contains.call(this,t,i))return!1;for(var s=this._children.length-1;s>=0;s--){if(this._children[s]._processPicking(t,i,r,n,o))return!0}return!!this.isHitTestVisible&&this._processObservables(r,t,i,n,o)},r.prototype._clipForChildren=function(t){},r.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(this._currentMeasure)},r.prototype.dispose=function(){e.prototype.dispose.call(this);for(var t=0,i=this._children;tn&&(n=a._currentMeasure.width),a.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP):(a.left=n+"px",a._left.ignoreAdaptiveScaling||a._markAsDirty(),a._left.ignoreAdaptiveScaling=!0,n+=a._currentMeasure.width,a._currentMeasure.height>o&&(o=a._currentMeasure.height),a.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT),a._currentMeasure.copyFrom(this._tempMeasureStore)}this._doNotTrackManualChanges=!0;var l=!1,u=!1,c=this.height,_=this.width;this._manualHeight||(this.height=o+"px"),this._manualWidth||(this.width=n+"px"),l=_!==this.width||!this._width.ignoreAdaptiveScaling,u=c!==this.height||!this._height.ignoreAdaptiveScaling,u&&(this._height.ignoreAdaptiveScaling=!0),l&&(this._width.ignoreAdaptiveScaling=!0),this._doNotTrackManualChanges=!1,(l||u)&&this._markAllAsDirty(),r.prototype._preMeasure.call(this,e,i)},n})(e.Container);e.StackPanel=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(function(t){function e(e){var i=t.call(this,e)||this;return i.name=e,i._thickness=1,i._cornerRadius=0,i}return i(e,t),Object.defineProperty(e.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,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:!0,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})(t.Container);t.Rectangle=e})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(function(e){function r(t){var i=e.call(this,t)||this;return i.name=t,i._thickness=1,i}return i(r,e),Object.defineProperty(r.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"Ellipse"},r.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),t.Control.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),this._background&&(e.fillStyle=this._background,e.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.stroke()),e.restore()},r.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},r.prototype._clipForChildren=function(e){t.Control.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,e),e.clip()},r})(t.Container);t.Ellipse=e})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(r){function n(t){var i=r.call(this,t)||this;return i.name=t,i._lineWidth=1,i._x1=new e.ValueAndUnit(0),i._y1=new e.ValueAndUnit(0),i._x2=new e.ValueAndUnit(0),i._y2=new e.ValueAndUnit(0),i._dash=new Array,i.isHitTestVisible=!1,i._horizontalAlignment=e.Control.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=e.Control.VERTICAL_ALIGNMENT_TOP,i}return i(n,r),Object.defineProperty(n.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"horizontalAlignment",{set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"verticalAlignment",{set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!0,configurable:!0}),n.prototype._getTypeName=function(){return"Line"},n.prototype._draw=function(t,e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),this._processMeasures(t,e)&&(e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath(),e.moveTo(this._x1.getValue(this._host),this._y1.getValue(this._host)),e.lineTo(this._effectiveX2,this._effectiveY2),e.stroke()),e.restore()},n.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},n.prototype._computeAlignment=function(t,e){this._currentMeasure.left=Math.min(this._x1.getValue(this._host),this._effectiveX2)-this._lineWidth/2,this._currentMeasure.top=Math.min(this._y1.getValue(this._host),this._effectiveY2)-this._lineWidth/2},n.prototype.moveToVector3=function(e,i,r){if(void 0===r&&(r=!1),!this._host||this._root!==this._host._rootContainer)return void t.Tools.Error("Cannot move a control to a vector3 if the control is not at root level");var n=this._host._getGlobalViewport(i),o=t.Vector3.Project(e,t.Matrix.Identity(),i.getTransformMatrix(),n);if(this._moveToProjectedPosition(o,r),o.z<0||o.z>1)return void(this.notRenderable=!0);this.notRenderable=!1},n.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)},n})(e.Control);e.Line=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(r){function n(i){var n=r.call(this,i)||this;return n.name=i,n._thumbWidth=new e.ValueAndUnit(20,e.ValueAndUnit.UNITMODE_PIXEL,!1),n._minimum=0,n._maximum=100,n._value=50,n._isVertical=!1,n._background="black",n._borderColor="white",n._barOffset=new e.ValueAndUnit(5,e.ValueAndUnit.UNITMODE_PIXEL,!1),n._isThumbCircle=!1,n._isThumbClamped=!1,n.onValueChangedObservable=new t.Observable,n._pointerIsDown=!1,n.isPointerBlocker=!0,n}return i(n,r),Object.defineProperty(n.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isThumbCircle",{get:function(){return this._isThumbCircle},set:function(t){this._isThumbCircle!==t&&(this._isThumbCircle=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(t){this._isThumbClamped!==t&&(this._isThumbClamped=t,this._markAsDirty())},enumerable:!0,configurable:!0}),n.prototype._getTypeName=function(){return"Slider"},n.prototype._getThumbThickness=function(t,e){var i=0;switch(t){case"circle":i=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),e):e*this._thumbWidth.getValue(this._host);break;case"rectangle":i=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),e):e*this._thumbWidth.getValue(this._host)}return i},n.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i=0,r=this.isThumbCircle?"circle":"rectangle",n=this._currentMeasure.left,o=this._currentMeasure.top,s=this._currentMeasure.width,h=this._currentMeasure.height,a=Math.max(this._currentMeasure.width,this._currentMeasure.height),l=Math.min(this._currentMeasure.width,this._currentMeasure.height),u=this._getThumbThickness(r,l);a-=u;var c=0;if(this._isVertical&&this._currentMeasure.height0?t+" "+i[o]:i[0],h=e.measureText(s),a=h.width;a>r&&o>0?(this._lines.push({text:t,width:n}),t=i[o],n=e.measureText(t).width):(n=a,t=s)}return{text:t,width:n}},n.prototype._renderLines=function(t){var i=this._currentMeasure.height;this._fontOffset||(this._fontOffset=e.Control._GetFontOffset(t.font));var r=0;switch(this._textVerticalAlignment){case e.Control.VERTICAL_ALIGNMENT_TOP:r=this._fontOffset.ascent;break;case e.Control.VERTICAL_ALIGNMENT_BOTTOM:r=i-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case e.Control.VERTICAL_ALIGNMENT_CENTER:r=this._fontOffset.ascent+(i-this._fontOffset.height*this._lines.length)/2}r+=this._currentMeasure.top;for(var n=0,o=0;on&&(n=s.width)}this._resizeToFit&&(this.width=this.paddingLeftInPixels+this.paddingRightInPixels+n+"px",this.height=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length+"px")},n.prototype.dispose=function(){r.prototype.dispose.call(this),this.onTextChangedObservable.clear()},n})(e.Control);e.TextBlock=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t,r=Image;!(function(t){!(function(e){var n=(function(e){function n(t,i){void 0===i&&(i=null);var r=e.call(this,t)||this;return r.name=t,r._loaded=!1,r._stretch=n.STRETCH_FILL,r._autoScale=!1,r._sourceLeft=0,r._sourceTop=0,r._sourceWidth=0,r._sourceHeight=0,r._cellWidth=0,r._cellHeight=0,r._cellId=-1,r.source=i,r}return i(n,e),Object.defineProperty(n.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(t){this._sourceLeft!==t&&(this._sourceLeft=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(t){this._sourceTop!==t&&(this._sourceTop=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(t){this._sourceWidth!==t&&(this._sourceWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(t){this._sourceHeight!==t&&(this._sourceHeight=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoScale",{get:function(){return this._autoScale},set:function(t){this._autoScale!==t&&(this._autoScale=t,t&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"stretch",{get:function(){return this._stretch},set:function(t){this._stretch!==t&&(this._stretch=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"domImage",{get:function(){return this._domImage},set:function(t){var e=this;this._domImage=t,this._loaded=!1,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){e._onImageLoaded()}},enumerable:!0,configurable:!0}),n.prototype._onImageLoaded=function(){this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._autoScale&&this.synchronizeSizeWithContent(),this._markAsDirty()},Object.defineProperty(n.prototype,"source",{set:function(e){var i=this;this._source!==e&&(this._loaded=!1,this._source=e,this._domImage=new r,this._domImage.onload=function(){i._onImageLoaded()},e&&(t.Tools.SetCorsBehavior(e,this._domImage),this._domImage.src=e))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(t){this._cellWidth!==t&&(this._cellWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(t){this._cellHeight!==t&&(this._cellHeight=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cellId",{get:function(){return this._cellId},set:function(t){this._cellId!==t&&(this._cellId=t,this._markAsDirty())},enumerable:!0,configurable:!0}),n.prototype._getTypeName=function(){return"Image"},n.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},n.prototype._draw=function(t,e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY);var i,r,o,s;if(-1==this.cellId)i=this._sourceLeft,r=this._sourceTop,o=this._sourceWidth?this._sourceWidth:this._imageWidth,s=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var h=this._domImage.naturalWidth/this.cellWidth,a=this.cellId/h>>0,l=this.cellId%h;i=this.cellWidth*l,r=this.cellHeight*a,o=this.cellWidth,s=this.cellHeight}if(this._applyStates(e),this._processMeasures(t,e)&&this._loaded)switch(this._stretch){case n.STRETCH_NONE:case n.STRETCH_FILL:e.drawImage(this._domImage,i,r,o,s,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case n.STRETCH_UNIFORM:var u=this._currentMeasure.width/o,c=this._currentMeasure.height/s,_=Math.min(u,c),f=(this._currentMeasure.width-o*_)/2,d=(this._currentMeasure.height-s*_)/2;e.drawImage(this._domImage,i,r,o,s,this._currentMeasure.left+f,this._currentMeasure.top+d,o*_,s*_);break;case n.STRETCH_EXTEND:e.drawImage(this._domImage,i,r,o,s,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),this._autoScale&&this.synchronizeSizeWithContent(),this._root&&this._root.parent&&(this._root.width=this.width,this._root.height=this.height)}e.restore()},Object.defineProperty(n,"STRETCH_NONE",{get:function(){return n._STRETCH_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"STRETCH_FILL",{get:function(){return n._STRETCH_FILL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"STRETCH_UNIFORM",{get:function(){return n._STRETCH_UNIFORM},enumerable:!0,configurable:!0}),Object.defineProperty(n,"STRETCH_EXTEND",{get:function(){return n._STRETCH_EXTEND},enumerable:!0,configurable:!0}),n._STRETCH_NONE=0,n._STRETCH_FILL=1,n._STRETCH_UNIFORM=2,n._STRETCH_EXTEND=3,n})(e.Control);e.Image=n})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(e){function r(t){var i=e.call(this,t)||this;return i.name=t,i.thickness=1,i.isPointerBlocker=!0,i.pointerEnterAnimation=function(){i.alpha-=.1},i.pointerOutAnimation=function(){i.alpha+=.1},i.pointerDownAnimation=function(){i.scaleX-=.05,i.scaleY-=.05},i.pointerUpAnimation=function(){i.scaleX+=.05,i.scaleY+=.05},i}return i(r,e),r.prototype._getTypeName=function(){return"Button"},r.prototype._processPicking=function(t,i,r,n,o){return!(!this.isHitTestVisible||!this.isVisible||this.notRenderable)&&(!!e.prototype.contains.call(this,t,i)&&(this._processObservables(r,t,i,n,o),!0))},r.prototype._onPointerEnter=function(t){return!!e.prototype._onPointerEnter.call(this,t)&&(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},r.prototype._onPointerOut=function(t){this.pointerOutAnimation&&this.pointerOutAnimation(),e.prototype._onPointerOut.call(this,t)},r.prototype._onPointerDown=function(t,i,r,n){return!!e.prototype._onPointerDown.call(this,t,i,r,n)&&(this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},r.prototype._onPointerUp=function(t,i,r,n,o){this.pointerUpAnimation&&this.pointerUpAnimation(),e.prototype._onPointerUp.call(this,t,i,r,n,o)},r.CreateImageButton=function(e,i,n){var o=new r(e),s=new t.GUI.TextBlock(e+"_button",i);s.textWrapping=!0,s.textHorizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER,s.paddingLeft="20%",o.addControl(s);var h=new t.GUI.Image(e+"_icon",n);return h.width="20%",h.stretch=t.GUI.Image.STRETCH_UNIFORM,h.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,o.addControl(h),o},r.CreateImageOnlyButton=function(e,i){var n=new r(e),o=new t.GUI.Image(e+"_icon",i);return o.stretch=t.GUI.Image.STRETCH_FILL,o.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,n.addControl(o),n},r.CreateSimpleButton=function(e,i){var n=new r(e),o=new t.GUI.TextBlock(e+"_button",i);return o.textWrapping=!0,o.textHorizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER,n.addControl(o),n},r.CreateImageWithCenterTextButton=function(e,i,n){var o=new r(e),s=new t.GUI.Image(e+"_icon",n);s.stretch=t.GUI.Image.STRETCH_FILL,o.addControl(s);var h=new t.GUI.TextBlock(e+"_button",i);return h.textWrapping=!0,h.textHorizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER,o.addControl(h),o},r})(e.Rectangle);e.Button=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(e){function r(i){var r=e.call(this,i)||this;return r.name=i,r._value=t.Color3.Red(),r._tmpColor=new t.Color3,r._pointerStartedOnSquare=!1,r._pointerStartedOnWheel=!1,r._squareLeft=0,r._squareTop=0,r._squareSize=0,r._h=360,r._s=1,r._v=1,r.onValueChangedObservable=new t.Observable,r._pointerIsDown=!1,r.value=new t.Color3(.88,.1,.1),r.size="200px",r.isPointerBlocker=!0,r}return i(r,e),Object.defineProperty(r.prototype,"value",{get:function(){return this._value},set:function(t){this._value.equals(t)||(this._value.copyFrom(t),this._RGBtoHSV(this._value,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.onValueChangedObservable.notifyObservers(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{set:function(t){this._width.toString(this._host)!==t&&this._width.fromString(t)&&(this._height.fromString(t),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{set:function(t){this._height.toString(this._host)!==t&&this._height.fromString(t)&&(this._width.fromString(t),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this.width},set:function(t){this.width=t},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"ColorPicker"},r.prototype._updateSquareProps=function(){var t=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),e=.2*t,i=2*(t-e),r=i/Math.sqrt(2),n=t-.5*r;this._squareLeft=this._currentMeasure.left+n,this._squareTop=this._currentMeasure.top+n,this._squareSize=r},r.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 h=o.createLinearGradient(e,i,e,n+i);h.addColorStop(0,"rgba(0,0,0,0)"),h.addColorStop(1,"#000"),o.fillStyle=h,o.fillRect(e,i,r,n)},r.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()},r.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,s=this._tmpColor,h=t*t,a=t-e,l=a*a,u=-t;uh||_150?.04:-.16*(t-50)/100+.2;var g=(f-a)/(t-a);o[p+3]=g1-m?255*(1-(g-(1-m))/m):255}}return r.putImageData(n,0,0),i},r.prototype._RGBtoHSV=function(t,e){var i=t.r,r=t.g,n=t.b,o=Math.max(i,r,n),s=Math.min(i,r,n),h=0,a=0,l=o,u=o-s;0!==o&&(a=u/o),o!=s&&(o==i?(h=(r-n)/u,r=0&&o<=1?(h=n,a=s):o>=1&&o<=2?(h=s,a=n):o>=2&&o<=3?(a=n,l=s):o>=3&&o<=4?(a=s,l=n):o>=4&&o<=5?(h=s,l=n):o>=5&&o<=6&&(h=n,l=s);var u=i-n;r.set(h+u,a+u,l+u)},r.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=.2*i,n=this._currentMeasure.left,o=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*i||(this._colorWheelCanvas=this._createColorWheelCanvas(i,r)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY,e.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),e.drawImage(this._colorWheelCanvas,n,o),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var s=this._squareLeft+this._squareSize*this._s,h=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(s,h,.04*i,e);var a=i-.5*r;s=n+i+Math.cos((this._h-180)*Math.PI/180)*a,h=o+i+Math.sin((this._h-180)*Math.PI/180)*a,this._drawCircle(s,h,.35*r,e)}e.restore()},r.prototype._updateValueFromPointer=function(t,e){if(this._pointerStartedOnWheel){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i+this._currentMeasure.left,n=i+this._currentMeasure.top;this._h=180*Math.atan2(e-n,t-r)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(t-this._squareLeft)/this._squareSize,this._v=1-(e-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,1e-5),this._v=Math.min(this._v,1),this._v=Math.max(this._v,1e-5));this._HSVtoRGB(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},r.prototype._isPointOnSquare=function(t){this._updateSquareProps();var e=this._squareLeft,i=this._squareTop,r=this._squareSize;return t.x>=e&&t.x<=e+r&&t.y>=i&&t.y<=i+r},r.prototype._isPointOnWheel=function(t){var e=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=e+this._currentMeasure.left,r=e+this._currentMeasure.top,n=.2*e,o=e-n,s=e*e,h=o*o,a=t.x-i,l=t.y-r,u=a*a+l*l;return u<=s&&u>=h},r.prototype._onPointerDown=function(t,i,r,n){return!!e.prototype._onPointerDown.call(this,t,i,r,n)&&(this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._isPointOnSquare(i)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(i)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(i.x,i.y),this._host._capturingControl[r]=this,!0)},r.prototype._onPointerMove=function(t,i){this._pointerIsDown&&this._updateValueFromPointer(i.x,i.y),e.prototype._onPointerMove.call(this,t,i)},r.prototype._onPointerUp=function(t,i,r,n,o){this._pointerIsDown=!1,delete this._host._capturingControl[r],e.prototype._onPointerUp.call(this,t,i,r,n,o)},r})(e.Control);e.ColorPicker=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(r){function n(i,n){void 0===n&&(n="");var o=r.call(this,i)||this;return o.name=i,o._text="",o._placeholderText="",o._background="#222222",o._focusedBackground="#000000",o._placeholderColor="gray",o._thickness=1,o._margin=new e.ValueAndUnit(10,e.ValueAndUnit.UNITMODE_PIXEL),o._autoStretchWidth=!0,o._maxWidth=new e.ValueAndUnit(1,e.ValueAndUnit.UNITMODE_PERCENTAGE,!1),o._isFocused=!1,o._blinkIsEven=!1,o._cursorOffset=0,o.promptMessage="Please enter text:",o.onTextChangedObservable=new t.Observable,o.onFocusObservable=new t.Observable,o.onBlurObservable=new t.Observable,o.text=n,o}return i(n,r),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"maxWidthInPixels",{get:function(){return this._maxWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),Object.defineProperty(n.prototype,"marginInPixels",{get:function(){return this._margin.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoStretchWidth",{get:function(){return this._autoStretchWidth},set:function(t){this._autoStretchWidth!==t&&(this._autoStretchWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"focusedBackground",{get:function(){return this._focusedBackground},set:function(t){this._focusedBackground!==t&&(this._focusedBackground=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"placeholderColor",{get:function(){return this._placeholderColor},set:function(t){this._placeholderColor!==t&&(this._placeholderColor=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"placeholderText",{get:function(){return this._placeholderText},set:function(t){this._placeholderText!==t&&(this._placeholderText=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty(),this.onTextChangedObservable.notifyObservers(this))},enumerable:!0,configurable:!0}),Object.defineProperty(n.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:!0,configurable:!0}),n.prototype.onBlur=function(){this._isFocused=!1,this._scrollLeft=null,this._cursorOffset=0,clearTimeout(this._blinkTimeout),this._markAsDirty(),this.onBlurObservable.notifyObservers(this)},n.prototype.onFocus=function(){if(this._scrollLeft=null,this._isFocused=!0,this._blinkIsEven=!1,this._cursorOffset=0,this._markAsDirty(),this.onFocusObservable.notifyObservers(this),-1!==navigator.userAgent.indexOf("Mobile")){var t=prompt(this.promptMessage);return null!==t&&(this.text=t),void(this._host.focusedControl=null)}},n.prototype._getTypeName=function(){return"InputText"},n.prototype.processKey=function(t,e){switch(t){case 32:e=" ";break;case 8:if(this._text&&this._text.length>0)if(0===this._cursorOffset)this.text=this._text.substr(0,this._text.length-1);else{var i=this._text.length-this._cursorOffset;i>0&&(this.text=this._text.slice(0,i-1)+this._text.slice(i))}return;case 46:if(this._text&&this._text.length>0){var i=this._text.length-this._cursorOffset;this.text=this._text.slice(0,i)+this._text.slice(i+1),this._cursorOffset--}return;case 13:return void(this._host.focusedControl=null);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._text.length,this._blinkIsEven=!1,void this._markAsDirty();case 37:return this._cursorOffset++,this._cursorOffset>this._text.length&&(this._cursorOffset=this._text.length),this._blinkIsEven=!1,void this._markAsDirty();case 39:return this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),this._blinkIsEven=!1,void this._markAsDirty()}if(-1===t||32===t||t>47&&t<58||t>64&&t<91||t>185&&t<193||t>218&&t<223||t>95&&t<112)if(0===this._cursorOffset)this.text+=e;else{var r=this._text.length-this._cursorOffset;this.text=this._text.slice(0,r)+e+this._text.slice(r)}},n.prototype.processKeyboard=function(t){this.processKey(t.keyCode,t.key)},n.prototype._draw=function(t,i){var r=this;if(i.save(),this._applyStates(i),this._processMeasures(t,i)){(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(i.shadowColor=this.shadowColor,i.shadowBlur=this.shadowBlur,i.shadowOffsetX=this.shadowOffsetX,i.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(i.fillStyle=this._focusedBackground,i.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(i.fillStyle=this._background,i.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(i.shadowBlur=0,i.shadowOffsetX=0,i.shadowOffsetY=0),this._fontOffset||(this._fontOffset=e.Control._GetFontOffset(i.font));var n=this._currentMeasure.left+this._margin.getValueInPixel(this._host,t.width);this.color&&(i.fillStyle=this.color);var o=this._text;this._isFocused||this._text||!this._placeholderText||(o=this._placeholderText,this._placeholderColor&&(i.fillStyle=this._placeholderColor)),this._textWidth=i.measureText(o).width;var s=2*this._margin.getValueInPixel(this._host,t.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,t.width),this._textWidth+s)+"px");var h=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,a=this._width.getValueInPixel(this._host,t.width)-s;if(i.save(),i.beginPath(),i.rect(n,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,a+2,this._currentMeasure.height),i.clip(),this._isFocused&&this._textWidth>a){var l=n-this._textWidth+a;this._scrollLeft||(this._scrollLeft=l)}else this._scrollLeft=n;if(i.fillText(o,this._scrollLeft,this._currentMeasure.top+h),this._isFocused){if(this._clickedCoordinate){var u=this._scrollLeft+this._textWidth,c=u-this._clickedCoordinate,_=0;this._cursorOffset=0;var f=0;do{this._cursorOffset&&(f=Math.abs(c-_)),this._cursorOffset++,_=i.measureText(o.substr(o.length-this._cursorOffset,this._cursorOffset)).width}while(_=this._cursorOffset);Math.abs(c-_)>f&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var d=this.text.substr(this._text.length-this._cursorOffset),p=i.measureText(d).width,g=this._scrollLeft+this._textWidth-p;gn+a&&(this._scrollLeft+=n+a-g,g=n+a,this._markAsDirty()),i.fillRect(g,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){r._blinkIsEven=!r._blinkIsEven,r._markAsDirty()}),500)}i.restore(),this._thickness&&(this.color&&(i.strokeStyle=this.color),i.lineWidth=this._thickness,i.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,this._currentMeasure.width-this._thickness,this._currentMeasure.height-this._thickness))}i.restore()},n.prototype._onPointerDown=function(t,e,i,n){return!!r.prototype._onPointerDown.call(this,t,e,i,n)&&(this._clickedCoordinate=e.x,this._host.focusedControl===this?(clearTimeout(this._blinkTimeout),this._markAsDirty(),!0):(this._host.focusedControl=this,!0))},n.prototype._onPointerUp=function(t,e,i,n,o){r.prototype._onPointerUp.call(this,t,e,i,n,o)},n.prototype.dispose=function(){r.prototype.dispose.call(this),this.onBlurObservable.clear(),this.onFocusObservable.clear(),this.onTextChangedObservable.clear()},n})(e.Control);e.InputText=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(){function t(){}return t})();e.KeyPropertySet=r;var n=(function(r){function n(){var e=null!==r&&r.apply(this,arguments)||this;return e.onKeyPressObservable=new t.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}return i(n,r),n.prototype._getTypeName=function(){return"VirtualKeyboard"},n.prototype._createKey=function(t,i){var r=this,n=e.Button.CreateSimpleButton(t,t);return n.width=i&&i.width?i.width:this.defaultButtonWidth,n.height=i&&i.height?i.height:this.defaultButtonHeight,n.color=i&&i.color?i.color:this.defaultButtonColor,n.background=i&&i.background?i.background:this.defaultButtonBackground,n.paddingLeft=i&&i.paddingLeft?i.paddingLeft:this.defaultButtonPaddingLeft,n.paddingRight=i&&i.paddingRight?i.paddingRight:this.defaultButtonPaddingRight,n.paddingTop=i&&i.paddingTop?i.paddingTop:this.defaultButtonPaddingTop,n.paddingBottom=i&&i.paddingBottom?i.paddingBottom:this.defaultButtonPaddingBottom,n.thickness=0,n.isFocusInvisible=!0,n.shadowColor=this.shadowColor,n.shadowBlur=this.shadowBlur,n.shadowOffsetX=this.shadowOffsetX,n.shadowOffsetY=this.shadowOffsetY,n.onPointerUpObservable.add((function(){r.onKeyPressObservable.notifyObservers(t)})),n},n.prototype.addKeysRow=function(t,i){var r=new e.StackPanel;r.isVertical=!1,r.isFocusInvisible=!0;for(var n=0;n1?this.selectedShiftThickness:0),s.text=t>0?s.text.toUpperCase():s.text.toLowerCase()}}}},Object.defineProperty(n.prototype,"connectedInputText",{get:function(){return this._connectedInputText},enumerable:!0,configurable:!0}),n.prototype.connect=function(t){var e=this;this.isVisible=!1,this._connectedInputText=t,this._onFocusObserver=t.onFocusObservable.add((function(){e.isVisible=!0})),this._onBlurObserver=t.onBlurObservable.add((function(){e.isVisible=!1})),this._onKeyPressObserver=this.onKeyPressObservable.add((function(t){if(e._connectedInputText){switch(t){case"⇧":return e.shiftState++,e.shiftState>2&&(e.shiftState=0),void e.applyShiftState(e.shiftState);case"←":return void e._connectedInputText.processKey(8);case"↵":return void e._connectedInputText.processKey(13)}e._connectedInputText.processKey(-1,e.shiftState?t.toUpperCase():t),1===e.shiftState&&(e.shiftState=0,e.applyShiftState(e.shiftState))}}))},n.prototype.disconnect=function(){this._connectedInputText&&(this._connectedInputText.onFocusObservable.remove(this._onFocusObserver),this._connectedInputText.onBlurObservable.remove(this._onBlurObserver),this.onKeyPressObservable.remove(this._onKeyPressObserver),this._connectedInputText=null)},n.CreateDefaultLayout=function(){var t=new n;return t.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),t.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),t.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),t.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),t.addKeysRow([" "],[{width:"200px"}]),t},n})(e.StackPanel);e.VirtualKeyboard=n})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(r){function n(t){var i=r.call(this,t)||this;return i.name=t,i._lineWidth=1,i.onPointUpdate=function(){i._markAsDirty()},i.isHitTestVisible=!1,i._horizontalAlignment=e.Control.HORIZONTAL_ALIGNMENT_LEFT,i._verticalAlignment=e.Control.VERTICAL_ALIGNMENT_TOP,i._dash=[],i._points=[],i}return i(n,r),Object.defineProperty(n.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!0,configurable:!0}),n.prototype.getAt=function(t){return this._points[t]||(this._points[t]=new e.MultiLinePoint(this)),this._points[t]},n.prototype.add=function(){for(var t=this,e=[],i=0;ii._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)},n.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)},n.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)},n.prototype.dispose=function(){for(;this._points.length>0;)this.remove(this._points.length-1);r.prototype.dispose.call(this)},n})(e.Control);e.MultiLine=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(t){var e=(function(e){function r(t){var i=e.call(this,t)||this;return i.name=t,i._rowDefinitions=new Array,i._columnDefinitions=new Array,i._cells={},i._childControls=new Array,i}return i(r,e),Object.defineProperty(r.prototype,"children",{get:function(){return this._childControls},enumerable:!0,configurable:!0}),r.prototype.addRowDefinition=function(e,i){return void 0===i&&(i=!1),this._rowDefinitions.push(new t.ValueAndUnit(e,i?t.ValueAndUnit.UNITMODE_PIXEL:t.ValueAndUnit.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},r.prototype.addColumnDefinition=function(e,i){return void 0===i&&(i=!1),this._columnDefinitions.push(new t.ValueAndUnit(e,i?t.ValueAndUnit.UNITMODE_PIXEL:t.ValueAndUnit.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},r.prototype.setRowDefinition=function(e,i,r){return void 0===r&&(r=!1),e<0||e>=this._rowDefinitions.length?this:(this._rowDefinitions[e]=new t.ValueAndUnit(i,r?t.ValueAndUnit.UNITMODE_PIXEL:t.ValueAndUnit.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},r.prototype.setColumnDefinition=function(e,i,r){return void 0===r&&(r=!1),e<0||e>=this._columnDefinitions.length?this:(this._columnDefinitions[e]=new t.ValueAndUnit(i,r?t.ValueAndUnit.UNITMODE_PIXEL:t.ValueAndUnit.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},r.prototype._removeCell=function(t,i){if(t){e.prototype.removeControl.call(this,t);for(var r=0,n=t.children;r=this._columnDefinitions.length)return this;for(var e=0;e=this._rowDefinitions.length)return this;for(var e=0;e0,s.BORDER=this.renderBorders,s.HOVERLIGHT=this.renderHoverLight);var h=o.getEngine();if(s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var a=[t.VertexBuffer.PositionKind];a.push(t.VertexBuffer.NormalKind),a.push(t.VertexBuffer.UVKind);var l=["world","viewProjection","innerGlowColor","albedoColor","borderWidth","edgeSmoothingValue","scaleFactor","borderMinValue","hoverColor","hoverPosition","hoverRadius"],u=new Array,c=new Array;t.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:l,uniformBuffersNames:c,samplers:u,defines:s,maxSimultaneousLights:4});var _=s.toString();i.setEffect(o.getEngine().createEffect("fluent",{attributes:a,uniformsNames:l,uniformBuffersNames:c,samplers:u,defines:_,fallbacks:null,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:4}},h))}return!(!i.effect||!i.effect.isReady())&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},o.prototype.bindForSubMesh=function(e,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;s&&(this._activeEffect=s,this.bindOnlyWorldMatrix(e),this._activeEffect.setMatrix("viewProjection",n.getTransformMatrix()),this._mustRebind(n,s)&&(this._activeEffect.setColor4("albedoColor",this.albedoColor,this.alpha),o.INNERGLOW&&this._activeEffect.setColor4("innerGlowColor",this.innerGlowColor,this.innerGlowColorIntensity),o.BORDER&&(this._activeEffect.setFloat("borderWidth",this.borderWidth),this._activeEffect.setFloat("edgeSmoothingValue",this.edgeSmoothingValue),this._activeEffect.setFloat("borderMinValue",this.borderMinValue),i.getBoundingInfo().boundingBox.extendSize.multiplyToRef(i.scaling,t.Tmp.Vector3[0]),this._activeEffect.setVector3("scaleFactor",t.Tmp.Vector3[0])),o.HOVERLIGHT&&(this._activeEffect.setDirectColor4("hoverColor",this.hoverColor),this._activeEffect.setFloat("hoverRadius",this.hoverRadius),this._activeEffect.setVector3("hoverPosition",this.hoverPosition))),this._afterBind(i,this._activeEffect))}},o.prototype.getActiveTextures=function(){return r.prototype.getActiveTextures.call(this)},o.prototype.hasTexture=function(t){return!!r.prototype.hasTexture.call(this,t)},o.prototype.dispose=function(t){r.prototype.dispose.call(this,t)},o.prototype.clone=function(e){var i=this;return t.SerializationHelper.Clone((function(){return new o(e,i.getScene())}),this)},o.prototype.serialize=function(){var e=t.SerializationHelper.Serialize(this);return e.customType="BABYLON.GUI.FluentMaterial",e},o.prototype.getClassName=function(){return"FluentMaterial"},o.Parse=function(e,i,r){return t.SerializationHelper.Parse((function(){return new o(e.name,i)}),e,i,r)},e([t.serialize(),t.expandToProperty("_markAllSubMeshesAsTexturesDirty")],o.prototype,"innerGlowColorIntensity",void 0),e([t.serializeAsColor3()],o.prototype,"innerGlowColor",void 0),e([t.serialize()],o.prototype,"alpha",void 0),e([t.serializeAsColor3()],o.prototype,"albedoColor",void 0),e([t.serialize(),t.expandToProperty("_markAllSubMeshesAsTexturesDirty")],o.prototype,"renderBorders",void 0),e([t.serialize()],o.prototype,"borderWidth",void 0),e([t.serialize()],o.prototype,"edgeSmoothingValue",void 0),e([t.serialize()],o.prototype,"borderMinValue",void 0),e([t.serialize(),t.expandToProperty("_markAllSubMeshesAsTexturesDirty")],o.prototype,"renderHoverLight",void 0),e([t.serialize()],o.prototype,"hoverRadius",void 0),e([t.serializeAsColor4()],o.prototype,"hoverColor",void 0),e([t.serializeAsVector3()],o.prototype,"hoverPosition",void 0),o})(t.PushMaterial);r.FluentMaterial=o})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(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 i(e,t),e})(t.Vector3);e.Vector3WithInfo=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var i=(function(){function i(e){this.name=e,this._downCount=0,this._enterCount=-1,this._downPointerIds={},this._isVisible=!0,this.onPointerMoveObservable=new t.Observable,this.onPointerOutObservable=new t.Observable,this.onPointerDownObservable=new t.Observable,this.onPointerUpObservable=new t.Observable,this.onPointerClickObservable=new t.Observable,this.onPointerEnterObservable=new t.Observable,this._behaviors=new Array}return Object.defineProperty(i.prototype,"position",{get:function(){return this._node?this._node.position:t.Vector3.Zero()},set:function(t){this._node&&(this._node.position=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._node?this._node.scaling:new t.Vector3(1,1,1)},set:function(t){this._node&&(this._node.scaling=t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),i.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},i.prototype.removeBehavior=function(t){var e=this._behaviors.indexOf(t);return-1===e?this:(this._behaviors[e].detach(),this._behaviors.splice(e,1),this)},i.prototype.getBehaviorByName=function(t){for(var e=0,i=this._behaviors;e0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,t,this),this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},i.prototype._onPointerOut=function(t){this._enterCount=0,this.onPointerOutObservable.notifyObservers(this,-1,t,this),this.pointerOutAnimation&&this.pointerOutAnimation()},i.prototype._onPointerDown=function(t,i,r,n){return 0===this._downCount&&(this._downCount++,this._downPointerIds[r]=!0,this.onPointerDownObservable.notifyObservers(new e.Vector3WithInfo(i,n),-1,t,this),this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},i.prototype._onPointerUp=function(t,i,r,n,o){this._downCount=0,delete this._downPointerIds[r],o&&(this._enterCount>0||-1===this._enterCount)&&this.onPointerClickObservable.notifyObservers(new e.Vector3WithInfo(i,n),-1,t,this),this.onPointerUpObservable.notifyObservers(new e.Vector3WithInfo(i,n),-1,t,this),this.pointerUpAnimation&&this.pointerUpAnimation()},i.prototype.forcePointerUp=function(e){if(void 0===e&&(e=null),null!==e)this._onPointerUp(this,t.Vector3.Zero(),e,0,!0);else for(var i in this._downPointerIds)this._onPointerUp(this,t.Vector3.Zero(),+i,0,!0)},i.prototype._processObservables=function(e,i,r,n){if(e===t.PointerEventTypes.POINTERMOVE){this._onPointerMove(this,i);var o=this._host._lastControlOver[r];return o&&o!==this&&o._onPointerOut(this),o!==this&&this._onPointerEnter(this),this._host._lastControlOver[r]=this,!0} return e===t.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this,i,r,n),this._host._lastControlDown[r]=this,this._host._lastPickedControl=this,!0):e===t.PointerEventTypes.POINTERUP&&(this._host._lastControlDown[r]&&this._host._lastControlDown[r]._onPointerUp(this,i,r,n,!0),delete this._host._lastControlDown[r],!0)},i.prototype._disposeNode=function(){this._node&&(this._node.dispose(),this._node=null)},i.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;t0?this.margin:0}}},r})(e.Container3D);e.StackPanel3D=r})(t.GUI||(t.GUI={}))})(t||(t={}));var t;!(function(t){!(function(e){var r=(function(r){function n(){var t=r.call(this)||this;return t._columns=10,t._rows=0,t._rowThenColum=!0,t._orientation=e.Container3D.FACEORIGIN_ORIENTATION,t.margin=0,t}return i(n,r),Object.defineProperty(n.prototype,"orientation",{get:function(){return this._orientation},set:function(e){var i=this;this._orientation!==e&&(this._orientation=e,t.Tools.SetImmediate((function(){i._arrangeChildren()})))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"columns",{get:function(){return this._columns},set:function(e){var i=this;this._columns!==e&&(this._columns=e,this._rowThenColum=!0,t.Tools.SetImmediate((function(){i._arrangeChildren()})))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rows",{get:function(){return this._rows},set:function(e){var i=this;this._rows!==e&&(this._rows=e,this._rowThenColum=!1,t.Tools.SetImmediate((function(){i._arrangeChildren()})))},enumerable:!0,configurable:!0}),n.prototype._arrangeChildren=function(){this._cellWidth=0,this._cellHeight=0;for(var e=0,i=0,r=0,n=t.Matrix.Invert(this.node.computeWorldMatrix(!0)),o=0,s=this._children;or));p++);else for(var p=0;pr));d++);f=0;for(var g=0,m=this._children;gr?-1:0}));for(var s=Math.pow(this.margin,2),h=Math.max(this._cellWidth,this._cellHeight),a=t.Tmp.Vector2[0],l=t.Tmp.Vector3[0],u=0;u