babylon.gui.min.js 63 KB

123
  1. 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;i<r.length;i++){var n=r[i];n.children?this.executeOnAllControls(t,n):t(n)}},r.prototype.markAsDirty=function(){this._isDirty=!0},r.prototype.addControl=function(t){return this._rootContainer.addControl(t),this},r.prototype.removeControl=function(t){return this._rootContainer.removeControl(t),this},r.prototype.dispose=function(){this.getScene().onBeforeCameraRenderObservable.remove(this._renderObserver),this._resizeObserver&&this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._pointerMoveObserver&&this.getScene().onPrePointerObservable.remove(this._pointerMoveObserver),this._pointerObserver&&this.getScene().onPointerObservable.remove(this._pointerObserver),this._canvasBlurObserver&&this.getScene().getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver),this._layerToDispose&&(this._layerToDispose.texture=null,this._layerToDispose.dispose(),this._layerToDispose=null),i.prototype.dispose.call(this)},r.prototype._onResize=function(){var t=this.getScene().getEngine(),e=this.getSize(),i=t.getRenderWidth(),r=t.getRenderHeight();this._renderAtIdealSize&&(this._idealWidth?(r=r*this._idealWidth/i,i=this._idealWidth):this._idealHeight&&(i=i*this._idealHeight/r,r=this._idealHeight)),e.width===i&&e.height===r||(this.scaleTo(i,r),this.markAsDirty(),(this._idealWidth||this._idealHeight)&&this._rootContainer._markAllAsDirty())},r.prototype._getGlobalViewport=function(t){var e=t.getEngine();return this._fullscreenViewport.toGlobal(e.getRenderWidth(),e.getRenderHeight())},r.prototype._checkUpdate=function(e){if(!this._layerToDispose||0!=(e.layerMask&this._layerToDispose.layerMask)){if(this._isFullscreen&&this._linkedControls.length)for(var i=this.getScene(),r=this._getGlobalViewport(i),n=0,o=this._linkedControls;n<o.length;n++){var s=o[n],h=s._linkedMesh,a=h.getBoundingInfo().boundingSphere.center,u=t.Vector3.Project(a,h.getWorldMatrix(),i.getTransformMatrix(),r);u.z<0||u.z>1?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(a<t.Epsilon*t.Epsilon)return e.m[0]=0,e.m[1]=0,e.m[2]=0,e.m[3]=0,e.m[4]=0,e.m[5]=0,this;var u=1/a,_=n*h-o*s,c=r*s-i*h;return e.m[0]=o*u,e.m[1]=-r*u,e.m[2]=-n*u,e.m[3]=i*u,e.m[4]=_*u,e.m[5]=c*u,this},e.prototype.multiplyToRef=function(t,e){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],s=this.m[4],h=this.m[5],a=t.m[0],u=t.m[1],_=t.m[2],c=t.m[3],l=t.m[4],p=t.m[5];return e.m[0]=i*a+r*_,e.m[1]=i*u+r*c,e.m[2]=n*a+o*_,e.m[3]=n*u+o*c,e.m[4]=s*a+h*_+l,e.m[5]=s*u+h*c+p,this},e.prototype.transformCoordinates=function(t,e,i){return i.x=t*this.m[0]+e*this.m[2]+this.m[4],i.y=t*this.m[1]+e*this.m[3]+this.m[5],this},e.Identity=function(){return new e(1,0,0,1,0,0)},e.TranslationToRef=function(t,e,i){i.fromValues(1,0,0,1,t,e)},e.ScalingToRef=function(t,e,i){i.fromValues(t,0,0,e,0,0)},e.RotationToRef=function(t,e){var i=Math.sin(t),r=Math.cos(t);e.fromValues(r,i,-i,r,0,0)},e.ComposeToRef=function(t,i,r,n,o,s,h){e.TranslationToRef(t,i,e._TempPreTranslationMatrix),e.ScalingToRef(n,o,e._TempScalingMatrix),e.RotationToRef(r,e._TempRotationMatrix),e.TranslationToRef(-t,-i,e._TempPostTranslationMatrix),e._TempPreTranslationMatrix.multiplyToRef(e._TempScalingMatrix,e._TempCompose0),e._TempCompose0.multiplyToRef(e._TempRotationMatrix,e._TempCompose1),s?(e._TempCompose1.multiplyToRef(e._TempPostTranslationMatrix,e._TempCompose2),e._TempCompose2.multiplyToRef(s,h)):e._TempCompose1.multiplyToRef(e._TempPostTranslationMatrix,h)},e})();i._TempPreTranslationMatrix=i.Identity(),i._TempPostTranslationMatrix=i.Identity(),i._TempRotationMatrix=i.Identity(),i._TempScalingMatrix=i.Identity(),i._TempCompose0=i.Identity(),i._TempCompose1=i.Identity(),i._TempCompose2=i.Identity(),e.Matrix2D=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(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.getValue=function(e){if(e&&!this.ignoreAdaptiveScaling&&this.unit!==t.UNITMODE_PERCENTAGE){if(e.idealWidth)return this._value*e.getSize().width/e.idealWidth;if(e.idealHeight)return this._value*e.getSize().height/e.idealHeight}return this._value},t.prototype.toString=function(e){switch(this.unit){case t.UNITMODE_PERCENTAGE:return 100*this.getValue(e)+"%";case t.UNITMODE_PIXEL:return this.getValue(e)+"px"}return this.unit.toString()},t.prototype.fromString=function(e){var i=t._Regex.exec(e.toString());if(!i||0===i.length)return!1;var r=parseFloat(i[1]),n=this.unit;if(this.negativeValueAllowed||r<0&&(r=0),4===i.length)switch(i[3]){case"px":n=t.UNITMODE_PIXEL;break;case"%":n=t.UNITMODE_PERCENTAGE,r/=100}return(r!==this._value||n!==this.unit)&&(this._value=r,this.unit=n,!0)},Object.defineProperty(t,"UNITMODE_PERCENTAGE",{get:function(){return t._UNITMODE_PERCENTAGE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UNITMODE_PIXEL",{get:function(){return t._UNITMODE_PIXEL},enumerable:!0,configurable:!0}),t})();e._Regex=/(^-?\d*(\.\d+)?)(%|px)?/,e._UNITMODE_PERCENTAGE=0,e._UNITMODE_PIXEL=1,t.ValueAndUnit=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(){function i(r){this.name=r,this._alpha=1,this._alphaSet=!1,this._zIndex=0,this._currentMeasure=e.Measure.Empty(),this._fontFamily="Arial",this._fontSize=new e.ValueAndUnit(18,e.ValueAndUnit.UNITMODE_PIXEL,!1),this._width=new e.ValueAndUnit(1,e.ValueAndUnit.UNITMODE_PERCENTAGE,!1),this._height=new e.ValueAndUnit(1,e.ValueAndUnit.UNITMODE_PERCENTAGE,!1),this._color="white",this._horizontalAlignment=i.HORIZONTAL_ALIGNMENT_CENTER,this._verticalAlignment=i.VERTICAL_ALIGNMENT_CENTER,this._isDirty=!0,this._cachedParentMeasure=e.Measure.Empty(),this._paddingLeft=new e.ValueAndUnit(0),this._paddingRight=new e.ValueAndUnit(0),this._paddingTop=new e.ValueAndUnit(0),this._paddingBottom=new e.ValueAndUnit(0),this._left=new e.ValueAndUnit(0),this._top=new e.ValueAndUnit(0),this._scaleX=1,this._scaleY=1,this._rotation=0,this._transformCenterX=.5,this._transformCenterY=.5,this._transformMatrix=e.Matrix2D.Identity(),this._invertTransformMatrix=e.Matrix2D.Identity(),this._transformedPosition=t.Vector2.Zero(),this._isMatrixDirty=!0,this._isVisible=!0,this._fontSet=!1,this._dummyVector2=t.Vector2.Zero(),this._downCount=0,this._enterCount=0,this.isHitTestVisible=!0,this.isPointerBlocker=!1,this._linkOffsetX=new e.ValueAndUnit(0),this._linkOffsetY=new e.ValueAndUnit(0),this.onPointerMoveObservable=new t.Observable,this.onPointerOutObservable=new t.Observable,this.onPointerDownObservable=new t.Observable,this.onPointerUpObservable=new t.Observable,this.onPointerEnterObservable=new t.Observable,this.onDirtyObservable=new t.Observable}return Object.defineProperty(i.prototype,"typeName",{get:function(){return this._getTypeName()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alphaSet=!0,this._alpha=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaleX",{get:function(){return this._scaleX},set:function(t){this._scaleX!==t&&(this._scaleX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaleY",{get:function(){return this._scaleY},set:function(t){this._scaleY!==t&&(this._scaleY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(t){this._rotation!==t&&(this._rotation=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"transformCenterY",{get:function(){return this._transformCenterY},set:function(t){this._transformCenterY!==t&&(this._transformCenterY=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"transformCenterX",{get:function(){return this._transformCenterX},set:function(t){this._transformCenterX!==t&&(this._transformCenterX=t,this._markAsDirty(),this._markMatrixAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"horizontalAlignment",{get:function(){return this._horizontalAlignment},set:function(t){this._horizontalAlignment!==t&&(this._horizontalAlignment=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlignment",{get:function(){return this._verticalAlignment},set:function(t){this._verticalAlignment!==t&&(this._verticalAlignment=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.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()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(t){this._height.toString(this._host)!==t&&this._height.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(t){this._fontFamily!==t&&(this._fontFamily=t,this._fontSet=!0)},enumerable:!0,configurable:!0}),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._markAsDirty(),this._fontSet=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(t){this._color!==t&&(this._color=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"zIndex",{get:function(){return this._zIndex},set:function(t){this.zIndex!==t&&(this._zIndex=t,this._root&&this._root._reOrderControl(this))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!==t&&(this._isVisible=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paddingLeft",{get:function(){return this._paddingLeft.toString(this._host)},set:function(t){this._paddingLeft.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paddingRight",{get:function(){return this._paddingRight.toString(this._host)},set:function(t){this._paddingRight.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paddingTop",{get:function(){return this._paddingTop.toString(this._host)},set:function(t){this._paddingTop.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paddingBottom",{get:function(){return this._paddingBottom.toString(this._host)},set:function(t){this._paddingBottom.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"left",{get:function(){return this._left.toString(this._host)},set:function(t){this._left.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"top",{get:function(){return this._top.toString(this._host)},set:function(t){this._top.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"linkOffsetX",{get:function(){return this._linkOffsetX.toString(this._host)},set:function(t){this._linkOffsetX.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"linkOffsetY",{get:function(){return this._linkOffsetY.toString(this._host)},set:function(t){this._linkOffsetY.fromString(t)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"centerX",{get:function(){return this._currentMeasure.left+this._currentMeasure.width/2},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"centerY",{get:function(){return this._currentMeasure.top+this._currentMeasure.height/2},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Control"},i.prototype.getLocalCoordinates=function(e){var i=t.Vector2.Zero();return this.getLocalCoordinatesToRef(e,i),i},i.prototype.getLocalCoordinatesToRef=function(t,e){return e.x=t.x-this._currentMeasure.left,e.y=t.y-this._currentMeasure.top,this},i.prototype.moveToVector3=function(e,i){if(!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");this.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP;var r=(i.getEngine(),this._host._getGlobalViewport(i)),n=t.Vector3.Project(e,t.Matrix.Identity(),i.getTransformMatrix(),r);if(this._moveToProjectedPosition(n),n.z<0||n.z>1)return void(this.isVisible=!1);this.isVisible=!0},i.prototype.linkWithMesh=function(e){if(!this._host||this._root!==this._host._rootContainer)return void t.Tools.Error("Cannot link a control to a mesh if the control is not at root level");-1===this._host._linkedControls.indexOf(this)&&(this.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=e,this._host._linkedControls.push(this))},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.width<t.left)&&(!(this._currentMeasure.top>t.top+t.height)&&(!(this._currentMeasure.top+this._currentMeasure.height<t.top)&&(this._transform(e),this._clip(e),e.clip(),!0))))},i.prototype._clip=function(t){t.beginPath(),t.rect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},i.prototype._measure=function(){this._width.isPixel?this._currentMeasure.width=this._width.getValue(this._host):this._currentMeasure.width*=this._width.getValue(this._host),this._height.isPixel?this._currentMeasure.height=this._height.getValue(this._host):this._currentMeasure.height*=this._height.getValue(this._host)},i.prototype._computeAlignment=function(t,e){var r=this._currentMeasure.width,n=this._currentMeasure.height,o=t.width,s=t.height,h=0,a=0;switch(this.horizontalAlignment){case i.HORIZONTAL_ALIGNMENT_LEFT:h=0;break;case i.HORIZONTAL_ALIGNMENT_RIGHT:h=o-r;break;case i.HORIZONTAL_ALIGNMENT_CENTER:h=(o-r)/2}switch(this.verticalAlignment){case i.VERTICAL_ALIGNMENT_TOP:a=0;break;case i.VERTICAL_ALIGNMENT_BOTTOM:a=s-n;break;case i.VERTICAL_ALIGNMENT_CENTER:a=(s-n)/2}this._paddingLeft.isPixel?(this._currentMeasure.left+=this._paddingLeft.getValue(this._host),this._currentMeasure.width-=this._paddingLeft.getValue(this._host)):(this._currentMeasure.left+=o*this._paddingLeft.getValue(this._host),this._currentMeasure.width-=o*this._paddingLeft.getValue(this._host)),this._paddingRight.isPixel?this._currentMeasure.width-=this._paddingRight.getValue(this._host):this._currentMeasure.width-=o*this._paddingRight.getValue(this._host),this._paddingTop.isPixel?(this._currentMeasure.top+=this._paddingTop.getValue(this._host),this._currentMeasure.height-=this._paddingTop.getValue(this._host)):(this._currentMeasure.top+=s*this._paddingTop.getValue(this._host),this._currentMeasure.height-=s*this._paddingTop.getValue(this._host)),this._paddingBottom.isPixel?this._currentMeasure.height-=this._paddingBottom.getValue(this._host):this._currentMeasure.height-=s*this._paddingBottom.getValue(this._host),this._left.isPixel?this._currentMeasure.left+=this._left.getValue(this._host):this._currentMeasure.left+=o*this._left.getValue(this._host),this._top.isPixel?this._currentMeasure.top+=this._top.getValue(this._host):this._currentMeasure.top+=s*this._top.getValue(this._host),this._currentMeasure.left+=h,this._currentMeasure.top+=a},i.prototype._preMeasure=function(t,e){},i.prototype._additionalProcessing=function(t,e){},i.prototype._draw=function(t,e){},i.prototype.contains=function(t,e){return this._invertTransformMatrix.transformCoordinates(t,e,this._transformedPosition),t=this._transformedPosition.x,e=this._transformedPosition.y,!(t<this._currentMeasure.left)&&(!(t>this._currentMeasure.left+this._currentMeasure.width)&&(!(e<this._currentMeasure.top)&&(!(e>this._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},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;e<i.length;e++){var r=i[e];if(r.name===t)return r}return null},i.prototype.getChildByType=function(t,e){for(var i=0,r=this._children;i<r.length;i++){var n=r[i];if(n.typeName===e)return n}return null},i.prototype.containsControl=function(t){return-1!==this._children.indexOf(t)},i.prototype.addControl=function(t){return-1!==this._children.indexOf(t)?this:(t._link(this,this._host),this._reOrderControl(t),this._markAsDirty(),this)},i.prototype.removeControl=function(t){var e=this._children.indexOf(t);return-1!==e&&this._children.splice(e,1),this._markAsDirty(),this},i.prototype._reOrderControl=function(t){this.removeControl(t);for(var e=0;e<this._children.length;e++)if(this._children[e].zIndex>t.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<this._children.length;t++)this._children[t]._markMatrixAsDirty()},i.prototype._markAllAsDirty=function(){e.prototype._markAllAsDirty.call(this);for(var t=0;t<this._children.length;t++)this._children[t]._markAllAsDirty()},i.prototype._localDraw=function(t){this._background&&(t.fillStyle=this._background,t.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height))},i.prototype._link=function(t,i){e.prototype._link.call(this,t,i);for(var r=0,n=this._children;r<n.length;r++){n[r]._link(t,i)}},i.prototype._draw=function(t,e){if(this.isVisible){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){this._localDraw(e),this._clipForChildren(e);for(var i=0,r=this._children;i<r.length;i++){var n=r[i];n.isVisible&&n._draw(this._measureForChildren,e)}}e.restore()}},i.prototype._processPicking=function(t,i,r){if(!this.isHitTestVisible||!this.isVisible)return!1;if(!e.prototype.contains.call(this,t,i))return!1;for(var n=this._children.length-1;n>=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){
  2. 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;o<s.length;o++){var h=s[o];this._tempMeasureStore.copyFrom(h._currentMeasure),h._currentMeasure.copyFrom(e),h._measure(),this._isVertical?(h.top=n+"px",h._top.ignoreAdaptiveScaling||h._markAsDirty(),h._top.ignoreAdaptiveScaling=!0,n+=h._currentMeasure.height,h.verticalAlignment=t.GUI.Control.VERTICAL_ALIGNMENT_TOP):(h.left=n+"px",h._left.ignoreAdaptiveScaling||h._markAsDirty(),h._left.ignoreAdaptiveScaling=!0,n+=h._currentMeasure.width,h.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT),h._currentMeasure.copyFrom(this._tempMeasureStore)}var a=!1;if(this._isVertical){var u=this.height;this.height=n+"px",a=u!==this.height||!this._height.ignoreAdaptiveScaling,this._height.ignoreAdaptiveScaling=!0}else{var _=this.width;this.width=n+"px",a=_!==this.width||!this._width.ignoreAdaptiveScaling,this._width.ignoreAdaptiveScaling=!0}a&&this._markAllAsDirty(),i.prototype._preMeasure.call(this,e,r)},r})(e.Container);e.StackPanel=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(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 __extends(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._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.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={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(t){var i=e.call(this,t)||this;return i.name=t,i._thickness=1,i}return __extends(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Ellipse"},i.prototype._localDraw=function(e){e.save(),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._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.stroke()),e.restore()},i.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},i.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()},i})(t.Container);t.Ellipse=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i){var r=e.call(this,i)||this;return r.name=i,r._lineWidth=1,r._x1=new t.ValueAndUnit(0),r._y1=new t.ValueAndUnit(0),r._x2=new t.ValueAndUnit(0),r._y2=new t.ValueAndUnit(0),r._dash=new Array,r.isHitTestVisible=!1,r._horizontalAlignment=t.Control.HORIZONTAL_ALIGNMENT_LEFT,r._verticalAlignment=t.Control.VERTICAL_ALIGNMENT_TOP,r}return __extends(i,e),Object.defineProperty(i.prototype,"dash",{get:function(){return this._dash},set:function(t){this._dash!==t&&(this._dash=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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(i.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(i.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(i.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(i.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(t){this._lineWidth!==t&&(this._lineWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"horizontalAlignment",{set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"verticalAlignment",{set:function(t){},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_effectiveX2",{get:function(){return(this._connectedControl?this._connectedControl.centerX:0)+this._x2.getValue(this._host)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_effectiveY2",{get:function(){return(this._connectedControl?this._connectedControl.centerY:0)+this._y2.getValue(this._host)},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"Line"},i.prototype._draw=function(t,e){e.save(),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()},i.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},i.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},i.prototype._moveToProjectedPosition=function(t){this.x1=t.x+this._linkOffsetX.getValue(this._host)+"px",this.y1=t.y+this._linkOffsetY.getValue(this._host)+"px",this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0},i})(t.Control);t.Line=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(e){var i=(function(i){function r(r){var n=i.call(this,r)||this;return n.name=r,n._thumbWidth=new e.ValueAndUnit(30,e.ValueAndUnit.UNITMODE_PIXEL,!1),n._minimum=0,n._maximum=100,n._value=50,n._background="black",n._borderColor="white",n._barOffset=new e.ValueAndUnit(5,e.ValueAndUnit.UNITMODE_PIXEL,!1),n.onValueChangedObservable=new t.Observable,n._pointerIsDown=!1,n.isPointerBlocker=!0,n}return __extends(r,i),Object.defineProperty(r.prototype,"borderColor",{get:function(){return this._borderColor},set:function(t){this._borderColor!==t&&(this._borderColor=t,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,"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(r.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(r.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(r.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(r.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}),r.prototype._getTypeName=function(){return"Slider"},r.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i,r;i=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._currentMeasure.height):this._currentMeasure.height*this._thumbWidth.getValue(this._host),r=this._barOffset.isPixel?Math.min(this._barOffset.getValue(this._host),this._currentMeasure.height):this._currentMeasure.height*this._barOffset.getValue(this._host);var n=this._currentMeasure.left+i/2,o=this._currentMeasure.width-i,s=(this._value-this._minimum)/(this._maximum-this._minimum)*o;e.fillStyle=this._background,e.fillRect(n,this._currentMeasure.top+r,o,this._currentMeasure.height-2*r),e.fillStyle=this.color,e.fillRect(n,this._currentMeasure.top+r,s,this._currentMeasure.height-2*r),e.fillRect(n+s-i/2,this._currentMeasure.top,i,this._currentMeasure.height),e.strokeStyle=this._borderColor,e.strokeRect(n+s-i/2,this._currentMeasure.top,i,this._currentMeasure.height)}e.restore()},r.prototype._updateValueFromPointer=function(t){this.value=this._minimum+(t-this._currentMeasure.left)/this._currentMeasure.width*(this._maximum-this._minimum)},r.prototype._onPointerDown=function(t){return!!i.prototype._onPointerDown.call(this,t)&&(this._pointerIsDown=!0,this._updateValueFromPointer(t.x),this._host._capturingControl=this,!0)},r.prototype._onPointerMove=function(t){this._pointerIsDown&&this._updateValueFromPointer(t.x)},r.prototype._onPointerUp=function(t){this._pointerIsDown=!1,this._host._capturingControl=null,i.prototype._onPointerUp.call(this,t)},r})(e.Control);e.Slider=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(e){var i=(function(e){function i(i){var r=e.call(this,i)||this;return r.name=i,r._isChecked=!1,r._background="black",r._checkSizeRatio=.8,r._thickness=1,r.onIsCheckedChangedObservable=new t.Observable,r.isPointerBlocker=!0,r}return __extends(i,e),Object.defineProperty(i.prototype,"thickness",{get:function(){return this._thickness},set:function(t){this._thickness!==t&&(this._thickness=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!0,configurable:!0}),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,"isChecked",{get:function(){return this._isChecked},set:function(t){this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t))},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"CheckBox"},i.prototype._draw=function(t,e){if(e.save(),this._applyStates(e),this._processMeasures(t,e)){var i=this._currentMeasure.width-this._thickness,r=this._currentMeasure.height-this._thickness;if(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r),this._isChecked){e.fillStyle=this.color;var n=i*this._checkSizeRatio,o=r*this._checkSizeRatio;e.fillRect(this._currentMeasure.left+this._thickness/2+(i-n)/2,this._currentMeasure.top+this._thickness/2+(r-o)/2,n,o)}e.strokeStyle=this.color,e.lineWidth=this._thickness,e.strokeRect(this._currentMeasure.left+this._thickness/2,this._currentMeasure.top+this._thickness/2,i,r)}e.restore()},i.prototype._onPointerDown=function(t){return!!e.prototype._onPointerDown.call(this,t)&&(this.isChecked=!this.isChecked,!0)},i})(e.Control);e.Checkbox=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(e){var i=(function(i){function r(e){var r=i.call(this,e)||this;return r.name=e,r._isChecked=!1,r._background="black",r._checkSizeRatio=.8,r._thickness=1,r.group="",r.onIsCheckedChangedObservable=new t.Observable,r.isPointerBlocker=!0,r}return __extends(r,i),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}),Object.defineProperty(r.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(t){t=Math.max(Math.min(1,t),0),this._checkSizeRatio!==t&&(this._checkSizeRatio=t,this._markAsDirty())},enumerable:!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,"isChecked",{get:function(){return this._isChecked},set:function(t){var e=this;this._isChecked!==t&&(this._isChecked=t,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(t),this._isChecked&&this._host.executeOnAllControls((function(t){if(t!==e&&void 0!==t.group){var i=t;i.group===e.group&&(i.isChecked=!1)}})))},enumerable:!0,configurable:!0}),r.prototype._getTypeName=function(){return"RadioButton"},r.prototype._draw=function(t,i){if(i.save(),this._applyStates(i),this._processMeasures(t,i)){var r=this._currentMeasure.width-this._thickness,n=this._currentMeasure.height-this._thickness;if(e.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,i),i.fillStyle=this._background,i.fill(),i.strokeStyle=this.color,i.lineWidth=this._thickness,i.stroke(),this._isChecked){i.fillStyle=this.color;var o=r*this._checkSizeRatio,s=n*this._checkSizeRatio;e.Control.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,o/2-this._thickness/2,s/2-this._thickness/2,i),i.fill()}}i.restore()},r.prototype._onPointerDown=function(t){return!!i.prototype._onPointerDown.call(this,t)&&(this.isChecked=!this.isChecked,!0)},r})(e.Control);e.RadioButton=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(t){var e=(function(e){function i(i,r){void 0===r&&(r="");var n=e.call(this,i)||this;return n.name=i,n._text="",n._textWrapping=!1,n._textHorizontalAlignment=t.Control.HORIZONTAL_ALIGNMENT_CENTER,n._textVerticalAlignment=t.Control.VERTICAL_ALIGNMENT_CENTER,n.text=r,n}return __extends(i,e),Object.defineProperty(i.prototype,"textWrapping",{get:function(){return this._textWrapping},set:function(t){this._textWrapping!==t&&(this._textWrapping=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"text",{get:function(){return this._text},set:function(t){this._text!==t&&(this._text=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textHorizontalAlignment",{get:function(){return this._textHorizontalAlignment},set:function(t){this._textHorizontalAlignment!==t&&(this._textHorizontalAlignment=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textVerticalAlignment",{get:function(){return this._textVerticalAlignment},set:function(t){this._textVerticalAlignment!==t&&(this._textVerticalAlignment=t,this._markAsDirty())},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"TextBlock"},i.prototype._drawText=function(e,i,r,n){var o=this._currentMeasure.width,s=0;switch(this._textHorizontalAlignment){case t.Control.HORIZONTAL_ALIGNMENT_LEFT:s=0;break;case t.Control.HORIZONTAL_ALIGNMENT_RIGHT:s=o-i;break;case t.Control.HORIZONTAL_ALIGNMENT_CENTER:s=(o-i)/2}n.fillText(e,this._currentMeasure.left+s,r)},i.prototype._draw=function(t,e){e.save(),this._applyStates(e),this._processMeasures(t,e)&&this._renderLines(e),e.restore()},i.prototype._additionalProcessing=function(t,e){this._lines=[];var i=this.text.split("\n");if(this._textWrapping)for(var r=0,n=i;r<n.length;r++){var o=n[r];this._lines.push(this._parseLineWithTextWrapping(o,e))}else for(var s=0,h=i;s<h.length;s++){var o=h[s];this._lines.push(this._parseLine(o,e))}},i.prototype._parseLine=function(t,e){return void 0===t&&(t=""),{text:t,width:e.measureText(t).width}},i.prototype._parseLineWithTextWrapping=function(t,e){void 0===t&&(t="");for(var i=t.split(" "),r=this._currentMeasure.width,n=0,o=0;o<i.length;o++){var s=o>0?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;n<o.length;n++){var s=o[n];this._drawText(s.text,s.width,r,e),r+=this._fontOffset.height}},i})(t.Control);t.TextBlock=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(t){var e=(function(t){function e(i,r){var n=t.call(this,i)||this;return n.name=i,n._loaded=!1,n._stretch=e.STRETCH_FILL,n._autoScale=!1,n._sourceLeft=0,n._sourceTop=0,n._sourceWidth=0,n._sourceHeight=0,n.source=r,n}return __extends(e,t),Object.defineProperty(e.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(t){this._sourceLeft!==t&&(this._sourceLeft=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(t){this._sourceTop!==t&&(this._sourceTop=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(t){this._sourceWidth!==t&&(this._sourceWidth=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(t){this._sourceHeight!==t&&(this._sourceHeight=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"autoScale",{get:function(){return this._autoScale},set:function(t){this._autoScale!==t&&(this._autoScale=t,t&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stretch",{get:function(){return this._stretch},set:function(t){this._stretch!==t&&(this._stretch=t,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype._onImageLoaded=function(){this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._autoScale&&this.synchronizeSizeWithContent(),this._markAsDirty()},Object.defineProperty(e.prototype,"source",{set:function(t){var e=this;this._source!==t&&(this._loaded=!1,this._source=t,this._domImage=new DOMImage,this._domImage.onload=function(){e._onImageLoaded()},this._domImage.crossOrigin="anonymous",this._domImage.src=t)},enumerable:!0,configurable:!0}),e.prototype._getTypeName=function(){return"Image"},e.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},e.prototype._draw=function(t,i){i.save();var r=this._sourceLeft,n=this._sourceTop,o=this._sourceWidth?this._sourceWidth:this._imageWidth,s=this._sourceHeight?this._sourceHeight:this._imageHeight;if(this._applyStates(i),this._processMeasures(t,i)&&this._loaded)switch(this._stretch){case e.STRETCH_NONE:case e.STRETCH_FILL:i.drawImage(this._domImage,r,n,o,s,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case e.STRETCH_UNIFORM:var h=this._currentMeasure.width/o,a=this._currentMeasure.height/s,u=Math.min(h,a),_=(this._currentMeasure.width-o*u)/2,c=(this._currentMeasure.height-s*u)/2;i.drawImage(this._domImage,r,n,o,s,this._currentMeasure.left+_,this._currentMeasure.top+c,o*u,s*u);break;case e.STRETCH_EXTEND:i.drawImage(this._domImage,r,n,o,s,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height),this._autoScale&&this.synchronizeSizeWithContent(),this._root.width=this.width,this._root.height=this.height}i.restore()},Object.defineProperty(e,"STRETCH_NONE",{get:function(){return e._STRETCH_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"STRETCH_FILL",{get:function(){return e._STRETCH_FILL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"STRETCH_UNIFORM",{get:function(){return e._STRETCH_UNIFORM},enumerable:!0,configurable:!0}),Object.defineProperty(e,"STRETCH_EXTEND",{get:function(){return e._STRETCH_EXTEND},enumerable:!0,configurable:!0}),e})(t.Control);e._STRETCH_NONE=0,e._STRETCH_FILL=1,e._STRETCH_UNIFORM=2,e._STRETCH_EXTEND=3,t.Image=e})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(t){!(function(e){var i=(function(e){function i(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 __extends(i,e),i.prototype._getTypeName=function(){return"Button"},i.prototype._processPicking=function(t,e,i){return!!this.contains(t,e)&&(this._processObservables(i,t,e),!0)},i.prototype._onPointerEnter=function(){return!!e.prototype._onPointerEnter.call(this)&&(this.pointerEnterAnimation&&this.pointerEnterAnimation(),!0)},i.prototype._onPointerOut=function(){this.pointerOutAnimation&&this.pointerOutAnimation(),e.prototype._onPointerOut.call(this)},i.prototype._onPointerDown=function(t){return!!e.prototype._onPointerDown.call(this,t)&&(this.pointerDownAnimation&&this.pointerDownAnimation(),!0)},i.prototype._onPointerUp=function(t){this.pointerUpAnimation&&this.pointerUpAnimation(),e.prototype._onPointerUp.call(this,t)},i.CreateImageButton=function(e,r,n){var o=new i(e),s=new t.GUI.TextBlock(e+"_button",r);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},i.CreateImageOnlyButton=function(e,r){var n=new i(e),o=new t.GUI.Image(e+"_icon",r);return o.stretch=t.GUI.Image.STRETCH_FILL,o.horizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT,n.addControl(o),n},i.CreateSimpleButton=function(e,r){var n=new i(e),o=new t.GUI.TextBlock(e+"_button",r);return o.textWrapping=!0,o.textHorizontalAlignment=t.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER,n.addControl(o),n},i})(e.Rectangle);e.Button=i})(t.GUI||(t.GUI={}))})(BABYLON||(BABYLON={}));var DOMImage=Image,BABYLON;!(function(t){!(function(e){var i=(function(e){function i(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 __extends(i,e),Object.defineProperty(i.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(i.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(i.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(i.prototype,"size",{get:function(){return this.width},set:function(t){this.width=t},enumerable:!0,configurable:!0}),i.prototype._getTypeName=function(){return"ColorPicker"},i.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},i.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)},i.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()},i.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,u=a*a,_=-t;_<t;_++)for(var c=-t;c<t;c++){var l=_*_+c*c;if(!(l>h||l<u)){var p=Math.sqrt(l),f=Math.atan2(c,_);this._HSVtoRGB(180*f/Math.PI+180,p/t,1,s);var d=4*(_+t+2*(c+t)*t);o[d]=255*s.r,o[d+1]=255*s.g,o[d+2]=255*s.b;var g=(p-a)/(t-a),m=.2;m=t<50?.2:t>150?.04:-.16*(t-50)/100+.2;var g=(p-a)/(t-a);o[d+3]=g<m?g/m*255:g>1-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<n&&(h+=6)):o==r?h=(n-i)/_+2:o==n&&(h=(i-r)/_+4),h*=60),e.r=h,e.g=a,e.b=u},i.prototype._HSVtoRGB=function(t,e,i,r){var n=i*e,o=t/60,s=n*(1-Math.abs(o%2-1)),h=0,a=0,u=0;o>=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){
  3. 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={}));