var BABYLON;!(function(t){!(function(e){var i=(function(i){function r(r,n,o,s,h,a){void 0===n&&(n=0),void 0===o&&(o=0),void 0===h&&(h=!1),void 0===a&&(a=t.Texture.NEAREST_SAMPLINGMODE);var u=i.call(this,r,{width:n,height:o},s,h,a,t.Engine.TEXTUREFORMAT_RGBA)||this;return u._isDirty=!1,u._rootContainer=new e.Container("root"),u._linkedControls=new Array,u._isFullscreen=!1,u._fullscreenViewport=new t.Viewport(0,0,1,1),u._idealWidth=0,u._idealHeight=0,u._renderAtIdealSize=!1,u._renderObserver=u.getScene().onBeforeCameraRenderObservable.add((function(t){return u._checkUpdate(t)})),u._rootContainer._link(null,u),u.hasAlpha=!0,n&&o||(u._resizeObserver=u.getScene().getEngine().onResizeObservable.add((function(){return u._onResize()})),u._onResize()),u._texture.isReady=!0,u}return __extends(r,i),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,"idealWidth",{get:function(){return this._idealWidth},set:function(t){this._idealWidth!==t&&(this._idealWidth=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(t){this._idealHeight!==t&&(this._idealHeight=t,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(t){this._renderAtIdealSize!==t&&(this._renderAtIdealSize=t,this._onResize())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!0,configurable:!0}),r.prototype.executeOnAllControls=function(t,e){e||(e=this._rootContainer);for(var i=0,r=e.children;i1?s.isVisible=!1:(s.isVisible=!0,s._moveToProjectedPosition(u))}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update())}},r.prototype._render=function(){var t=(this.getScene().getEngine(),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";var o=new e.Measure(0,0,i,r);this._rootContainer._draw(o,n)},r.prototype._doPicking=function(e,i,r){var n=this.getScene().getEngine(),o=this.getSize();if(this._isFullscreen&&(e*=o.width/n.getRenderWidth(),i*=o.height/n.getRenderHeight()),this._capturingControl)return void this._capturingControl._processObservables(r,e,i);this._rootContainer._processPicking(e,i,r)||r===t.PointerEventTypes.POINTERMOVE&&(this._lastControlOver&&this._lastControlOver.onPointerOutObservable.hasObservers()&&this._lastControlOver.onPointerOutObservable.notifyObservers(this._lastControlOver),this._lastControlOver=null)},r.prototype.attach=function(){var e=this,i=this.getScene();this._pointerMoveObserver=i.onPrePointerObservable.add((function(r,n){r.type!==t.PointerEventTypes.POINTERMOVE&&r.type!==t.PointerEventTypes.POINTERUP&&r.type!==t.PointerEventTypes.POINTERDOWN||(e._shouldBlockPointer=!1,e._doPicking(i.pointerX,i.pointerY,r.type),r.skipOnPointerObservable=e._shouldBlockPointer&&r.type!==t.PointerEventTypes.POINTERUP)})),this._attachToOnBlur(i)},r.prototype.attachToMesh=function(e){var i=this,r=this.getScene();this._pointerObserver=r.onPointerObservable.add((function(r,n){if(r.type===t.PointerEventTypes.POINTERUP||r.type===t.PointerEventTypes.POINTERDOWN)if(r.pickInfo.hit&&r.pickInfo.pickedMesh===e){var o=r.pickInfo.getTextureCoordinates(),s=i.getSize();i._doPicking(o.x*s.width,(1-o.y)*s.height,r.type)}else r.type===t.PointerEventTypes.POINTERUP&&(i._lastControlDown&&i._lastControlDown.forcePointerUp(),i._lastControlDown=null)})),this._attachToOnBlur(r)},r.prototype._attachToOnBlur=function(t){var e=this;this._canvasBlurObserver=t.getEngine().onCanvasBlurObservable.add((function(){e._lastControlOver&&e._lastControlOver.onPointerOutObservable.hasObservers()&&e._lastControlOver.onPointerOutObservable.notifyObservers(e._lastControlOver),e._lastControlOver=null,e._lastControlDown&&e._lastControlDown.forcePointerUp(),e._lastControlDown=null}))},r.CreateForMesh=function(e,i,n){void 0===i&&(i=1024),void 0===n&&(n=1024);var o=new r(e.name+" AdvancedDynamicTexture",i,n,e.getScene(),!0,t.Texture.TRILINEAR_SAMPLINGMODE),s=new t.StandardMaterial("AdvancedDynamicTextureMaterial",e.getScene());return s.backFaceCulling=!1,s.diffuseColor=t.Color3.Black(),s.specularColor=t.Color3.Black(),s.emissiveTexture=o,s.opacityTexture=o,e.material=s,o.attachToMesh(e),o},r.CreateFullscreenUI=function(e,i,n){void 0===i&&(i=!0),void 0===n&&(n=null);var o=new r(e,0,0,n),s=new t.Layer(e+"_layer",null,n,!i);return s.texture=o,o._layerToDispose=s,o._isFullscreen=!0,o.attach(),o},r})(t.DynamicTexture);e.AdvancedDynamicTexture=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(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={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(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.isVisible=!1);this.isVisible=!0},i.prototype.linkWithMesh=function(e){return this._host&&this._root===this._host._rootContainer?-1!==this._host._linkedControls.indexOf(this)?void(this._linkedMesh=e):(this.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,void this._host._linkedControls.push(this)):void t.Tools.Error("Cannot link a control to a mesh if the control is not at root level")},i.prototype._moveToProjectedPosition=function(t){this.left=t.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2+"px",this.top=t.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2+"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._fontSet=!1,this._prepareFont()),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){return!(!this.isHitTestVisible||!this.isVisible)&&(!!this.contains(t,e)&&(this._processObservables(i,t,e),!0))},i.prototype._onPointerMove=function(t){this.onPointerMoveObservable.hasObservers()&&this.onPointerMoveObservable.notifyObservers(t)},i.prototype._onPointerEnter=function(){return 0===this._enterCount&&(this._enterCount++,this.onPointerEnterObservable.hasObservers()&&this.onPointerEnterObservable.notifyObservers(this),!0)},i.prototype._onPointerOut=function(){this._enterCount=0,this.onPointerOutObservable.hasObservers()&&this.onPointerOutObservable.notifyObservers(this)},i.prototype._onPointerDown=function(t){return 0===this._downCount&&(this._downCount++,this.onPointerDownObservable.hasObservers()&&this.onPointerDownObservable.notifyObservers(t),!0)},i.prototype._onPointerUp=function(t){this._downCount=0,this.onPointerUpObservable.hasObservers()&&this.onPointerUpObservable.notifyObservers(t)},i.prototype.forcePointerUp=function(){this._onPointerUp(t.Vector2.Zero())},i.prototype._processObservables=function(e,i,r){if(this._dummyVector2.copyFromFloats(i,r),e===t.PointerEventTypes.POINTERMOVE){this._onPointerMove(this._dummyVector2);var n=this._host._lastControlOver;return n&&n!==this&&n._onPointerOut(),n!==this&&this._onPointerEnter(),this._host._lastControlOver=this,!0}return e===t.PointerEventTypes.POINTERDOWN?(this._onPointerDown(this._dummyVector2),this._host._lastControlDown=this,!0):e===t.PointerEventTypes.POINTERUP&&(this._host._lastControlDown&&this._host._lastControlDown._onPointerUp(this._dummyVector2),this._host._lastControlDown=null,!0)},i.prototype._prepareFont=function(){this._fontFamily&&(this._font=this._fontSize.getValue(this._host)+"px "+this._fontFamily,this._fontOffset=i._GetFontOffset(this._font))},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 u=new t.GUI.TextBlock("header");return u.text=r,u.textHorizontalAlignment=i.HORIZONTAL_ALIGNMENT_LEFT,h?u.width=n:u.height=n,a?(s.addControl(e),s.addControl(u),u.paddingLeft="5px"):(s.addControl(u),s.addControl(e),u.paddingRight="5px"),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})();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={},e.Control=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i){var r=e.call(this,i)||this;return r.name=i,r._children=new Array,r._measureForChildren=t.Measure.Empty(),r}return __extends(i,e),Object.defineProperty(i.prototype,"background",{get:function(){return this._background},set:function(t){this._background!==t&&(this._background=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Container"},i.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),this._markAsDirty()},i.prototype._markMatrixAsDirty=function(){e.prototype._markMatrixAsDirty.call(this);for(var t=0;t=0;n--){if(this._children[n]._processPicking(t,i,r))return!0}return this._processObservables(r,t,i)},i.prototype._clipForChildren=function(t){},i.prototype._additionalProcessing=function(t,i){e.prototype._additionalProcessing.call(this,t,i),this._measureForChildren.copyFrom(this._currentMeasure)},i})(t.Control);t.Container=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){ !(function(e){var i=(function(i){function r(t){var r=i.call(this,t)||this;return r.name=t,r._isVertical=!0,r._tempMeasureStore=e.Measure.Empty(),r}return __extends(r,i),Object.defineProperty(r.prototype,"isVertical",{get:function(){return this._isVertical},set:function(t){this._isVertical!==t&&(this._isVertical=t,this._markAsDirty())},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"StackPanel"},r.prototype._preMeasure=function(e,r){for(var n=0,o=0,s=this._children;o0?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}},i.prototype._renderLines=function(e){var i=(this._currentMeasure.width,this._currentMeasure.height);this._fontOffset||(this._fontOffset=t.Control._GetFontOffset(e.font));var r=0;switch(this._textVerticalAlignment){case t.Control.VERTICAL_ALIGNMENT_TOP:r=this._fontOffset.ascent;break;case t.Control.VERTICAL_ALIGNMENT_BOTTOM:r=i-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case t.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=this._lines;nh||l150?.04:-.16*(t-50)/100+.2;var g=(p-a)/(t-a);o[d+3]=g1-m?255*(1-(g-(1-m))/m):255}}return r.putImageData(n,0,0),i},i.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,u=o,_=o-s;0!==o&&(a=_/o),o!=s&&(o==i?(h=(r-n)/_,r=0&&o<=1?(h=n,a=s):o>=1&&o<=2?(h=s,a=n):o>=2&&o<=3?(a=n,u=s):o>=3&&o<=4?(a=s,u=n):o>=4&&o<=5?(h=s,u=n):o>=5&&o<=6&&(h=n,u=s);var _=i-n;r.set(h+_,a+_,u+_)},i.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)),e.drawImage(this._colorWheelCanvas,n,o),this._updateSquareProps(),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()},i.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},i.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},i.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,u=t.y-r,_=a*a+u*u;return _<=s&&_>=h}, i.prototype._onPointerDown=function(t){return!!e.prototype._onPointerDown.call(this,t)&&(this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._isPointOnSquare(t)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(t)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(t.x,t.y),this._host._capturingControl=this,!0)},i.prototype._onPointerMove=function(t){this._pointerIsDown&&this._updateValueFromPointer(t.x,t.y),e.prototype._onPointerMove.call(this,t)},i.prototype._onPointerUp=function(t){this._pointerIsDown=!1,this._host._capturingControl=null,e.prototype._onPointerUp.call(this,t)},i})(e.Control);e.ColorPicker=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));