babylon.gui.js 150 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471
  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. if (!this.isVisible) {
  1597. return;
  1598. }
  1599. context.save();
  1600. this._applyStates(context);
  1601. if (this._processMeasures(parentMeasure, context)) {
  1602. this._localDraw(context);
  1603. this._clipForChildren(context);
  1604. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1605. var child = _a[_i];
  1606. if (child.isVisible) {
  1607. child._draw(this._measureForChildren, context);
  1608. }
  1609. }
  1610. }
  1611. context.restore();
  1612. };
  1613. Container.prototype._processPicking = function (x, y, type) {
  1614. if (!this.isHitTestVisible || !this.isVisible) {
  1615. return false;
  1616. }
  1617. if (!_super.prototype.contains.call(this, x, y)) {
  1618. return false;
  1619. }
  1620. // Checking backwards to pick closest first
  1621. for (var index = this._children.length - 1; index >= 0; index--) {
  1622. var child = this._children[index];
  1623. if (child._processPicking(x, y, type)) {
  1624. return true;
  1625. }
  1626. }
  1627. return this._processObservables(type, x, y);
  1628. };
  1629. Container.prototype._clipForChildren = function (context) {
  1630. // DO nothing
  1631. };
  1632. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  1633. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1634. this._measureForChildren.copyFrom(this._currentMeasure);
  1635. };
  1636. return Container;
  1637. }(GUI.Control));
  1638. GUI.Container = Container;
  1639. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1640. })(BABYLON || (BABYLON = {}));
  1641. //# sourceMappingURL=container.js.map
  1642. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1643. var __extends = (this && this.__extends) || (function () {
  1644. var extendStatics = Object.setPrototypeOf ||
  1645. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1646. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1647. return function (d, b) {
  1648. extendStatics(d, b);
  1649. function __() { this.constructor = d; }
  1650. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1651. };
  1652. })();
  1653. var BABYLON;
  1654. (function (BABYLON) {
  1655. var GUI;
  1656. (function (GUI) {
  1657. var StackPanel = (function (_super) {
  1658. __extends(StackPanel, _super);
  1659. function StackPanel(name) {
  1660. var _this = _super.call(this, name) || this;
  1661. _this.name = name;
  1662. _this._isVertical = true;
  1663. _this._tempMeasureStore = GUI.Measure.Empty();
  1664. return _this;
  1665. }
  1666. Object.defineProperty(StackPanel.prototype, "isVertical", {
  1667. get: function () {
  1668. return this._isVertical;
  1669. },
  1670. set: function (value) {
  1671. if (this._isVertical === value) {
  1672. return;
  1673. }
  1674. this._isVertical = value;
  1675. this._markAsDirty();
  1676. },
  1677. enumerable: true,
  1678. configurable: true
  1679. });
  1680. StackPanel.prototype._getTypeName = function () {
  1681. return "StackPanel";
  1682. };
  1683. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  1684. var stack = 0;
  1685. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  1686. var child = _a[_i];
  1687. this._tempMeasureStore.copyFrom(child._currentMeasure);
  1688. child._currentMeasure.copyFrom(parentMeasure);
  1689. child._measure();
  1690. if (this._isVertical) {
  1691. child.top = stack + "px";
  1692. if (!child._top.ignoreAdaptiveScaling) {
  1693. child._markAsDirty();
  1694. }
  1695. child._top.ignoreAdaptiveScaling = true;
  1696. stack += child._currentMeasure.height;
  1697. child.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1698. }
  1699. else {
  1700. child.left = stack + "px";
  1701. if (!child._left.ignoreAdaptiveScaling) {
  1702. child._markAsDirty();
  1703. }
  1704. child._left.ignoreAdaptiveScaling = true;
  1705. stack += child._currentMeasure.width;
  1706. child.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1707. }
  1708. child._currentMeasure.copyFrom(this._tempMeasureStore);
  1709. }
  1710. var panelChanged = false;
  1711. if (this._isVertical) {
  1712. var previousHeight = this.height;
  1713. this.height = stack + "px";
  1714. panelChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  1715. this._height.ignoreAdaptiveScaling = true;
  1716. }
  1717. else {
  1718. var previousWidth = this.width;
  1719. this.width = stack + "px";
  1720. panelChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  1721. this._width.ignoreAdaptiveScaling = true;
  1722. }
  1723. if (panelChanged) {
  1724. this._markAllAsDirty();
  1725. }
  1726. _super.prototype._preMeasure.call(this, parentMeasure, context);
  1727. };
  1728. return StackPanel;
  1729. }(GUI.Container));
  1730. GUI.StackPanel = StackPanel;
  1731. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1732. })(BABYLON || (BABYLON = {}));
  1733. //# sourceMappingURL=stackPanel.js.map
  1734. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1735. var __extends = (this && this.__extends) || (function () {
  1736. var extendStatics = Object.setPrototypeOf ||
  1737. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1738. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1739. return function (d, b) {
  1740. extendStatics(d, b);
  1741. function __() { this.constructor = d; }
  1742. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1743. };
  1744. })();
  1745. var BABYLON;
  1746. (function (BABYLON) {
  1747. var GUI;
  1748. (function (GUI) {
  1749. var Rectangle = (function (_super) {
  1750. __extends(Rectangle, _super);
  1751. function Rectangle(name) {
  1752. var _this = _super.call(this, name) || this;
  1753. _this.name = name;
  1754. _this._thickness = 1;
  1755. _this._cornerRadius = 0;
  1756. return _this;
  1757. }
  1758. Object.defineProperty(Rectangle.prototype, "thickness", {
  1759. get: function () {
  1760. return this._thickness;
  1761. },
  1762. set: function (value) {
  1763. if (this._thickness === value) {
  1764. return;
  1765. }
  1766. this._thickness = value;
  1767. this._markAsDirty();
  1768. },
  1769. enumerable: true,
  1770. configurable: true
  1771. });
  1772. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  1773. get: function () {
  1774. return this._cornerRadius;
  1775. },
  1776. set: function (value) {
  1777. if (value < 0) {
  1778. value = 0;
  1779. }
  1780. if (this._cornerRadius === value) {
  1781. return;
  1782. }
  1783. this._cornerRadius = value;
  1784. this._markAsDirty();
  1785. },
  1786. enumerable: true,
  1787. configurable: true
  1788. });
  1789. Rectangle.prototype._getTypeName = function () {
  1790. return "Rectangle";
  1791. };
  1792. Rectangle.prototype._localDraw = function (context) {
  1793. context.save();
  1794. if (this._background) {
  1795. context.fillStyle = this._background;
  1796. if (this._cornerRadius) {
  1797. this._drawRoundedRect(context, this._thickness / 2);
  1798. context.fill();
  1799. }
  1800. else {
  1801. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  1802. }
  1803. }
  1804. if (this._thickness) {
  1805. if (this.color) {
  1806. context.strokeStyle = this.color;
  1807. }
  1808. context.lineWidth = this._thickness;
  1809. if (this._cornerRadius) {
  1810. this._drawRoundedRect(context, this._thickness / 2);
  1811. context.stroke();
  1812. }
  1813. else {
  1814. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  1815. }
  1816. }
  1817. context.restore();
  1818. };
  1819. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  1820. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1821. this._measureForChildren.width -= 2 * this._thickness;
  1822. this._measureForChildren.height -= 2 * this._thickness;
  1823. this._measureForChildren.left += this._thickness;
  1824. this._measureForChildren.top += this._thickness;
  1825. };
  1826. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  1827. if (offset === void 0) { offset = 0; }
  1828. var x = this._currentMeasure.left + offset;
  1829. var y = this._currentMeasure.top + offset;
  1830. var width = this._currentMeasure.width - offset * 2;
  1831. var height = this._currentMeasure.height - offset * 2;
  1832. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  1833. context.beginPath();
  1834. context.moveTo(x + radius, y);
  1835. context.lineTo(x + width - radius, y);
  1836. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  1837. context.lineTo(x + width, y + height - radius);
  1838. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  1839. context.lineTo(x + radius, y + height);
  1840. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  1841. context.lineTo(x, y + radius);
  1842. context.quadraticCurveTo(x, y, x + radius, y);
  1843. context.closePath();
  1844. };
  1845. Rectangle.prototype._clipForChildren = function (context) {
  1846. if (this._cornerRadius) {
  1847. this._drawRoundedRect(context, this._thickness);
  1848. context.clip();
  1849. }
  1850. };
  1851. return Rectangle;
  1852. }(GUI.Container));
  1853. GUI.Rectangle = Rectangle;
  1854. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1855. })(BABYLON || (BABYLON = {}));
  1856. //# sourceMappingURL=rectangle.js.map
  1857. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1858. var __extends = (this && this.__extends) || (function () {
  1859. var extendStatics = Object.setPrototypeOf ||
  1860. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1861. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1862. return function (d, b) {
  1863. extendStatics(d, b);
  1864. function __() { this.constructor = d; }
  1865. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1866. };
  1867. })();
  1868. var BABYLON;
  1869. (function (BABYLON) {
  1870. var GUI;
  1871. (function (GUI) {
  1872. var Ellipse = (function (_super) {
  1873. __extends(Ellipse, _super);
  1874. function Ellipse(name) {
  1875. var _this = _super.call(this, name) || this;
  1876. _this.name = name;
  1877. _this._thickness = 1;
  1878. return _this;
  1879. }
  1880. Object.defineProperty(Ellipse.prototype, "thickness", {
  1881. get: function () {
  1882. return this._thickness;
  1883. },
  1884. set: function (value) {
  1885. if (this._thickness === value) {
  1886. return;
  1887. }
  1888. this._thickness = value;
  1889. this._markAsDirty();
  1890. },
  1891. enumerable: true,
  1892. configurable: true
  1893. });
  1894. Ellipse.prototype._getTypeName = function () {
  1895. return "Ellipse";
  1896. };
  1897. Ellipse.prototype._localDraw = function (context) {
  1898. context.save();
  1899. 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);
  1900. if (this._background) {
  1901. context.fillStyle = this._background;
  1902. context.fill();
  1903. }
  1904. if (this._thickness) {
  1905. if (this.color) {
  1906. context.strokeStyle = this.color;
  1907. }
  1908. context.lineWidth = this._thickness;
  1909. context.stroke();
  1910. }
  1911. context.restore();
  1912. };
  1913. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  1914. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  1915. this._measureForChildren.width -= 2 * this._thickness;
  1916. this._measureForChildren.height -= 2 * this._thickness;
  1917. this._measureForChildren.left += this._thickness;
  1918. this._measureForChildren.top += this._thickness;
  1919. };
  1920. Ellipse.prototype._clipForChildren = function (context) {
  1921. 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);
  1922. context.clip();
  1923. };
  1924. return Ellipse;
  1925. }(GUI.Container));
  1926. GUI.Ellipse = Ellipse;
  1927. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  1928. })(BABYLON || (BABYLON = {}));
  1929. //# sourceMappingURL=ellipse.js.map
  1930. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  1931. var __extends = (this && this.__extends) || (function () {
  1932. var extendStatics = Object.setPrototypeOf ||
  1933. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1934. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1935. return function (d, b) {
  1936. extendStatics(d, b);
  1937. function __() { this.constructor = d; }
  1938. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1939. };
  1940. })();
  1941. var DOMImage = Image;
  1942. var BABYLON;
  1943. (function (BABYLON) {
  1944. var GUI;
  1945. (function (GUI) {
  1946. var Line = (function (_super) {
  1947. __extends(Line, _super);
  1948. function Line(name) {
  1949. var _this = _super.call(this, name) || this;
  1950. _this.name = name;
  1951. _this._lineWidth = 1;
  1952. _this._x1 = new GUI.ValueAndUnit(0);
  1953. _this._y1 = new GUI.ValueAndUnit(0);
  1954. _this._x2 = new GUI.ValueAndUnit(0);
  1955. _this._y2 = new GUI.ValueAndUnit(0);
  1956. _this._dash = new Array();
  1957. _this.isHitTestVisible = false;
  1958. _this._horizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  1959. _this._verticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_TOP;
  1960. return _this;
  1961. }
  1962. Object.defineProperty(Line.prototype, "dash", {
  1963. get: function () {
  1964. return this._dash;
  1965. },
  1966. set: function (value) {
  1967. if (this._dash === value) {
  1968. return;
  1969. }
  1970. this._dash = value;
  1971. this._markAsDirty();
  1972. },
  1973. enumerable: true,
  1974. configurable: true
  1975. });
  1976. Object.defineProperty(Line.prototype, "connectedControl", {
  1977. get: function () {
  1978. return this._connectedControl;
  1979. },
  1980. set: function (value) {
  1981. var _this = this;
  1982. if (this._connectedControl === value) {
  1983. return;
  1984. }
  1985. if (this._connectedControlDirtyObserver && this._connectedControl) {
  1986. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  1987. this._connectedControlDirtyObserver = null;
  1988. }
  1989. if (value) {
  1990. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  1991. }
  1992. this._connectedControl = value;
  1993. this._markAsDirty();
  1994. },
  1995. enumerable: true,
  1996. configurable: true
  1997. });
  1998. Object.defineProperty(Line.prototype, "x1", {
  1999. get: function () {
  2000. return this._x1.toString(this._host);
  2001. },
  2002. set: function (value) {
  2003. if (this._x1.toString(this._host) === value) {
  2004. return;
  2005. }
  2006. if (this._x1.fromString(value)) {
  2007. this._markAsDirty();
  2008. }
  2009. },
  2010. enumerable: true,
  2011. configurable: true
  2012. });
  2013. Object.defineProperty(Line.prototype, "y1", {
  2014. get: function () {
  2015. return this._y1.toString(this._host);
  2016. },
  2017. set: function (value) {
  2018. if (this._y1.toString(this._host) === value) {
  2019. return;
  2020. }
  2021. if (this._y1.fromString(value)) {
  2022. this._markAsDirty();
  2023. }
  2024. },
  2025. enumerable: true,
  2026. configurable: true
  2027. });
  2028. Object.defineProperty(Line.prototype, "x2", {
  2029. get: function () {
  2030. return this._x2.toString(this._host);
  2031. },
  2032. set: function (value) {
  2033. if (this._x2.toString(this._host) === value) {
  2034. return;
  2035. }
  2036. if (this._x2.fromString(value)) {
  2037. this._markAsDirty();
  2038. }
  2039. },
  2040. enumerable: true,
  2041. configurable: true
  2042. });
  2043. Object.defineProperty(Line.prototype, "y2", {
  2044. get: function () {
  2045. return this._y2.toString(this._host);
  2046. },
  2047. set: function (value) {
  2048. if (this._y2.toString(this._host) === value) {
  2049. return;
  2050. }
  2051. if (this._y2.fromString(value)) {
  2052. this._markAsDirty();
  2053. }
  2054. },
  2055. enumerable: true,
  2056. configurable: true
  2057. });
  2058. Object.defineProperty(Line.prototype, "lineWidth", {
  2059. get: function () {
  2060. return this._lineWidth;
  2061. },
  2062. set: function (value) {
  2063. if (this._lineWidth === value) {
  2064. return;
  2065. }
  2066. this._lineWidth = value;
  2067. this._markAsDirty();
  2068. },
  2069. enumerable: true,
  2070. configurable: true
  2071. });
  2072. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  2073. set: function (value) {
  2074. return;
  2075. },
  2076. enumerable: true,
  2077. configurable: true
  2078. });
  2079. Object.defineProperty(Line.prototype, "verticalAlignment", {
  2080. set: function (value) {
  2081. return;
  2082. },
  2083. enumerable: true,
  2084. configurable: true
  2085. });
  2086. Object.defineProperty(Line.prototype, "_effectiveX2", {
  2087. get: function () {
  2088. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  2089. },
  2090. enumerable: true,
  2091. configurable: true
  2092. });
  2093. Object.defineProperty(Line.prototype, "_effectiveY2", {
  2094. get: function () {
  2095. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  2096. },
  2097. enumerable: true,
  2098. configurable: true
  2099. });
  2100. Line.prototype._getTypeName = function () {
  2101. return "Line";
  2102. };
  2103. Line.prototype._draw = function (parentMeasure, context) {
  2104. context.save();
  2105. this._applyStates(context);
  2106. if (this._processMeasures(parentMeasure, context)) {
  2107. context.strokeStyle = this.color;
  2108. context.lineWidth = this._lineWidth;
  2109. context.setLineDash(this._dash);
  2110. context.beginPath();
  2111. context.moveTo(this._x1.getValue(this._host), this._y1.getValue(this._host));
  2112. context.lineTo(this._effectiveX2, this._effectiveY2);
  2113. context.stroke();
  2114. }
  2115. context.restore();
  2116. };
  2117. Line.prototype._measure = function () {
  2118. // Width / Height
  2119. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  2120. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  2121. };
  2122. Line.prototype._computeAlignment = function (parentMeasure, context) {
  2123. this._currentMeasure.left = Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  2124. this._currentMeasure.top = Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  2125. };
  2126. Line.prototype._moveToProjectedPosition = function (projectedPosition) {
  2127. this.x1 = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  2128. this.y1 = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  2129. this._x1.ignoreAdaptiveScaling = true;
  2130. this._y1.ignoreAdaptiveScaling = true;
  2131. };
  2132. return Line;
  2133. }(GUI.Control));
  2134. GUI.Line = Line;
  2135. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2136. })(BABYLON || (BABYLON = {}));
  2137. //# sourceMappingURL=line.js.map
  2138. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2139. var __extends = (this && this.__extends) || (function () {
  2140. var extendStatics = Object.setPrototypeOf ||
  2141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2143. return function (d, b) {
  2144. extendStatics(d, b);
  2145. function __() { this.constructor = d; }
  2146. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2147. };
  2148. })();
  2149. var DOMImage = Image;
  2150. var BABYLON;
  2151. (function (BABYLON) {
  2152. var GUI;
  2153. (function (GUI) {
  2154. var Slider = (function (_super) {
  2155. __extends(Slider, _super);
  2156. function Slider(name) {
  2157. var _this = _super.call(this, name) || this;
  2158. _this.name = name;
  2159. _this._thumbWidth = new GUI.ValueAndUnit(30, GUI.ValueAndUnit.UNITMODE_PIXEL, false);
  2160. _this._minimum = 0;
  2161. _this._maximum = 100;
  2162. _this._value = 50;
  2163. _this._background = "black";
  2164. _this._borderColor = "white";
  2165. _this._barOffset = new GUI.ValueAndUnit(5, GUI.ValueAndUnit.UNITMODE_PIXEL, false);
  2166. _this.onValueChangedObservable = new BABYLON.Observable();
  2167. // Events
  2168. _this._pointerIsDown = false;
  2169. _this.isPointerBlocker = true;
  2170. return _this;
  2171. }
  2172. Object.defineProperty(Slider.prototype, "borderColor", {
  2173. get: function () {
  2174. return this._borderColor;
  2175. },
  2176. set: function (value) {
  2177. if (this._borderColor === value) {
  2178. return;
  2179. }
  2180. this._borderColor = value;
  2181. this._markAsDirty();
  2182. },
  2183. enumerable: true,
  2184. configurable: true
  2185. });
  2186. Object.defineProperty(Slider.prototype, "background", {
  2187. get: function () {
  2188. return this._background;
  2189. },
  2190. set: function (value) {
  2191. if (this._background === value) {
  2192. return;
  2193. }
  2194. this._background = value;
  2195. this._markAsDirty();
  2196. },
  2197. enumerable: true,
  2198. configurable: true
  2199. });
  2200. Object.defineProperty(Slider.prototype, "barOffset", {
  2201. get: function () {
  2202. return this._barOffset.toString(this._host);
  2203. },
  2204. set: function (value) {
  2205. if (this._barOffset.toString(this._host) === value) {
  2206. return;
  2207. }
  2208. if (this._barOffset.fromString(value)) {
  2209. this._markAsDirty();
  2210. }
  2211. },
  2212. enumerable: true,
  2213. configurable: true
  2214. });
  2215. Object.defineProperty(Slider.prototype, "thumbWidth", {
  2216. get: function () {
  2217. return this._thumbWidth.toString(this._host);
  2218. },
  2219. set: function (value) {
  2220. if (this._thumbWidth.toString(this._host) === value) {
  2221. return;
  2222. }
  2223. if (this._thumbWidth.fromString(value)) {
  2224. this._markAsDirty();
  2225. }
  2226. },
  2227. enumerable: true,
  2228. configurable: true
  2229. });
  2230. Object.defineProperty(Slider.prototype, "minimum", {
  2231. get: function () {
  2232. return this._minimum;
  2233. },
  2234. set: function (value) {
  2235. if (this._minimum === value) {
  2236. return;
  2237. }
  2238. this._minimum = value;
  2239. this._markAsDirty();
  2240. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  2241. },
  2242. enumerable: true,
  2243. configurable: true
  2244. });
  2245. Object.defineProperty(Slider.prototype, "maximum", {
  2246. get: function () {
  2247. return this._maximum;
  2248. },
  2249. set: function (value) {
  2250. if (this._maximum === value) {
  2251. return;
  2252. }
  2253. this._maximum = value;
  2254. this._markAsDirty();
  2255. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  2256. },
  2257. enumerable: true,
  2258. configurable: true
  2259. });
  2260. Object.defineProperty(Slider.prototype, "value", {
  2261. get: function () {
  2262. return this._value;
  2263. },
  2264. set: function (value) {
  2265. value = Math.max(Math.min(value, this._maximum), this._minimum);
  2266. if (this._value === value) {
  2267. return;
  2268. }
  2269. this._value = value;
  2270. this._markAsDirty();
  2271. this.onValueChangedObservable.notifyObservers(this._value);
  2272. },
  2273. enumerable: true,
  2274. configurable: true
  2275. });
  2276. Slider.prototype._getTypeName = function () {
  2277. return "Slider";
  2278. };
  2279. Slider.prototype._draw = function (parentMeasure, context) {
  2280. context.save();
  2281. this._applyStates(context);
  2282. if (this._processMeasures(parentMeasure, context)) {
  2283. // Main bar
  2284. var effectiveThumbWidth;
  2285. var effectiveBarOffset;
  2286. if (this._thumbWidth.isPixel) {
  2287. effectiveThumbWidth = Math.min(this._thumbWidth.getValue(this._host), this._currentMeasure.height);
  2288. }
  2289. else {
  2290. effectiveThumbWidth = this._currentMeasure.height * this._thumbWidth.getValue(this._host);
  2291. }
  2292. if (this._barOffset.isPixel) {
  2293. effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._currentMeasure.height);
  2294. }
  2295. else {
  2296. effectiveBarOffset = this._currentMeasure.height * this._barOffset.getValue(this._host);
  2297. }
  2298. var left = this._currentMeasure.left + effectiveThumbWidth / 2;
  2299. var width = this._currentMeasure.width - effectiveThumbWidth;
  2300. var thumbPosition = (this._value - this._minimum) / (this._maximum - this._minimum) * width;
  2301. // Bar
  2302. context.fillStyle = this._background;
  2303. context.fillRect(left, this._currentMeasure.top + effectiveBarOffset, width, this._currentMeasure.height - effectiveBarOffset * 2);
  2304. context.fillStyle = this.color;
  2305. context.fillRect(left, this._currentMeasure.top + effectiveBarOffset, thumbPosition, this._currentMeasure.height - effectiveBarOffset * 2);
  2306. // Thumb
  2307. context.fillRect(left + thumbPosition - effectiveThumbWidth / 2, this._currentMeasure.top, effectiveThumbWidth, this._currentMeasure.height);
  2308. context.strokeStyle = this._borderColor;
  2309. context.strokeRect(left + thumbPosition - effectiveThumbWidth / 2, this._currentMeasure.top, effectiveThumbWidth, this._currentMeasure.height);
  2310. }
  2311. context.restore();
  2312. };
  2313. Slider.prototype._updateValueFromPointer = function (x) {
  2314. this.value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  2315. };
  2316. Slider.prototype._onPointerDown = function (coordinates) {
  2317. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2318. return false;
  2319. }
  2320. this._pointerIsDown = true;
  2321. this._updateValueFromPointer(coordinates.x);
  2322. this._host._capturingControl = this;
  2323. return true;
  2324. };
  2325. Slider.prototype._onPointerMove = function (coordinates) {
  2326. if (this._pointerIsDown) {
  2327. this._updateValueFromPointer(coordinates.x);
  2328. }
  2329. };
  2330. Slider.prototype._onPointerUp = function (coordinates) {
  2331. this._pointerIsDown = false;
  2332. this._host._capturingControl = null;
  2333. _super.prototype._onPointerUp.call(this, coordinates);
  2334. };
  2335. return Slider;
  2336. }(GUI.Control));
  2337. GUI.Slider = Slider;
  2338. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2339. })(BABYLON || (BABYLON = {}));
  2340. //# sourceMappingURL=slider.js.map
  2341. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2342. var __extends = (this && this.__extends) || (function () {
  2343. var extendStatics = Object.setPrototypeOf ||
  2344. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2345. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2346. return function (d, b) {
  2347. extendStatics(d, b);
  2348. function __() { this.constructor = d; }
  2349. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2350. };
  2351. })();
  2352. var DOMImage = Image;
  2353. var BABYLON;
  2354. (function (BABYLON) {
  2355. var GUI;
  2356. (function (GUI) {
  2357. var Checkbox = (function (_super) {
  2358. __extends(Checkbox, _super);
  2359. function Checkbox(name) {
  2360. var _this = _super.call(this, name) || this;
  2361. _this.name = name;
  2362. _this._isChecked = false;
  2363. _this._background = "black";
  2364. _this._checkSizeRatio = 0.8;
  2365. _this._thickness = 1;
  2366. _this.onIsCheckedChangedObservable = new BABYLON.Observable();
  2367. _this.isPointerBlocker = true;
  2368. return _this;
  2369. }
  2370. Object.defineProperty(Checkbox.prototype, "thickness", {
  2371. get: function () {
  2372. return this._thickness;
  2373. },
  2374. set: function (value) {
  2375. if (this._thickness === value) {
  2376. return;
  2377. }
  2378. this._thickness = value;
  2379. this._markAsDirty();
  2380. },
  2381. enumerable: true,
  2382. configurable: true
  2383. });
  2384. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  2385. get: function () {
  2386. return this._checkSizeRatio;
  2387. },
  2388. set: function (value) {
  2389. value = Math.max(Math.min(1, value), 0);
  2390. if (this._checkSizeRatio === value) {
  2391. return;
  2392. }
  2393. this._checkSizeRatio = value;
  2394. this._markAsDirty();
  2395. },
  2396. enumerable: true,
  2397. configurable: true
  2398. });
  2399. Object.defineProperty(Checkbox.prototype, "background", {
  2400. get: function () {
  2401. return this._background;
  2402. },
  2403. set: function (value) {
  2404. if (this._background === value) {
  2405. return;
  2406. }
  2407. this._background = value;
  2408. this._markAsDirty();
  2409. },
  2410. enumerable: true,
  2411. configurable: true
  2412. });
  2413. Object.defineProperty(Checkbox.prototype, "isChecked", {
  2414. get: function () {
  2415. return this._isChecked;
  2416. },
  2417. set: function (value) {
  2418. if (this._isChecked === value) {
  2419. return;
  2420. }
  2421. this._isChecked = value;
  2422. this._markAsDirty();
  2423. this.onIsCheckedChangedObservable.notifyObservers(value);
  2424. },
  2425. enumerable: true,
  2426. configurable: true
  2427. });
  2428. Checkbox.prototype._getTypeName = function () {
  2429. return "CheckBox";
  2430. };
  2431. Checkbox.prototype._draw = function (parentMeasure, context) {
  2432. context.save();
  2433. this._applyStates(context);
  2434. if (this._processMeasures(parentMeasure, context)) {
  2435. var actualWidth = this._currentMeasure.width - this._thickness;
  2436. var actualHeight = this._currentMeasure.height - this._thickness;
  2437. context.fillStyle = this._background;
  2438. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  2439. if (this._isChecked) {
  2440. context.fillStyle = this.color;
  2441. var offsetWidth = actualWidth * this._checkSizeRatio;
  2442. var offseHeight = actualHeight * this._checkSizeRatio;
  2443. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  2444. }
  2445. context.strokeStyle = this.color;
  2446. context.lineWidth = this._thickness;
  2447. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  2448. }
  2449. context.restore();
  2450. };
  2451. // Events
  2452. Checkbox.prototype._onPointerDown = function (coordinates) {
  2453. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2454. return false;
  2455. }
  2456. this.isChecked = !this.isChecked;
  2457. return true;
  2458. };
  2459. return Checkbox;
  2460. }(GUI.Control));
  2461. GUI.Checkbox = Checkbox;
  2462. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2463. })(BABYLON || (BABYLON = {}));
  2464. //# sourceMappingURL=checkBox.js.map
  2465. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2466. var __extends = (this && this.__extends) || (function () {
  2467. var extendStatics = Object.setPrototypeOf ||
  2468. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2469. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2470. return function (d, b) {
  2471. extendStatics(d, b);
  2472. function __() { this.constructor = d; }
  2473. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2474. };
  2475. })();
  2476. var DOMImage = Image;
  2477. var BABYLON;
  2478. (function (BABYLON) {
  2479. var GUI;
  2480. (function (GUI) {
  2481. var RadioButton = (function (_super) {
  2482. __extends(RadioButton, _super);
  2483. function RadioButton(name) {
  2484. var _this = _super.call(this, name) || this;
  2485. _this.name = name;
  2486. _this._isChecked = false;
  2487. _this._background = "black";
  2488. _this._checkSizeRatio = 0.8;
  2489. _this._thickness = 1;
  2490. _this.group = "";
  2491. _this.onIsCheckedChangedObservable = new BABYLON.Observable();
  2492. _this.isPointerBlocker = true;
  2493. return _this;
  2494. }
  2495. Object.defineProperty(RadioButton.prototype, "thickness", {
  2496. get: function () {
  2497. return this._thickness;
  2498. },
  2499. set: function (value) {
  2500. if (this._thickness === value) {
  2501. return;
  2502. }
  2503. this._thickness = value;
  2504. this._markAsDirty();
  2505. },
  2506. enumerable: true,
  2507. configurable: true
  2508. });
  2509. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  2510. get: function () {
  2511. return this._checkSizeRatio;
  2512. },
  2513. set: function (value) {
  2514. value = Math.max(Math.min(1, value), 0);
  2515. if (this._checkSizeRatio === value) {
  2516. return;
  2517. }
  2518. this._checkSizeRatio = value;
  2519. this._markAsDirty();
  2520. },
  2521. enumerable: true,
  2522. configurable: true
  2523. });
  2524. Object.defineProperty(RadioButton.prototype, "background", {
  2525. get: function () {
  2526. return this._background;
  2527. },
  2528. set: function (value) {
  2529. if (this._background === value) {
  2530. return;
  2531. }
  2532. this._background = value;
  2533. this._markAsDirty();
  2534. },
  2535. enumerable: true,
  2536. configurable: true
  2537. });
  2538. Object.defineProperty(RadioButton.prototype, "isChecked", {
  2539. get: function () {
  2540. return this._isChecked;
  2541. },
  2542. set: function (value) {
  2543. var _this = this;
  2544. if (this._isChecked === value) {
  2545. return;
  2546. }
  2547. this._isChecked = value;
  2548. this._markAsDirty();
  2549. this.onIsCheckedChangedObservable.notifyObservers(value);
  2550. if (this._isChecked) {
  2551. // Update all controls from same group
  2552. this._host.executeOnAllControls(function (control) {
  2553. if (control === _this) {
  2554. return;
  2555. }
  2556. if (control.group === undefined) {
  2557. return;
  2558. }
  2559. var childRadio = control;
  2560. if (childRadio.group === _this.group) {
  2561. childRadio.isChecked = false;
  2562. }
  2563. });
  2564. }
  2565. },
  2566. enumerable: true,
  2567. configurable: true
  2568. });
  2569. RadioButton.prototype._getTypeName = function () {
  2570. return "RadioButton";
  2571. };
  2572. RadioButton.prototype._draw = function (parentMeasure, context) {
  2573. context.save();
  2574. this._applyStates(context);
  2575. if (this._processMeasures(parentMeasure, context)) {
  2576. var actualWidth = this._currentMeasure.width - this._thickness;
  2577. var actualHeight = this._currentMeasure.height - this._thickness;
  2578. // Outer
  2579. 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);
  2580. context.fillStyle = this._background;
  2581. context.fill();
  2582. context.strokeStyle = this.color;
  2583. context.lineWidth = this._thickness;
  2584. context.stroke();
  2585. // Inner
  2586. if (this._isChecked) {
  2587. context.fillStyle = this.color;
  2588. var offsetWidth = actualWidth * this._checkSizeRatio;
  2589. var offseHeight = actualHeight * this._checkSizeRatio;
  2590. 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);
  2591. context.fill();
  2592. }
  2593. }
  2594. context.restore();
  2595. };
  2596. // Events
  2597. RadioButton.prototype._onPointerDown = function (coordinates) {
  2598. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  2599. return false;
  2600. }
  2601. this.isChecked = !this.isChecked;
  2602. return true;
  2603. };
  2604. return RadioButton;
  2605. }(GUI.Control));
  2606. GUI.RadioButton = RadioButton;
  2607. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2608. })(BABYLON || (BABYLON = {}));
  2609. //# sourceMappingURL=radioButton.js.map
  2610. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2611. var __extends = (this && this.__extends) || (function () {
  2612. var extendStatics = Object.setPrototypeOf ||
  2613. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2614. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2615. return function (d, b) {
  2616. extendStatics(d, b);
  2617. function __() { this.constructor = d; }
  2618. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2619. };
  2620. })();
  2621. var BABYLON;
  2622. (function (BABYLON) {
  2623. var GUI;
  2624. (function (GUI) {
  2625. var TextBlock = (function (_super) {
  2626. __extends(TextBlock, _super);
  2627. function TextBlock(name, text) {
  2628. if (text === void 0) { text = ""; }
  2629. var _this = _super.call(this, name) || this;
  2630. _this.name = name;
  2631. _this._text = "";
  2632. _this._textWrapping = false;
  2633. _this._textHorizontalAlignment = GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  2634. _this._textVerticalAlignment = GUI.Control.VERTICAL_ALIGNMENT_CENTER;
  2635. _this.text = text;
  2636. return _this;
  2637. }
  2638. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  2639. get: function () {
  2640. return this._textWrapping;
  2641. },
  2642. set: function (value) {
  2643. if (this._textWrapping === value) {
  2644. return;
  2645. }
  2646. this._textWrapping = value;
  2647. this._markAsDirty();
  2648. },
  2649. enumerable: true,
  2650. configurable: true
  2651. });
  2652. Object.defineProperty(TextBlock.prototype, "text", {
  2653. get: function () {
  2654. return this._text;
  2655. },
  2656. set: function (value) {
  2657. if (this._text === value) {
  2658. return;
  2659. }
  2660. this._text = value;
  2661. this._markAsDirty();
  2662. },
  2663. enumerable: true,
  2664. configurable: true
  2665. });
  2666. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  2667. get: function () {
  2668. return this._textHorizontalAlignment;
  2669. },
  2670. set: function (value) {
  2671. if (this._textHorizontalAlignment === value) {
  2672. return;
  2673. }
  2674. this._textHorizontalAlignment = value;
  2675. this._markAsDirty();
  2676. },
  2677. enumerable: true,
  2678. configurable: true
  2679. });
  2680. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  2681. get: function () {
  2682. return this._textVerticalAlignment;
  2683. },
  2684. set: function (value) {
  2685. if (this._textVerticalAlignment === value) {
  2686. return;
  2687. }
  2688. this._textVerticalAlignment = value;
  2689. this._markAsDirty();
  2690. },
  2691. enumerable: true,
  2692. configurable: true
  2693. });
  2694. TextBlock.prototype._getTypeName = function () {
  2695. return "TextBlock";
  2696. };
  2697. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  2698. var width = this._currentMeasure.width;
  2699. var x = 0;
  2700. switch (this._textHorizontalAlignment) {
  2701. case GUI.Control.HORIZONTAL_ALIGNMENT_LEFT:
  2702. x = 0;
  2703. break;
  2704. case GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT:
  2705. x = width - textWidth;
  2706. break;
  2707. case GUI.Control.HORIZONTAL_ALIGNMENT_CENTER:
  2708. x = (width - textWidth) / 2;
  2709. break;
  2710. }
  2711. context.fillText(text, this._currentMeasure.left + x, y);
  2712. };
  2713. TextBlock.prototype._draw = function (parentMeasure, context) {
  2714. context.save();
  2715. this._applyStates(context);
  2716. if (this._processMeasures(parentMeasure, context)) {
  2717. // Render lines
  2718. this._renderLines(context);
  2719. }
  2720. context.restore();
  2721. };
  2722. TextBlock.prototype._additionalProcessing = function (parentMeasure, context) {
  2723. this._lines = [];
  2724. if (this._textWrapping) {
  2725. var words = this.text.split(' ');
  2726. var line = '';
  2727. var width = this._currentMeasure.width;
  2728. var lineWidth = 0;
  2729. for (var n = 0; n < words.length; n++) {
  2730. var testLine = n > 0 ? line + " " + words[n] : words[0];
  2731. var metrics = context.measureText(testLine);
  2732. var testWidth = metrics.width;
  2733. if (testWidth > width && n > 0) {
  2734. this._lines.push({ text: line, width: lineWidth });
  2735. line = words[n];
  2736. lineWidth = context.measureText(line).width;
  2737. }
  2738. else {
  2739. lineWidth = testWidth;
  2740. line = testLine;
  2741. }
  2742. }
  2743. this._lines.push({ text: line, width: lineWidth });
  2744. }
  2745. else {
  2746. this._lines.push({ text: this.text, width: context.measureText(this.text).width });
  2747. }
  2748. };
  2749. TextBlock.prototype._renderLines = function (context) {
  2750. var width = this._currentMeasure.width;
  2751. var height = this._currentMeasure.height;
  2752. if (!this._fontOffset) {
  2753. this._fontOffset = GUI.Control._GetFontOffset(context.font);
  2754. }
  2755. var rootY = 0;
  2756. switch (this._textVerticalAlignment) {
  2757. case GUI.Control.VERTICAL_ALIGNMENT_TOP:
  2758. rootY = this._fontOffset.ascent;
  2759. break;
  2760. case GUI.Control.VERTICAL_ALIGNMENT_BOTTOM:
  2761. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  2762. break;
  2763. case GUI.Control.VERTICAL_ALIGNMENT_CENTER:
  2764. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  2765. break;
  2766. }
  2767. rootY += this._currentMeasure.top;
  2768. for (var _i = 0, _a = this._lines; _i < _a.length; _i++) {
  2769. var line = _a[_i];
  2770. this._drawText(line.text, line.width, rootY, context);
  2771. rootY += this._fontOffset.height;
  2772. }
  2773. };
  2774. return TextBlock;
  2775. }(GUI.Control));
  2776. GUI.TextBlock = TextBlock;
  2777. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2778. })(BABYLON || (BABYLON = {}));
  2779. //# sourceMappingURL=textBlock.js.map
  2780. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2781. var __extends = (this && this.__extends) || (function () {
  2782. var extendStatics = Object.setPrototypeOf ||
  2783. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2784. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2785. return function (d, b) {
  2786. extendStatics(d, b);
  2787. function __() { this.constructor = d; }
  2788. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2789. };
  2790. })();
  2791. var DOMImage = Image;
  2792. var BABYLON;
  2793. (function (BABYLON) {
  2794. var GUI;
  2795. (function (GUI) {
  2796. var Image = (function (_super) {
  2797. __extends(Image, _super);
  2798. function Image(name, url) {
  2799. var _this = _super.call(this, name) || this;
  2800. _this.name = name;
  2801. _this._loaded = false;
  2802. _this._stretch = Image.STRETCH_FILL;
  2803. _this._autoScale = false;
  2804. _this.source = url;
  2805. return _this;
  2806. }
  2807. Object.defineProperty(Image.prototype, "autoScale", {
  2808. get: function () {
  2809. return this._autoScale;
  2810. },
  2811. set: function (value) {
  2812. if (this._autoScale === value) {
  2813. return;
  2814. }
  2815. this._autoScale = value;
  2816. if (value && this._loaded) {
  2817. this.synchronizeSizeWithContent();
  2818. }
  2819. },
  2820. enumerable: true,
  2821. configurable: true
  2822. });
  2823. Object.defineProperty(Image.prototype, "stretch", {
  2824. get: function () {
  2825. return this._stretch;
  2826. },
  2827. set: function (value) {
  2828. if (this._stretch === value) {
  2829. return;
  2830. }
  2831. this._stretch = value;
  2832. this._markAsDirty();
  2833. },
  2834. enumerable: true,
  2835. configurable: true
  2836. });
  2837. Object.defineProperty(Image.prototype, "domImage", {
  2838. get: function () {
  2839. return this._domImage;
  2840. },
  2841. set: function (value) {
  2842. var _this = this;
  2843. this._domImage = value;
  2844. this._loaded = false;
  2845. if (this._domImage.width) {
  2846. this._onImageLoaded();
  2847. }
  2848. else {
  2849. this._domImage.onload = function () {
  2850. _this._onImageLoaded();
  2851. };
  2852. }
  2853. },
  2854. enumerable: true,
  2855. configurable: true
  2856. });
  2857. Image.prototype._onImageLoaded = function () {
  2858. this._imageWidth = this._domImage.width;
  2859. this._imageHeight = this._domImage.height;
  2860. this._loaded = true;
  2861. if (this._autoScale) {
  2862. this.synchronizeSizeWithContent();
  2863. }
  2864. this._markAsDirty();
  2865. };
  2866. Object.defineProperty(Image.prototype, "source", {
  2867. set: function (value) {
  2868. var _this = this;
  2869. if (this._source === value) {
  2870. return;
  2871. }
  2872. this._loaded = false;
  2873. this._source = value;
  2874. this._domImage = new DOMImage();
  2875. this._domImage.onload = function () {
  2876. _this._onImageLoaded();
  2877. };
  2878. this._domImage.src = value;
  2879. },
  2880. enumerable: true,
  2881. configurable: true
  2882. });
  2883. Image.prototype._getTypeName = function () {
  2884. return "Image";
  2885. };
  2886. Image.prototype.synchronizeSizeWithContent = function () {
  2887. if (!this._loaded) {
  2888. return;
  2889. }
  2890. this.width = this._domImage.width + "px";
  2891. this.height = this._domImage.height + "px";
  2892. };
  2893. Image.prototype._draw = function (parentMeasure, context) {
  2894. context.save();
  2895. this._applyStates(context);
  2896. if (this._processMeasures(parentMeasure, context)) {
  2897. if (this._loaded) {
  2898. switch (this._stretch) {
  2899. case Image.STRETCH_NONE:
  2900. context.drawImage(this._domImage, this._currentMeasure.left, this._currentMeasure.top);
  2901. break;
  2902. case Image.STRETCH_FILL:
  2903. context.drawImage(this._domImage, 0, 0, this._imageWidth, this._imageHeight, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  2904. break;
  2905. case Image.STRETCH_UNIFORM:
  2906. var hRatio = this._currentMeasure.width / this._imageWidth;
  2907. var vRatio = this._currentMeasure.height / this._imageHeight;
  2908. var ratio = Math.min(hRatio, vRatio);
  2909. var centerX = (this._currentMeasure.width - this._imageWidth * ratio) / 2;
  2910. var centerY = (this._currentMeasure.height - this._imageHeight * ratio) / 2;
  2911. context.drawImage(this._domImage, 0, 0, this._imageWidth, this._imageHeight, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, this._imageWidth * ratio, this._imageHeight * ratio);
  2912. break;
  2913. case Image.STRETCH_EXTEND:
  2914. context.drawImage(this._domImage, this._currentMeasure.left, this._currentMeasure.top);
  2915. if (this._autoScale) {
  2916. this.synchronizeSizeWithContent();
  2917. }
  2918. this._root.width = this.width;
  2919. this._root.height = this.height;
  2920. break;
  2921. }
  2922. }
  2923. }
  2924. context.restore();
  2925. };
  2926. Object.defineProperty(Image, "STRETCH_NONE", {
  2927. get: function () {
  2928. return Image._STRETCH_NONE;
  2929. },
  2930. enumerable: true,
  2931. configurable: true
  2932. });
  2933. Object.defineProperty(Image, "STRETCH_FILL", {
  2934. get: function () {
  2935. return Image._STRETCH_FILL;
  2936. },
  2937. enumerable: true,
  2938. configurable: true
  2939. });
  2940. Object.defineProperty(Image, "STRETCH_UNIFORM", {
  2941. get: function () {
  2942. return Image._STRETCH_UNIFORM;
  2943. },
  2944. enumerable: true,
  2945. configurable: true
  2946. });
  2947. Object.defineProperty(Image, "STRETCH_EXTEND", {
  2948. get: function () {
  2949. return Image._STRETCH_EXTEND;
  2950. },
  2951. enumerable: true,
  2952. configurable: true
  2953. });
  2954. return Image;
  2955. }(GUI.Control));
  2956. // Static
  2957. Image._STRETCH_NONE = 0;
  2958. Image._STRETCH_FILL = 1;
  2959. Image._STRETCH_UNIFORM = 2;
  2960. Image._STRETCH_EXTEND = 3;
  2961. GUI.Image = Image;
  2962. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  2963. })(BABYLON || (BABYLON = {}));
  2964. //# sourceMappingURL=image.js.map
  2965. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  2966. var __extends = (this && this.__extends) || (function () {
  2967. var extendStatics = Object.setPrototypeOf ||
  2968. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2969. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2970. return function (d, b) {
  2971. extendStatics(d, b);
  2972. function __() { this.constructor = d; }
  2973. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2974. };
  2975. })();
  2976. var BABYLON;
  2977. (function (BABYLON) {
  2978. var GUI;
  2979. (function (GUI) {
  2980. var Button = (function (_super) {
  2981. __extends(Button, _super);
  2982. function Button(name) {
  2983. var _this = _super.call(this, name) || this;
  2984. _this.name = name;
  2985. _this.thickness = 1;
  2986. _this.isPointerBlocker = true;
  2987. _this.pointerEnterAnimation = function () {
  2988. _this.alpha -= 0.1;
  2989. };
  2990. _this.pointerOutAnimation = function () {
  2991. _this.alpha += 0.1;
  2992. };
  2993. _this.pointerDownAnimation = function () {
  2994. _this.scaleX -= 0.05;
  2995. _this.scaleY -= 0.05;
  2996. };
  2997. _this.pointerUpAnimation = function () {
  2998. _this.scaleX += 0.05;
  2999. _this.scaleY += 0.05;
  3000. };
  3001. return _this;
  3002. }
  3003. Button.prototype._getTypeName = function () {
  3004. return "Button";
  3005. };
  3006. // While being a container, the button behaves like a control.
  3007. Button.prototype._processPicking = function (x, y, type) {
  3008. if (!this.contains(x, y)) {
  3009. return false;
  3010. }
  3011. this._processObservables(type, x, y);
  3012. return true;
  3013. };
  3014. Button.prototype._onPointerEnter = function () {
  3015. if (!_super.prototype._onPointerEnter.call(this)) {
  3016. return false;
  3017. }
  3018. if (this.pointerEnterAnimation) {
  3019. this.pointerEnterAnimation();
  3020. }
  3021. return true;
  3022. };
  3023. Button.prototype._onPointerOut = function () {
  3024. if (this.pointerOutAnimation) {
  3025. this.pointerOutAnimation();
  3026. }
  3027. _super.prototype._onPointerOut.call(this);
  3028. };
  3029. Button.prototype._onPointerDown = function (coordinates) {
  3030. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  3031. return false;
  3032. }
  3033. if (this.pointerDownAnimation) {
  3034. this.pointerDownAnimation();
  3035. }
  3036. return true;
  3037. };
  3038. Button.prototype._onPointerUp = function (coordinates) {
  3039. if (this.pointerUpAnimation) {
  3040. this.pointerUpAnimation();
  3041. }
  3042. _super.prototype._onPointerUp.call(this, coordinates);
  3043. };
  3044. // Statics
  3045. Button.CreateImageButton = function (name, text, imageUrl) {
  3046. var result = new Button(name);
  3047. // Adding text
  3048. var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
  3049. textBlock.textWrapping = true;
  3050. textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  3051. textBlock.paddingLeft = "20%";
  3052. result.addControl(textBlock);
  3053. // Adding image
  3054. var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
  3055. iconImage.width = "20%";
  3056. iconImage.stretch = BABYLON.GUI.Image.STRETCH_UNIFORM;
  3057. iconImage.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  3058. result.addControl(iconImage);
  3059. return result;
  3060. };
  3061. Button.CreateImageOnlyButton = function (name, imageUrl) {
  3062. var result = new Button(name);
  3063. // Adding image
  3064. var iconImage = new BABYLON.GUI.Image(name + "_icon", imageUrl);
  3065. iconImage.stretch = BABYLON.GUI.Image.STRETCH_FILL;
  3066. iconImage.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_LEFT;
  3067. result.addControl(iconImage);
  3068. return result;
  3069. };
  3070. Button.CreateSimpleButton = function (name, text) {
  3071. var result = new Button(name);
  3072. // Adding text
  3073. var textBlock = new BABYLON.GUI.TextBlock(name + "_button", text);
  3074. textBlock.textWrapping = true;
  3075. textBlock.textHorizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER;
  3076. result.addControl(textBlock);
  3077. return result;
  3078. };
  3079. return Button;
  3080. }(GUI.Rectangle));
  3081. GUI.Button = Button;
  3082. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  3083. })(BABYLON || (BABYLON = {}));
  3084. //# sourceMappingURL=button.js.map
  3085. /// <reference path="../../../dist/preview release/babylon.d.ts"/>
  3086. var __extends = (this && this.__extends) || (function () {
  3087. var extendStatics = Object.setPrototypeOf ||
  3088. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3089. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3090. return function (d, b) {
  3091. extendStatics(d, b);
  3092. function __() { this.constructor = d; }
  3093. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3094. };
  3095. })();
  3096. var DOMImage = Image;
  3097. var BABYLON;
  3098. (function (BABYLON) {
  3099. var GUI;
  3100. (function (GUI) {
  3101. var ColorPicker = (function (_super) {
  3102. __extends(ColorPicker, _super);
  3103. function ColorPicker(name) {
  3104. var _this = _super.call(this, name) || this;
  3105. _this.name = name;
  3106. _this._value = BABYLON.Color3.Red();
  3107. _this._tmpColor = new BABYLON.Color3();
  3108. _this._pointerStartedOnSquare = false;
  3109. _this._pointerStartedOnWheel = false;
  3110. _this._squareLeft = 0;
  3111. _this._squareTop = 0;
  3112. _this._squareSize = 0;
  3113. _this._h = 360;
  3114. _this._s = 1;
  3115. _this._v = 1;
  3116. _this.onValueChangedObservable = new BABYLON.Observable();
  3117. // Events
  3118. _this._pointerIsDown = false;
  3119. _this.value = new BABYLON.Color3(.88, .1, .1);
  3120. _this.size = "200px";
  3121. _this.isPointerBlocker = true;
  3122. return _this;
  3123. }
  3124. Object.defineProperty(ColorPicker.prototype, "value", {
  3125. get: function () {
  3126. return this._value;
  3127. },
  3128. set: function (value) {
  3129. if (this._value.equals(value)) {
  3130. return;
  3131. }
  3132. this._value.copyFrom(value);
  3133. this._RGBtoHSV(this._value, this._tmpColor);
  3134. this._h = this._tmpColor.r;
  3135. this._s = Math.max(this._tmpColor.g, 0.00001);
  3136. this._v = Math.max(this._tmpColor.b, 0.00001);
  3137. this._markAsDirty();
  3138. this.onValueChangedObservable.notifyObservers(this._value);
  3139. },
  3140. enumerable: true,
  3141. configurable: true
  3142. });
  3143. Object.defineProperty(ColorPicker.prototype, "width", {
  3144. set: function (value) {
  3145. if (this._width.toString(this._host) === value) {
  3146. return;
  3147. }
  3148. if (this._width.fromString(value)) {
  3149. this._height.fromString(value);
  3150. this._markAsDirty();
  3151. }
  3152. },
  3153. enumerable: true,
  3154. configurable: true
  3155. });
  3156. Object.defineProperty(ColorPicker.prototype, "height", {
  3157. set: function (value) {
  3158. if (this._height.toString(this._host) === value) {
  3159. return;
  3160. }
  3161. if (this._height.fromString(value)) {
  3162. this._width.fromString(value);
  3163. this._markAsDirty();
  3164. }
  3165. },
  3166. enumerable: true,
  3167. configurable: true
  3168. });
  3169. Object.defineProperty(ColorPicker.prototype, "size", {
  3170. get: function () {
  3171. return this.width;
  3172. },
  3173. set: function (value) {
  3174. this.width = value;
  3175. },
  3176. enumerable: true,
  3177. configurable: true
  3178. });
  3179. ColorPicker.prototype._getTypeName = function () {
  3180. return "ColorPicker";
  3181. };
  3182. ColorPicker.prototype._updateSquareProps = function () {
  3183. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3184. var wheelThickness = radius * .2;
  3185. var innerDiameter = (radius - wheelThickness) * 2;
  3186. var squareSize = innerDiameter / (Math.sqrt(2));
  3187. var offset = radius - squareSize * .5;
  3188. this._squareLeft = this._currentMeasure.left + offset;
  3189. this._squareTop = this._currentMeasure.top + offset;
  3190. this._squareSize = squareSize;
  3191. };
  3192. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  3193. var lgh = context.createLinearGradient(left, top, width + left, top);
  3194. lgh.addColorStop(0, '#fff');
  3195. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  3196. context.fillStyle = lgh;
  3197. context.fillRect(left, top, width, height);
  3198. var lgv = context.createLinearGradient(left, top, left, height + top);
  3199. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  3200. lgv.addColorStop(1, '#000');
  3201. context.fillStyle = lgv;
  3202. context.fillRect(left, top, width, height);
  3203. };
  3204. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  3205. context.beginPath();
  3206. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  3207. context.lineWidth = 3;
  3208. context.strokeStyle = '#333333';
  3209. context.stroke();
  3210. context.beginPath();
  3211. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  3212. context.lineWidth = 3;
  3213. context.strokeStyle = '#ffffff';
  3214. context.stroke();
  3215. };
  3216. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  3217. var canvas = document.createElement("canvas");
  3218. canvas.width = radius * 2;
  3219. canvas.height = radius * 2;
  3220. var context = canvas.getContext("2d");
  3221. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  3222. var data = image.data;
  3223. var color = this._tmpColor;
  3224. var maxDistSq = radius * radius;
  3225. var innerRadius = radius - thickness;
  3226. var minDistSq = innerRadius * innerRadius;
  3227. for (var x = -radius; x < radius; x++) {
  3228. for (var y = -radius; y < radius; y++) {
  3229. var distSq = x * x + y * y;
  3230. if (distSq > maxDistSq || distSq < minDistSq) {
  3231. continue;
  3232. }
  3233. var dist = Math.sqrt(distSq);
  3234. var ang = Math.atan2(y, x);
  3235. this._HSVtoRGB(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  3236. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  3237. data[index] = color.r * 255;
  3238. data[index + 1] = color.g * 255;
  3239. data[index + 2] = color.b * 255;
  3240. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  3241. //apply less alpha to bigger color pickers
  3242. var alphaAmount = .2;
  3243. var maxAlpha = .2;
  3244. var minAlpha = .04;
  3245. var lowerRadius = 50;
  3246. var upperRadius = 150;
  3247. if (radius < lowerRadius) {
  3248. alphaAmount = maxAlpha;
  3249. }
  3250. else if (radius > upperRadius) {
  3251. alphaAmount = minAlpha;
  3252. }
  3253. else {
  3254. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  3255. }
  3256. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  3257. if (alphaRatio < alphaAmount) {
  3258. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  3259. }
  3260. else if (alphaRatio > 1 - alphaAmount) {
  3261. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  3262. }
  3263. else {
  3264. data[index + 3] = 255;
  3265. }
  3266. }
  3267. }
  3268. context.putImageData(image, 0, 0);
  3269. return canvas;
  3270. };
  3271. ColorPicker.prototype._RGBtoHSV = function (color, result) {
  3272. var r = color.r;
  3273. var g = color.g;
  3274. var b = color.b;
  3275. var max = Math.max(r, g, b);
  3276. var min = Math.min(r, g, b);
  3277. var h = 0;
  3278. var s = 0;
  3279. var v = max;
  3280. var dm = max - min;
  3281. if (max !== 0) {
  3282. s = dm / max;
  3283. }
  3284. if (max != min) {
  3285. if (max == r) {
  3286. h = (g - b) / dm;
  3287. if (g < b) {
  3288. h += 6;
  3289. }
  3290. }
  3291. else if (max == g) {
  3292. h = (b - r) / dm + 2;
  3293. }
  3294. else if (max == b) {
  3295. h = (r - g) / dm + 4;
  3296. }
  3297. h *= 60;
  3298. }
  3299. result.r = h;
  3300. result.g = s;
  3301. result.b = v;
  3302. };
  3303. ColorPicker.prototype._HSVtoRGB = function (hue, saturation, value, result) {
  3304. var chroma = value * saturation;
  3305. var h = hue / 60;
  3306. var x = chroma * (1 - Math.abs((h % 2) - 1));
  3307. var r = 0;
  3308. var g = 0;
  3309. var b = 0;
  3310. if (h >= 0 && h <= 1) {
  3311. r = chroma;
  3312. g = x;
  3313. }
  3314. else if (h >= 1 && h <= 2) {
  3315. r = x;
  3316. g = chroma;
  3317. }
  3318. else if (h >= 2 && h <= 3) {
  3319. g = chroma;
  3320. b = x;
  3321. }
  3322. else if (h >= 3 && h <= 4) {
  3323. g = x;
  3324. b = chroma;
  3325. }
  3326. else if (h >= 4 && h <= 5) {
  3327. r = x;
  3328. b = chroma;
  3329. }
  3330. else if (h >= 5 && h <= 6) {
  3331. r = chroma;
  3332. b = x;
  3333. }
  3334. var m = value - chroma;
  3335. result.set((r + m), (g + m), (b + m));
  3336. };
  3337. ColorPicker.prototype._draw = function (parentMeasure, context) {
  3338. context.save();
  3339. this._applyStates(context);
  3340. if (this._processMeasures(parentMeasure, context)) {
  3341. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3342. var wheelThickness = radius * .2;
  3343. var left = this._currentMeasure.left;
  3344. var top = this._currentMeasure.top;
  3345. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  3346. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  3347. }
  3348. context.drawImage(this._colorWheelCanvas, left, top);
  3349. this._updateSquareProps();
  3350. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  3351. var cx = this._squareLeft + this._squareSize * this._s;
  3352. var cy = this._squareTop + this._squareSize * (1 - this._v);
  3353. this._drawCircle(cx, cy, radius * .04, context);
  3354. var dist = radius - wheelThickness * .5;
  3355. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  3356. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  3357. this._drawCircle(cx, cy, wheelThickness * .35, context);
  3358. }
  3359. context.restore();
  3360. };
  3361. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  3362. if (this._pointerStartedOnWheel) {
  3363. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3364. var centerX = radius + this._currentMeasure.left;
  3365. var centerY = radius + this._currentMeasure.top;
  3366. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  3367. }
  3368. else if (this._pointerStartedOnSquare) {
  3369. this._updateSquareProps();
  3370. this._s = (x - this._squareLeft) / this._squareSize;
  3371. this._v = 1 - (y - this._squareTop) / this._squareSize;
  3372. this._s = Math.min(this._s, 1);
  3373. this._s = Math.max(this._s, 0.00001);
  3374. this._v = Math.min(this._v, 1);
  3375. this._v = Math.max(this._v, 0.00001);
  3376. }
  3377. this._HSVtoRGB(this._h, this._s, this._v, this._tmpColor);
  3378. this.value = this._tmpColor;
  3379. };
  3380. ColorPicker.prototype._isPointOnSquare = function (coordinates) {
  3381. this._updateSquareProps();
  3382. var left = this._squareLeft;
  3383. var top = this._squareTop;
  3384. var size = this._squareSize;
  3385. if (coordinates.x >= left && coordinates.x <= left + size &&
  3386. coordinates.y >= top && coordinates.y <= top + size) {
  3387. return true;
  3388. }
  3389. return false;
  3390. };
  3391. ColorPicker.prototype._isPointOnWheel = function (coordinates) {
  3392. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  3393. var centerX = radius + this._currentMeasure.left;
  3394. var centerY = radius + this._currentMeasure.top;
  3395. var wheelThickness = radius * .2;
  3396. var innerRadius = radius - wheelThickness;
  3397. var radiusSq = radius * radius;
  3398. var innerRadiusSq = innerRadius * innerRadius;
  3399. var dx = coordinates.x - centerX;
  3400. var dy = coordinates.y - centerY;
  3401. var distSq = dx * dx + dy * dy;
  3402. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  3403. return true;
  3404. }
  3405. return false;
  3406. };
  3407. ColorPicker.prototype._onPointerDown = function (coordinates) {
  3408. if (!_super.prototype._onPointerDown.call(this, coordinates)) {
  3409. return false;
  3410. }
  3411. this._pointerIsDown = true;
  3412. this._pointerStartedOnSquare = false;
  3413. this._pointerStartedOnWheel = false;
  3414. if (this._isPointOnSquare(coordinates)) {
  3415. this._pointerStartedOnSquare = true;
  3416. }
  3417. else if (this._isPointOnWheel(coordinates)) {
  3418. this._pointerStartedOnWheel = true;
  3419. }
  3420. this._updateValueFromPointer(coordinates.x, coordinates.y);
  3421. this._host._capturingControl = this;
  3422. return true;
  3423. };
  3424. ColorPicker.prototype._onPointerMove = function (coordinates) {
  3425. if (this._pointerIsDown) {
  3426. this._updateValueFromPointer(coordinates.x, coordinates.y);
  3427. }
  3428. _super.prototype._onPointerMove.call(this, coordinates);
  3429. };
  3430. ColorPicker.prototype._onPointerUp = function (coordinates) {
  3431. this._pointerIsDown = false;
  3432. this._host._capturingControl = null;
  3433. _super.prototype._onPointerUp.call(this, coordinates);
  3434. };
  3435. return ColorPicker;
  3436. }(GUI.Control));
  3437. GUI.ColorPicker = ColorPicker;
  3438. })(GUI = BABYLON.GUI || (BABYLON.GUI = {}));
  3439. })(BABYLON || (BABYLON = {}));