babylon.gui.js 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465
  1. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. var BABYLON;
  13. (function (BABYLON) {
  14. var GUI;
  15. (function (GUI) {
  16. var AdvancedDynamicTexture = (function (_super) {
  17. __extends(AdvancedDynamicTexture, _super);
  18. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  19. if (width === void 0) { width = 0; }
  20. if (height === void 0) { height = 0; }
  21. if (generateMipMaps === void 0) { generateMipMaps = false; }
  22. if (samplingMode === void 0) { samplingMode = BABYLON.Texture.NEAREST_SAMPLINGMODE; }
  23. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, BABYLON.Engine.TEXTUREFORMAT_RGBA) || this;
  24. _this._isDirty = false;
  25. _this._rootContainer = new GUI.Container("root");
  26. _this._linkedControls = new Array();
  27. _this._isFullscreen = false;
  28. _this._fullscreenViewport = new BABYLON.Viewport(0, 0, 1, 1);
  29. _this._idealWidth = 0;
  30. _this._idealHeight = 0;
  31. _this._renderObserver = _this.getScene().onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  32. _this._rootContainer._link(null, _this);
  33. _this.hasAlpha = true;
  34. if (!width || !height) {
  35. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  36. _this._onResize();
  37. }
  38. _this._texture.isReady = true;
  39. return _this;
  40. }
  41. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  42. get: function () {
  43. return this._background;
  44. },
  45. set: function (value) {
  46. if (this._background === value) {
  47. return;
  48. }
  49. this._background = value;
  50. this.markAsDirty();
  51. },
  52. enumerable: true,
  53. configurable: true
  54. });
  55. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  56. get: function () {
  57. return this._idealWidth;
  58. },
  59. set: function (value) {
  60. if (this._idealWidth === value) {
  61. return;
  62. }
  63. this._idealWidth = value;
  64. this.markAsDirty();
  65. this._rootContainer._markAllAsDirty();
  66. },
  67. enumerable: true,
  68. configurable: true
  69. });
  70. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  71. get: function () {
  72. return this._idealHeight;
  73. },
  74. set: function (value) {
  75. if (this._idealHeight === value) {
  76. return;
  77. }
  78. this._idealHeight = value;
  79. this.markAsDirty();
  80. this._rootContainer._markAllAsDirty();
  81. },
  82. enumerable: true,
  83. configurable: true
  84. });
  85. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  86. get: function () {
  87. return this._layerToDispose;
  88. },
  89. enumerable: true,
  90. configurable: true
  91. });
  92. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  93. if (!container) {
  94. container = this._rootContainer;
  95. }
  96. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  97. var child = _a[_i];
  98. if (child.children) {
  99. this.executeOnAllControls(func, child);
  100. continue;
  101. }
  102. func(child);
  103. }
  104. };
  105. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  106. this._isDirty = true;
  107. };
  108. AdvancedDynamicTexture.prototype.addControl = function (control) {
  109. this._rootContainer.addControl(control);
  110. return this;
  111. };
  112. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  113. this._rootContainer.removeControl(control);
  114. return this;
  115. };
  116. AdvancedDynamicTexture.prototype.dispose = function () {
  117. this.getScene().onBeforeCameraRenderObservable.remove(this._renderObserver);
  118. if (this._resizeObserver) {
  119. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  120. }
  121. if (this._pointerMoveObserver) {
  122. this.getScene().onPrePointerObservable.remove(this._pointerMoveObserver);
  123. }
  124. if (this._pointerObserver) {
  125. this.getScene().onPointerObservable.remove(this._pointerObserver);
  126. }
  127. if (this._canvasBlurObserver) {
  128. this.getScene().getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  129. }
  130. if (this._layerToDispose) {
  131. this._layerToDispose.texture = null;
  132. this._layerToDispose.dispose();
  133. this._layerToDispose = null;
  134. }
  135. _super.prototype.dispose.call(this);
  136. };
  137. AdvancedDynamicTexture.prototype._onResize = function () {
  138. // Check size
  139. var engine = this.getScene().getEngine();
  140. var textureSize = this.getSize();
  141. var renderWidth = engine.getRenderWidth();
  142. var renderHeight = engine.getRenderHeight();
  143. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  144. this.scaleTo(renderWidth, renderHeight);
  145. this.markAsDirty();
  146. if (this._idealWidth || this._idealHeight) {
  147. this._rootContainer._markAllAsDirty();
  148. }
  149. }
  150. };
  151. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  152. var engine = scene.getEngine();
  153. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  154. };
  155. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  156. if (this._layerToDispose) {
  157. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  158. return;
  159. }
  160. }
  161. if (this._isFullscreen && this._linkedControls.length) {
  162. var scene = this.getScene();
  163. var globalViewport = this._getGlobalViewport(scene);
  164. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  165. var control = _a[_i];
  166. var mesh = control._linkedMesh;
  167. var position = mesh.getBoundingInfo().boundingSphere.center;
  168. var projectedPosition = BABYLON.Vector3.Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  169. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  170. control.isVisible = false;
  171. continue;
  172. }
  173. control.isVisible = true;
  174. control._moveToProjectedPosition(projectedPosition);
  175. }
  176. }
  177. if (!this._isDirty && !this._rootContainer.isDirty) {
  178. return;
  179. }
  180. this._isDirty = false;
  181. this._render();
  182. this.update();
  183. };
  184. AdvancedDynamicTexture.prototype._render = function () {
  185. var textureSize = this.getSize();
  186. var renderWidth = textureSize.width;
  187. var renderHeight = textureSize.height;
  188. // Clear
  189. var context = this.getContext();
  190. context.clearRect(0, 0, renderWidth, renderHeight);
  191. if (this._background) {
  192. context.save();
  193. context.fillStyle = this._background;
  194. context.fillRect(0, 0, renderWidth, renderHeight);
  195. context.restore();
  196. }
  197. // Render
  198. context.font = "18px Arial";
  199. var measure = new GUI.Measure(0, 0, renderWidth, renderHeight);
  200. this._rootContainer._draw(measure, context);
  201. };
  202. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type) {
  203. if (this._capturingControl) {
  204. this._capturingControl._processObservables(type, x, y);
  205. return;
  206. }
  207. if (!this._rootContainer._processPicking(x, y, type)) {
  208. if (type === BABYLON.PointerEventTypes.POINTERMOVE) {
  209. if (this._lastControlOver && this._lastControlOver.onPointerOutObservable.hasObservers()) {
  210. this._lastControlOver.onPointerOutObservable.notifyObservers(this._lastControlOver);
  211. }
  212. this._lastControlOver = null;
  213. }
  214. }
  215. };
  216. AdvancedDynamicTexture.prototype.attach = function () {
  217. var _this = this;
  218. var scene = this.getScene();
  219. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  220. if (pi.type !== BABYLON.PointerEventTypes.POINTERMOVE
  221. && pi.type !== BABYLON.PointerEventTypes.POINTERUP
  222. && pi.type !== BABYLON.PointerEventTypes.POINTERDOWN) {
  223. return;
  224. }
  225. _this._shouldBlockPointer = false;
  226. _this._doPicking(scene.pointerX, scene.pointerY, pi.type);
  227. pi.skipOnPointerObservable = _this._shouldBlockPointer && pi.type !== BABYLON.PointerEventTypes.POINTERUP;
  228. });
  229. this._attachToOnBlur(scene);
  230. };
  231. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh) {
  232. var _this = this;
  233. var scene = this.getScene();
  234. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  235. if (pi.type !== BABYLON.PointerEventTypes.POINTERUP && pi.type !== BABYLON.PointerEventTypes.POINTERDOWN) {
  236. return;
  237. }
  238. if (pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  239. var uv = pi.pickInfo.getTextureCoordinates();
  240. var size = _this.getSize();
  241. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type);
  242. }
  243. else if (pi.type === BABYLON.PointerEventTypes.POINTERUP) {
  244. if (_this._lastControlDown) {
  245. _this._lastControlDown.forcePointerUp();
  246. }
  247. _this._lastControlDown = null;
  248. }
  249. });
  250. this._attachToOnBlur(scene);
  251. };
  252. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  253. var _this = this;
  254. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function () {
  255. if (_this._lastControlOver && _this._lastControlOver.onPointerOutObservable.hasObservers()) {
  256. _this._lastControlOver.onPointerOutObservable.notifyObservers(_this._lastControlOver);
  257. }
  258. _this._lastControlOver = null;
  259. if (_this._lastControlDown) {
  260. _this._lastControlDown.forcePointerUp();
  261. }
  262. _this._lastControlDown = null;
  263. });
  264. };
  265. // Statics
  266. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height) {
  267. if (width === void 0) { width = 1024; }
  268. if (height === void 0) { height = 1024; }
  269. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, BABYLON.Texture.TRILINEAR_SAMPLINGMODE);
  270. var material = new BABYLON.StandardMaterial("AdvancedDynamicTextureMaterial", mesh.getScene());
  271. material.backFaceCulling = false;
  272. material.diffuseColor = BABYLON.Color3.Black();
  273. material.specularColor = BABYLON.Color3.Black();
  274. material.emissiveTexture = result;
  275. material.opacityTexture = result;
  276. mesh.material = material;
  277. result.attachToMesh(mesh);
  278. return result;
  279. };
  280. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene) {
  281. if (foreground === void 0) { foreground = true; }
  282. if (scene === void 0) { scene = null; }
  283. var result = new AdvancedDynamicTexture(name, 0, 0, scene);
  284. // Display
  285. var layer = new BABYLON.Layer(name + "_layer", null, scene, !foreground);
  286. layer.texture = result;
  287. result._layerToDispose = layer;
  288. result._isFullscreen = true;
  289. // Attach
  290. result.attach();
  291. return result;
  292. };
  293. return AdvancedDynamicTexture;
  294. }(BABYLON.DynamicTexture));
  295. GUI.AdvancedDynamicTexture = AdvancedDynamicTexture;
  296. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  297. })(BABYLON || (BABYLON = {}));
  298. //# sourceMappingURL=advancedDynamicTexture.js.map
  299. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  300. var BABYLON;
  301. (function (BABYLON) {
  302. var GUI;
  303. (function (GUI) {
  304. var Measure = (function () {
  305. function Measure(left, top, width, height) {
  306. this.left = left;
  307. this.top = top;
  308. this.width = width;
  309. this.height = height;
  310. }
  311. Measure.prototype.copyFrom = function (other) {
  312. this.left = other.left;
  313. this.top = other.top;
  314. this.width = other.width;
  315. this.height = other.height;
  316. };
  317. Measure.prototype.isEqualsTo = function (other) {
  318. if (this.left !== other.left) {
  319. return false;
  320. }
  321. if (this.top !== other.top) {
  322. return false;
  323. }
  324. if (this.width !== other.width) {
  325. return false;
  326. }
  327. if (this.height !== other.height) {
  328. return false;
  329. }
  330. return true;
  331. };
  332. Measure.Empty = function () {
  333. return new Measure(0, 0, 0, 0);
  334. };
  335. return Measure;
  336. }());
  337. GUI.Measure = Measure;
  338. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  339. })(BABYLON || (BABYLON = {}));
  340. //# sourceMappingURL=measure.js.map
  341. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  342. var BABYLON;
  343. (function (BABYLON) {
  344. var GUI;
  345. (function (GUI) {
  346. var Matrix2D = (function () {
  347. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  348. this.m = new Float32Array(6);
  349. this.fromValues(m00, m01, m10, m11, m20, m21);
  350. }
  351. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  352. this.m[0] = m00;
  353. this.m[1] = m01;
  354. this.m[2] = m10;
  355. this.m[3] = m11;
  356. this.m[4] = m20;
  357. this.m[5] = m21;
  358. return this;
  359. };
  360. Matrix2D.prototype.determinant = function () {
  361. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  362. };
  363. Matrix2D.prototype.invertToRef = function (result) {
  364. var l0 = this.m[0];
  365. var l1 = this.m[1];
  366. var l2 = this.m[2];
  367. var l3 = this.m[3];
  368. var l4 = this.m[4];
  369. var l5 = this.m[5];
  370. var det = this.determinant();
  371. if (det < (BABYLON.Epsilon * BABYLON.Epsilon)) {
  372. result.m[0] = 0;
  373. result.m[1] = 0;
  374. result.m[2] = 0;
  375. result.m[3] = 0;
  376. result.m[4] = 0;
  377. result.m[5] = 0;
  378. return this;
  379. }
  380. var detDiv = 1 / det;
  381. var det4 = l2 * l5 - l3 * l4;
  382. var det5 = l1 * l4 - l0 * l5;
  383. result.m[0] = l3 * detDiv;
  384. result.m[1] = -l1 * detDiv;
  385. result.m[2] = -l2 * detDiv;
  386. result.m[3] = l0 * detDiv;
  387. result.m[4] = det4 * detDiv;
  388. result.m[5] = det5 * detDiv;
  389. return this;
  390. };
  391. Matrix2D.prototype.multiplyToRef = function (other, result) {
  392. var l0 = this.m[0];
  393. var l1 = this.m[1];
  394. var l2 = this.m[2];
  395. var l3 = this.m[3];
  396. var l4 = this.m[4];
  397. var l5 = this.m[5];
  398. var r0 = other.m[0];
  399. var r1 = other.m[1];
  400. var r2 = other.m[2];
  401. var r3 = other.m[3];
  402. var r4 = other.m[4];
  403. var r5 = other.m[5];
  404. result.m[0] = l0 * r0 + l1 * r2;
  405. result.m[1] = l0 * r1 + l1 * r3;
  406. result.m[2] = l2 * r0 + l3 * r2;
  407. result.m[3] = l2 * r1 + l3 * r3;
  408. result.m[4] = l4 * r0 + l5 * r2 + r4;
  409. result.m[5] = l4 * r1 + l5 * r3 + r5;
  410. return this;
  411. };
  412. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  413. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  414. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  415. return this;
  416. };
  417. // Statics
  418. Matrix2D.Identity = function () {
  419. return new Matrix2D(1, 0, 0, 1, 0, 0);
  420. };
  421. Matrix2D.TranslationToRef = function (x, y, result) {
  422. result.fromValues(1, 0, 0, 1, x, y);
  423. };
  424. Matrix2D.ScalingToRef = function (x, y, result) {
  425. result.fromValues(x, 0, 0, y, 0, 0);
  426. };
  427. Matrix2D.RotationToRef = function (angle, result) {
  428. var s = Math.sin(angle);
  429. var c = Math.cos(angle);
  430. result.fromValues(c, s, -s, c, 0, 0);
  431. };
  432. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  433. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  434. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  435. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  436. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  437. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  438. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  439. if (parentMatrix) {
  440. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  441. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  442. }
  443. else {
  444. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  445. }
  446. };
  447. return Matrix2D;
  448. }());
  449. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  450. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  451. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  452. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  453. Matrix2D._TempCompose0 = Matrix2D.Identity();
  454. Matrix2D._TempCompose1 = Matrix2D.Identity();
  455. Matrix2D._TempCompose2 = Matrix2D.Identity();
  456. GUI.Matrix2D = Matrix2D;
  457. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  458. })(BABYLON || (BABYLON = {}));
  459. //# sourceMappingURL=math2D.js.map
  460. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  461. var BABYLON;
  462. (function (BABYLON) {
  463. var GUI;
  464. (function (GUI) {
  465. var ValueAndUnit = (function () {
  466. function ValueAndUnit(value, unit, negativeValueAllowed) {
  467. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  468. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  469. this.unit = unit;
  470. this.negativeValueAllowed = negativeValueAllowed;
  471. this._value = 1;
  472. this.ignoreAdaptiveScaling = false;
  473. this._value = value;
  474. }
  475. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  476. get: function () {
  477. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  478. },
  479. enumerable: true,
  480. configurable: true
  481. });
  482. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  483. get: function () {
  484. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  485. },
  486. enumerable: true,
  487. configurable: true
  488. });
  489. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  490. get: function () {
  491. return this._value;
  492. },
  493. enumerable: true,
  494. configurable: true
  495. });
  496. ValueAndUnit.prototype.getValue = function (host) {
  497. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  498. if (host.idealWidth) {
  499. return (this._value * host.getSize().width) / host.idealWidth;
  500. }
  501. if (host.idealHeight) {
  502. return (this._value * host.getSize().height) / host.idealHeight;
  503. }
  504. }
  505. return this._value;
  506. };
  507. ValueAndUnit.prototype.toString = function (host) {
  508. switch (this.unit) {
  509. case ValueAndUnit.UNITMODE_PERCENTAGE:
  510. return (this.getValue(host) * 100) + "%";
  511. case ValueAndUnit.UNITMODE_PIXEL:
  512. return this.getValue(host) + "px";
  513. }
  514. return this.unit.toString();
  515. };
  516. ValueAndUnit.prototype.fromString = function (source) {
  517. var match = ValueAndUnit._Regex.exec(source.toString());
  518. if (!match || match.length === 0) {
  519. return false;
  520. }
  521. var sourceValue = parseFloat(match[1]);
  522. var sourceUnit = this.unit;
  523. if (!this.negativeValueAllowed) {
  524. if (sourceValue < 0) {
  525. sourceValue = 0;
  526. }
  527. }
  528. if (match.length === 4) {
  529. switch (match[3]) {
  530. case "px":
  531. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  532. break;
  533. case "%":
  534. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  535. sourceValue /= 100.0;
  536. break;
  537. }
  538. }
  539. if (sourceValue === this._value && sourceUnit === this.unit) {
  540. return false;
  541. }
  542. this._value = sourceValue;
  543. this.unit = sourceUnit;
  544. return true;
  545. };
  546. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  547. get: function () {
  548. return ValueAndUnit._UNITMODE_PERCENTAGE;
  549. },
  550. enumerable: true,
  551. configurable: true
  552. });
  553. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  554. get: function () {
  555. return ValueAndUnit._UNITMODE_PIXEL;
  556. },
  557. enumerable: true,
  558. configurable: true
  559. });
  560. return ValueAndUnit;
  561. }());
  562. // Static
  563. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  564. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  565. ValueAndUnit._UNITMODE_PIXEL = 1;
  566. GUI.ValueAndUnit = ValueAndUnit;
  567. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  568. })(BABYLON || (BABYLON = {}));
  569. //# sourceMappingURL=valueAndUnit.js.map
  570. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  571. var BABYLON;
  572. (function (BABYLON) {
  573. var GUI;
  574. (function (GUI) {
  575. var Control = (function () {
  576. // Functions
  577. function Control(name) {
  578. this.name = name;
  579. this._alpha = 1;
  580. this._alphaSet = false;
  581. this._zIndex = 0;
  582. this._currentMeasure = GUI.Measure.Empty();
  583. this._fontFamily = "Arial";
  584. this._fontSize = new GUI.ValueAndUnit(18, GUI.ValueAndUnit.UNITMODE_PIXEL, false);
  585. this._width = new GUI.ValueAndUnit(1, GUI.ValueAndUnit.UNITMODE_PERCENTAGE, false);
  586. this._height = new GUI.ValueAndUnit(1, GUI.ValueAndUnit.UNITMODE_PERCENTAGE, false);
  587. this._color = "white";
  588. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  589. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  590. this._isDirty = true;
  591. this._cachedParentMeasure = GUI.Measure.Empty();
  592. this._paddingLeft = new GUI.ValueAndUnit(0);
  593. this._paddingRight = new GUI.ValueAndUnit(0);
  594. this._paddingTop = new GUI.ValueAndUnit(0);
  595. this._paddingBottom = new GUI.ValueAndUnit(0);
  596. this._left = new GUI.ValueAndUnit(0);
  597. this._top = new GUI.ValueAndUnit(0);
  598. this._scaleX = 1.0;
  599. this._scaleY = 1.0;
  600. this._rotation = 0;
  601. this._transformCenterX = 0.5;
  602. this._transformCenterY = 0.5;
  603. this._transformMatrix = GUI.Matrix2D.Identity();
  604. this._invertTransformMatrix = GUI.Matrix2D.Identity();
  605. this._transformedPosition = BABYLON.Vector2.Zero();
  606. this._isMatrixDirty = true;
  607. this._isVisible = true;
  608. this._fontSet = false;
  609. this._dummyVector2 = BABYLON.Vector2.Zero();
  610. this._downCount = 0;
  611. this._enterCount = 0;
  612. this.isHitTestVisible = true;
  613. this.isPointerBlocker = false;
  614. this._linkOffsetX = new GUI.ValueAndUnit(0);
  615. this._linkOffsetY = new GUI.ValueAndUnit(0);
  616. /**
  617. * An event triggered when the pointer move over the control.
  618. * @type {BABYLON.Observable}
  619. */
  620. this.onPointerMoveObservable = new BABYLON.Observable();
  621. /**
  622. * An event triggered when the pointer move out of the control.
  623. * @type {BABYLON.Observable}
  624. */
  625. this.onPointerOutObservable = new BABYLON.Observable();
  626. /**
  627. * An event triggered when the pointer taps the control
  628. * @type {BABYLON.Observable}
  629. */
  630. this.onPointerDownObservable = new BABYLON.Observable();
  631. /**
  632. * An event triggered when pointer up
  633. * @type {BABYLON.Observable}
  634. */
  635. this.onPointerUpObservable = new BABYLON.Observable();
  636. /**
  637. * An event triggered when pointer enters the control
  638. * @type {BABYLON.Observable}
  639. */
  640. this.onPointerEnterObservable = new BABYLON.Observable();
  641. /**
  642. * An event triggered when the control is marked as dirty
  643. * @type {BABYLON.Observable}
  644. */
  645. this.onDirtyObservable = new BABYLON.Observable();
  646. }
  647. Object.defineProperty(Control.prototype, "typeName", {
  648. // Properties
  649. get: function () {
  650. return this._getTypeName();
  651. },
  652. enumerable: true,
  653. configurable: true
  654. });
  655. Object.defineProperty(Control.prototype, "alpha", {
  656. get: function () {
  657. return this._alpha;
  658. },
  659. set: function (value) {
  660. if (this._alpha === value) {
  661. return;
  662. }
  663. this._alphaSet = true;
  664. this._alpha = value;
  665. this._markAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(Control.prototype, "scaleX", {
  671. get: function () {
  672. return this._scaleX;
  673. },
  674. set: function (value) {
  675. if (this._scaleX === value) {
  676. return;
  677. }
  678. this._scaleX = value;
  679. this._markAsDirty();
  680. this._markMatrixAsDirty();
  681. },
  682. enumerable: true,
  683. configurable: true
  684. });
  685. Object.defineProperty(Control.prototype, "scaleY", {
  686. get: function () {
  687. return this._scaleY;
  688. },
  689. set: function (value) {
  690. if (this._scaleY === value) {
  691. return;
  692. }
  693. this._scaleY = value;
  694. this._markAsDirty();
  695. this._markMatrixAsDirty();
  696. },
  697. enumerable: true,
  698. configurable: true
  699. });
  700. Object.defineProperty(Control.prototype, "rotation", {
  701. get: function () {
  702. return this._rotation;
  703. },
  704. set: function (value) {
  705. if (this._rotation === value) {
  706. return;
  707. }
  708. this._rotation = value;
  709. this._markAsDirty();
  710. this._markMatrixAsDirty();
  711. },
  712. enumerable: true,
  713. configurable: true
  714. });
  715. Object.defineProperty(Control.prototype, "transformCenterY", {
  716. get: function () {
  717. return this._transformCenterY;
  718. },
  719. set: function (value) {
  720. if (this._transformCenterY === value) {
  721. return;
  722. }
  723. this._transformCenterY = value;
  724. this._markAsDirty();
  725. this._markMatrixAsDirty();
  726. },
  727. enumerable: true,
  728. configurable: true
  729. });
  730. Object.defineProperty(Control.prototype, "transformCenterX", {
  731. get: function () {
  732. return this._transformCenterX;
  733. },
  734. set: function (value) {
  735. if (this._transformCenterX === value) {
  736. return;
  737. }
  738. this._transformCenterX = value;
  739. this._markAsDirty();
  740. this._markMatrixAsDirty();
  741. },
  742. enumerable: true,
  743. configurable: true
  744. });
  745. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  746. get: function () {
  747. return this._horizontalAlignment;
  748. },
  749. set: function (value) {
  750. if (this._horizontalAlignment === value) {
  751. return;
  752. }
  753. this._horizontalAlignment = value;
  754. this._markAsDirty();
  755. },
  756. enumerable: true,
  757. configurable: true
  758. });
  759. Object.defineProperty(Control.prototype, "verticalAlignment", {
  760. get: function () {
  761. return this._verticalAlignment;
  762. },
  763. set: function (value) {
  764. if (this._verticalAlignment === value) {
  765. return;
  766. }
  767. this._verticalAlignment = value;
  768. this._markAsDirty();
  769. },
  770. enumerable: true,
  771. configurable: true
  772. });
  773. Object.defineProperty(Control.prototype, "width", {
  774. get: function () {
  775. return this._width.toString(this._host);
  776. },
  777. set: function (value) {
  778. if (this._width.toString(this._host) === value) {
  779. return;
  780. }
  781. if (this._width.fromString(value)) {
  782. this._markAsDirty();
  783. }
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(Control.prototype, "height", {
  789. get: function () {
  790. return this._height.toString(this._host);
  791. },
  792. set: function (value) {
  793. if (this._height.toString(this._host) === value) {
  794. return;
  795. }
  796. if (this._height.fromString(value)) {
  797. this._markAsDirty();
  798. }
  799. },
  800. enumerable: true,
  801. configurable: true
  802. });
  803. Object.defineProperty(Control.prototype, "fontFamily", {
  804. get: function () {
  805. return this._fontFamily;
  806. },
  807. set: function (value) {
  808. if (this._fontFamily === value) {
  809. return;
  810. }
  811. this._fontFamily = value;
  812. this._fontSet = true;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(Control.prototype, "fontSize", {
  818. get: function () {
  819. return this._fontSize.toString(this._host);
  820. },
  821. set: function (value) {
  822. if (this._fontSize.toString(this._host) === value) {
  823. return;
  824. }
  825. if (this._fontSize.fromString(value)) {
  826. this._markAsDirty();
  827. this._fontSet = true;
  828. }
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. Object.defineProperty(Control.prototype, "color", {
  834. get: function () {
  835. return this._color;
  836. },
  837. set: function (value) {
  838. if (this._color === value) {
  839. return;
  840. }
  841. this._color = value;
  842. this._markAsDirty();
  843. },
  844. enumerable: true,
  845. configurable: true
  846. });
  847. Object.defineProperty(Control.prototype, "zIndex", {
  848. get: function () {
  849. return this._zIndex;
  850. },
  851. set: function (value) {
  852. if (this.zIndex === value) {
  853. return;
  854. }
  855. this._zIndex = value;
  856. if (this._root) {
  857. this._root._reOrderControl(this);
  858. }
  859. },
  860. enumerable: true,
  861. configurable: true
  862. });
  863. Object.defineProperty(Control.prototype, "isVisible", {
  864. get: function () {
  865. return this._isVisible;
  866. },
  867. set: function (value) {
  868. if (this._isVisible === value) {
  869. return;
  870. }
  871. this._isVisible = value;
  872. this._markAsDirty();
  873. },
  874. enumerable: true,
  875. configurable: true
  876. });
  877. Object.defineProperty(Control.prototype, "isDirty", {
  878. get: function () {
  879. return this._isDirty;
  880. },
  881. enumerable: true,
  882. configurable: true
  883. });
  884. Object.defineProperty(Control.prototype, "paddingLeft", {
  885. get: function () {
  886. return this._paddingLeft.toString(this._host);
  887. },
  888. set: function (value) {
  889. if (this._paddingLeft.fromString(value)) {
  890. this._markAsDirty();
  891. }
  892. },
  893. enumerable: true,
  894. configurable: true
  895. });
  896. Object.defineProperty(Control.prototype, "paddingRight", {
  897. get: function () {
  898. return this._paddingRight.toString(this._host);
  899. },
  900. set: function (value) {
  901. if (this._paddingRight.fromString(value)) {
  902. this._markAsDirty();
  903. }
  904. },
  905. enumerable: true,
  906. configurable: true
  907. });
  908. Object.defineProperty(Control.prototype, "paddingTop", {
  909. get: function () {
  910. return this._paddingTop.toString(this._host);
  911. },
  912. set: function (value) {
  913. if (this._paddingTop.fromString(value)) {
  914. this._markAsDirty();
  915. }
  916. },
  917. enumerable: true,
  918. configurable: true
  919. });
  920. Object.defineProperty(Control.prototype, "paddingBottom", {
  921. get: function () {
  922. return this._paddingBottom.toString(this._host);
  923. },
  924. set: function (value) {
  925. if (this._paddingBottom.fromString(value)) {
  926. this._markAsDirty();
  927. }
  928. },
  929. enumerable: true,
  930. configurable: true
  931. });
  932. Object.defineProperty(Control.prototype, "left", {
  933. get: function () {
  934. return this._left.toString(this._host);
  935. },
  936. set: function (value) {
  937. if (this._left.fromString(value)) {
  938. this._markAsDirty();
  939. }
  940. },
  941. enumerable: true,
  942. configurable: true
  943. });
  944. Object.defineProperty(Control.prototype, "top", {
  945. get: function () {
  946. return this._top.toString(this._host);
  947. },
  948. set: function (value) {
  949. if (this._top.fromString(value)) {
  950. this._markAsDirty();
  951. }
  952. },
  953. enumerable: true,
  954. configurable: true
  955. });
  956. Object.defineProperty(Control.prototype, "linkOffsetX", {
  957. get: function () {
  958. return this._linkOffsetX.toString(this._host);
  959. },
  960. set: function (value) {
  961. if (this._linkOffsetX.fromString(value)) {
  962. this._markAsDirty();
  963. }
  964. },
  965. enumerable: true,
  966. configurable: true
  967. });
  968. Object.defineProperty(Control.prototype, "linkOffsetY", {
  969. get: function () {
  970. return this._linkOffsetY.toString(this._host);
  971. },
  972. set: function (value) {
  973. if (this._linkOffsetY.fromString(value)) {
  974. this._markAsDirty();
  975. }
  976. },
  977. enumerable: true,
  978. configurable: true
  979. });
  980. Object.defineProperty(Control.prototype, "centerX", {
  981. get: function () {
  982. return this._currentMeasure.left + this._currentMeasure.width / 2;
  983. },
  984. enumerable: true,
  985. configurable: true
  986. });
  987. Object.defineProperty(Control.prototype, "centerY", {
  988. get: function () {
  989. return this._currentMeasure.top + this._currentMeasure.height / 2;
  990. },
  991. enumerable: true,
  992. configurable: true
  993. });
  994. Control.prototype._getTypeName = function () {
  995. return "Control";
  996. };
  997. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  998. var result = BABYLON.Vector2.Zero();
  999. this.getLocalCoordinatesToRef(globalCoordinates, result);
  1000. return result;
  1001. };
  1002. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  1003. result.x = globalCoordinates.x - this._currentMeasure.left;
  1004. result.y = globalCoordinates.y - this._currentMeasure.top;
  1005. return this;
  1006. };
  1007. Control.prototype.moveToVector3 = function (position, scene) {
  1008. if (!this._host || this._root !== this._host._rootContainer) {
  1009. BABYLON.Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
  1010. return;
  1011. }
  1012. this.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1013. this.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1014. var engine = scene.getEngine();
  1015. var globalViewport = this._host._getGlobalViewport(scene);
  1016. var projectedPosition = BABYLON.Vector3.Project(position, BABYLON.Matrix.Identity(), scene.getTransformMatrix(), globalViewport);
  1017. this._moveToProjectedPosition(projectedPosition);
  1018. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1019. this.isVisible = false;
  1020. return;
  1021. }
  1022. this.isVisible = true;
  1023. };
  1024. Control.prototype.linkWithMesh = function (mesh) {
  1025. if (!this._host || this._root !== this._host._rootContainer) {
  1026. BABYLON.Tools.Error("Cannot link a control to a mesh if the control is not at root level");
  1027. return;
  1028. }
  1029. if (this._host._linkedControls.indexOf(this) !== -1) {
  1030. return;
  1031. }
  1032. this.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1033. this.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1034. this._linkedMesh = mesh;
  1035. this._host._linkedControls.push(this);
  1036. };
  1037. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  1038. this.left = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2) + "px";
  1039. this.top = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2) + "px";
  1040. this._left.ignoreAdaptiveScaling = true;
  1041. this._top.ignoreAdaptiveScaling = true;
  1042. };
  1043. Control.prototype._markMatrixAsDirty = function () {
  1044. this._isMatrixDirty = true;
  1045. this._markAsDirty();
  1046. };
  1047. Control.prototype._markAsDirty = function () {
  1048. this._isDirty = true;
  1049. if (!this._host) {
  1050. return; // Not yet connected
  1051. }
  1052. this._host.markAsDirty();
  1053. };
  1054. Control.prototype._markAllAsDirty = function () {
  1055. this._markAsDirty();
  1056. if (this._font) {
  1057. this._prepareFont();
  1058. }
  1059. };
  1060. Control.prototype._link = function (root, host) {
  1061. this._root = root;
  1062. this._host = host;
  1063. };
  1064. Control.prototype._transform = function (context) {
  1065. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  1066. return;
  1067. }
  1068. // postTranslate
  1069. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  1070. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  1071. context.translate(offsetX, offsetY);
  1072. // rotate
  1073. context.rotate(this._rotation);
  1074. // scale
  1075. context.scale(this._scaleX, this._scaleY);
  1076. // preTranslate
  1077. context.translate(-offsetX, -offsetY);
  1078. // Need to update matrices?
  1079. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  1080. this._cachedOffsetX = offsetX;
  1081. this._cachedOffsetY = offsetY;
  1082. this._isMatrixDirty = false;
  1083. GUI.Matrix2D.ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this._root ? this._root._transformMatrix : null, this._transformMatrix);
  1084. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  1085. }
  1086. };
  1087. Control.prototype._applyStates = function (context) {
  1088. if (this._fontSet) {
  1089. this._fontSet = false;
  1090. this._prepareFont();
  1091. }
  1092. if (this._font) {
  1093. context.font = this._font;
  1094. }
  1095. if (this._color) {
  1096. context.fillStyle = this._color;
  1097. }
  1098. if (this._alphaSet) {
  1099. context.globalAlpha = this._alpha;
  1100. }
  1101. };
  1102. Control.prototype._processMeasures = function (parentMeasure, context) {
  1103. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  1104. this._isDirty = false;
  1105. this._currentMeasure.copyFrom(parentMeasure);
  1106. // Let children take some pre-measurement actions
  1107. this._preMeasure(parentMeasure, context);
  1108. this._measure();
  1109. this._computeAlignment(parentMeasure, context);
  1110. // Convert to int values
  1111. this._currentMeasure.left = this._currentMeasure.left | 0;
  1112. this._currentMeasure.top = this._currentMeasure.top | 0;
  1113. this._currentMeasure.width = this._currentMeasure.width | 0;
  1114. this._currentMeasure.height = this._currentMeasure.height | 0;
  1115. // Let children add more features
  1116. this._additionalProcessing(parentMeasure, context);
  1117. this._cachedParentMeasure.copyFrom(parentMeasure);
  1118. if (this.onDirtyObservable.hasObservers()) {
  1119. this.onDirtyObservable.notifyObservers(this);
  1120. }
  1121. }
  1122. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  1123. return false;
  1124. }
  1125. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  1126. return false;
  1127. }
  1128. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  1129. return false;
  1130. }
  1131. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  1132. return false;
  1133. }
  1134. // Transform
  1135. this._transform(context);
  1136. // Clip
  1137. this._clip(context);
  1138. context.clip();
  1139. return true;
  1140. };
  1141. Control.prototype._clip = function (context) {
  1142. context.beginPath();
  1143. context.rect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  1144. };
  1145. Control.prototype._measure = function () {
  1146. // Width / Height
  1147. if (this._width.isPixel) {
  1148. this._currentMeasure.width = this._width.getValue(this._host);
  1149. }
  1150. else {
  1151. this._currentMeasure.width *= this._width.getValue(this._host);
  1152. }
  1153. if (this._height.isPixel) {
  1154. this._currentMeasure.height = this._height.getValue(this._host);
  1155. }
  1156. else {
  1157. this._currentMeasure.height *= this._height.getValue(this._host);
  1158. }
  1159. };
  1160. Control.prototype._computeAlignment = function (parentMeasure, context) {
  1161. var width = this._currentMeasure.width;
  1162. var height = this._currentMeasure.height;
  1163. var parentWidth = parentMeasure.width;
  1164. var parentHeight = parentMeasure.height;
  1165. // Left / top
  1166. var x = 0;
  1167. var y = 0;
  1168. switch (this.horizontalAlignment) {
  1169. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  1170. x = 0;
  1171. break;
  1172. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  1173. x = parentWidth - width;
  1174. break;
  1175. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  1176. x = (parentWidth - width) / 2;
  1177. break;
  1178. }
  1179. switch (this.verticalAlignment) {
  1180. case Control.VERTICAL_ALIGNMENT_TOP:
  1181. y = 0;
  1182. break;
  1183. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  1184. y = parentHeight - height;
  1185. break;
  1186. case Control.VERTICAL_ALIGNMENT_CENTER:
  1187. y = (parentHeight - height) / 2;
  1188. break;
  1189. }
  1190. if (this._paddingLeft.isPixel) {
  1191. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  1192. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  1193. }
  1194. else {
  1195. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  1196. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  1197. }
  1198. if (this._paddingRight.isPixel) {
  1199. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  1200. }
  1201. else {
  1202. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  1203. }
  1204. if (this._paddingTop.isPixel) {
  1205. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  1206. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  1207. }
  1208. else {
  1209. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  1210. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  1211. }
  1212. if (this._paddingBottom.isPixel) {
  1213. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  1214. }
  1215. else {
  1216. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  1217. }
  1218. if (this._left.isPixel) {
  1219. this._currentMeasure.left += this._left.getValue(this._host);
  1220. }
  1221. else {
  1222. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  1223. }
  1224. if (this._top.isPixel) {
  1225. this._currentMeasure.top += this._top.getValue(this._host);
  1226. }
  1227. else {
  1228. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  1229. }
  1230. this._currentMeasure.left += x;
  1231. this._currentMeasure.top += y;
  1232. };
  1233. Control.prototype._preMeasure = function (parentMeasure, context) {
  1234. // Do nothing
  1235. };
  1236. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  1237. // Do nothing
  1238. };
  1239. Control.prototype._draw = function (parentMeasure, context) {
  1240. // Do nothing
  1241. };
  1242. Control.prototype.contains = function (x, y) {
  1243. // Invert transform
  1244. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  1245. x = this._transformedPosition.x;
  1246. y = this._transformedPosition.y;
  1247. // Check
  1248. if (x < this._currentMeasure.left) {
  1249. return false;
  1250. }
  1251. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  1252. return false;
  1253. }
  1254. if (y < this._currentMeasure.top) {
  1255. return false;
  1256. }
  1257. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  1258. return false;
  1259. }
  1260. if (this.isPointerBlocker) {
  1261. this._host._shouldBlockPointer = true;
  1262. }
  1263. return true;
  1264. };
  1265. Control.prototype._processPicking = function (x, y, type) {
  1266. if (!this.isHitTestVisible || !this.isVisible) {
  1267. return false;
  1268. }
  1269. if (!this.contains(x, y)) {
  1270. return false;
  1271. }
  1272. this._processObservables(type, x, y);
  1273. return true;
  1274. };
  1275. Control.prototype._onPointerMove = function (coordinates) {
  1276. if (this.onPointerMoveObservable.hasObservers()) {
  1277. this.onPointerMoveObservable.notifyObservers(coordinates);
  1278. }
  1279. };
  1280. Control.prototype._onPointerEnter = function () {
  1281. if (this._enterCount !== 0) {
  1282. return false;
  1283. }
  1284. this._enterCount++;
  1285. if (this.onPointerEnterObservable.hasObservers()) {
  1286. this.onPointerEnterObservable.notifyObservers(this);
  1287. }
  1288. return true;
  1289. };
  1290. Control.prototype._onPointerOut = function () {
  1291. this._enterCount = 0;
  1292. if (this.onPointerOutObservable.hasObservers()) {
  1293. this.onPointerOutObservable.notifyObservers(this);
  1294. }
  1295. };
  1296. Control.prototype._onPointerDown = function (coordinates) {
  1297. if (this._downCount !== 0) {
  1298. return false;
  1299. }
  1300. this._downCount++;
  1301. if (this.onPointerDownObservable.hasObservers()) {
  1302. this.onPointerDownObservable.notifyObservers(coordinates);
  1303. }
  1304. return true;
  1305. };
  1306. Control.prototype._onPointerUp = function (coordinates) {
  1307. this._downCount = 0;
  1308. if (this.onPointerUpObservable.hasObservers()) {
  1309. this.onPointerUpObservable.notifyObservers(coordinates);
  1310. }
  1311. };
  1312. Control.prototype.forcePointerUp = function () {
  1313. this._onPointerUp(BABYLON.Vector2.Zero());
  1314. };
  1315. Control.prototype._processObservables = function (type, x, y) {
  1316. this._dummyVector2.copyFromFloats(x, y);
  1317. if (type === BABYLON.PointerEventTypes.POINTERMOVE) {
  1318. this._onPointerMove(this._dummyVector2);
  1319. var previousControlOver = this._host._lastControlOver;
  1320. if (previousControlOver && previousControlOver !== this) {
  1321. previousControlOver._onPointerOut();
  1322. }
  1323. if (previousControlOver !== this) {
  1324. this._onPointerEnter();
  1325. }
  1326. this._host._lastControlOver = this;
  1327. return true;
  1328. }
  1329. if (type === BABYLON.PointerEventTypes.POINTERDOWN) {
  1330. this._onPointerDown(this._dummyVector2);
  1331. this._host._lastControlDown = this;
  1332. return true;
  1333. }
  1334. if (type === BABYLON.PointerEventTypes.POINTERUP) {
  1335. if (this._host._lastControlDown) {
  1336. this._host._lastControlDown._onPointerUp(this._dummyVector2);
  1337. }
  1338. this._host._lastControlDown = null;
  1339. return true;
  1340. }
  1341. return false;
  1342. };
  1343. Control.prototype._prepareFont = function () {
  1344. if (!this._fontFamily) {
  1345. return;
  1346. }
  1347. this._font = this._fontSize.getValue(this._host) + "px " + this._fontFamily;
  1348. this._fontOffset = Control._GetFontOffset(this._font);
  1349. };
  1350. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  1351. get: function () {
  1352. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  1353. },
  1354. enumerable: true,
  1355. configurable: true
  1356. });
  1357. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  1358. get: function () {
  1359. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  1360. },
  1361. enumerable: true,
  1362. configurable: true
  1363. });
  1364. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  1365. get: function () {
  1366. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  1367. },
  1368. enumerable: true,
  1369. configurable: true
  1370. });
  1371. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  1372. get: function () {
  1373. return Control._VERTICAL_ALIGNMENT_TOP;
  1374. },
  1375. enumerable: true,
  1376. configurable: true
  1377. });
  1378. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  1379. get: function () {
  1380. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  1386. get: function () {
  1387. return Control._VERTICAL_ALIGNMENT_CENTER;
  1388. },
  1389. enumerable: true,
  1390. configurable: true
  1391. });
  1392. Control._GetFontOffset = function (font) {
  1393. if (Control._FontHeightSizes[font]) {
  1394. return Control._FontHeightSizes[font];
  1395. }
  1396. var text = document.createElement("span");
  1397. text.innerHTML = "Hg";
  1398. text.style.font = font;
  1399. var block = document.createElement("div");
  1400. block.style.display = "inline-block";
  1401. block.style.width = "1px";
  1402. block.style.height = "0px";
  1403. block.style.verticalAlign = "bottom";
  1404. var div = document.createElement("div");
  1405. div.appendChild(text);
  1406. div.appendChild(block);
  1407. document.body.appendChild(div);
  1408. var fontAscent = 0;
  1409. var fontHeight = 0;
  1410. try {
  1411. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  1412. block.style.verticalAlign = "baseline";
  1413. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  1414. }
  1415. finally {
  1416. document.body.removeChild(div);
  1417. }
  1418. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  1419. Control._FontHeightSizes[font] = result;
  1420. return result;
  1421. };
  1422. ;
  1423. Control.AddHeader = function (control, text, size, options) {
  1424. var panel = new BABYLON.GUI.StackPanel("panel");
  1425. var isHorizontal = options ? options.isHorizontal : true;
  1426. var controlFirst = options ? options.controlFirst : true;
  1427. panel.isVertical = !isHorizontal;
  1428. var header = new BABYLON.GUI.TextBlock("header");
  1429. header.text = text;
  1430. header.textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  1431. if (isHorizontal) {
  1432. header.width = size;
  1433. }
  1434. else {
  1435. header.height = size;
  1436. }
  1437. if (controlFirst) {
  1438. panel.addControl(control);
  1439. panel.addControl(header);
  1440. header.paddingLeft = "5px";
  1441. }
  1442. else {
  1443. panel.addControl(header);
  1444. panel.addControl(control);
  1445. header.paddingRight = "5px";
  1446. }
  1447. return panel;
  1448. };
  1449. Control.drawEllipse = function (x, y, width, height, context) {
  1450. context.translate(x, y);
  1451. context.scale(width, height);
  1452. context.beginPath();
  1453. context.arc(0, 0, 1, 0, 2 * Math.PI);
  1454. context.closePath();
  1455. context.scale(1 / width, 1 / height);
  1456. context.translate(-x, -y);
  1457. };
  1458. return Control;
  1459. }());
  1460. // Statics
  1461. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  1462. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  1463. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  1464. Control._VERTICAL_ALIGNMENT_TOP = 0;
  1465. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  1466. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  1467. Control._FontHeightSizes = {};
  1468. GUI.Control = Control;
  1469. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1470. })(BABYLON || (BABYLON = {}));
  1471. //# sourceMappingURL=control.js.map
  1472. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1473. var __extends = (this && this.__extends) || (function () {
  1474. var extendStatics = Object.setPrototypeOf ||
  1475. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1476. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1477. return function (d, b) {
  1478. extendStatics(d, b);
  1479. function __() { this.constructor = d; }
  1480. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1481. };
  1482. })();
  1483. var BABYLON;
  1484. (function (BABYLON) {
  1485. var GUI;
  1486. (function (GUI) {
  1487. var Container = (function (_super) {
  1488. __extends(Container, _super);
  1489. function Container(name) {
  1490. var _this = _super.call(this, name) || this;
  1491. _this.name = name;
  1492. _this._children = new Array();
  1493. _this._measureForChildren = GUI.Measure.Empty();
  1494. return _this;
  1495. }
  1496. Object.defineProperty(Container.prototype, "background", {
  1497. get: function () {
  1498. return this._background;
  1499. },
  1500. set: function (value) {
  1501. if (this._background === value) {
  1502. return;
  1503. }
  1504. this._background = value;
  1505. this._markAsDirty();
  1506. },
  1507. enumerable: true,
  1508. configurable: true
  1509. });
  1510. Object.defineProperty(Container.prototype, "children", {
  1511. get: function () {
  1512. return this._children;
  1513. },
  1514. enumerable: true,
  1515. configurable: true
  1516. });
  1517. Container.prototype._getTypeName = function () {
  1518. return "Container";
  1519. };
  1520. Container.prototype.getChildByName = function (name) {
  1521. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1522. var child = _a[_i];
  1523. if (child.name === name) {
  1524. return child;
  1525. }
  1526. }
  1527. return null;
  1528. };
  1529. Container.prototype.getChildByType = function (name, type) {
  1530. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1531. var child = _a[_i];
  1532. if (child.typeName === type) {
  1533. return child;
  1534. }
  1535. }
  1536. return null;
  1537. };
  1538. Container.prototype.containsControl = function (control) {
  1539. return this._children.indexOf(control) !== -1;
  1540. };
  1541. Container.prototype.addControl = function (control) {
  1542. var index = this._children.indexOf(control);
  1543. if (index !== -1) {
  1544. return this;
  1545. }
  1546. control._link(this, this._host);
  1547. this._reOrderControl(control);
  1548. this._markAsDirty();
  1549. return this;
  1550. };
  1551. Container.prototype.removeControl = function (control) {
  1552. var index = this._children.indexOf(control);
  1553. if (index !== -1) {
  1554. this._children.splice(index, 1);
  1555. }
  1556. this._markAsDirty();
  1557. return this;
  1558. };
  1559. Container.prototype._reOrderControl = function (control) {
  1560. this.removeControl(control);
  1561. for (var index = 0; index < this._children.length; index++) {
  1562. if (this._children[index].zIndex > control.zIndex) {
  1563. this._children.splice(index, 0, control);
  1564. return;
  1565. }
  1566. }
  1567. this._children.push(control);
  1568. this._markAsDirty();
  1569. };
  1570. Container.prototype._markMatrixAsDirty = function () {
  1571. _super.prototype._markMatrixAsDirty.call(this);
  1572. for (var index = 0; index < this._children.length; index++) {
  1573. this._children[index]._markMatrixAsDirty();
  1574. }
  1575. };
  1576. Container.prototype._markAllAsDirty = function () {
  1577. _super.prototype._markAllAsDirty.call(this);
  1578. for (var index = 0; index < this._children.length; index++) {
  1579. this._children[index]._markAllAsDirty();
  1580. }
  1581. };
  1582. Container.prototype._localDraw = function (context) {
  1583. if (this._background) {
  1584. context.fillStyle = this._background;
  1585. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  1586. }
  1587. };
  1588. Container.prototype._link = function (root, host) {
  1589. _super.prototype._link.call(this, root, host);
  1590. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1591. var child = _a[_i];
  1592. child._link(root, host);
  1593. }
  1594. };
  1595. Container.prototype._draw = function (parentMeasure, context) {
  1596. context.save();
  1597. this._applyStates(context);
  1598. if (this._processMeasures(parentMeasure, context)) {
  1599. this._localDraw(context);
  1600. this._clipForChildren(context);
  1601. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1602. var child = _a[_i];
  1603. if (child.isVisible) {
  1604. child._draw(this._measureForChildren, context);
  1605. }
  1606. }
  1607. }
  1608. context.restore();
  1609. };
  1610. Container.prototype._processPicking = function (x, y, type) {
  1611. if (!_super.prototype.contains.call(this, x, y)) {
  1612. return false;
  1613. }
  1614. // Checking backwards to pick closest first
  1615. for (var index = this._children.length - 1; index >= 0; index--) {
  1616. var child = this._children[index];
  1617. if (child._processPicking(x, y, type)) {
  1618. return true;
  1619. }
  1620. }
  1621. return this._processObservables(type, x, y);
  1622. };
  1623. Container.prototype._clipForChildren = function (context) {
  1624. // DO nothing
  1625. };
  1626. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  1627. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1628. this._measureForChildren.copyFrom(this._currentMeasure);
  1629. };
  1630. return Container;
  1631. }(GUI.Control));
  1632. GUI.Container = Container;
  1633. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1634. })(BABYLON || (BABYLON = {}));
  1635. //# sourceMappingURL=container.js.map
  1636. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1637. var __extends = (this && this.__extends) || (function () {
  1638. var extendStatics = Object.setPrototypeOf ||
  1639. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1640. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1641. return function (d, b) {
  1642. extendStatics(d, b);
  1643. function __() { this.constructor = d; }
  1644. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1645. };
  1646. })();
  1647. var BABYLON;
  1648. (function (BABYLON) {
  1649. var GUI;
  1650. (function (GUI) {
  1651. var StackPanel = (function (_super) {
  1652. __extends(StackPanel, _super);
  1653. function StackPanel(name) {
  1654. var _this = _super.call(this, name) || this;
  1655. _this.name = name;
  1656. _this._isVertical = true;
  1657. _this._tempMeasureStore = GUI.Measure.Empty();
  1658. return _this;
  1659. }
  1660. Object.defineProperty(StackPanel.prototype, "isVertical", {
  1661. get: function () {
  1662. return this._isVertical;
  1663. },
  1664. set: function (value) {
  1665. if (this._isVertical === value) {
  1666. return;
  1667. }
  1668. this._isVertical = value;
  1669. this._markAsDirty();
  1670. },
  1671. enumerable: true,
  1672. configurable: true
  1673. });
  1674. StackPanel.prototype._getTypeName = function () {
  1675. return "StackPanel";
  1676. };
  1677. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  1678. var stack = 0;
  1679. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1680. var child = _a[_i];
  1681. this._tempMeasureStore.copyFrom(child._currentMeasure);
  1682. child._currentMeasure.copyFrom(parentMeasure);
  1683. child._measure();
  1684. if (this._isVertical) {
  1685. child.top = stack + "px";
  1686. if (!child._top.ignoreAdaptiveScaling) {
  1687. child._markAsDirty();
  1688. }
  1689. child._top.ignoreAdaptiveScaling = true;
  1690. stack += child._currentMeasure.height;
  1691. child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1692. }
  1693. else {
  1694. child.left = stack + "px";
  1695. if (!child._left.ignoreAdaptiveScaling) {
  1696. child._markAsDirty();
  1697. }
  1698. child._left.ignoreAdaptiveScaling = true;
  1699. stack += child._currentMeasure.width;
  1700. child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1701. }
  1702. child._currentMeasure.copyFrom(this._tempMeasureStore);
  1703. }
  1704. var panelChanged = false;
  1705. if (this._isVertical) {
  1706. var previousHeight = this.height;
  1707. this.height = stack + "px";
  1708. panelChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  1709. this._height.ignoreAdaptiveScaling = true;
  1710. }
  1711. else {
  1712. var previousWidth = this.width;
  1713. this.width = stack + "px";
  1714. panelChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  1715. this._width.ignoreAdaptiveScaling = true;
  1716. }
  1717. if (panelChanged) {
  1718. this._markAllAsDirty();
  1719. }
  1720. _super.prototype._preMeasure.call(this, parentMeasure, context);
  1721. };
  1722. return StackPanel;
  1723. }(GUI.Container));
  1724. GUI.StackPanel = StackPanel;
  1725. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1726. })(BABYLON || (BABYLON = {}));
  1727. //# sourceMappingURL=stackPanel.js.map
  1728. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1729. var __extends = (this && this.__extends) || (function () {
  1730. var extendStatics = Object.setPrototypeOf ||
  1731. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1732. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1733. return function (d, b) {
  1734. extendStatics(d, b);
  1735. function __() { this.constructor = d; }
  1736. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1737. };
  1738. })();
  1739. var BABYLON;
  1740. (function (BABYLON) {
  1741. var GUI;
  1742. (function (GUI) {
  1743. var Rectangle = (function (_super) {
  1744. __extends(Rectangle, _super);
  1745. function Rectangle(name) {
  1746. var _this = _super.call(this, name) || this;
  1747. _this.name = name;
  1748. _this._thickness = 1;
  1749. _this._cornerRadius = 0;
  1750. return _this;
  1751. }
  1752. Object.defineProperty(Rectangle.prototype, "thickness", {
  1753. get: function () {
  1754. return this._thickness;
  1755. },
  1756. set: function (value) {
  1757. if (this._thickness === value) {
  1758. return;
  1759. }
  1760. this._thickness = value;
  1761. this._markAsDirty();
  1762. },
  1763. enumerable: true,
  1764. configurable: true
  1765. });
  1766. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  1767. get: function () {
  1768. return this._cornerRadius;
  1769. },
  1770. set: function (value) {
  1771. if (value < 0) {
  1772. value = 0;
  1773. }
  1774. if (this._cornerRadius === value) {
  1775. return;
  1776. }
  1777. this._cornerRadius = value;
  1778. this._markAsDirty();
  1779. },
  1780. enumerable: true,
  1781. configurable: true
  1782. });
  1783. Rectangle.prototype._getTypeName = function () {
  1784. return "Rectangle";
  1785. };
  1786. Rectangle.prototype._localDraw = function (context) {
  1787. context.save();
  1788. if (this._background) {
  1789. context.fillStyle = this._background;
  1790. if (this._cornerRadius) {
  1791. this._drawRoundedRect(context, this._thickness / 2);
  1792. context.fill();
  1793. }
  1794. else {
  1795. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  1796. }
  1797. }
  1798. if (this._thickness) {
  1799. if (this.color) {
  1800. context.strokeStyle = this.color;
  1801. }
  1802. context.lineWidth = this._thickness;
  1803. if (this._cornerRadius) {
  1804. this._drawRoundedRect(context, this._thickness / 2);
  1805. context.stroke();
  1806. }
  1807. else {
  1808. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  1809. }
  1810. }
  1811. context.restore();
  1812. };
  1813. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  1814. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1815. this._measureForChildren.width -= 2 * this._thickness;
  1816. this._measureForChildren.height -= 2 * this._thickness;
  1817. this._measureForChildren.left += this._thickness;
  1818. this._measureForChildren.top += this._thickness;
  1819. };
  1820. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  1821. if (offset === void 0) { offset = 0; }
  1822. var x = this._currentMeasure.left + offset;
  1823. var y = this._currentMeasure.top + offset;
  1824. var width = this._currentMeasure.width - offset * 2;
  1825. var height = this._currentMeasure.height - offset * 2;
  1826. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  1827. context.beginPath();
  1828. context.moveTo(x + radius, y);
  1829. context.lineTo(x + width - radius, y);
  1830. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  1831. context.lineTo(x + width, y + height - radius);
  1832. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  1833. context.lineTo(x + radius, y + height);
  1834. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  1835. context.lineTo(x, y + radius);
  1836. context.quadraticCurveTo(x, y, x + radius, y);
  1837. context.closePath();
  1838. };
  1839. Rectangle.prototype._clipForChildren = function (context) {
  1840. if (this._cornerRadius) {
  1841. this._drawRoundedRect(context, this._thickness);
  1842. context.clip();
  1843. }
  1844. };
  1845. return Rectangle;
  1846. }(GUI.Container));
  1847. GUI.Rectangle = Rectangle;
  1848. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1849. })(BABYLON || (BABYLON = {}));
  1850. //# sourceMappingURL=rectangle.js.map
  1851. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1852. var __extends = (this && this.__extends) || (function () {
  1853. var extendStatics = Object.setPrototypeOf ||
  1854. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1855. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1856. return function (d, b) {
  1857. extendStatics(d, b);
  1858. function __() { this.constructor = d; }
  1859. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1860. };
  1861. })();
  1862. var BABYLON;
  1863. (function (BABYLON) {
  1864. var GUI;
  1865. (function (GUI) {
  1866. var Ellipse = (function (_super) {
  1867. __extends(Ellipse, _super);
  1868. function Ellipse(name) {
  1869. var _this = _super.call(this, name) || this;
  1870. _this.name = name;
  1871. _this._thickness = 1;
  1872. return _this;
  1873. }
  1874. Object.defineProperty(Ellipse.prototype, "thickness", {
  1875. get: function () {
  1876. return this._thickness;
  1877. },
  1878. set: function (value) {
  1879. if (this._thickness === value) {
  1880. return;
  1881. }
  1882. this._thickness = value;
  1883. this._markAsDirty();
  1884. },
  1885. enumerable: true,
  1886. configurable: true
  1887. });
  1888. Ellipse.prototype._getTypeName = function () {
  1889. return "Ellipse";
  1890. };
  1891. Ellipse.prototype._localDraw = function (context) {
  1892. context.save();
  1893. GUI.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, context);
  1894. if (this._background) {
  1895. context.fillStyle = this._background;
  1896. context.fill();
  1897. }
  1898. if (this._thickness) {
  1899. if (this.color) {
  1900. context.strokeStyle = this.color;
  1901. }
  1902. context.lineWidth = this._thickness;
  1903. context.stroke();
  1904. }
  1905. context.restore();
  1906. };
  1907. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  1908. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1909. this._measureForChildren.width -= 2 * this._thickness;
  1910. this._measureForChildren.height -= 2 * this._thickness;
  1911. this._measureForChildren.left += this._thickness;
  1912. this._measureForChildren.top += this._thickness;
  1913. };
  1914. Ellipse.prototype._clipForChildren = function (context) {
  1915. GUI.Control.drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  1916. context.clip();
  1917. };
  1918. return Ellipse;
  1919. }(GUI.Container));
  1920. GUI.Ellipse = Ellipse;
  1921. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1922. })(BABYLON || (BABYLON = {}));
  1923. //# sourceMappingURL=ellipse.js.map
  1924. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1925. var __extends = (this && this.__extends) || (function () {
  1926. var extendStatics = Object.setPrototypeOf ||
  1927. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1928. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1929. return function (d, b) {
  1930. extendStatics(d, b);
  1931. function __() { this.constructor = d; }
  1932. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1933. };
  1934. })();
  1935. var DOMImage = Image;
  1936. var BABYLON;
  1937. (function (BABYLON) {
  1938. var GUI;
  1939. (function (GUI) {
  1940. var Line = (function (_super) {
  1941. __extends(Line, _super);
  1942. function Line(name) {
  1943. var _this = _super.call(this, name) || this;
  1944. _this.name = name;
  1945. _this._lineWidth = 1;
  1946. _this._x1 = new GUI.ValueAndUnit(0);
  1947. _this._y1 = new GUI.ValueAndUnit(0);
  1948. _this._x2 = new GUI.ValueAndUnit(0);
  1949. _this._y2 = new GUI.ValueAndUnit(0);
  1950. _this._dash = new Array();
  1951. _this.isHitTestVisible = false;
  1952. _this._horizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1953. _this._verticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1954. return _this;
  1955. }
  1956. Object.defineProperty(Line.prototype, "dash", {
  1957. get: function () {
  1958. return this._dash;
  1959. },
  1960. set: function (value) {
  1961. if (this._dash === value) {
  1962. return;
  1963. }
  1964. this._dash = value;
  1965. this._markAsDirty();
  1966. },
  1967. enumerable: true,
  1968. configurable: true
  1969. });
  1970. Object.defineProperty(Line.prototype, "connectedControl", {
  1971. get: function () {
  1972. return this._connectedControl;
  1973. },
  1974. set: function (value) {
  1975. var _this = this;
  1976. if (this._connectedControl === value) {
  1977. return;
  1978. }
  1979. if (this._connectedControlDirtyObserver && this._connectedControl) {
  1980. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  1981. this._connectedControlDirtyObserver = null;
  1982. }
  1983. if (value) {
  1984. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  1985. }
  1986. this._connectedControl = value;
  1987. this._markAsDirty();
  1988. },
  1989. enumerable: true,
  1990. configurable: true
  1991. });
  1992. Object.defineProperty(Line.prototype, "x1", {
  1993. get: function () {
  1994. return this._x1.toString(this._host);
  1995. },
  1996. set: function (value) {
  1997. if (this._x1.toString(this._host) === value) {
  1998. return;
  1999. }
  2000. if (this._x1.fromString(value)) {
  2001. this._markAsDirty();
  2002. }
  2003. },
  2004. enumerable: true,
  2005. configurable: true
  2006. });
  2007. Object.defineProperty(Line.prototype, "y1", {
  2008. get: function () {
  2009. return this._y1.toString(this._host);
  2010. },
  2011. set: function (value) {
  2012. if (this._y1.toString(this._host) === value) {
  2013. return;
  2014. }
  2015. if (this._y1.fromString(value)) {
  2016. this._markAsDirty();
  2017. }
  2018. },
  2019. enumerable: true,
  2020. configurable: true
  2021. });
  2022. Object.defineProperty(Line.prototype, "x2", {
  2023. get: function () {
  2024. return this._x2.toString(this._host);
  2025. },
  2026. set: function (value) {
  2027. if (this._x2.toString(this._host) === value) {
  2028. return;
  2029. }
  2030. if (this._x2.fromString(value)) {
  2031. this._markAsDirty();
  2032. }
  2033. },
  2034. enumerable: true,
  2035. configurable: true
  2036. });
  2037. Object.defineProperty(Line.prototype, "y2", {
  2038. get: function () {
  2039. return this._y2.toString(this._host);
  2040. },
  2041. set: function (value) {
  2042. if (this._y2.toString(this._host) === value) {
  2043. return;
  2044. }
  2045. if (this._y2.fromString(value)) {
  2046. this._markAsDirty();
  2047. }
  2048. },
  2049. enumerable: true,
  2050. configurable: true
  2051. });
  2052. Object.defineProperty(Line.prototype, "lineWidth", {
  2053. get: function () {
  2054. return this._lineWidth;
  2055. },
  2056. set: function (value) {
  2057. if (this._lineWidth === value) {
  2058. return;
  2059. }
  2060. this._lineWidth = value;
  2061. this._markAsDirty();
  2062. },
  2063. enumerable: true,
  2064. configurable: true
  2065. });
  2066. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  2067. set: function (value) {
  2068. return;
  2069. },
  2070. enumerable: true,
  2071. configurable: true
  2072. });
  2073. Object.defineProperty(Line.prototype, "verticalAlignment", {
  2074. set: function (value) {
  2075. return;
  2076. },
  2077. enumerable: true,
  2078. configurable: true
  2079. });
  2080. Object.defineProperty(Line.prototype, "_effectiveX2", {
  2081. get: function () {
  2082. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  2083. },
  2084. enumerable: true,
  2085. configurable: true
  2086. });
  2087. Object.defineProperty(Line.prototype, "_effectiveY2", {
  2088. get: function () {
  2089. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  2090. },
  2091. enumerable: true,
  2092. configurable: true
  2093. });
  2094. Line.prototype._getTypeName = function () {
  2095. return "Line";
  2096. };
  2097. Line.prototype._draw = function (parentMeasure, context) {
  2098. context.save();
  2099. this._applyStates(context);
  2100. if (this._processMeasures(parentMeasure, context)) {
  2101. context.strokeStyle = this.color;
  2102. context.lineWidth = this._lineWidth;
  2103. context.setLineDash(this._dash);
  2104. context.beginPath();
  2105. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  2106. context.lineTo(this._effectiveX2, this._effectiveY2);
  2107. context.stroke();
  2108. }
  2109. context.restore();
  2110. };
  2111. Line.prototype._measure = function () {
  2112. // Width / Height
  2113. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  2114. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  2115. };
  2116. Line.prototype._computeAlignment = function (parentMeasure, context) {
  2117. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  2118. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  2119. };
  2120. Line.prototype._moveToProjectedPosition = function (projectedPosition) {
  2121. this.x1 = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  2122. this.y1 = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  2123. this._x1.ignoreAdaptiveScaling = true;
  2124. this._y1.ignoreAdaptiveScaling = true;
  2125. };
  2126. return Line;
  2127. }(GUI.Control));
  2128. GUI.Line = Line;
  2129. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2130. })(BABYLON || (BABYLON = {}));
  2131. //# sourceMappingURL=line.js.map
  2132. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2133. var __extends = (this && this.__extends) || (function () {
  2134. var extendStatics = Object.setPrototypeOf ||
  2135. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2136. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2137. return function (d, b) {
  2138. extendStatics(d, b);
  2139. function __() { this.constructor = d; }
  2140. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2141. };
  2142. })();
  2143. var DOMImage = Image;
  2144. var BABYLON;
  2145. (function (BABYLON) {
  2146. var GUI;
  2147. (function (GUI) {
  2148. var Slider = (function (_super) {
  2149. __extends(Slider, _super);
  2150. function Slider(name) {
  2151. var _this = _super.call(this, name) || this;
  2152. _this.name = name;
  2153. _this._thumbWidth = new GUI.ValueAndUnit(30, GUI.ValueAndUnit.UNITMODE_PIXEL, false);
  2154. _this._minimum = 0;
  2155. _this._maximum = 100;
  2156. _this._value = 50;
  2157. _this._background = "black";
  2158. _this._borderColor = "white";
  2159. _this._barOffset = new GUI.ValueAndUnit(5, GUI.ValueAndUnit.UNITMODE_PIXEL, false);
  2160. _this.onValueChangedObservable = new BABYLON.Observable();
  2161. // Events
  2162. _this._pointerIsDown = false;
  2163. _this.isPointerBlocker = true;
  2164. return _this;
  2165. }
  2166. Object.defineProperty(Slider.prototype, "borderColor", {
  2167. get: function () {
  2168. return this._borderColor;
  2169. },
  2170. set: function (value) {
  2171. if (this._borderColor === value) {
  2172. return;
  2173. }
  2174. this._borderColor = value;
  2175. this._markAsDirty();
  2176. },
  2177. enumerable: true,
  2178. configurable: true
  2179. });
  2180. Object.defineProperty(Slider.prototype, "background", {
  2181. get: function () {
  2182. return this._background;
  2183. },
  2184. set: function (value) {
  2185. if (this._background === value) {
  2186. return;
  2187. }
  2188. this._background = value;
  2189. this._markAsDirty();
  2190. },
  2191. enumerable: true,
  2192. configurable: true
  2193. });
  2194. Object.defineProperty(Slider.prototype, "barOffset", {
  2195. get: function () {
  2196. return this._barOffset.toString(this._host);
  2197. },
  2198. set: function (value) {
  2199. if (this._barOffset.toString(this._host) === value) {
  2200. return;
  2201. }
  2202. if (this._barOffset.fromString(value)) {
  2203. this._markAsDirty();
  2204. }
  2205. },
  2206. enumerable: true,
  2207. configurable: true
  2208. });
  2209. Object.defineProperty(Slider.prototype, "thumbWidth", {
  2210. get: function () {
  2211. return this._thumbWidth.toString(this._host);
  2212. },
  2213. set: function (value) {
  2214. if (this._thumbWidth.toString(this._host) === value) {
  2215. return;
  2216. }
  2217. if (this._thumbWidth.fromString(value)) {
  2218. this._markAsDirty();
  2219. }
  2220. },
  2221. enumerable: true,
  2222. configurable: true
  2223. });
  2224. Object.defineProperty(Slider.prototype, "minimum", {
  2225. get: function () {
  2226. return this._minimum;
  2227. },
  2228. set: function (value) {
  2229. if (this._minimum === value) {
  2230. return;
  2231. }
  2232. this._minimum = value;
  2233. this._markAsDirty();
  2234. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  2235. },
  2236. enumerable: true,
  2237. configurable: true
  2238. });
  2239. Object.defineProperty(Slider.prototype, "maximum", {
  2240. get: function () {
  2241. return this._maximum;
  2242. },
  2243. set: function (value) {
  2244. if (this._maximum === value) {
  2245. return;
  2246. }
  2247. this._maximum = value;
  2248. this._markAsDirty();
  2249. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  2250. },
  2251. enumerable: true,
  2252. configurable: true
  2253. });
  2254. Object.defineProperty(Slider.prototype, "value", {
  2255. get: function () {
  2256. return this._value;
  2257. },
  2258. set: function (value) {
  2259. value = Math.max(Math.min(value, this._maximum), this._minimum);
  2260. if (this._value === value) {
  2261. return;
  2262. }
  2263. this._value = value;
  2264. this._markAsDirty();
  2265. this.onValueChangedObservable.notifyObservers(this._value);
  2266. },
  2267. enumerable: true,
  2268. configurable: true
  2269. });
  2270. Slider.prototype._getTypeName = function () {
  2271. return "Slider";
  2272. };
  2273. Slider.prototype._draw = function (parentMeasure, context) {
  2274. context.save();
  2275. this._applyStates(context);
  2276. if (this._processMeasures(parentMeasure, context)) {
  2277. // Main bar
  2278. var effectiveThumbWidth;
  2279. var effectiveBarOffset;
  2280. if (this._thumbWidth.isPixel) {
  2281. effectiveThumbWidth = Math.min(this._thumbWidth.getValue(this._host), this._currentMeasure.height);
  2282. }
  2283. else {
  2284. effectiveThumbWidth = this._currentMeasure.height * this._thumbWidth.getValue(this._host);
  2285. }
  2286. if (this._barOffset.isPixel) {
  2287. effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._currentMeasure.height);
  2288. }
  2289. else {
  2290. effectiveBarOffset = this._currentMeasure.height * this._barOffset.getValue(this._host);
  2291. }
  2292. var left = this._currentMeasure.left + effectiveThumbWidth / 2;
  2293. var width = this._currentMeasure.width - effectiveThumbWidth;
  2294. var thumbPosition = (this._value - this._minimum) / (this._maximum - this._minimum) * width;
  2295. // Bar
  2296. context.fillStyle = this._background;
  2297. context.fillRect(left, this._currentMeasure.top + effectiveBarOffset, width, this._currentMeasure.height - effectiveBarOffset * 2);
  2298. context.fillStyle = this.color;
  2299. context.fillRect(left, this._currentMeasure.top + effectiveBarOffset, thumbPosition, this._currentMeasure.height - effectiveBarOffset * 2);
  2300. // Thumb
  2301. context.fillRect(left + thumbPosition - effectiveThumbWidth / 2, this._currentMeasure.top, effectiveThumbWidth, this._currentMeasure.height);
  2302. context.strokeStyle = this._borderColor;
  2303. context.strokeRect(left + thumbPosition - effectiveThumbWidth / 2, this._currentMeasure.top, effectiveThumbWidth, this._currentMeasure.height);
  2304. }
  2305. context.restore();
  2306. };
  2307. Slider.prototype._updateValueFromPointer = function (x) {
  2308. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  2309. };
  2310. Slider.prototype._onPointerDown = function (coordinates) {
  2311. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2312. return false;
  2313. }
  2314. this._pointerIsDown = true;
  2315. this._updateValueFromPointer(coordinates.x);
  2316. this._host._capturingControl = this;
  2317. return true;
  2318. };
  2319. Slider.prototype._onPointerMove = function (coordinates) {
  2320. if (this._pointerIsDown) {
  2321. this._updateValueFromPointer(coordinates.x);
  2322. }
  2323. };
  2324. Slider.prototype._onPointerUp = function (coordinates) {
  2325. this._pointerIsDown = false;
  2326. this._host._capturingControl = null;
  2327. _super.prototype._onPointerUp.call(this, coordinates);
  2328. };
  2329. return Slider;
  2330. }(GUI.Control));
  2331. GUI.Slider = Slider;
  2332. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2333. })(BABYLON || (BABYLON = {}));
  2334. //# sourceMappingURL=slider.js.map
  2335. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2336. var __extends = (this && this.__extends) || (function () {
  2337. var extendStatics = Object.setPrototypeOf ||
  2338. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2339. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2340. return function (d, b) {
  2341. extendStatics(d, b);
  2342. function __() { this.constructor = d; }
  2343. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2344. };
  2345. })();
  2346. var DOMImage = Image;
  2347. var BABYLON;
  2348. (function (BABYLON) {
  2349. var GUI;
  2350. (function (GUI) {
  2351. var Checkbox = (function (_super) {
  2352. __extends(Checkbox, _super);
  2353. function Checkbox(name) {
  2354. var _this = _super.call(this, name) || this;
  2355. _this.name = name;
  2356. _this._isChecked = false;
  2357. _this._background = "black";
  2358. _this._checkSizeRatio = 0.8;
  2359. _this._thickness = 1;
  2360. _this.onIsCheckedChangedObservable = new BABYLON.Observable();
  2361. _this.isPointerBlocker = true;
  2362. return _this;
  2363. }
  2364. Object.defineProperty(Checkbox.prototype, "thickness", {
  2365. get: function () {
  2366. return this._thickness;
  2367. },
  2368. set: function (value) {
  2369. if (this._thickness === value) {
  2370. return;
  2371. }
  2372. this._thickness = value;
  2373. this._markAsDirty();
  2374. },
  2375. enumerable: true,
  2376. configurable: true
  2377. });
  2378. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  2379. get: function () {
  2380. return this._checkSizeRatio;
  2381. },
  2382. set: function (value) {
  2383. value = Math.max(Math.min(1, value), 0);
  2384. if (this._checkSizeRatio === value) {
  2385. return;
  2386. }
  2387. this._checkSizeRatio = value;
  2388. this._markAsDirty();
  2389. },
  2390. enumerable: true,
  2391. configurable: true
  2392. });
  2393. Object.defineProperty(Checkbox.prototype, "background", {
  2394. get: function () {
  2395. return this._background;
  2396. },
  2397. set: function (value) {
  2398. if (this._background === value) {
  2399. return;
  2400. }
  2401. this._background = value;
  2402. this._markAsDirty();
  2403. },
  2404. enumerable: true,
  2405. configurable: true
  2406. });
  2407. Object.defineProperty(Checkbox.prototype, "isChecked", {
  2408. get: function () {
  2409. return this._isChecked;
  2410. },
  2411. set: function (value) {
  2412. if (this._isChecked === value) {
  2413. return;
  2414. }
  2415. this._isChecked = value;
  2416. this._markAsDirty();
  2417. this.onIsCheckedChangedObservable.notifyObservers(value);
  2418. },
  2419. enumerable: true,
  2420. configurable: true
  2421. });
  2422. Checkbox.prototype._getTypeName = function () {
  2423. return "CheckBox";
  2424. };
  2425. Checkbox.prototype._draw = function (parentMeasure, context) {
  2426. context.save();
  2427. this._applyStates(context);
  2428. if (this._processMeasures(parentMeasure, context)) {
  2429. var actualWidth = this._currentMeasure.width - this._thickness;
  2430. var actualHeight = this._currentMeasure.height - this._thickness;
  2431. context.fillStyle = this._background;
  2432. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  2433. if (this._isChecked) {
  2434. context.fillStyle = this.color;
  2435. var offsetWidth = actualWidth * this._checkSizeRatio;
  2436. var offseHeight = actualHeight * this._checkSizeRatio;
  2437. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  2438. }
  2439. context.strokeStyle = this.color;
  2440. context.lineWidth = this._thickness;
  2441. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  2442. }
  2443. context.restore();
  2444. };
  2445. // Events
  2446. Checkbox.prototype._onPointerDown = function (coordinates) {
  2447. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2448. return false;
  2449. }
  2450. this.isChecked = !this.isChecked;
  2451. return true;
  2452. };
  2453. return Checkbox;
  2454. }(GUI.Control));
  2455. GUI.Checkbox = Checkbox;
  2456. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2457. })(BABYLON || (BABYLON = {}));
  2458. //# sourceMappingURL=checkBox.js.map
  2459. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2460. var __extends = (this && this.__extends) || (function () {
  2461. var extendStatics = Object.setPrototypeOf ||
  2462. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2463. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2464. return function (d, b) {
  2465. extendStatics(d, b);
  2466. function __() { this.constructor = d; }
  2467. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2468. };
  2469. })();
  2470. var DOMImage = Image;
  2471. var BABYLON;
  2472. (function (BABYLON) {
  2473. var GUI;
  2474. (function (GUI) {
  2475. var RadioButton = (function (_super) {
  2476. __extends(RadioButton, _super);
  2477. function RadioButton(name) {
  2478. var _this = _super.call(this, name) || this;
  2479. _this.name = name;
  2480. _this._isChecked = false;
  2481. _this._background = "black";
  2482. _this._checkSizeRatio = 0.8;
  2483. _this._thickness = 1;
  2484. _this.group = "";
  2485. _this.onIsCheckedChangedObservable = new BABYLON.Observable();
  2486. _this.isPointerBlocker = true;
  2487. return _this;
  2488. }
  2489. Object.defineProperty(RadioButton.prototype, "thickness", {
  2490. get: function () {
  2491. return this._thickness;
  2492. },
  2493. set: function (value) {
  2494. if (this._thickness === value) {
  2495. return;
  2496. }
  2497. this._thickness = value;
  2498. this._markAsDirty();
  2499. },
  2500. enumerable: true,
  2501. configurable: true
  2502. });
  2503. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  2504. get: function () {
  2505. return this._checkSizeRatio;
  2506. },
  2507. set: function (value) {
  2508. value = Math.max(Math.min(1, value), 0);
  2509. if (this._checkSizeRatio === value) {
  2510. return;
  2511. }
  2512. this._checkSizeRatio = value;
  2513. this._markAsDirty();
  2514. },
  2515. enumerable: true,
  2516. configurable: true
  2517. });
  2518. Object.defineProperty(RadioButton.prototype, "background", {
  2519. get: function () {
  2520. return this._background;
  2521. },
  2522. set: function (value) {
  2523. if (this._background === value) {
  2524. return;
  2525. }
  2526. this._background = value;
  2527. this._markAsDirty();
  2528. },
  2529. enumerable: true,
  2530. configurable: true
  2531. });
  2532. Object.defineProperty(RadioButton.prototype, "isChecked", {
  2533. get: function () {
  2534. return this._isChecked;
  2535. },
  2536. set: function (value) {
  2537. var _this = this;
  2538. if (this._isChecked === value) {
  2539. return;
  2540. }
  2541. this._isChecked = value;
  2542. this._markAsDirty();
  2543. this.onIsCheckedChangedObservable.notifyObservers(value);
  2544. if (this._isChecked) {
  2545. // Update all controls from same group
  2546. this._host.executeOnAllControls(function (control) {
  2547. if (control === _this) {
  2548. return;
  2549. }
  2550. if (control.group === undefined) {
  2551. return;
  2552. }
  2553. var childRadio = control;
  2554. if (childRadio.group === _this.group) {
  2555. childRadio.isChecked = false;
  2556. }
  2557. });
  2558. }
  2559. },
  2560. enumerable: true,
  2561. configurable: true
  2562. });
  2563. RadioButton.prototype._getTypeName = function () {
  2564. return "RadioButton";
  2565. };
  2566. RadioButton.prototype._draw = function (parentMeasure, context) {
  2567. context.save();
  2568. this._applyStates(context);
  2569. if (this._processMeasures(parentMeasure, context)) {
  2570. var actualWidth = this._currentMeasure.width - this._thickness;
  2571. var actualHeight = this._currentMeasure.height - this._thickness;
  2572. // Outer
  2573. GUI.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, context);
  2574. context.fillStyle = this._background;
  2575. context.fill();
  2576. context.strokeStyle = this.color;
  2577. context.lineWidth = this._thickness;
  2578. context.stroke();
  2579. // Inner
  2580. if (this._isChecked) {
  2581. context.fillStyle = this.color;
  2582. var offsetWidth = actualWidth * this._checkSizeRatio;
  2583. var offseHeight = actualHeight * this._checkSizeRatio;
  2584. GUI.Control.drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  2585. context.fill();
  2586. }
  2587. }
  2588. context.restore();
  2589. };
  2590. // Events
  2591. RadioButton.prototype._onPointerDown = function (coordinates) {
  2592. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2593. return false;
  2594. }
  2595. this.isChecked = !this.isChecked;
  2596. return true;
  2597. };
  2598. return RadioButton;
  2599. }(GUI.Control));
  2600. GUI.RadioButton = RadioButton;
  2601. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2602. })(BABYLON || (BABYLON = {}));
  2603. //# sourceMappingURL=radioButton.js.map
  2604. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2605. var __extends = (this && this.__extends) || (function () {
  2606. var extendStatics = Object.setPrototypeOf ||
  2607. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2608. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2609. return function (d, b) {
  2610. extendStatics(d, b);
  2611. function __() { this.constructor = d; }
  2612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2613. };
  2614. })();
  2615. var BABYLON;
  2616. (function (BABYLON) {
  2617. var GUI;
  2618. (function (GUI) {
  2619. var TextBlock = (function (_super) {
  2620. __extends(TextBlock, _super);
  2621. function TextBlock(name, text) {
  2622. if (text === void 0) { text = ""; }
  2623. var _this = _super.call(this, name) || this;
  2624. _this.name = name;
  2625. _this._text = "";
  2626. _this._textWrapping = false;
  2627. _this._textHorizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  2628. _this._textVerticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_CENTER;
  2629. _this.text = text;
  2630. return _this;
  2631. }
  2632. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  2633. get: function () {
  2634. return this._textWrapping;
  2635. },
  2636. set: function (value) {
  2637. if (this._textWrapping === value) {
  2638. return;
  2639. }
  2640. this._textWrapping = value;
  2641. this._markAsDirty();
  2642. },
  2643. enumerable: true,
  2644. configurable: true
  2645. });
  2646. Object.defineProperty(TextBlock.prototype, "text", {
  2647. get: function () {
  2648. return this._text;
  2649. },
  2650. set: function (value) {
  2651. if (this._text === value) {
  2652. return;
  2653. }
  2654. this._text = value;
  2655. this._markAsDirty();
  2656. },
  2657. enumerable: true,
  2658. configurable: true
  2659. });
  2660. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  2661. get: function () {
  2662. return this._textHorizontalAlignment;
  2663. },
  2664. set: function (value) {
  2665. if (this._textHorizontalAlignment === value) {
  2666. return;
  2667. }
  2668. this._textHorizontalAlignment = value;
  2669. this._markAsDirty();
  2670. },
  2671. enumerable: true,
  2672. configurable: true
  2673. });
  2674. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  2675. get: function () {
  2676. return this._textVerticalAlignment;
  2677. },
  2678. set: function (value) {
  2679. if (this._textVerticalAlignment === value) {
  2680. return;
  2681. }
  2682. this._textVerticalAlignment = value;
  2683. this._markAsDirty();
  2684. },
  2685. enumerable: true,
  2686. configurable: true
  2687. });
  2688. TextBlock.prototype._getTypeName = function () {
  2689. return "TextBlock";
  2690. };
  2691. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  2692. var width = this._currentMeasure.width;
  2693. var x = 0;
  2694. switch (this._textHorizontalAlignment) {
  2695. case GUI.Control.HORIZONTAL_ALIGNMENT_LEFT:
  2696. x = 0;
  2697. break;
  2698. case GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT:
  2699. x = width - textWidth;
  2700. break;
  2701. case GUI.Control.HORIZONTAL_ALIGNMENT_CENTER:
  2702. x = (width - textWidth) / 2;
  2703. break;
  2704. }
  2705. context.fillText(text, this._currentMeasure.left + x, y);
  2706. };
  2707. TextBlock.prototype._draw = function (parentMeasure, context) {
  2708. context.save();
  2709. this._applyStates(context);
  2710. if (this._processMeasures(parentMeasure, context)) {
  2711. // Render lines
  2712. this._renderLines(context);
  2713. }
  2714. context.restore();
  2715. };
  2716. TextBlock.prototype._additionalProcessing = function (parentMeasure, context) {
  2717. this._lines = [];
  2718. if (this._textWrapping) {
  2719. var words = this.text.split(' ');
  2720. var line = '';
  2721. var width = this._currentMeasure.width;
  2722. var lineWidth = 0;
  2723. for (var n = 0; n < words.length; n++) {
  2724. var testLine = n > 0 ? line + " " + words[n] : words[0];
  2725. var metrics = context.measureText(testLine);
  2726. var testWidth = metrics.width;
  2727. if (testWidth > width && n > 0) {
  2728. this._lines.push({ text: line, width: lineWidth });
  2729. line = words[n];
  2730. lineWidth = context.measureText(line).width;
  2731. }
  2732. else {
  2733. lineWidth = testWidth;
  2734. line = testLine;
  2735. }
  2736. }
  2737. this._lines.push({ text: line, width: lineWidth });
  2738. }
  2739. else {
  2740. this._lines.push({ text: this.text, width: context.measureText(this.text).width });
  2741. }
  2742. };
  2743. TextBlock.prototype._renderLines = function (context) {
  2744. var width = this._currentMeasure.width;
  2745. var height = this._currentMeasure.height;
  2746. if (!this._fontOffset) {
  2747. this._fontOffset = GUI.Control._GetFontOffset(context.font);
  2748. }
  2749. var rootY = 0;
  2750. switch (this._textVerticalAlignment) {
  2751. case GUI.Control.VERTICAL_ALIGNMENT_TOP:
  2752. rootY = this._fontOffset.ascent;
  2753. break;
  2754. case GUI.Control.VERTICAL_ALIGNMENT_BOTTOM:
  2755. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  2756. break;
  2757. case GUI.Control.VERTICAL_ALIGNMENT_CENTER:
  2758. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  2759. break;
  2760. }
  2761. rootY += this._currentMeasure.top;
  2762. for (var _i = 0, _a = this._lines; _i < _a.length; _i++) {
  2763. var line = _a[_i];
  2764. this._drawText(line.text, line.width, rootY, context);
  2765. rootY += this._fontOffset.height;
  2766. }
  2767. };
  2768. return TextBlock;
  2769. }(GUI.Control));
  2770. GUI.TextBlock = TextBlock;
  2771. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2772. })(BABYLON || (BABYLON = {}));
  2773. //# sourceMappingURL=textBlock.js.map
  2774. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2775. var __extends = (this && this.__extends) || (function () {
  2776. var extendStatics = Object.setPrototypeOf ||
  2777. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2778. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2779. return function (d, b) {
  2780. extendStatics(d, b);
  2781. function __() { this.constructor = d; }
  2782. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2783. };
  2784. })();
  2785. var DOMImage = Image;
  2786. var BABYLON;
  2787. (function (BABYLON) {
  2788. var GUI;
  2789. (function (GUI) {
  2790. var Image = (function (_super) {
  2791. __extends(Image, _super);
  2792. function Image(name, url) {
  2793. var _this = _super.call(this, name) || this;
  2794. _this.name = name;
  2795. _this._loaded = false;
  2796. _this._stretch = Image.STRETCH_FILL;
  2797. _this._autoScale = false;
  2798. _this.source = url;
  2799. return _this;
  2800. }
  2801. Object.defineProperty(Image.prototype, "autoScale", {
  2802. get: function () {
  2803. return this._autoScale;
  2804. },
  2805. set: function (value) {
  2806. if (this._autoScale === value) {
  2807. return;
  2808. }
  2809. this._autoScale = value;
  2810. if (value && this._loaded) {
  2811. this.synchronizeSizeWithContent();
  2812. }
  2813. },
  2814. enumerable: true,
  2815. configurable: true
  2816. });
  2817. Object.defineProperty(Image.prototype, "stretch", {
  2818. get: function () {
  2819. return this._stretch;
  2820. },
  2821. set: function (value) {
  2822. if (this._stretch === value) {
  2823. return;
  2824. }
  2825. this._stretch = value;
  2826. this._markAsDirty();
  2827. },
  2828. enumerable: true,
  2829. configurable: true
  2830. });
  2831. Object.defineProperty(Image.prototype, "domImage", {
  2832. get: function () {
  2833. return this._domImage;
  2834. },
  2835. set: function (value) {
  2836. var _this = this;
  2837. this._domImage = value;
  2838. this._loaded = false;
  2839. if (this._domImage.width) {
  2840. this._onImageLoaded();
  2841. }
  2842. else {
  2843. this._domImage.onload = function () {
  2844. _this._onImageLoaded();
  2845. };
  2846. }
  2847. },
  2848. enumerable: true,
  2849. configurable: true
  2850. });
  2851. Image.prototype._onImageLoaded = function () {
  2852. this._imageWidth = this._domImage.width;
  2853. this._imageHeight = this._domImage.height;
  2854. this._loaded = true;
  2855. if (this._autoScale) {
  2856. this.synchronizeSizeWithContent();
  2857. }
  2858. this._markAsDirty();
  2859. };
  2860. Object.defineProperty(Image.prototype, "source", {
  2861. set: function (value) {
  2862. var _this = this;
  2863. if (this._source === value) {
  2864. return;
  2865. }
  2866. this._loaded = false;
  2867. this._source = value;
  2868. this._domImage = new DOMImage();
  2869. this._domImage.onload = function () {
  2870. _this._onImageLoaded();
  2871. };
  2872. this._domImage.src = value;
  2873. },
  2874. enumerable: true,
  2875. configurable: true
  2876. });
  2877. Image.prototype._getTypeName = function () {
  2878. return "Image";
  2879. };
  2880. Image.prototype.synchronizeSizeWithContent = function () {
  2881. if (!this._loaded) {
  2882. return;
  2883. }
  2884. this.width = this._domImage.width + "px";
  2885. this.height = this._domImage.height + "px";
  2886. };
  2887. Image.prototype._draw = function (parentMeasure, context) {
  2888. context.save();
  2889. this._applyStates(context);
  2890. if (this._processMeasures(parentMeasure, context)) {
  2891. if (this._loaded) {
  2892. switch (this._stretch) {
  2893. case Image.STRETCH_NONE:
  2894. context.drawImage(this._domImage, this._currentMeasure.left, this._currentMeasure.top);
  2895. break;
  2896. case Image.STRETCH_FILL:
  2897. context.drawImage(this._domImage, 0, 0, this._imageWidth, this._imageHeight, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  2898. break;
  2899. case Image.STRETCH_UNIFORM:
  2900. var hRatio = this._currentMeasure.width / this._imageWidth;
  2901. var vRatio = this._currentMeasure.height / this._imageHeight;
  2902. var ratio = Math.min(hRatio, vRatio);
  2903. var centerX = (this._currentMeasure.width - this._imageWidth * ratio) / 2;
  2904. var centerY = (this._currentMeasure.height - this._imageHeight * ratio) / 2;
  2905. context.drawImage(this._domImage, 0, 0, this._imageWidth, this._imageHeight, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, this._imageWidth * ratio, this._imageHeight * ratio);
  2906. break;
  2907. case Image.STRETCH_EXTEND:
  2908. context.drawImage(this._domImage, this._currentMeasure.left, this._currentMeasure.top);
  2909. if (this._autoScale) {
  2910. this.synchronizeSizeWithContent();
  2911. }
  2912. this._root.width = this.width;
  2913. this._root.height = this.height;
  2914. break;
  2915. }
  2916. }
  2917. }
  2918. context.restore();
  2919. };
  2920. Object.defineProperty(Image, "STRETCH_NONE", {
  2921. get: function () {
  2922. return Image._STRETCH_NONE;
  2923. },
  2924. enumerable: true,
  2925. configurable: true
  2926. });
  2927. Object.defineProperty(Image, "STRETCH_FILL", {
  2928. get: function () {
  2929. return Image._STRETCH_FILL;
  2930. },
  2931. enumerable: true,
  2932. configurable: true
  2933. });
  2934. Object.defineProperty(Image, "STRETCH_UNIFORM", {
  2935. get: function () {
  2936. return Image._STRETCH_UNIFORM;
  2937. },
  2938. enumerable: true,
  2939. configurable: true
  2940. });
  2941. Object.defineProperty(Image, "STRETCH_EXTEND", {
  2942. get: function () {
  2943. return Image._STRETCH_EXTEND;
  2944. },
  2945. enumerable: true,
  2946. configurable: true
  2947. });
  2948. return Image;
  2949. }(GUI.Control));
  2950. // Static
  2951. Image._STRETCH_NONE = 0;
  2952. Image._STRETCH_FILL = 1;
  2953. Image._STRETCH_UNIFORM = 2;
  2954. Image._STRETCH_EXTEND = 3;
  2955. GUI.Image = Image;
  2956. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2957. })(BABYLON || (BABYLON = {}));
  2958. //# sourceMappingURL=image.js.map
  2959. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2960. var __extends = (this && this.__extends) || (function () {
  2961. var extendStatics = Object.setPrototypeOf ||
  2962. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2963. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2964. return function (d, b) {
  2965. extendStatics(d, b);
  2966. function __() { this.constructor = d; }
  2967. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2968. };
  2969. })();
  2970. var BABYLON;
  2971. (function (BABYLON) {
  2972. var GUI;
  2973. (function (GUI) {
  2974. var Button = (function (_super) {
  2975. __extends(Button, _super);
  2976. function Button(name) {
  2977. var _this = _super.call(this, name) || this;
  2978. _this.name = name;
  2979. _this.thickness = 1;
  2980. _this.isPointerBlocker = true;
  2981. _this.pointerEnterAnimation = function () {
  2982. _this.alpha -= 0.1;
  2983. };
  2984. _this.pointerOutAnimation = function () {
  2985. _this.alpha += 0.1;
  2986. };
  2987. _this.pointerDownAnimation = function () {
  2988. _this.scaleX -= 0.05;
  2989. _this.scaleY -= 0.05;
  2990. };
  2991. _this.pointerUpAnimation = function () {
  2992. _this.scaleX += 0.05;
  2993. _this.scaleY += 0.05;
  2994. };
  2995. return _this;
  2996. }
  2997. Button.prototype._getTypeName = function () {
  2998. return "Button";
  2999. };
  3000. // While being a container, the button behaves like a control.
  3001. Button.prototype._processPicking = function (x, y, type) {
  3002. if (!this.contains(x, y)) {
  3003. return false;
  3004. }
  3005. this._processObservables(type, x, y);
  3006. return true;
  3007. };
  3008. Button.prototype._onPointerEnter = function () {
  3009. if (!_super.prototype._onPointerEnter.call(this)) {
  3010. return false;
  3011. }
  3012. if (this.pointerEnterAnimation) {
  3013. this.pointerEnterAnimation();
  3014. }
  3015. return true;
  3016. };
  3017. Button.prototype._onPointerOut = function () {
  3018. if (this.pointerOutAnimation) {
  3019. this.pointerOutAnimation();
  3020. }
  3021. _super.prototype._onPointerOut.call(this);
  3022. };
  3023. Button.prototype._onPointerDown = function (coordinates) {
  3024. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  3025. return false;
  3026. }
  3027. if (this.pointerDownAnimation) {
  3028. this.pointerDownAnimation();
  3029. }
  3030. return true;
  3031. };
  3032. Button.prototype._onPointerUp = function (coordinates) {
  3033. if (this.pointerUpAnimation) {
  3034. this.pointerUpAnimation();
  3035. }
  3036. _super.prototype._onPointerUp.call(this, coordinates);
  3037. };
  3038. // Statics
  3039. Button.CreateImageButton = function (name, text, imageUrl) {
  3040. var result = new Button(name);
  3041. // Adding text
  3042. var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
  3043. textBlock.textWrapping = true;
  3044. textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  3045. textBlock.paddingLeft = "20%";
  3046. result.addControl(textBlock);
  3047. // Adding image
  3048. var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
  3049. iconImage.width = "20%";
  3050. iconImage.stretch = BABYLON.GUI.Image.STRETCH_UNIFORM;
  3051. iconImage.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  3052. result.addControl(iconImage);
  3053. return result;
  3054. };
  3055. Button.CreateImageOnlyButton = function (name, imageUrl) {
  3056. var result = new Button(name);
  3057. // Adding image
  3058. var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
  3059. iconImage.stretch = BABYLON.GUI.Image.STRETCH_FILL;
  3060. iconImage.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  3061. result.addControl(iconImage);
  3062. return result;
  3063. };
  3064. Button.CreateSimpleButton = function (name, text) {
  3065. var result = new Button(name);
  3066. // Adding text
  3067. var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
  3068. textBlock.textWrapping = true;
  3069. textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  3070. result.addControl(textBlock);
  3071. return result;
  3072. };
  3073. return Button;
  3074. }(GUI.Rectangle));
  3075. GUI.Button = Button;
  3076. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  3077. })(BABYLON || (BABYLON = {}));
  3078. //# sourceMappingURL=button.js.map
  3079. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  3080. var __extends = (this && this.__extends) || (function () {
  3081. var extendStatics = Object.setPrototypeOf ||
  3082. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3083. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3084. return function (d, b) {
  3085. extendStatics(d, b);
  3086. function __() { this.constructor = d; }
  3087. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3088. };
  3089. })();
  3090. var DOMImage = Image;
  3091. var BABYLON;
  3092. (function (BABYLON) {
  3093. var GUI;
  3094. (function (GUI) {
  3095. var ColorPicker = (function (_super) {
  3096. __extends(ColorPicker, _super);
  3097. function ColorPicker(name) {
  3098. var _this = _super.call(this, name) || this;
  3099. _this.name = name;
  3100. _this._value = BABYLON.Color3.Red();
  3101. _this._tmpColor = new BABYLON.Color3();
  3102. _this._pointerStartedOnSquare = false;
  3103. _this._pointerStartedOnWheel = false;
  3104. _this._squareLeft = 0;
  3105. _this._squareTop = 0;
  3106. _this._squareSize = 0;
  3107. _this._h = 360;
  3108. _this._s = 1;
  3109. _this._v = 1;
  3110. _this.onValueChangedObservable = new BABYLON.Observable();
  3111. // Events
  3112. _this._pointerIsDown = false;
  3113. _this.value = new BABYLON.Color3(.88, .1, .1);
  3114. _this.size = "200px";
  3115. _this.isPointerBlocker = true;
  3116. return _this;
  3117. }
  3118. Object.defineProperty(ColorPicker.prototype, "value", {
  3119. get: function () {
  3120. return this._value;
  3121. },
  3122. set: function (value) {
  3123. if (this._value.equals(value)) {
  3124. return;
  3125. }
  3126. this._value.copyFrom(value);
  3127. this._RGBtoHSV(this._value, this._tmpColor);
  3128. this._h = this._tmpColor.r;
  3129. this._s = Math.max(this._tmpColor.g, 0.00001);
  3130. this._v = Math.max(this._tmpColor.b, 0.00001);
  3131. this._markAsDirty();
  3132. this.onValueChangedObservable.notifyObservers(this._value);
  3133. },
  3134. enumerable: true,
  3135. configurable: true
  3136. });
  3137. Object.defineProperty(ColorPicker.prototype, "width", {
  3138. set: function (value) {
  3139. if (this._width.toString(this._host) === value) {
  3140. return;
  3141. }
  3142. if (this._width.fromString(value)) {
  3143. this._height.fromString(value);
  3144. this._markAsDirty();
  3145. }
  3146. },
  3147. enumerable: true,
  3148. configurable: true
  3149. });
  3150. Object.defineProperty(ColorPicker.prototype, "height", {
  3151. set: function (value) {
  3152. if (this._height.toString(this._host) === value) {
  3153. return;
  3154. }
  3155. if (this._height.fromString(value)) {
  3156. this._width.fromString(value);
  3157. this._markAsDirty();
  3158. }
  3159. },
  3160. enumerable: true,
  3161. configurable: true
  3162. });
  3163. Object.defineProperty(ColorPicker.prototype, "size", {
  3164. get: function () {
  3165. return this.width;
  3166. },
  3167. set: function (value) {
  3168. this.width = value;
  3169. },
  3170. enumerable: true,
  3171. configurable: true
  3172. });
  3173. ColorPicker.prototype._getTypeName = function () {
  3174. return "ColorPicker";
  3175. };
  3176. ColorPicker.prototype._updateSquareProps = function () {
  3177. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3178. var wheelThickness = radius * .2;
  3179. var innerDiameter = (radius - wheelThickness) * 2;
  3180. var squareSize = innerDiameter / (Math.sqrt(2));
  3181. var offset = radius - squareSize * .5;
  3182. this._squareLeft = this._currentMeasure.left + offset;
  3183. this._squareTop = this._currentMeasure.top + offset;
  3184. this._squareSize = squareSize;
  3185. };
  3186. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  3187. var lgh = context.createLinearGradient(left, top, width + left, top);
  3188. lgh.addColorStop(0, '#fff');
  3189. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  3190. context.fillStyle = lgh;
  3191. context.fillRect(left, top, width, height);
  3192. var lgv = context.createLinearGradient(left, top, left, height + top);
  3193. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  3194. lgv.addColorStop(1, '#000');
  3195. context.fillStyle = lgv;
  3196. context.fillRect(left, top, width, height);
  3197. };
  3198. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  3199. context.beginPath();
  3200. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  3201. context.lineWidth = 3;
  3202. context.strokeStyle = '#333333';
  3203. context.stroke();
  3204. context.beginPath();
  3205. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  3206. context.lineWidth = 3;
  3207. context.strokeStyle = '#ffffff';
  3208. context.stroke();
  3209. };
  3210. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  3211. var canvas = document.createElement("canvas");
  3212. canvas.width = radius * 2;
  3213. canvas.height = radius * 2;
  3214. var context = canvas.getContext("2d");
  3215. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  3216. var data = image.data;
  3217. var color = this._tmpColor;
  3218. var maxDistSq = radius * radius;
  3219. var innerRadius = radius - thickness;
  3220. var minDistSq = innerRadius * innerRadius;
  3221. for (var x = -radius; x < radius; x++) {
  3222. for (var y = -radius; y < radius; y++) {
  3223. var distSq = x * x + y * y;
  3224. if (distSq > maxDistSq || distSq < minDistSq) {
  3225. continue;
  3226. }
  3227. var dist = Math.sqrt(distSq);
  3228. var ang = Math.atan2(y, x);
  3229. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  3230. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  3231. data[index] = color.r * 255;
  3232. data[index + 1] = color.g * 255;
  3233. data[index + 2] = color.b * 255;
  3234. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  3235. //apply less alpha to bigger color pickers
  3236. var alphaAmount = .2;
  3237. var maxAlpha = .2;
  3238. var minAlpha = .04;
  3239. var lowerRadius = 50;
  3240. var upperRadius = 150;
  3241. if (radius < lowerRadius) {
  3242. alphaAmount = maxAlpha;
  3243. }
  3244. else if (radius > upperRadius) {
  3245. alphaAmount = minAlpha;
  3246. }
  3247. else {
  3248. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  3249. }
  3250. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  3251. if (alphaRatio < alphaAmount) {
  3252. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  3253. }
  3254. else if (alphaRatio > 1 - alphaAmount) {
  3255. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  3256. }
  3257. else {
  3258. data[index + 3] = 255;
  3259. }
  3260. }
  3261. }
  3262. context.putImageData(image, 0, 0);
  3263. return canvas;
  3264. };
  3265. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  3266. var r = color.r;
  3267. var g = color.g;
  3268. var b = color.b;
  3269. var max = Math.max(r, g, b);
  3270. var min = Math.min(r, g, b);
  3271. var h = 0;
  3272. var s = 0;
  3273. var v = max;
  3274. var dm = max - min;
  3275. if (max !== 0) {
  3276. s = dm / max;
  3277. }
  3278. if (max != min) {
  3279. if (max == r) {
  3280. h = (g - b) / dm;
  3281. if (g < b) {
  3282. h += 6;
  3283. }
  3284. }
  3285. else if (max == g) {
  3286. h = (b - r) / dm + 2;
  3287. }
  3288. else if (max == b) {
  3289. h = (r - g) / dm + 4;
  3290. }
  3291. h *= 60;
  3292. }
  3293. result.r = h;
  3294. result.g = s;
  3295. result.b = v;
  3296. };
  3297. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  3298. var chroma = value * saturation;
  3299. var h = hue / 60;
  3300. var x = chroma * (1 - Math.abs((h % 2) - 1));
  3301. var r = 0;
  3302. var g = 0;
  3303. var b = 0;
  3304. if (h >= 0 && h <= 1) {
  3305. r = chroma;
  3306. g = x;
  3307. }
  3308. else if (h >= 1 && h <= 2) {
  3309. r = x;
  3310. g = chroma;
  3311. }
  3312. else if (h >= 2 && h <= 3) {
  3313. g = chroma;
  3314. b = x;
  3315. }
  3316. else if (h >= 3 && h <= 4) {
  3317. g = x;
  3318. b = chroma;
  3319. }
  3320. else if (h >= 4 && h <= 5) {
  3321. r = x;
  3322. b = chroma;
  3323. }
  3324. else if (h >= 5 && h <= 6) {
  3325. r = chroma;
  3326. b = x;
  3327. }
  3328. var m = value - chroma;
  3329. result.set((r + m), (g + m), (b + m));
  3330. };
  3331. ColorPicker.prototype._draw = function (parentMeasure, context) {
  3332. context.save();
  3333. this._applyStates(context);
  3334. if (this._processMeasures(parentMeasure, context)) {
  3335. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3336. var wheelThickness = radius * .2;
  3337. var left = this._currentMeasure.left;
  3338. var top = this._currentMeasure.top;
  3339. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  3340. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  3341. }
  3342. context.drawImage(this._colorWheelCanvas, left, top);
  3343. this._updateSquareProps();
  3344. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  3345. var cx = this._squareLeft + this._squareSize * this._s;
  3346. var cy = this._squareTop + this._squareSize * (1 - this._v);
  3347. this._drawCircle(cx, cy, radius * .04, context);
  3348. var dist = radius - wheelThickness * .5;
  3349. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  3350. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  3351. this._drawCircle(cx, cy, wheelThickness * .35, context);
  3352. }
  3353. context.restore();
  3354. };
  3355. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  3356. if (this._pointerStartedOnWheel) {
  3357. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3358. var centerX = radius + this._currentMeasure.left;
  3359. var centerY = radius + this._currentMeasure.top;
  3360. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  3361. }
  3362. else if (this._pointerStartedOnSquare) {
  3363. this._updateSquareProps();
  3364. this._s = (x - this._squareLeft) / this._squareSize;
  3365. this._v = 1 - (y - this._squareTop) / this._squareSize;
  3366. this._s = Math.min(this._s, 1);
  3367. this._s = Math.max(this._s, 0.00001);
  3368. this._v = Math.min(this._v, 1);
  3369. this._v = Math.max(this._v, 0.00001);
  3370. }
  3371. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  3372. this.value = this._tmpColor;
  3373. };
  3374. ColorPicker.prototype._isPointOnSquare = function (coordinates) {
  3375. this._updateSquareProps();
  3376. var left = this._squareLeft;
  3377. var top = this._squareTop;
  3378. var size = this._squareSize;
  3379. if (coordinates.x >= left && coordinates.x <= left + size &&
  3380. coordinates.y >= top && coordinates.y <= top + size) {
  3381. return true;
  3382. }
  3383. return false;
  3384. };
  3385. ColorPicker.prototype._isPointOnWheel = function (coordinates) {
  3386. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3387. var centerX = radius + this._currentMeasure.left;
  3388. var centerY = radius + this._currentMeasure.top;
  3389. var wheelThickness = radius * .2;
  3390. var innerRadius = radius - wheelThickness;
  3391. var radiusSq = radius * radius;
  3392. var innerRadiusSq = innerRadius * innerRadius;
  3393. var dx = coordinates.x - centerX;
  3394. var dy = coordinates.y - centerY;
  3395. var distSq = dx * dx + dy * dy;
  3396. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  3397. return true;
  3398. }
  3399. return false;
  3400. };
  3401. ColorPicker.prototype._onPointerDown = function (coordinates) {
  3402. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  3403. return false;
  3404. }
  3405. this._pointerIsDown = true;
  3406. this._pointerStartedOnSquare = false;
  3407. this._pointerStartedOnWheel = false;
  3408. if (this._isPointOnSquare(coordinates)) {
  3409. this._pointerStartedOnSquare = true;
  3410. }
  3411. else if (this._isPointOnWheel(coordinates)) {
  3412. this._pointerStartedOnWheel = true;
  3413. }
  3414. this._updateValueFromPointer(coordinates.x, coordinates.y);
  3415. this._host._capturingControl = this;
  3416. return true;
  3417. };
  3418. ColorPicker.prototype._onPointerMove = function (coordinates) {
  3419. if (this._pointerIsDown) {
  3420. this._updateValueFromPointer(coordinates.x, coordinates.y);
  3421. }
  3422. _super.prototype._onPointerMove.call(this, coordinates);
  3423. };
  3424. ColorPicker.prototype._onPointerUp = function (coordinates) {
  3425. this._pointerIsDown = false;
  3426. this._host._capturingControl = null;
  3427. _super.prototype._onPointerUp.call(this, coordinates);
  3428. };
  3429. return ColorPicker;
  3430. }(GUI.Control));
  3431. GUI.ColorPicker = ColorPicker;
  3432. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  3433. })(BABYLON || (BABYLON = {}));