babylon.gui.module.d.ts 246 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430
  1. /*BabylonJS GUI*/
  2. // Dependencies for this module:
  3. // ../../../../Tools/Gulp/babylonjs
  4. declare module 'babylonjs-gui' {
  5. export * from "babylonjs-gui/2D";
  6. export * from "babylonjs-gui/3D";
  7. }
  8. declare module 'babylonjs-gui/2D' {
  9. export * from "babylonjs-gui/2D/controls";
  10. export * from "babylonjs-gui/2D/advancedDynamicTexture";
  11. export * from "babylonjs-gui/2D/math2D";
  12. export * from "babylonjs-gui/2D/measure";
  13. export * from "babylonjs-gui/2D/multiLinePoint";
  14. export * from "babylonjs-gui/2D/style";
  15. export * from "babylonjs-gui/2D/valueAndUnit";
  16. }
  17. declare module 'babylonjs-gui/3D' {
  18. export * from "babylonjs-gui/3D/controls";
  19. export * from "babylonjs-gui/3D/materials";
  20. export * from "babylonjs-gui/3D/gui3DManager";
  21. export * from "babylonjs-gui/3D/vector3WithInfo";
  22. }
  23. declare module 'babylonjs-gui/2D/controls' {
  24. export * from "babylonjs-gui/2D/controls/button";
  25. export * from "babylonjs-gui/2D/controls/checkbox";
  26. export * from "babylonjs-gui/2D/controls/colorpicker";
  27. export * from "babylonjs-gui/2D/controls/container";
  28. export * from "babylonjs-gui/2D/controls/control";
  29. export * from "babylonjs-gui/2D/controls/ellipse";
  30. export * from "babylonjs-gui/2D/controls/grid";
  31. export * from "babylonjs-gui/2D/controls/image";
  32. export * from "babylonjs-gui/2D/controls/inputText";
  33. export * from "babylonjs-gui/2D/controls/inputPassword";
  34. export * from "babylonjs-gui/2D/controls/line";
  35. export * from "babylonjs-gui/2D/controls/multiLine";
  36. export * from "babylonjs-gui/2D/controls/radioButton";
  37. export * from "babylonjs-gui/2D/controls/stackPanel";
  38. export * from "babylonjs-gui/2D/controls/selector";
  39. export * from "babylonjs-gui/2D/controls/textBlock";
  40. export * from "babylonjs-gui/2D/controls/virtualKeyboard";
  41. export * from "babylonjs-gui/2D/controls/slider";
  42. export * from "babylonjs-gui/2D/controls/rectangle";
  43. export * from "babylonjs-gui/2D/controls/displayGrid";
  44. export * from "babylonjs-gui/2D/controls/statics";
  45. }
  46. declare module 'babylonjs-gui/2D/advancedDynamicTexture' {
  47. import { DynamicTexture, Nullable, Layer, Viewport, Scene, Vector3, Matrix, Vector2, AbstractMesh } from "babylonjs";
  48. import { Container } from "babylonjs-gui/2D/controls/container";
  49. import { Control } from "babylonjs-gui/2D/controls/control";
  50. import { Style } from "babylonjs-gui/2D/style";
  51. /**
  52. * Interface used to define a control that can receive focus
  53. */
  54. export interface IFocusableControl {
  55. /**
  56. * Function called when the control receives the focus
  57. */
  58. onFocus(): void;
  59. /**
  60. * Function called when the control loses the focus
  61. */
  62. onBlur(): void;
  63. /**
  64. * Function called to let the control handle keyboard events
  65. * @param evt defines the current keyboard event
  66. */
  67. processKeyboard(evt: KeyboardEvent): void;
  68. /**
  69. * Function called to get the list of controls that should not steal the focus from this control
  70. * @returns an array of controls
  71. */
  72. keepsFocusWith(): Nullable<Control[]>;
  73. }
  74. /**
  75. * Class used to create texture to support 2D GUI elements
  76. * @see http://doc.babylonjs.com/how_to/gui
  77. */
  78. export class AdvancedDynamicTexture extends DynamicTexture {
  79. /** @hidden */
  80. _rootContainer: Container;
  81. /** @hidden */
  82. _lastPickedControl: Control;
  83. /** @hidden */
  84. _lastControlOver: {
  85. [pointerId: number]: Control;
  86. };
  87. /** @hidden */
  88. _lastControlDown: {
  89. [pointerId: number]: Control;
  90. };
  91. /** @hidden */
  92. _capturingControl: {
  93. [pointerId: number]: Control;
  94. };
  95. /** @hidden */
  96. _shouldBlockPointer: boolean;
  97. /** @hidden */
  98. _layerToDispose: Nullable<Layer>;
  99. /** @hidden */
  100. _linkedControls: Control[];
  101. /**
  102. * Gets or sets a boolean defining if alpha is stored as premultiplied
  103. */
  104. premulAlpha: boolean;
  105. /**
  106. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  107. * Useful when you want more antialiasing
  108. */
  109. renderScale: number;
  110. /** Gets or sets the background color */
  111. background: string;
  112. /**
  113. * Gets or sets the ideal width used to design controls.
  114. * The GUI will then rescale everything accordingly
  115. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  116. */
  117. idealWidth: number;
  118. /**
  119. * Gets or sets the ideal height used to design controls.
  120. * The GUI will then rescale everything accordingly
  121. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  122. */
  123. idealHeight: number;
  124. /**
  125. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  126. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  127. */
  128. useSmallestIdeal: boolean;
  129. /**
  130. * Gets or sets a boolean indicating if adaptive scaling must be used
  131. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  132. */
  133. renderAtIdealSize: boolean;
  134. /**
  135. * Gets the underlying layer used to render the texture when in fullscreen mode
  136. */
  137. readonly layer: Nullable<Layer>;
  138. /**
  139. * Gets the root container control
  140. */
  141. readonly rootContainer: Container;
  142. /**
  143. * Gets or sets the current focused control
  144. */
  145. focusedControl: Nullable<IFocusableControl>;
  146. /**
  147. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  148. */
  149. isForeground: boolean;
  150. /**
  151. * Creates a new AdvancedDynamicTexture
  152. * @param name defines the name of the texture
  153. * @param width defines the width of the texture
  154. * @param height defines the height of the texture
  155. * @param scene defines the hosting scene
  156. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  157. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  158. */
  159. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  160. /**
  161. * Function used to execute a function on all controls
  162. * @param func defines the function to execute
  163. * @param container defines the container where controls belong. If null the root container will be used
  164. */
  165. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  166. /**
  167. * Marks the texture as dirty forcing a complete update
  168. */
  169. markAsDirty(): void;
  170. /**
  171. * Helper function used to create a new style
  172. * @returns a new style
  173. * @see http://doc.babylonjs.com/how_to/gui#styles
  174. */
  175. createStyle(): Style;
  176. /**
  177. * Adds a new control to the root container
  178. * @param control defines the control to add
  179. * @returns the current texture
  180. */
  181. addControl(control: Control): AdvancedDynamicTexture;
  182. /**
  183. * Removes a control from the root container
  184. * @param control defines the control to remove
  185. * @returns the current texture
  186. */
  187. removeControl(control: Control): AdvancedDynamicTexture;
  188. /**
  189. * Release all resources
  190. */
  191. dispose(): void;
  192. /** @hidden */
  193. _getGlobalViewport(scene: Scene): Viewport;
  194. /**
  195. * Get screen coordinates for a vector3
  196. * @param position defines the position to project
  197. * @param worldMatrix defines the world matrix to use
  198. * @returns the projected position
  199. */
  200. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  201. /** @hidden */
  202. _changeCursor(cursor: string): void;
  203. /** @hidden */
  204. _cleanControlAfterRemovalFromList(list: {
  205. [pointerId: number]: Control;
  206. }, control: Control): void;
  207. /** @hidden */
  208. _cleanControlAfterRemoval(control: Control): void;
  209. /** Attach to all scene events required to support pointer events */
  210. attach(): void;
  211. /**
  212. * Connect the texture to a hosting mesh to enable interactions
  213. * @param mesh defines the mesh to attach to
  214. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  215. */
  216. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  217. /**
  218. * Move the focus to a specific control
  219. * @param control defines the control which will receive the focus
  220. */
  221. moveFocusToControl(control: IFocusableControl): void;
  222. /**
  223. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  224. * @param mesh defines the mesh which will receive the texture
  225. * @param width defines the texture width (1024 by default)
  226. * @param height defines the texture height (1024 by default)
  227. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  228. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  229. * @returns a new AdvancedDynamicTexture
  230. */
  231. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  232. /**
  233. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  234. * In this mode the texture will rely on a layer for its rendering.
  235. * This allows it to be treated like any other layer.
  236. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  237. * LayerMask is set through advancedTexture.layer.layerMask
  238. * @param name defines name for the texture
  239. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  240. * @param scene defines the hsoting scene
  241. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  242. * @returns a new AdvancedDynamicTexture
  243. */
  244. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  245. }
  246. }
  247. declare module 'babylonjs-gui/2D/math2D' {
  248. import { Vector2, Nullable } from "babylonjs";
  249. /**
  250. * Class used to transport Vector2 information for pointer events
  251. */
  252. export class Vector2WithInfo extends Vector2 {
  253. /** defines the current mouse button index */
  254. buttonIndex: number;
  255. /**
  256. * Creates a new Vector2WithInfo
  257. * @param source defines the vector2 data to transport
  258. * @param buttonIndex defines the current mouse button index
  259. */
  260. constructor(source: Vector2,
  261. /** defines the current mouse button index */
  262. buttonIndex?: number);
  263. }
  264. /** Class used to provide 2D matrix features */
  265. export class Matrix2D {
  266. /** Gets the internal array of 6 floats used to store matrix data */
  267. m: Float32Array;
  268. /**
  269. * Creates a new matrix
  270. * @param m00 defines value for (0, 0)
  271. * @param m01 defines value for (0, 1)
  272. * @param m10 defines value for (1, 0)
  273. * @param m11 defines value for (1, 1)
  274. * @param m20 defines value for (2, 0)
  275. * @param m21 defines value for (2, 1)
  276. */
  277. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  278. /**
  279. * Fills the matrix from direct values
  280. * @param m00 defines value for (0, 0)
  281. * @param m01 defines value for (0, 1)
  282. * @param m10 defines value for (1, 0)
  283. * @param m11 defines value for (1, 1)
  284. * @param m20 defines value for (2, 0)
  285. * @param m21 defines value for (2, 1)
  286. * @returns the current modified matrix
  287. */
  288. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  289. /**
  290. * Gets matrix determinant
  291. * @returns the determinant
  292. */
  293. determinant(): number;
  294. /**
  295. * Inverses the matrix and stores it in a target matrix
  296. * @param result defines the target matrix
  297. * @returns the current matrix
  298. */
  299. invertToRef(result: Matrix2D): Matrix2D;
  300. /**
  301. * Multiplies the current matrix with another one
  302. * @param other defines the second operand
  303. * @param result defines the target matrix
  304. * @returns the current matrix
  305. */
  306. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  307. /**
  308. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  309. * @param x defines the x coordinate to transform
  310. * @param y defines the x coordinate to transform
  311. * @param result defines the target vector2
  312. * @returns the current matrix
  313. */
  314. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  315. /**
  316. * Creates an identity matrix
  317. * @returns a new matrix
  318. */
  319. static Identity(): Matrix2D;
  320. /**
  321. * Creates a translation matrix and stores it in a target matrix
  322. * @param x defines the x coordinate of the translation
  323. * @param y defines the y coordinate of the translation
  324. * @param result defines the target matrix
  325. */
  326. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  327. /**
  328. * Creates a scaling matrix and stores it in a target matrix
  329. * @param x defines the x coordinate of the scaling
  330. * @param y defines the y coordinate of the scaling
  331. * @param result defines the target matrix
  332. */
  333. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  334. /**
  335. * Creates a rotation matrix and stores it in a target matrix
  336. * @param angle defines the rotation angle
  337. * @param result defines the target matrix
  338. */
  339. static RotationToRef(angle: number, result: Matrix2D): void;
  340. /**
  341. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  342. * @param tx defines the x coordinate of the translation
  343. * @param ty defines the y coordinate of the translation
  344. * @param angle defines the rotation angle
  345. * @param scaleX defines the x coordinate of the scaling
  346. * @param scaleY defines the y coordinate of the scaling
  347. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  348. * @param result defines the target matrix
  349. */
  350. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  351. }
  352. }
  353. declare module 'babylonjs-gui/2D/measure' {
  354. /**
  355. * Class used to store 2D control sizes
  356. */
  357. export class Measure {
  358. /** defines left coordinate */
  359. left: number;
  360. /** defines top coordinate */
  361. top: number;
  362. /** defines width dimension */
  363. width: number;
  364. /** defines height dimension */
  365. height: number;
  366. /**
  367. * Creates a new measure
  368. * @param left defines left coordinate
  369. * @param top defines top coordinate
  370. * @param width defines width dimension
  371. * @param height defines height dimension
  372. */
  373. constructor(
  374. /** defines left coordinate */
  375. left: number,
  376. /** defines top coordinate */
  377. top: number,
  378. /** defines width dimension */
  379. width: number,
  380. /** defines height dimension */
  381. height: number);
  382. /**
  383. * Copy from another measure
  384. * @param other defines the other measure to copy from
  385. */
  386. copyFrom(other: Measure): void;
  387. /**
  388. * Check equality between this measure and another one
  389. * @param other defines the other measures
  390. * @returns true if both measures are equals
  391. */
  392. isEqualsTo(other: Measure): boolean;
  393. /**
  394. * Creates an empty measure
  395. * @returns a new measure
  396. */
  397. static Empty(): Measure;
  398. }
  399. }
  400. declare module 'babylonjs-gui/2D/multiLinePoint' {
  401. import { MultiLine } from "babylonjs-gui/2D/controls/multiLine";
  402. import { Control } from "babylonjs-gui/2D/controls/control";
  403. import { AbstractMesh, Nullable, Vector2 } from "babylonjs";
  404. /**
  405. * Class used to store a point for a MultiLine object.
  406. * The point can be pure 2D coordinates, a mesh or a control
  407. */
  408. export class MultiLinePoint {
  409. /** @hidden */
  410. _point: Vector2;
  411. /**
  412. * Creates a new MultiLinePoint
  413. * @param multiLine defines the source MultiLine object
  414. */
  415. constructor(multiLine: MultiLine);
  416. /** Gets or sets x coordinate */
  417. x: string | number;
  418. /** Gets or sets y coordinate */
  419. y: string | number;
  420. /** Gets or sets the control associated with this point */
  421. control: Nullable<Control>;
  422. /** Gets or sets the mesh associated with this point */
  423. mesh: Nullable<AbstractMesh>;
  424. /** Resets links */
  425. resetLinks(): void;
  426. /**
  427. * Gets a translation vector
  428. * @returns the translation vector
  429. */
  430. translate(): Vector2;
  431. /** Release associated resources */
  432. dispose(): void;
  433. }
  434. }
  435. declare module 'babylonjs-gui/2D/style' {
  436. import { IDisposable, Observable } from "babylonjs";
  437. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  438. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  439. /**
  440. * Define a style used by control to automatically setup properties based on a template.
  441. * Only support font related properties so far
  442. */
  443. export class Style implements IDisposable {
  444. /** @hidden */
  445. _host: AdvancedDynamicTexture;
  446. /** @hidden */
  447. _fontSize: ValueAndUnit;
  448. /**
  449. * Observable raised when the style values are changed
  450. */
  451. onChangedObservable: Observable<Style>;
  452. /**
  453. * Creates a new style object
  454. * @param host defines the AdvancedDynamicTexture which hosts this style
  455. */
  456. constructor(host: AdvancedDynamicTexture);
  457. /**
  458. * Gets or sets the font size
  459. */
  460. fontSize: string | number;
  461. /**
  462. * Gets or sets the font family
  463. */
  464. fontFamily: string;
  465. /**
  466. * Gets or sets the font style
  467. */
  468. fontStyle: string;
  469. /** Gets or sets font weight */
  470. fontWeight: string;
  471. /** Dispose all associated resources */
  472. dispose(): void;
  473. }
  474. }
  475. declare module 'babylonjs-gui/2D/valueAndUnit' {
  476. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  477. /**
  478. * Class used to specific a value and its associated unit
  479. */
  480. export class ValueAndUnit {
  481. /** defines the unit to store */
  482. unit: number;
  483. /** defines a boolean indicating if the value can be negative */
  484. negativeValueAllowed: boolean;
  485. /**
  486. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  487. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  488. */
  489. ignoreAdaptiveScaling: boolean;
  490. /**
  491. * Creates a new ValueAndUnit
  492. * @param value defines the value to store
  493. * @param unit defines the unit to store
  494. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  495. */
  496. constructor(value: number,
  497. /** defines the unit to store */
  498. unit?: number,
  499. /** defines a boolean indicating if the value can be negative */
  500. negativeValueAllowed?: boolean);
  501. /** Gets a boolean indicating if the value is a percentage */
  502. readonly isPercentage: boolean;
  503. /** Gets a boolean indicating if the value is store as pixel */
  504. readonly isPixel: boolean;
  505. /** Gets direct internal value */
  506. readonly internalValue: number;
  507. /**
  508. * Gets value as pixel
  509. * @param host defines the root host
  510. * @param refValue defines the reference value for percentages
  511. * @returns the value as pixel
  512. */
  513. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  514. /**
  515. * Gets the value accordingly to its unit
  516. * @param host defines the root host
  517. * @returns the value
  518. */
  519. getValue(host: AdvancedDynamicTexture): number;
  520. /**
  521. * Gets a string representation of the value
  522. * @param host defines the root host
  523. * @returns a string
  524. */
  525. toString(host: AdvancedDynamicTexture): string;
  526. /**
  527. * Store a value parsed from a string
  528. * @param source defines the source string
  529. * @returns true if the value was successfully parsed
  530. */
  531. fromString(source: string | number): boolean;
  532. /** UNITMODE_PERCENTAGE */
  533. static readonly UNITMODE_PERCENTAGE: number;
  534. /** UNITMODE_PIXEL */
  535. static readonly UNITMODE_PIXEL: number;
  536. }
  537. }
  538. declare module 'babylonjs-gui/3D/controls' {
  539. export * from "babylonjs-gui/3D/controls/abstractButton3D";
  540. export * from "babylonjs-gui/3D/controls/button3D";
  541. export * from "babylonjs-gui/3D/controls/container3D";
  542. export * from "babylonjs-gui/3D/controls/control3D";
  543. export * from "babylonjs-gui/3D/controls/cylinderPanel";
  544. export * from "babylonjs-gui/3D/controls/holographicButton";
  545. export * from "babylonjs-gui/3D/controls/meshButton3D";
  546. export * from "babylonjs-gui/3D/controls/planePanel";
  547. export * from "babylonjs-gui/3D/controls/scatterPanel";
  548. export * from "babylonjs-gui/3D/controls/spherePanel";
  549. export * from "babylonjs-gui/3D/controls/stackPanel3D";
  550. export * from "babylonjs-gui/3D/controls/volumeBasedPanel";
  551. }
  552. declare module 'babylonjs-gui/3D/materials' {
  553. export * from "babylonjs-gui/3D/materials/fluentMaterial";
  554. }
  555. declare module 'babylonjs-gui/3D/gui3DManager' {
  556. import { IDisposable, Scene, Nullable, UtilityLayerRenderer, Observable, Vector3, Material } from "babylonjs";
  557. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  558. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  559. /**
  560. * Class used to manage 3D user interface
  561. * @see http://doc.babylonjs.com/how_to/gui3d
  562. */
  563. export class GUI3DManager implements IDisposable {
  564. /** @hidden */
  565. _lastPickedControl: Control3D;
  566. /** @hidden */
  567. _lastControlOver: {
  568. [pointerId: number]: Control3D;
  569. };
  570. /** @hidden */
  571. _lastControlDown: {
  572. [pointerId: number]: Control3D;
  573. };
  574. /**
  575. * Observable raised when the point picked by the pointer events changed
  576. */
  577. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  578. /** @hidden */
  579. _sharedMaterials: {
  580. [key: string]: Material;
  581. };
  582. /** Gets the hosting scene */
  583. readonly scene: Scene;
  584. /** Gets associated utility layer */
  585. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  586. /**
  587. * Creates a new GUI3DManager
  588. * @param scene
  589. */
  590. constructor(scene?: Scene);
  591. /**
  592. * Gets the root container
  593. */
  594. readonly rootContainer: Container3D;
  595. /**
  596. * Gets a boolean indicating if the given control is in the root child list
  597. * @param control defines the control to check
  598. * @returns true if the control is in the root child list
  599. */
  600. containsControl(control: Control3D): boolean;
  601. /**
  602. * Adds a control to the root child list
  603. * @param control defines the control to add
  604. * @returns the current manager
  605. */
  606. addControl(control: Control3D): GUI3DManager;
  607. /**
  608. * Removes a control from the root child list
  609. * @param control defines the control to remove
  610. * @returns the current container
  611. */
  612. removeControl(control: Control3D): GUI3DManager;
  613. /**
  614. * Releases all associated resources
  615. */
  616. dispose(): void;
  617. }
  618. }
  619. declare module 'babylonjs-gui/3D/vector3WithInfo' {
  620. import { Vector3 } from "babylonjs";
  621. /**
  622. * Class used to transport Vector3 information for pointer events
  623. */
  624. export class Vector3WithInfo extends Vector3 {
  625. /** defines the current mouse button index */
  626. buttonIndex: number;
  627. /**
  628. * Creates a new Vector3WithInfo
  629. * @param source defines the vector3 data to transport
  630. * @param buttonIndex defines the current mouse button index
  631. */
  632. constructor(source: Vector3,
  633. /** defines the current mouse button index */
  634. buttonIndex?: number);
  635. }
  636. }
  637. declare module 'babylonjs-gui/2D/controls/button' {
  638. import { Rectangle } from "babylonjs-gui/2D/controls/rectangle";
  639. import { Control } from "babylonjs-gui/2D/controls/control";
  640. import { Vector2 } from "babylonjs";
  641. /**
  642. * Class used to create 2D buttons
  643. */
  644. export class Button extends Rectangle {
  645. name?: string | undefined;
  646. /**
  647. * Function called to generate a pointer enter animation
  648. */
  649. pointerEnterAnimation: () => void;
  650. /**
  651. * Function called to generate a pointer out animation
  652. */
  653. pointerOutAnimation: () => void;
  654. /**
  655. * Function called to generate a pointer down animation
  656. */
  657. pointerDownAnimation: () => void;
  658. /**
  659. * Function called to generate a pointer up animation
  660. */
  661. pointerUpAnimation: () => void;
  662. /**
  663. * Creates a new Button
  664. * @param name defines the name of the button
  665. */
  666. constructor(name?: string | undefined);
  667. protected _getTypeName(): string;
  668. /** @hidden */
  669. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  670. /** @hidden */
  671. _onPointerEnter(target: Control): boolean;
  672. /** @hidden */
  673. _onPointerOut(target: Control): void;
  674. /** @hidden */
  675. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  676. /** @hidden */
  677. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  678. /**
  679. * Creates a new button made with an image and a text
  680. * @param name defines the name of the button
  681. * @param text defines the text of the button
  682. * @param imageUrl defines the url of the image
  683. * @returns a new Button
  684. */
  685. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  686. /**
  687. * Creates a new button made with an image
  688. * @param name defines the name of the button
  689. * @param imageUrl defines the url of the image
  690. * @returns a new Button
  691. */
  692. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  693. /**
  694. * Creates a new button made with a text
  695. * @param name defines the name of the button
  696. * @param text defines the text of the button
  697. * @returns a new Button
  698. */
  699. static CreateSimpleButton(name: string, text: string): Button;
  700. /**
  701. * Creates a new button made with an image and a centered text
  702. * @param name defines the name of the button
  703. * @param text defines the text of the button
  704. * @param imageUrl defines the url of the image
  705. * @returns a new Button
  706. */
  707. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  708. }
  709. }
  710. declare module 'babylonjs-gui/2D/controls/checkbox' {
  711. import { Control } from "babylonjs-gui/2D/controls/control";
  712. import { Measure } from "babylonjs-gui/2D/measure";
  713. import { Observable, Vector2 } from "babylonjs";
  714. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  715. /**
  716. * Class used to represent a 2D checkbox
  717. */
  718. export class Checkbox extends Control {
  719. name?: string | undefined;
  720. /** Gets or sets border thickness */
  721. thickness: number;
  722. /**
  723. * Observable raised when isChecked property changes
  724. */
  725. onIsCheckedChangedObservable: Observable<boolean>;
  726. /** Gets or sets a value indicating the ratio between overall size and check size */
  727. checkSizeRatio: number;
  728. /** Gets or sets background color */
  729. background: string;
  730. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  731. isChecked: boolean;
  732. /**
  733. * Creates a new CheckBox
  734. * @param name defines the control name
  735. */
  736. constructor(name?: string | undefined);
  737. protected _getTypeName(): string;
  738. /** @hidden */
  739. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  740. /** @hidden */
  741. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  742. /**
  743. * Utility function to easily create a checkbox with a header
  744. * @param title defines the label to use for the header
  745. * @param onValueChanged defines the callback to call when value changes
  746. * @returns a StackPanel containing the checkbox and a textBlock
  747. */
  748. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  749. }
  750. }
  751. declare module 'babylonjs-gui/2D/controls/colorpicker' {
  752. import { Control } from "babylonjs-gui/2D/controls/control";
  753. import { Color3, Observable, Vector2 } from "babylonjs";
  754. import { Measure } from "babylonjs-gui/2D/measure";
  755. /** Class used to create color pickers */
  756. export class ColorPicker extends Control {
  757. name?: string | undefined;
  758. /**
  759. * Observable raised when the value changes
  760. */
  761. onValueChangedObservable: Observable<Color3>;
  762. /** Gets or sets the color of the color picker */
  763. value: Color3;
  764. /** Gets or sets control width */
  765. width: string | number;
  766. /** Gets or sets control height */
  767. height: string | number;
  768. /** Gets or sets control size */
  769. size: string | number;
  770. /**
  771. * Creates a new ColorPicker
  772. * @param name defines the control name
  773. */
  774. constructor(name?: string | undefined);
  775. protected _getTypeName(): string;
  776. /** @hidden */
  777. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  778. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  779. _onPointerMove(target: Control, coordinates: Vector2): void;
  780. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  781. }
  782. }
  783. declare module 'babylonjs-gui/2D/controls/container' {
  784. import { Control } from "babylonjs-gui/2D/controls/control";
  785. import { Measure } from "babylonjs-gui/2D/measure";
  786. import { Nullable } from "babylonjs";
  787. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  788. /**
  789. * Root class for 2D containers
  790. * @see http://doc.babylonjs.com/how_to/gui#containers
  791. */
  792. export class Container extends Control {
  793. name?: string | undefined;
  794. /** @hidden */
  795. protected _children: Control[];
  796. /** @hidden */
  797. protected _measureForChildren: Measure;
  798. /** @hidden */
  799. protected _background: string;
  800. /** @hidden */
  801. protected _adaptWidthToChildren: boolean;
  802. /** @hidden */
  803. protected _adaptHeightToChildren: boolean;
  804. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  805. adaptHeightToChildren: boolean;
  806. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  807. adaptWidthToChildren: boolean;
  808. /** Gets or sets background color */
  809. background: string;
  810. /** Gets the list of children */
  811. readonly children: Control[];
  812. /**
  813. * Creates a new Container
  814. * @param name defines the name of the container
  815. */
  816. constructor(name?: string | undefined);
  817. protected _getTypeName(): string;
  818. _flagDescendantsAsMatrixDirty(): void;
  819. /**
  820. * Gets a child using its name
  821. * @param name defines the child name to look for
  822. * @returns the child control if found
  823. */
  824. getChildByName(name: string): Nullable<Control>;
  825. /**
  826. * Gets a child using its type and its name
  827. * @param name defines the child name to look for
  828. * @param type defines the child type to look for
  829. * @returns the child control if found
  830. */
  831. getChildByType(name: string, type: string): Nullable<Control>;
  832. /**
  833. * Search for a specific control in children
  834. * @param control defines the control to look for
  835. * @returns true if the control is in child list
  836. */
  837. containsControl(control: Control): boolean;
  838. /**
  839. * Adds a new control to the current container
  840. * @param control defines the control to add
  841. * @returns the current container
  842. */
  843. addControl(control: Nullable<Control>): Container;
  844. /**
  845. * Removes all controls from the current container
  846. * @returns the current container
  847. */
  848. clearControls(): Container;
  849. /**
  850. * Removes a control from the current container
  851. * @param control defines the control to remove
  852. * @returns the current container
  853. */
  854. removeControl(control: Control): Container;
  855. /** @hidden */
  856. _reOrderControl(control: Control): void;
  857. /** @hidden */
  858. _markAllAsDirty(): void;
  859. /** @hidden */
  860. protected _localDraw(context: CanvasRenderingContext2D): void;
  861. /** @hidden */
  862. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  863. /** @hidden */
  864. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  865. /** @hidden */
  866. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  867. /** @hidden */
  868. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  869. /** @hidden */
  870. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  871. /** Releases associated resources */
  872. dispose(): void;
  873. }
  874. }
  875. declare module 'babylonjs-gui/2D/controls/control' {
  876. import { Container } from "babylonjs-gui/2D/controls/container";
  877. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  878. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  879. import { Nullable, Vector2, AbstractMesh, Observable, Vector3, Scene } from "babylonjs";
  880. import { Measure } from "babylonjs-gui/2D/measure";
  881. import { Style } from "babylonjs-gui/2D/style";
  882. import { Matrix2D, Vector2WithInfo } from "babylonjs-gui/2D/math2D";
  883. /**
  884. * Root class used for all 2D controls
  885. * @see http://doc.babylonjs.com/how_to/gui#controls
  886. */
  887. export class Control {
  888. /** defines the name of the control */
  889. name?: string | undefined;
  890. /** @hidden */
  891. _root: Nullable<Container>;
  892. /** @hidden */
  893. _host: AdvancedDynamicTexture;
  894. /** Gets or sets the control parent */
  895. parent: Nullable<Container>;
  896. /** @hidden */
  897. _currentMeasure: Measure;
  898. /** @hidden */
  899. _width: ValueAndUnit;
  900. /** @hidden */
  901. _height: ValueAndUnit;
  902. /** @hidden */
  903. protected _fontOffset: {
  904. ascent: number;
  905. height: number;
  906. descent: number;
  907. };
  908. /** @hidden */
  909. protected _horizontalAlignment: number;
  910. /** @hidden */
  911. protected _verticalAlignment: number;
  912. /** @hidden */
  913. _tempParentMeasure: Measure;
  914. /** @hidden */
  915. protected _cachedParentMeasure: Measure;
  916. /** @hidden */
  917. _left: ValueAndUnit;
  918. /** @hidden */
  919. _top: ValueAndUnit;
  920. /** @hidden */
  921. protected _invertTransformMatrix: Matrix2D;
  922. /** @hidden */
  923. protected _transformedPosition: Vector2;
  924. /** @hidden */
  925. _linkedMesh: Nullable<AbstractMesh>;
  926. protected _isEnabled: boolean;
  927. protected _disabledColor: string;
  928. /** @hidden */
  929. _tag: any;
  930. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  931. isHitTestVisible: boolean;
  932. /** Gets or sets a boolean indicating if the control can block pointer events */
  933. isPointerBlocker: boolean;
  934. /** Gets or sets a boolean indicating if the control can be focusable */
  935. isFocusInvisible: boolean;
  936. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  937. shadowOffsetX: number;
  938. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  939. shadowOffsetY: number;
  940. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  941. shadowBlur: number;
  942. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  943. shadowColor: string;
  944. /** Gets or sets the cursor to use when the control is hovered */
  945. hoverCursor: string;
  946. /** @hidden */
  947. protected _linkOffsetX: ValueAndUnit;
  948. /** @hidden */
  949. protected _linkOffsetY: ValueAndUnit;
  950. /** Gets the control type name */
  951. readonly typeName: string;
  952. /**
  953. * An event triggered when the pointer move over the control.
  954. */
  955. onPointerMoveObservable: Observable<Vector2>;
  956. /**
  957. * An event triggered when the pointer move out of the control.
  958. */
  959. onPointerOutObservable: Observable<Control>;
  960. /**
  961. * An event triggered when the pointer taps the control
  962. */
  963. onPointerDownObservable: Observable<Vector2WithInfo>;
  964. /**
  965. * An event triggered when pointer up
  966. */
  967. onPointerUpObservable: Observable<Vector2WithInfo>;
  968. /**
  969. * An event triggered when a control is clicked on
  970. */
  971. onPointerClickObservable: Observable<Vector2WithInfo>;
  972. /**
  973. * An event triggered when pointer enters the control
  974. */
  975. onPointerEnterObservable: Observable<Control>;
  976. /**
  977. * An event triggered when the control is marked as dirty
  978. */
  979. onDirtyObservable: Observable<Control>;
  980. /**
  981. * An event triggered after the control is drawn
  982. */
  983. onAfterDrawObservable: Observable<Control>;
  984. /** Gets or set information about font offsets (used to render and align text) */
  985. fontOffset: {
  986. ascent: number;
  987. height: number;
  988. descent: number;
  989. };
  990. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  991. alpha: number;
  992. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  993. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  994. */
  995. scaleX: number;
  996. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  997. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  998. */
  999. scaleY: number;
  1000. /** Gets or sets the rotation angle (0 by default)
  1001. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  1002. */
  1003. rotation: number;
  1004. /** Gets or sets the transformation center on Y axis (0 by default)
  1005. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  1006. */
  1007. transformCenterY: number;
  1008. /** Gets or sets the transformation center on X axis (0 by default)
  1009. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  1010. */
  1011. transformCenterX: number;
  1012. /**
  1013. * Gets or sets the horizontal alignment
  1014. * @see http://doc.babylonjs.com/how_to/gui#alignments
  1015. */
  1016. horizontalAlignment: number;
  1017. /**
  1018. * Gets or sets the vertical alignment
  1019. * @see http://doc.babylonjs.com/how_to/gui#alignments
  1020. */
  1021. verticalAlignment: number;
  1022. /**
  1023. * Gets or sets control width
  1024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1025. */
  1026. width: string | number;
  1027. /**
  1028. * Gets control width in pixel
  1029. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1030. */
  1031. readonly widthInPixels: number;
  1032. /**
  1033. * Gets or sets control height
  1034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1035. */
  1036. height: string | number;
  1037. /**
  1038. * Gets control height in pixel
  1039. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1040. */
  1041. readonly heightInPixels: number;
  1042. /** Gets or set font family */
  1043. fontFamily: string;
  1044. /** Gets or sets font style */
  1045. fontStyle: string;
  1046. /** Gets or sets font weight */
  1047. fontWeight: string;
  1048. /**
  1049. * Gets or sets style
  1050. * @see http://doc.babylonjs.com/how_to/gui#styles
  1051. */
  1052. style: Nullable<Style>;
  1053. /** @hidden */
  1054. readonly _isFontSizeInPercentage: boolean;
  1055. /** Gets font size in pixels */
  1056. readonly fontSizeInPixels: number;
  1057. /** Gets or sets font size */
  1058. fontSize: string | number;
  1059. /** Gets or sets foreground color */
  1060. color: string;
  1061. /** Gets or sets z index which is used to reorder controls on the z axis */
  1062. zIndex: number;
  1063. /** Gets or sets a boolean indicating if the control can be rendered */
  1064. notRenderable: boolean;
  1065. /** Gets or sets a boolean indicating if the control is visible */
  1066. isVisible: boolean;
  1067. /** Gets a boolean indicating that the control needs to update its rendering */
  1068. readonly isDirty: boolean;
  1069. /**
  1070. * Gets the current linked mesh (or null if none)
  1071. */
  1072. readonly linkedMesh: Nullable<AbstractMesh>;
  1073. /**
  1074. * Gets or sets a value indicating the padding to use on the left of the control
  1075. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1076. */
  1077. paddingLeft: string | number;
  1078. /**
  1079. * Gets a value indicating the padding in pixels to use on the left of the control
  1080. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1081. */
  1082. readonly paddingLeftInPixels: number;
  1083. /**
  1084. * Gets or sets a value indicating the padding to use on the right of the control
  1085. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1086. */
  1087. paddingRight: string | number;
  1088. /**
  1089. * Gets a value indicating the padding in pixels to use on the right of the control
  1090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1091. */
  1092. readonly paddingRightInPixels: number;
  1093. /**
  1094. * Gets or sets a value indicating the padding to use on the top of the control
  1095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1096. */
  1097. paddingTop: string | number;
  1098. /**
  1099. * Gets a value indicating the padding in pixels to use on the top of the control
  1100. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1101. */
  1102. readonly paddingTopInPixels: number;
  1103. /**
  1104. * Gets or sets a value indicating the padding to use on the bottom of the control
  1105. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1106. */
  1107. paddingBottom: string | number;
  1108. /**
  1109. * Gets a value indicating the padding in pixels to use on the bottom of the control
  1110. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1111. */
  1112. readonly paddingBottomInPixels: number;
  1113. /**
  1114. * Gets or sets a value indicating the left coordinate of the control
  1115. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1116. */
  1117. left: string | number;
  1118. /**
  1119. * Gets a value indicating the left coordinate in pixels of the control
  1120. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1121. */
  1122. readonly leftInPixels: number;
  1123. /**
  1124. * Gets or sets a value indicating the top coordinate of the control
  1125. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1126. */
  1127. top: string | number;
  1128. /**
  1129. * Gets a value indicating the top coordinate in pixels of the control
  1130. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1131. */
  1132. readonly topInPixels: number;
  1133. /**
  1134. * Gets or sets a value indicating the offset on X axis to the linked mesh
  1135. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1136. */
  1137. linkOffsetX: string | number;
  1138. /**
  1139. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  1140. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1141. */
  1142. readonly linkOffsetXInPixels: number;
  1143. /**
  1144. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  1145. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1146. */
  1147. linkOffsetY: string | number;
  1148. /**
  1149. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  1150. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1151. */
  1152. readonly linkOffsetYInPixels: number;
  1153. /** Gets the center coordinate on X axis */
  1154. readonly centerX: number;
  1155. /** Gets the center coordinate on Y axis */
  1156. readonly centerY: number;
  1157. /** Gets or sets if control is Enabled*/
  1158. isEnabled: boolean;
  1159. /** Gets or sets background color of control if it's disabled*/
  1160. disabledColor: string;
  1161. /**
  1162. * Creates a new control
  1163. * @param name defines the name of the control
  1164. */
  1165. constructor(
  1166. /** defines the name of the control */
  1167. name?: string | undefined);
  1168. /** @hidden */
  1169. protected _getTypeName(): string;
  1170. /** @hidden */
  1171. _resetFontCache(): void;
  1172. /**
  1173. * Determines if a container is an ascendant of the current control
  1174. * @param container defines the container to look for
  1175. * @returns true if the container is one of the ascendant of the control
  1176. */
  1177. isAscendant(container: Control): boolean;
  1178. /**
  1179. * Gets coordinates in local control space
  1180. * @param globalCoordinates defines the coordinates to transform
  1181. * @returns the new coordinates in local space
  1182. */
  1183. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  1184. /**
  1185. * Gets coordinates in local control space
  1186. * @param globalCoordinates defines the coordinates to transform
  1187. * @param result defines the target vector2 where to store the result
  1188. * @returns the current control
  1189. */
  1190. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  1191. /**
  1192. * Gets coordinates in parent local control space
  1193. * @param globalCoordinates defines the coordinates to transform
  1194. * @returns the new coordinates in parent local space
  1195. */
  1196. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  1197. /**
  1198. * Move the current control to a vector3 position projected onto the screen.
  1199. * @param position defines the target position
  1200. * @param scene defines the hosting scene
  1201. */
  1202. moveToVector3(position: Vector3, scene: Scene): void;
  1203. /**
  1204. * Link current control with a target mesh
  1205. * @param mesh defines the mesh to link with
  1206. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1207. */
  1208. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  1209. /** @hidden */
  1210. _moveToProjectedPosition(projectedPosition: Vector3): void;
  1211. /** @hidden */
  1212. _markMatrixAsDirty(): void;
  1213. /** @hidden */
  1214. _flagDescendantsAsMatrixDirty(): void;
  1215. /** @hidden */
  1216. _markAsDirty(force?: boolean): void;
  1217. /** @hidden */
  1218. _markAllAsDirty(): void;
  1219. /** @hidden */
  1220. _link(root: Nullable<Container>, host: AdvancedDynamicTexture): void;
  1221. /** @hidden */
  1222. protected _transform(context: CanvasRenderingContext2D): void;
  1223. /** @hidden */
  1224. protected _applyStates(context: CanvasRenderingContext2D): void;
  1225. /** @hidden */
  1226. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1227. /** @hidden */
  1228. protected _clip(context: CanvasRenderingContext2D): void;
  1229. /** @hidden */
  1230. _measure(): void;
  1231. /** @hidden */
  1232. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1233. /** @hidden */
  1234. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1235. /** @hidden */
  1236. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1237. /** @hidden */
  1238. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1239. /**
  1240. * Tests if a given coordinates belong to the current control
  1241. * @param x defines x coordinate to test
  1242. * @param y defines y coordinate to test
  1243. * @returns true if the coordinates are inside the control
  1244. */
  1245. contains(x: number, y: number): boolean;
  1246. /** @hidden */
  1247. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1248. /** @hidden */
  1249. _onPointerMove(target: Control, coordinates: Vector2): void;
  1250. /** @hidden */
  1251. _onPointerEnter(target: Control): boolean;
  1252. /** @hidden */
  1253. _onPointerOut(target: Control): void;
  1254. /** @hidden */
  1255. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1256. /** @hidden */
  1257. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1258. /** @hidden */
  1259. _forcePointerUp(pointerId?: Nullable<number>): void;
  1260. /** @hidden */
  1261. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  1262. /** Releases associated resources */
  1263. dispose(): void;
  1264. /** HORIZONTAL_ALIGNMENT_LEFT */
  1265. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  1266. /** HORIZONTAL_ALIGNMENT_RIGHT */
  1267. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  1268. /** HORIZONTAL_ALIGNMENT_CENTER */
  1269. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  1270. /** VERTICAL_ALIGNMENT_TOP */
  1271. static readonly VERTICAL_ALIGNMENT_TOP: number;
  1272. /** VERTICAL_ALIGNMENT_BOTTOM */
  1273. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  1274. /** VERTICAL_ALIGNMENT_CENTER */
  1275. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  1276. /** @hidden */
  1277. static _GetFontOffset(font: string): {
  1278. ascent: number;
  1279. height: number;
  1280. descent: number;
  1281. };
  1282. /**
  1283. * Creates a stack panel that can be used to render headers
  1284. * @param control defines the control to associate with the header
  1285. * @param text defines the text of the header
  1286. * @param size defines the size of the header
  1287. * @param options defines options used to configure the header
  1288. * @returns a new StackPanel
  1289. * @ignore
  1290. * @hidden
  1291. */
  1292. static AddHeader: (control: Control, text: string, size: string | number, options: {
  1293. isHorizontal: boolean;
  1294. controlFirst: boolean;
  1295. }) => any;
  1296. /** @hidden */
  1297. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  1298. }
  1299. }
  1300. declare module 'babylonjs-gui/2D/controls/ellipse' {
  1301. import { Container } from "babylonjs-gui/2D/controls/container";
  1302. import { Measure } from "babylonjs-gui/2D/measure";
  1303. /** Class used to create 2D ellipse containers */
  1304. export class Ellipse extends Container {
  1305. name?: string | undefined;
  1306. /** Gets or sets border thickness */
  1307. thickness: number;
  1308. /**
  1309. * Creates a new Ellipse
  1310. * @param name defines the control name
  1311. */
  1312. constructor(name?: string | undefined);
  1313. protected _getTypeName(): string;
  1314. protected _localDraw(context: CanvasRenderingContext2D): void;
  1315. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1316. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1317. }
  1318. }
  1319. declare module 'babylonjs-gui/2D/controls/grid' {
  1320. import { Container } from "babylonjs-gui/2D/controls/container";
  1321. import { Control } from "babylonjs-gui/2D/controls/control";
  1322. import { Measure } from "babylonjs-gui/2D/measure";
  1323. /**
  1324. * Class used to create a 2D grid container
  1325. */
  1326. export class Grid extends Container {
  1327. name?: string | undefined;
  1328. /** Gets the list of children */
  1329. readonly children: Control[];
  1330. /**
  1331. * Adds a new row to the grid
  1332. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  1333. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  1334. * @returns the current grid
  1335. */
  1336. addRowDefinition(height: number, isPixel?: boolean): Grid;
  1337. /**
  1338. * Adds a new column to the grid
  1339. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  1340. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  1341. * @returns the current grid
  1342. */
  1343. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  1344. /**
  1345. * Update a row definition
  1346. * @param index defines the index of the row to update
  1347. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  1348. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  1349. * @returns the current grid
  1350. */
  1351. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  1352. /**
  1353. * Update a column definition
  1354. * @param index defines the index of the column to update
  1355. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  1356. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  1357. * @returns the current grid
  1358. */
  1359. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  1360. /**
  1361. * Remove a column definition at specified index
  1362. * @param index defines the index of the column to remove
  1363. * @returns the current grid
  1364. */
  1365. removeColumnDefinition(index: number): Grid;
  1366. /**
  1367. * Remove a row definition at specified index
  1368. * @param index defines the index of the row to remove
  1369. * @returns the current grid
  1370. */
  1371. removeRowDefinition(index: number): Grid;
  1372. /**
  1373. * Adds a new control to the current grid
  1374. * @param control defines the control to add
  1375. * @param row defines the row where to add the control (0 by default)
  1376. * @param column defines the column where to add the control (0 by default)
  1377. * @returns the current grid
  1378. */
  1379. addControl(control: Control, row?: number, column?: number): Grid;
  1380. /**
  1381. * Removes a control from the current container
  1382. * @param control defines the control to remove
  1383. * @returns the current container
  1384. */
  1385. removeControl(control: Control): Container;
  1386. /**
  1387. * Creates a new Grid
  1388. * @param name defines control name
  1389. */
  1390. constructor(name?: string | undefined);
  1391. protected _getTypeName(): string;
  1392. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1393. /** Releases associated resources */
  1394. dispose(): void;
  1395. }
  1396. }
  1397. declare module 'babylonjs-gui/2D/controls/image' {
  1398. import { Control } from "babylonjs-gui/2D/controls/control";
  1399. import { Nullable } from "babylonjs";
  1400. import { Measure } from "babylonjs-gui/2D/measure";
  1401. /**
  1402. * Class used to create 2D images
  1403. */
  1404. export class Image extends Control {
  1405. name?: string | undefined;
  1406. /**
  1407. * Gets or sets the left coordinate in the source image
  1408. */
  1409. sourceLeft: number;
  1410. /**
  1411. * Gets or sets the top coordinate in the source image
  1412. */
  1413. sourceTop: number;
  1414. /**
  1415. * Gets or sets the width to capture in the source image
  1416. */
  1417. sourceWidth: number;
  1418. /**
  1419. * Gets or sets the height to capture in the source image
  1420. */
  1421. sourceHeight: number;
  1422. /**
  1423. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1424. * @see http://doc.babylonjs.com/how_to/gui#image
  1425. */
  1426. autoScale: boolean;
  1427. /** Gets or sets the streching mode used by the image */
  1428. stretch: number;
  1429. /**
  1430. * Gets or sets the internal DOM image used to render the control
  1431. */
  1432. domImage: HTMLImageElement;
  1433. /**
  1434. * Gets or sets image source url
  1435. */
  1436. source: Nullable<string>;
  1437. /**
  1438. * Gets or sets the cell width to use when animation sheet is enabled
  1439. * @see http://doc.babylonjs.com/how_to/gui#image
  1440. */
  1441. cellWidth: number;
  1442. /**
  1443. * Gets or sets the cell height to use when animation sheet is enabled
  1444. * @see http://doc.babylonjs.com/how_to/gui#image
  1445. */
  1446. cellHeight: number;
  1447. /**
  1448. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1449. * @see http://doc.babylonjs.com/how_to/gui#image
  1450. */
  1451. cellId: number;
  1452. /**
  1453. * Creates a new Image
  1454. * @param name defines the control name
  1455. * @param url defines the image url
  1456. */
  1457. constructor(name?: string | undefined, url?: Nullable<string>);
  1458. protected _getTypeName(): string;
  1459. /** Force the control to synchronize with its content */
  1460. synchronizeSizeWithContent(): void;
  1461. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1462. /** STRETCH_NONE */
  1463. static readonly STRETCH_NONE: number;
  1464. /** STRETCH_FILL */
  1465. static readonly STRETCH_FILL: number;
  1466. /** STRETCH_UNIFORM */
  1467. static readonly STRETCH_UNIFORM: number;
  1468. /** STRETCH_EXTEND */
  1469. static readonly STRETCH_EXTEND: number;
  1470. }
  1471. }
  1472. declare module 'babylonjs-gui/2D/controls/inputText' {
  1473. import { Control } from "babylonjs-gui/2D/controls/control";
  1474. import { IFocusableControl } from "babylonjs-gui/2D/advancedDynamicTexture";
  1475. import { Nullable, Observable, Vector2 } from "babylonjs";
  1476. import { Measure } from "babylonjs-gui/2D/measure";
  1477. import { VirtualKeyboard } from "babylonjs-gui/2D/controls/virtualKeyboard";
  1478. /**
  1479. * Class used to create input text control
  1480. */
  1481. export class InputText extends Control implements IFocusableControl {
  1482. name?: string | undefined;
  1483. /** @hidden */
  1484. _connectedVirtualKeyboard: Nullable<VirtualKeyboard>;
  1485. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1486. promptMessage: string;
  1487. /** Observable raised when the text changes */
  1488. onTextChangedObservable: Observable<InputText>;
  1489. /** Observable raised just before an entered character is to be added */
  1490. onBeforeKeyAddObservable: Observable<InputText>;
  1491. /** Observable raised when the control gets the focus */
  1492. onFocusObservable: Observable<InputText>;
  1493. /** Observable raised when the control loses the focus */
  1494. onBlurObservable: Observable<InputText>;
  1495. /** Gets or sets the maximum width allowed by the control */
  1496. maxWidth: string | number;
  1497. /** Gets the maximum width allowed by the control in pixels */
  1498. readonly maxWidthInPixels: number;
  1499. /** Gets or sets control margin */
  1500. margin: string;
  1501. /** Gets control margin in pixels */
  1502. readonly marginInPixels: number;
  1503. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  1504. autoStretchWidth: boolean;
  1505. /** Gets or sets border thickness */
  1506. thickness: number;
  1507. /** Gets or sets the background color when focused */
  1508. focusedBackground: string;
  1509. /** Gets or sets the background color */
  1510. background: string;
  1511. /** Gets or sets the placeholder color */
  1512. placeholderColor: string;
  1513. /** Gets or sets the text displayed when the control is empty */
  1514. placeholderText: string;
  1515. /** Gets or sets the dead key flag */
  1516. deadKey: boolean;
  1517. /** Gets or sets if the current key should be added */
  1518. addKey: boolean;
  1519. /** Gets or sets the value of the current key being entered */
  1520. currentKey: string;
  1521. /** Gets or sets the text displayed in the control */
  1522. text: string;
  1523. /** Gets or sets control width */
  1524. width: string | number;
  1525. /**
  1526. * Creates a new InputText
  1527. * @param name defines the control name
  1528. * @param text defines the text of the control
  1529. */
  1530. constructor(name?: string | undefined, text?: string);
  1531. /** @hidden */
  1532. onBlur(): void;
  1533. /** @hidden */
  1534. onFocus(): void;
  1535. protected _getTypeName(): string;
  1536. /**
  1537. * Function called to get the list of controls that should not steal the focus from this control
  1538. * @returns an array of controls
  1539. */
  1540. keepsFocusWith(): Nullable<Control[]>;
  1541. /** @hidden */
  1542. processKey(keyCode: number, key?: string): void;
  1543. /** @hidden */
  1544. processKeyboard(evt: KeyboardEvent): void;
  1545. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1546. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1547. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1548. protected _beforeRenderText(text: string): string;
  1549. dispose(): void;
  1550. }
  1551. }
  1552. declare module 'babylonjs-gui/2D/controls/inputPassword' {
  1553. import { InputText } from "babylonjs-gui/2D/controls/inputText";
  1554. /**
  1555. * Class used to create a password control
  1556. */
  1557. export class InputPassword extends InputText {
  1558. protected _beforeRenderText(text: string): string;
  1559. }
  1560. }
  1561. declare module 'babylonjs-gui/2D/controls/line' {
  1562. import { Control } from "babylonjs-gui/2D/controls/control";
  1563. import { Vector3, Scene } from "babylonjs";
  1564. import { Measure } from "babylonjs-gui/2D/measure";
  1565. /** Class used to render 2D lines */
  1566. export class Line extends Control {
  1567. name?: string | undefined;
  1568. /** Gets or sets the dash pattern */
  1569. dash: Array<number>;
  1570. /** Gets or sets the control connected with the line end */
  1571. connectedControl: Control;
  1572. /** Gets or sets start coordinates on X axis */
  1573. x1: string | number;
  1574. /** Gets or sets start coordinates on Y axis */
  1575. y1: string | number;
  1576. /** Gets or sets end coordinates on X axis */
  1577. x2: string | number;
  1578. /** Gets or sets end coordinates on Y axis */
  1579. y2: string | number;
  1580. /** Gets or sets line width */
  1581. lineWidth: number;
  1582. /** Gets or sets horizontal alignment */
  1583. horizontalAlignment: number;
  1584. /** Gets or sets vertical alignment */
  1585. verticalAlignment: number;
  1586. /**
  1587. * Creates a new Line
  1588. * @param name defines the control name
  1589. */
  1590. constructor(name?: string | undefined);
  1591. protected _getTypeName(): string;
  1592. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1593. _measure(): void;
  1594. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1595. /**
  1596. * Move one end of the line given 3D cartesian coordinates.
  1597. * @param position Targeted world position
  1598. * @param scene Scene
  1599. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1600. */
  1601. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  1602. /**
  1603. * Move one end of the line to a position in screen absolute space.
  1604. * @param projectedPosition Position in screen absolute space (X, Y)
  1605. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  1606. */
  1607. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  1608. }
  1609. }
  1610. declare module 'babylonjs-gui/2D/controls/multiLine' {
  1611. import { Control } from "babylonjs-gui/2D/controls/control";
  1612. import { MultiLinePoint } from "babylonjs-gui/2D/multiLinePoint";
  1613. import { AbstractMesh } from "babylonjs";
  1614. import { Measure } from "babylonjs-gui/2D/measure";
  1615. /**
  1616. * Class used to create multi line control
  1617. */
  1618. export class MultiLine extends Control {
  1619. name?: string | undefined;
  1620. /**
  1621. * Creates a new MultiLine
  1622. * @param name defines the control name
  1623. */
  1624. constructor(name?: string | undefined);
  1625. /** Gets or sets dash pattern */
  1626. dash: Array<number>;
  1627. /**
  1628. * Gets point stored at specified index
  1629. * @param index defines the index to look for
  1630. * @returns the requested point if found
  1631. */
  1632. getAt(index: number): MultiLinePoint;
  1633. /** Function called when a point is updated */
  1634. onPointUpdate: () => void;
  1635. /**
  1636. * Adds new points to the point collection
  1637. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  1638. * @returns the list of created MultiLinePoint
  1639. */
  1640. add(...items: (AbstractMesh | Control | {
  1641. x: string | number;
  1642. y: string | number;
  1643. })[]): MultiLinePoint[];
  1644. /**
  1645. * Adds a new point to the point collection
  1646. * @param item defines the item (mesh, control or 2d coordiantes) to add
  1647. * @returns the created MultiLinePoint
  1648. */
  1649. push(item?: (AbstractMesh | Control | {
  1650. x: string | number;
  1651. y: string | number;
  1652. })): MultiLinePoint;
  1653. /**
  1654. * Remove a specific value or point from the active point collection
  1655. * @param value defines the value or point to remove
  1656. */
  1657. remove(value: number | MultiLinePoint): void;
  1658. /**
  1659. * Resets this object to initial state (no point)
  1660. */
  1661. reset(): void;
  1662. /**
  1663. * Resets all links
  1664. */
  1665. resetLinks(): void;
  1666. /** Gets or sets line width */
  1667. lineWidth: number;
  1668. horizontalAlignment: number;
  1669. verticalAlignment: number;
  1670. protected _getTypeName(): string;
  1671. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1672. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1673. _measure(): void;
  1674. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1675. dispose(): void;
  1676. }
  1677. }
  1678. declare module 'babylonjs-gui/2D/controls/radioButton' {
  1679. import { Control } from "babylonjs-gui/2D/controls/control";
  1680. import { Observable, Vector2 } from "babylonjs";
  1681. import { Measure } from "babylonjs-gui/2D/measure";
  1682. import { StackPanel } from "babylonjs-gui/2D/controls";
  1683. /**
  1684. * Class used to create radio button controls
  1685. */
  1686. export class RadioButton extends Control {
  1687. name?: string | undefined;
  1688. /** Gets or sets border thickness */
  1689. thickness: number;
  1690. /** Gets or sets group name */
  1691. group: string;
  1692. /** Observable raised when isChecked is changed */
  1693. onIsCheckedChangedObservable: Observable<boolean>;
  1694. /** Gets or sets a value indicating the ratio between overall size and check size */
  1695. checkSizeRatio: number;
  1696. /** Gets or sets background color */
  1697. background: string;
  1698. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1699. isChecked: boolean;
  1700. /**
  1701. * Creates a new RadioButton
  1702. * @param name defines the control name
  1703. */
  1704. constructor(name?: string | undefined);
  1705. protected _getTypeName(): string;
  1706. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1707. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1708. /**
  1709. * Utility function to easily create a radio button with a header
  1710. * @param title defines the label to use for the header
  1711. * @param group defines the group to use for the radio button
  1712. * @param isChecked defines the initial state of the radio button
  1713. * @param onValueChanged defines the callback to call when value changes
  1714. * @returns a StackPanel containing the radio button and a textBlock
  1715. */
  1716. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  1717. }
  1718. }
  1719. declare module 'babylonjs-gui/2D/controls/stackPanel' {
  1720. import { Container } from "babylonjs-gui/2D/controls/container";
  1721. import { Measure } from "babylonjs-gui/2D/measure";
  1722. /**
  1723. * Class used to create a 2D stack panel container
  1724. */
  1725. export class StackPanel extends Container {
  1726. name?: string | undefined;
  1727. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1728. isVertical: boolean;
  1729. /** Gets or sets panel width */
  1730. width: string | number;
  1731. /** Gets or sets panel height */
  1732. height: string | number;
  1733. /**
  1734. * Creates a new StackPanel
  1735. * @param name defines control name
  1736. */
  1737. constructor(name?: string | undefined);
  1738. protected _getTypeName(): string;
  1739. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1740. }
  1741. }
  1742. declare module 'babylonjs-gui/2D/controls/selector' {
  1743. import { Rectangle } from "babylonjs-gui/2D/controls/rectangle";
  1744. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  1745. /** Class used to create a RadioGroup
  1746. * which contains groups of radio buttons
  1747. */
  1748. export class SelectorGroup {
  1749. /** name of SelectorGroup */
  1750. name: string;
  1751. /**
  1752. * Creates a new SelectorGroup
  1753. * @param name of group, used as a group heading
  1754. */
  1755. constructor(
  1756. /** name of SelectorGroup */
  1757. name: string);
  1758. /** Gets the groupPanel of the SelectorGroup */
  1759. readonly groupPanel: StackPanel;
  1760. /** Gets the selectors array */
  1761. readonly selectors: StackPanel[];
  1762. /** Gets and sets the group header */
  1763. header: string;
  1764. /** @hidden*/
  1765. _getSelector(selectorNb: number): StackPanel | undefined;
  1766. /** Removes the selector at the given position
  1767. * @param selectorNb the position of the selector within the group
  1768. */
  1769. removeSelector(selectorNb: number): void;
  1770. }
  1771. /** Class used to create a CheckboxGroup
  1772. * which contains groups of checkbox buttons
  1773. */
  1774. export class CheckboxGroup extends SelectorGroup {
  1775. /** Adds a checkbox as a control
  1776. * @param text is the label for the selector
  1777. * @param func is the function called when the Selector is checked
  1778. * @param checked is true when Selector is checked
  1779. */
  1780. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  1781. /** @hidden */
  1782. _setSelectorLabel(selectorNb: number, label: string): void;
  1783. /** @hidden */
  1784. _setSelectorLabelColor(selectorNb: number, color: string): void;
  1785. /** @hidden */
  1786. _setSelectorButtonColor(selectorNb: number, color: string): void;
  1787. /** @hidden */
  1788. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  1789. }
  1790. /** Class used to create a RadioGroup
  1791. * which contains groups of radio buttons
  1792. */
  1793. export class RadioGroup extends SelectorGroup {
  1794. /** Adds a radio button as a control
  1795. * @param label is the label for the selector
  1796. * @param func is the function called when the Selector is checked
  1797. * @param checked is true when Selector is checked
  1798. */
  1799. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  1800. /** @hidden */
  1801. _setSelectorLabel(selectorNb: number, label: string): void;
  1802. /** @hidden */
  1803. _setSelectorLabelColor(selectorNb: number, color: string): void;
  1804. /** @hidden */
  1805. _setSelectorButtonColor(selectorNb: number, color: string): void;
  1806. /** @hidden */
  1807. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  1808. }
  1809. /** Class used to create a SliderGroup
  1810. * which contains groups of slider buttons
  1811. */
  1812. export class SliderGroup extends SelectorGroup {
  1813. /**
  1814. * Adds a slider to the SelectorGroup
  1815. * @param label is the label for the SliderBar
  1816. * @param func is the function called when the Slider moves
  1817. * @param unit is a string describing the units used, eg degrees or metres
  1818. * @param min is the minimum value for the Slider
  1819. * @param max is the maximum value for the Slider
  1820. * @param value is the start value for the Slider between min and max
  1821. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  1822. */
  1823. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  1824. /** @hidden */
  1825. _setSelectorLabel(selectorNb: number, label: string): void;
  1826. /** @hidden */
  1827. _setSelectorLabelColor(selectorNb: number, color: string): void;
  1828. /** @hidden */
  1829. _setSelectorButtonColor(selectorNb: number, color: string): void;
  1830. /** @hidden */
  1831. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  1832. }
  1833. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  1834. * @see http://doc.babylonjs.com/how_to/selector
  1835. */
  1836. export class SelectionPanel extends Rectangle {
  1837. /** name of SelectionPanel */
  1838. name: string;
  1839. /** an array of SelectionGroups */
  1840. groups: SelectorGroup[];
  1841. /**
  1842. * Creates a new SelectionPanel
  1843. * @param name of SelectionPanel
  1844. * @param groups is an array of SelectionGroups
  1845. */
  1846. constructor(
  1847. /** name of SelectionPanel */
  1848. name: string,
  1849. /** an array of SelectionGroups */
  1850. groups?: SelectorGroup[]);
  1851. protected _getTypeName(): string;
  1852. /** Gets or sets the headerColor */
  1853. headerColor: string;
  1854. /** Gets or sets the button color */
  1855. buttonColor: string;
  1856. /** Gets or sets the label color */
  1857. labelColor: string;
  1858. /** Gets or sets the button background */
  1859. buttonBackground: string;
  1860. /** Gets or sets the color of separator bar */
  1861. barColor: string;
  1862. /** Gets or sets the height of separator bar */
  1863. barHeight: string;
  1864. /** Gets or sets the height of spacers*/
  1865. spacerHeight: string;
  1866. /** Add a group to the selection panel
  1867. * @param group is the selector group to add
  1868. */
  1869. addGroup(group: SelectorGroup): void;
  1870. /** Remove the group from the given position
  1871. * @param groupNb is the position of the group in the list
  1872. */
  1873. removeGroup(groupNb: number): void;
  1874. /** Change a group header label
  1875. * @param label is the new group header label
  1876. * @param groupNb is the number of the group to relabel
  1877. * */
  1878. setHeaderName(label: string, groupNb: number): void;
  1879. /** Change selector label to the one given
  1880. * @param label is the new selector label
  1881. * @param groupNb is the number of the groupcontaining the selector
  1882. * @param selectorNb is the number of the selector within a group to relabel
  1883. * */
  1884. relabel(label: string, groupNb: number, selectorNb: number): void;
  1885. /** For a given group position remove the selector at the given position
  1886. * @param groupNb is the number of the group to remove the selector from
  1887. * @param selectorNb is the number of the selector within the group
  1888. */
  1889. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  1890. /** For a given group position of correct type add a checkbox button
  1891. * @param groupNb is the number of the group to remove the selector from
  1892. * @param label is the label for the selector
  1893. * @param func is the function called when the Selector is checked
  1894. * @param checked is true when Selector is checked
  1895. */
  1896. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  1897. /** For a given group position of correct type add a radio button
  1898. * @param groupNb is the number of the group to remove the selector from
  1899. * @param label is the label for the selector
  1900. * @param func is the function called when the Selector is checked
  1901. * @param checked is true when Selector is checked
  1902. */
  1903. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  1904. /**
  1905. * For a given slider group add a slider
  1906. * @param groupNb is the number of the group to add the slider to
  1907. * @param label is the label for the Slider
  1908. * @param func is the function called when the Slider moves
  1909. * @param unit is a string describing the units used, eg degrees or metres
  1910. * @param min is the minimum value for the Slider
  1911. * @param max is the maximum value for the Slider
  1912. * @param value is the start value for the Slider between min and max
  1913. * @param onVal is the function used to format the value displayed, eg radians to degrees
  1914. */
  1915. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  1916. }
  1917. }
  1918. declare module 'babylonjs-gui/2D/controls/textBlock' {
  1919. import { Observable } from "babylonjs";
  1920. import { Measure } from "babylonjs-gui/2D/measure";
  1921. import { Control } from "babylonjs-gui/2D/controls/control";
  1922. /**
  1923. * Enum that determines the text-wrapping mode to use.
  1924. */
  1925. export enum TextWrapping {
  1926. /**
  1927. * Clip the text when it's larger than Control.width; this is the default mode.
  1928. */
  1929. Clip = 0,
  1930. /**
  1931. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  1932. */
  1933. WordWrap = 1,
  1934. /**
  1935. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  1936. */
  1937. Ellipsis = 2
  1938. }
  1939. /**
  1940. * Class used to create text block control
  1941. */
  1942. export class TextBlock extends Control {
  1943. /**
  1944. * Defines the name of the control
  1945. */
  1946. name?: string | undefined;
  1947. /**
  1948. * An event triggered after the text is changed
  1949. */
  1950. onTextChangedObservable: Observable<TextBlock>;
  1951. /**
  1952. * An event triggered after the text was broken up into lines
  1953. */
  1954. onLinesReadyObservable: Observable<TextBlock>;
  1955. /**
  1956. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1957. */
  1958. readonly lines: any[];
  1959. /**
  1960. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1961. */
  1962. resizeToFit: boolean;
  1963. /**
  1964. * Gets or sets a boolean indicating if text must be wrapped
  1965. */
  1966. textWrapping: TextWrapping | boolean;
  1967. /**
  1968. * Gets or sets text to display
  1969. */
  1970. text: string;
  1971. /**
  1972. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1973. */
  1974. textHorizontalAlignment: number;
  1975. /**
  1976. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1977. */
  1978. textVerticalAlignment: number;
  1979. /**
  1980. * Gets or sets line spacing value
  1981. */
  1982. lineSpacing: string | number;
  1983. /**
  1984. * Gets or sets outlineWidth of the text to display
  1985. */
  1986. outlineWidth: number;
  1987. /**
  1988. * Gets or sets outlineColor of the text to display
  1989. */
  1990. outlineColor: string;
  1991. /**
  1992. * Creates a new TextBlock object
  1993. * @param name defines the name of the control
  1994. * @param text defines the text to display (emptry string by default)
  1995. */
  1996. constructor(
  1997. /**
  1998. * Defines the name of the control
  1999. */
  2000. name?: string | undefined, text?: string);
  2001. protected _getTypeName(): string;
  2002. /** @hidden */
  2003. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2004. protected _applyStates(context: CanvasRenderingContext2D): void;
  2005. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2006. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  2007. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  2008. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  2009. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  2010. protected _renderLines(context: CanvasRenderingContext2D): void;
  2011. /**
  2012. * Given a width constraint applied on the text block, find the expected height
  2013. * @returns expected height
  2014. */
  2015. computeExpectedHeight(): number;
  2016. dispose(): void;
  2017. }
  2018. }
  2019. declare module 'babylonjs-gui/2D/controls/virtualKeyboard' {
  2020. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  2021. import { Observable, Nullable } from "babylonjs";
  2022. import { InputText } from "babylonjs-gui/2D/controls/inputText";
  2023. /**
  2024. * Class used to store key control properties
  2025. */
  2026. export class KeyPropertySet {
  2027. /** Width */
  2028. width?: string;
  2029. /** Height */
  2030. height?: string;
  2031. /** Left padding */
  2032. paddingLeft?: string;
  2033. /** Right padding */
  2034. paddingRight?: string;
  2035. /** Top padding */
  2036. paddingTop?: string;
  2037. /** Bottom padding */
  2038. paddingBottom?: string;
  2039. /** Foreground color */
  2040. color?: string;
  2041. /** Background color */
  2042. background?: string;
  2043. }
  2044. /**
  2045. * Class used to create virtual keyboard
  2046. */
  2047. export class VirtualKeyboard extends StackPanel {
  2048. /** Observable raised when a key is pressed */
  2049. onKeyPressObservable: Observable<string>;
  2050. /** Gets or sets default key button width */
  2051. defaultButtonWidth: string;
  2052. /** Gets or sets default key button height */
  2053. defaultButtonHeight: string;
  2054. /** Gets or sets default key button left padding */
  2055. defaultButtonPaddingLeft: string;
  2056. /** Gets or sets default key button right padding */
  2057. defaultButtonPaddingRight: string;
  2058. /** Gets or sets default key button top padding */
  2059. defaultButtonPaddingTop: string;
  2060. /** Gets or sets default key button bottom padding */
  2061. defaultButtonPaddingBottom: string;
  2062. /** Gets or sets default key button foreground color */
  2063. defaultButtonColor: string;
  2064. /** Gets or sets default key button background color */
  2065. defaultButtonBackground: string;
  2066. /** Gets or sets shift button foreground color */
  2067. shiftButtonColor: string;
  2068. /** Gets or sets shift button thickness*/
  2069. selectedShiftThickness: number;
  2070. /** Gets shift key state */
  2071. shiftState: number;
  2072. protected _getTypeName(): string;
  2073. /**
  2074. * Adds a new row of keys
  2075. * @param keys defines the list of keys to add
  2076. * @param propertySets defines the associated property sets
  2077. */
  2078. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  2079. /**
  2080. * Set the shift key to a specific state
  2081. * @param shiftState defines the new shift state
  2082. */
  2083. applyShiftState(shiftState: number): void;
  2084. /** Gets the input text control currently attached to the keyboard */
  2085. readonly connectedInputText: Nullable<InputText>;
  2086. /**
  2087. * Connects the keyboard with an input text control
  2088. *
  2089. * @param input defines the target control
  2090. */
  2091. connect(input: InputText): void;
  2092. /**
  2093. * Disconnects the keyboard from connected InputText controls
  2094. *
  2095. * @param input optionally defines a target control, otherwise all are disconnected
  2096. */
  2097. disconnect(input?: InputText): void;
  2098. /**
  2099. * Release all resources
  2100. */
  2101. dispose(): void;
  2102. /**
  2103. * Creates a new keyboard using a default layout
  2104. *
  2105. * @param name defines control name
  2106. * @returns a new VirtualKeyboard
  2107. */
  2108. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  2109. }
  2110. }
  2111. declare module 'babylonjs-gui/2D/controls/slider' {
  2112. import { Control } from "babylonjs-gui/2D/controls/control";
  2113. import { Observable, Vector2 } from "babylonjs";
  2114. import { Measure } from "babylonjs-gui/2D/measure";
  2115. /**
  2116. * Class used to create slider controls
  2117. */
  2118. export class Slider extends Control {
  2119. name?: string | undefined;
  2120. /** Observable raised when the sldier value changes */
  2121. onValueChangedObservable: Observable<number>;
  2122. /** Gets or sets border color */
  2123. borderColor: string;
  2124. /** Gets or sets background color */
  2125. background: string;
  2126. /** Gets or sets main bar offset */
  2127. barOffset: string | number;
  2128. /** Gets main bar offset in pixels*/
  2129. readonly barOffsetInPixels: number;
  2130. /** Gets or sets thumb width */
  2131. thumbWidth: string | number;
  2132. /** Gets thumb width in pixels */
  2133. readonly thumbWidthInPixels: number;
  2134. /** Gets or sets minimum value */
  2135. minimum: number;
  2136. /** Gets or sets maximum value */
  2137. maximum: number;
  2138. /** Gets or sets current value */
  2139. value: number;
  2140. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  2141. isVertical: boolean;
  2142. /** Gets or sets a boolean indicating if the thumb should be round or square */
  2143. isThumbCircle: boolean;
  2144. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  2145. isThumbClamped: boolean;
  2146. /**
  2147. * Creates a new Slider
  2148. * @param name defines the control name
  2149. */
  2150. constructor(name?: string | undefined);
  2151. protected _getTypeName(): string;
  2152. protected _getThumbThickness(type: string, backgroundLength: number): number;
  2153. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2154. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2155. _onPointerMove(target: Control, coordinates: Vector2): void;
  2156. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2157. }
  2158. }
  2159. declare module 'babylonjs-gui/2D/controls/rectangle' {
  2160. import { Container } from "babylonjs-gui/2D/controls/container";
  2161. import { Measure } from "babylonjs-gui/2D/measure";
  2162. /** Class used to create rectangle container */
  2163. export class Rectangle extends Container {
  2164. name?: string | undefined;
  2165. /** Gets or sets border thickness */
  2166. thickness: number;
  2167. /** Gets or sets the corner radius angle */
  2168. cornerRadius: number;
  2169. /**
  2170. * Creates a new Rectangle
  2171. * @param name defines the control name
  2172. */
  2173. constructor(name?: string | undefined);
  2174. protected _getTypeName(): string;
  2175. protected _localDraw(context: CanvasRenderingContext2D): void;
  2176. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2177. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  2178. }
  2179. }
  2180. declare module 'babylonjs-gui/2D/controls/displayGrid' {
  2181. import { Control } from "babylonjs-gui/2D/controls";
  2182. import { Measure } from "babylonjs-gui/2D";
  2183. /** Class used to render a grid */
  2184. export class DisplayGrid extends Control {
  2185. name?: string | undefined;
  2186. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  2187. displayMinorLines: boolean;
  2188. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  2189. displayMajorLines: boolean;
  2190. /** Gets or sets background color (Black by default) */
  2191. background: string;
  2192. /** Gets or sets the width of each cell (20 by default) */
  2193. cellWidth: number;
  2194. /** Gets or sets the height of each cell (20 by default) */
  2195. cellHeight: number;
  2196. /** Gets or sets the tickness of minor lines (1 by default) */
  2197. minorLineTickness: number;
  2198. /** Gets or sets the color of minor lines (DarkGray by default) */
  2199. minorLineColor: string;
  2200. /** Gets or sets the tickness of major lines (2 by default) */
  2201. majorLineTickness: number;
  2202. /** Gets or sets the color of major lines (White by default) */
  2203. majorLineColor: string;
  2204. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  2205. majorLineFrequency: number;
  2206. /**
  2207. * Creates a new GridDisplayRectangle
  2208. * @param name defines the control name
  2209. */
  2210. constructor(name?: string | undefined);
  2211. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2212. protected _getTypeName(): string;
  2213. }
  2214. }
  2215. declare module 'babylonjs-gui/2D/controls/statics' {
  2216. /**
  2217. * Forcing an export so that this code will execute
  2218. * @hidden
  2219. */
  2220. const name = "Statics";
  2221. export { name };
  2222. }
  2223. declare module 'babylonjs-gui/3D/controls/abstractButton3D' {
  2224. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2225. import { TransformNode, Scene } from "babylonjs";
  2226. /**
  2227. * Class used as a root to all buttons
  2228. */
  2229. export class AbstractButton3D extends Control3D {
  2230. /**
  2231. * Creates a new button
  2232. * @param name defines the control name
  2233. */
  2234. constructor(name?: string);
  2235. protected _getTypeName(): string;
  2236. protected _createNode(scene: Scene): TransformNode;
  2237. }
  2238. }
  2239. declare module 'babylonjs-gui/3D/controls/button3D' {
  2240. import { AbstractButton3D } from "babylonjs-gui/3D/controls/abstractButton3D";
  2241. import { Material, int, Scene, TransformNode, AbstractMesh } from "babylonjs";
  2242. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  2243. import { Control } from "babylonjs-gui/2D/controls/control";
  2244. /**
  2245. * Class used to create a button in 3D
  2246. */
  2247. export class Button3D extends AbstractButton3D {
  2248. /** @hidden */
  2249. protected _currentMaterial: Material;
  2250. /**
  2251. * Gets or sets the texture resolution used to render content (512 by default)
  2252. */
  2253. contentResolution: int;
  2254. /**
  2255. * Gets or sets the texture scale ratio used to render content (2 by default)
  2256. */
  2257. contentScaleRatio: number;
  2258. protected _disposeFacadeTexture(): void;
  2259. protected _resetContent(): void;
  2260. /**
  2261. * Creates a new button
  2262. * @param name defines the control name
  2263. */
  2264. constructor(name?: string);
  2265. /**
  2266. * Gets or sets the GUI 2D content used to display the button's facade
  2267. */
  2268. content: Control;
  2269. /**
  2270. * Apply the facade texture (created from the content property).
  2271. * This function can be overloaded by child classes
  2272. * @param facadeTexture defines the AdvancedDynamicTexture to use
  2273. */
  2274. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2275. protected _getTypeName(): string;
  2276. protected _createNode(scene: Scene): TransformNode;
  2277. protected _affectMaterial(mesh: AbstractMesh): void;
  2278. /**
  2279. * Releases all associated resources
  2280. */
  2281. dispose(): void;
  2282. }
  2283. }
  2284. declare module 'babylonjs-gui/3D/controls/container3D' {
  2285. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2286. import { Scene, Nullable, TransformNode } from "babylonjs";
  2287. /**
  2288. * Class used to create containers for controls
  2289. */
  2290. export class Container3D extends Control3D {
  2291. /**
  2292. * Gets the list of child controls
  2293. */
  2294. protected _children: Control3D[];
  2295. /**
  2296. * Gets the list of child controls
  2297. */
  2298. readonly children: Array<Control3D>;
  2299. /**
  2300. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  2301. * This is helpful to optimize layout operation when adding multiple children in a row
  2302. */
  2303. blockLayout: boolean;
  2304. /**
  2305. * Creates a new container
  2306. * @param name defines the container name
  2307. */
  2308. constructor(name?: string);
  2309. /**
  2310. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  2311. * @returns the current container
  2312. */
  2313. updateLayout(): Container3D;
  2314. /**
  2315. * Gets a boolean indicating if the given control is in the children of this control
  2316. * @param control defines the control to check
  2317. * @returns true if the control is in the child list
  2318. */
  2319. containsControl(control: Control3D): boolean;
  2320. /**
  2321. * Adds a control to the children of this control
  2322. * @param control defines the control to add
  2323. * @returns the current container
  2324. */
  2325. addControl(control: Control3D): Container3D;
  2326. /**
  2327. * This function will be called everytime a new control is added
  2328. */
  2329. protected _arrangeChildren(): void;
  2330. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2331. /**
  2332. * Removes a control from the children of this control
  2333. * @param control defines the control to remove
  2334. * @returns the current container
  2335. */
  2336. removeControl(control: Control3D): Container3D;
  2337. protected _getTypeName(): string;
  2338. /**
  2339. * Releases all associated resources
  2340. */
  2341. dispose(): void;
  2342. /** Control rotation will remain unchanged */
  2343. static readonly UNSET_ORIENTATION: number;
  2344. /** Control will rotate to make it look at sphere central axis */
  2345. static readonly FACEORIGIN_ORIENTATION: number;
  2346. /** Control will rotate to make it look back at sphere central axis */
  2347. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  2348. /** Control will rotate to look at z axis (0, 0, 1) */
  2349. static readonly FACEFORWARD_ORIENTATION: number;
  2350. /** Control will rotate to look at negative z axis (0, 0, -1) */
  2351. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  2352. }
  2353. }
  2354. declare module 'babylonjs-gui/3D/controls/control3D' {
  2355. import { IDisposable, IBehaviorAware, Nullable, TransformNode, Vector3, Observable, Behavior, AbstractMesh, Scene } from "babylonjs";
  2356. import { GUI3DManager } from "babylonjs-gui/3D/gui3DManager";
  2357. import { Vector3WithInfo } from "babylonjs-gui/3D/vector3WithInfo";
  2358. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  2359. /**
  2360. * Class used as base class for controls
  2361. */
  2362. export class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  2363. /** Defines the control name */
  2364. name?: string | undefined;
  2365. /** @hidden */
  2366. _host: GUI3DManager;
  2367. /** Gets or sets the control position in world space */
  2368. position: Vector3;
  2369. /** Gets or sets the control scaling in world space */
  2370. scaling: Vector3;
  2371. /** Callback used to start pointer enter animation */
  2372. pointerEnterAnimation: () => void;
  2373. /** Callback used to start pointer out animation */
  2374. pointerOutAnimation: () => void;
  2375. /** Callback used to start pointer down animation */
  2376. pointerDownAnimation: () => void;
  2377. /** Callback used to start pointer up animation */
  2378. pointerUpAnimation: () => void;
  2379. /**
  2380. * An event triggered when the pointer move over the control
  2381. */
  2382. onPointerMoveObservable: Observable<Vector3>;
  2383. /**
  2384. * An event triggered when the pointer move out of the control
  2385. */
  2386. onPointerOutObservable: Observable<Control3D>;
  2387. /**
  2388. * An event triggered when the pointer taps the control
  2389. */
  2390. onPointerDownObservable: Observable<Vector3WithInfo>;
  2391. /**
  2392. * An event triggered when pointer is up
  2393. */
  2394. onPointerUpObservable: Observable<Vector3WithInfo>;
  2395. /**
  2396. * An event triggered when a control is clicked on (with a mouse)
  2397. */
  2398. onPointerClickObservable: Observable<Vector3WithInfo>;
  2399. /**
  2400. * An event triggered when pointer enters the control
  2401. */
  2402. onPointerEnterObservable: Observable<Control3D>;
  2403. /**
  2404. * Gets or sets the parent container
  2405. */
  2406. parent: Nullable<Container3D>;
  2407. /**
  2408. * Gets the list of attached behaviors
  2409. * @see http://doc.babylonjs.com/features/behaviour
  2410. */
  2411. readonly behaviors: Behavior<Control3D>[];
  2412. /**
  2413. * Attach a behavior to the control
  2414. * @see http://doc.babylonjs.com/features/behaviour
  2415. * @param behavior defines the behavior to attach
  2416. * @returns the current control
  2417. */
  2418. addBehavior(behavior: Behavior<Control3D>): Control3D;
  2419. /**
  2420. * Remove an attached behavior
  2421. * @see http://doc.babylonjs.com/features/behaviour
  2422. * @param behavior defines the behavior to attach
  2423. * @returns the current control
  2424. */
  2425. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  2426. /**
  2427. * Gets an attached behavior by name
  2428. * @param name defines the name of the behavior to look for
  2429. * @see http://doc.babylonjs.com/features/behaviour
  2430. * @returns null if behavior was not found else the requested behavior
  2431. */
  2432. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  2433. /** Gets or sets a boolean indicating if the control is visible */
  2434. isVisible: boolean;
  2435. /**
  2436. * Creates a new control
  2437. * @param name defines the control name
  2438. */
  2439. constructor(
  2440. /** Defines the control name */
  2441. name?: string | undefined);
  2442. /**
  2443. * Gets a string representing the class name
  2444. */
  2445. readonly typeName: string;
  2446. protected _getTypeName(): string;
  2447. /**
  2448. * Gets the transform node used by this control
  2449. */
  2450. readonly node: Nullable<TransformNode>;
  2451. /**
  2452. * Gets the mesh used to render this control
  2453. */
  2454. readonly mesh: Nullable<AbstractMesh>;
  2455. /**
  2456. * Link the control as child of the given node
  2457. * @param node defines the node to link to. Use null to unlink the control
  2458. * @returns the current control
  2459. */
  2460. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  2461. /** @hidden **/
  2462. _prepareNode(scene: Scene): void;
  2463. /**
  2464. * Node creation.
  2465. * Can be overriden by children
  2466. * @param scene defines the scene where the node must be attached
  2467. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  2468. */
  2469. protected _createNode(scene: Scene): Nullable<TransformNode>;
  2470. /**
  2471. * Affect a material to the given mesh
  2472. * @param mesh defines the mesh which will represent the control
  2473. */
  2474. protected _affectMaterial(mesh: AbstractMesh): void;
  2475. /** @hidden */
  2476. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  2477. /** @hidden */
  2478. _onPointerEnter(target: Control3D): boolean;
  2479. /** @hidden */
  2480. _onPointerOut(target: Control3D): void;
  2481. /** @hidden */
  2482. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  2483. /** @hidden */
  2484. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2485. /** @hidden */
  2486. forcePointerUp(pointerId?: Nullable<number>): void;
  2487. /** @hidden */
  2488. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  2489. /** @hidden */
  2490. _disposeNode(): void;
  2491. /**
  2492. * Releases all associated resources
  2493. */
  2494. dispose(): void;
  2495. }
  2496. }
  2497. declare module 'babylonjs-gui/3D/controls/cylinderPanel' {
  2498. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  2499. import { float, Vector3 } from "babylonjs";
  2500. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2501. /**
  2502. * Class used to create a container panel deployed on the surface of a cylinder
  2503. */
  2504. export class CylinderPanel extends VolumeBasedPanel {
  2505. /**
  2506. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  2507. */
  2508. radius: float;
  2509. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2510. }
  2511. }
  2512. declare module 'babylonjs-gui/3D/controls/holographicButton' {
  2513. import { Button3D } from "babylonjs-gui/3D/controls/button3D";
  2514. import { Mesh, StandardMaterial, Nullable, Scene, TransformNode } from "babylonjs";
  2515. import { FluentMaterial } from "babylonjs-gui/3D/materials/fluentMaterial";
  2516. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  2517. /**
  2518. * Class used to create a holographic button in 3D
  2519. */
  2520. export class HolographicButton extends Button3D {
  2521. /**
  2522. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  2523. */
  2524. tooltipText: Nullable<string>;
  2525. /**
  2526. * Gets or sets text for the button
  2527. */
  2528. text: string;
  2529. /**
  2530. * Gets or sets the image url for the button
  2531. */
  2532. imageUrl: string;
  2533. /**
  2534. * Gets the back material used by this button
  2535. */
  2536. readonly backMaterial: FluentMaterial;
  2537. /**
  2538. * Gets the front material used by this button
  2539. */
  2540. readonly frontMaterial: FluentMaterial;
  2541. /**
  2542. * Gets the plate material used by this button
  2543. */
  2544. readonly plateMaterial: StandardMaterial;
  2545. /**
  2546. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  2547. */
  2548. readonly shareMaterials: boolean;
  2549. /**
  2550. * Creates a new button
  2551. * @param name defines the control name
  2552. */
  2553. constructor(name?: string, shareMaterials?: boolean);
  2554. protected _getTypeName(): string;
  2555. protected _createNode(scene: Scene): TransformNode;
  2556. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  2557. protected _affectMaterial(mesh: Mesh): void;
  2558. /**
  2559. * Releases all associated resources
  2560. */
  2561. dispose(): void;
  2562. }
  2563. }
  2564. declare module 'babylonjs-gui/3D/controls/meshButton3D' {
  2565. import { Scene, TransformNode, AbstractMesh, Mesh } from "babylonjs";
  2566. import { Button3D } from "babylonjs-gui/3D/controls/button3D";
  2567. /**
  2568. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  2569. */
  2570. export class MeshButton3D extends Button3D {
  2571. /** @hidden */
  2572. protected _currentMesh: Mesh;
  2573. /**
  2574. * Creates a new 3D button based on a mesh
  2575. * @param mesh mesh to become a 3D button
  2576. * @param name defines the control name
  2577. */
  2578. constructor(mesh: Mesh, name?: string);
  2579. protected _getTypeName(): string;
  2580. protected _createNode(scene: Scene): TransformNode;
  2581. protected _affectMaterial(mesh: AbstractMesh): void;
  2582. }
  2583. }
  2584. declare module 'babylonjs-gui/3D/controls/planePanel' {
  2585. import { Vector3 } from "babylonjs";
  2586. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2587. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  2588. /**
  2589. * Class used to create a container panel deployed on the surface of a plane
  2590. */
  2591. export class PlanePanel extends VolumeBasedPanel {
  2592. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2593. }
  2594. }
  2595. declare module 'babylonjs-gui/3D/controls/scatterPanel' {
  2596. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  2597. import { float, Vector3 } from "babylonjs";
  2598. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2599. /**
  2600. * Class used to create a container panel where items get randomized planar mapping
  2601. */
  2602. export class ScatterPanel extends VolumeBasedPanel {
  2603. /**
  2604. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  2605. */
  2606. iteration: float;
  2607. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2608. protected _finalProcessing(): void;
  2609. }
  2610. }
  2611. declare module 'babylonjs-gui/3D/controls/spherePanel' {
  2612. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  2613. import { float, Vector3 } from "babylonjs";
  2614. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2615. /**
  2616. * Class used to create a container panel deployed on the surface of a sphere
  2617. */
  2618. export class SpherePanel extends VolumeBasedPanel {
  2619. /**
  2620. * Gets or sets the radius of the sphere where to project controls (5 by default)
  2621. */
  2622. radius: float;
  2623. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2624. }
  2625. }
  2626. declare module 'babylonjs-gui/3D/controls/stackPanel3D' {
  2627. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  2628. /**
  2629. * Class used to create a stack panel in 3D on XY plane
  2630. */
  2631. export class StackPanel3D extends Container3D {
  2632. /**
  2633. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  2634. */
  2635. isVertical: boolean;
  2636. /**
  2637. * Gets or sets the distance between elements
  2638. */
  2639. margin: number;
  2640. /**
  2641. * Creates new StackPanel
  2642. * @param isVertical
  2643. */
  2644. constructor(isVertical?: boolean);
  2645. protected _arrangeChildren(): void;
  2646. }
  2647. }
  2648. declare module 'babylonjs-gui/3D/controls/volumeBasedPanel' {
  2649. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  2650. import { int, Vector3 } from "babylonjs";
  2651. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  2652. /**
  2653. * Abstract class used to create a container panel deployed on the surface of a volume
  2654. */
  2655. export abstract class VolumeBasedPanel extends Container3D {
  2656. protected _cellWidth: number;
  2657. protected _cellHeight: number;
  2658. /**
  2659. * Gets or sets the distance between elements
  2660. */
  2661. margin: number;
  2662. /**
  2663. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  2664. * | Value | Type | Description |
  2665. * | ----- | ----------------------------------- | ----------- |
  2666. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  2667. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  2668. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  2669. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  2670. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  2671. */
  2672. orientation: number;
  2673. /**
  2674. * Gets or sets the number of columns requested (10 by default).
  2675. * The panel will automatically compute the number of rows based on number of child controls.
  2676. */
  2677. columns: int;
  2678. /**
  2679. * Gets or sets a the number of rows requested.
  2680. * The panel will automatically compute the number of columns based on number of child controls.
  2681. */
  2682. rows: int;
  2683. /**
  2684. * Creates new VolumeBasedPanel
  2685. */
  2686. constructor();
  2687. protected _arrangeChildren(): void;
  2688. /** Child classes must implement this function to provide correct control positioning */
  2689. protected abstract _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  2690. /** Child classes can implement this function to provide additional processing */
  2691. protected _finalProcessing(): void;
  2692. }
  2693. }
  2694. declare module 'babylonjs-gui/3D/materials/fluentMaterial' {
  2695. import { MaterialDefines, PushMaterial, Color3, Color4, Vector3, Scene, Nullable, BaseTexture, AbstractMesh, SubMesh, Matrix, Mesh } from "babylonjs";
  2696. /** @hidden */
  2697. export class FluentMaterialDefines extends MaterialDefines {
  2698. INNERGLOW: boolean;
  2699. BORDER: boolean;
  2700. HOVERLIGHT: boolean;
  2701. TEXTURE: boolean;
  2702. constructor();
  2703. }
  2704. /**
  2705. * Class used to render controls with fluent desgin
  2706. */
  2707. export class FluentMaterial extends PushMaterial {
  2708. /**
  2709. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  2710. */
  2711. innerGlowColorIntensity: number;
  2712. /**
  2713. * Gets or sets the inner glow color (white by default)
  2714. */
  2715. innerGlowColor: Color3;
  2716. /**
  2717. * Gets or sets alpha value (default is 1.0)
  2718. */
  2719. alpha: number;
  2720. /**
  2721. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  2722. */
  2723. albedoColor: Color3;
  2724. /**
  2725. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  2726. */
  2727. renderBorders: boolean;
  2728. /**
  2729. * Gets or sets border width (default is 0.5)
  2730. */
  2731. borderWidth: number;
  2732. /**
  2733. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  2734. */
  2735. edgeSmoothingValue: number;
  2736. /**
  2737. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  2738. */
  2739. borderMinValue: number;
  2740. /**
  2741. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  2742. */
  2743. renderHoverLight: boolean;
  2744. /**
  2745. * Gets or sets the radius used to render the hover light (default is 1.0)
  2746. */
  2747. hoverRadius: number;
  2748. /**
  2749. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  2750. */
  2751. hoverColor: Color4;
  2752. /**
  2753. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  2754. */
  2755. hoverPosition: Vector3;
  2756. /** Gets or sets the texture to use for albedo color */
  2757. albedoTexture: Nullable<BaseTexture>;
  2758. /**
  2759. * Creates a new Fluent material
  2760. * @param name defines the name of the material
  2761. * @param scene defines the hosting scene
  2762. */
  2763. constructor(name: string, scene: Scene);
  2764. needAlphaBlending(): boolean;
  2765. needAlphaTesting(): boolean;
  2766. getAlphaTestTexture(): Nullable<BaseTexture>;
  2767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  2768. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  2769. getActiveTextures(): BaseTexture[];
  2770. hasTexture(texture: BaseTexture): boolean;
  2771. dispose(forceDisposeEffect?: boolean): void;
  2772. clone(name: string): FluentMaterial;
  2773. serialize(): any;
  2774. getClassName(): string;
  2775. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  2776. }
  2777. }
  2778. /*BabylonJS GUI*/
  2779. // Dependencies for this module:
  2780. // ../../../../Tools/Gulp/babylonjs
  2781. declare module BABYLON.GUI {
  2782. /**
  2783. * Interface used to define a control that can receive focus
  2784. */
  2785. export interface IFocusableControl {
  2786. /**
  2787. * Function called when the control receives the focus
  2788. */
  2789. onFocus(): void;
  2790. /**
  2791. * Function called when the control loses the focus
  2792. */
  2793. onBlur(): void;
  2794. /**
  2795. * Function called to let the control handle keyboard events
  2796. * @param evt defines the current keyboard event
  2797. */
  2798. processKeyboard(evt: KeyboardEvent): void;
  2799. /**
  2800. * Function called to get the list of controls that should not steal the focus from this control
  2801. * @returns an array of controls
  2802. */
  2803. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  2804. }
  2805. /**
  2806. * Class used to create texture to support 2D GUI elements
  2807. * @see http://doc.babylonjs.com/how_to/gui
  2808. */
  2809. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  2810. /** @hidden */
  2811. _rootContainer: Container;
  2812. /** @hidden */
  2813. _lastPickedControl: Control;
  2814. /** @hidden */
  2815. _lastControlOver: {
  2816. [pointerId: number]: Control;
  2817. };
  2818. /** @hidden */
  2819. _lastControlDown: {
  2820. [pointerId: number]: Control;
  2821. };
  2822. /** @hidden */
  2823. _capturingControl: {
  2824. [pointerId: number]: Control;
  2825. };
  2826. /** @hidden */
  2827. _shouldBlockPointer: boolean;
  2828. /** @hidden */
  2829. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  2830. /** @hidden */
  2831. _linkedControls: Control[];
  2832. /**
  2833. * Gets or sets a boolean defining if alpha is stored as premultiplied
  2834. */
  2835. premulAlpha: boolean;
  2836. /**
  2837. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  2838. * Useful when you want more antialiasing
  2839. */
  2840. renderScale: number;
  2841. /** Gets or sets the background color */
  2842. background: string;
  2843. /**
  2844. * Gets or sets the ideal width used to design controls.
  2845. * The GUI will then rescale everything accordingly
  2846. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  2847. */
  2848. idealWidth: number;
  2849. /**
  2850. * Gets or sets the ideal height used to design controls.
  2851. * The GUI will then rescale everything accordingly
  2852. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  2853. */
  2854. idealHeight: number;
  2855. /**
  2856. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  2857. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  2858. */
  2859. useSmallestIdeal: boolean;
  2860. /**
  2861. * Gets or sets a boolean indicating if adaptive scaling must be used
  2862. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  2863. */
  2864. renderAtIdealSize: boolean;
  2865. /**
  2866. * Gets the underlying layer used to render the texture when in fullscreen mode
  2867. */
  2868. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  2869. /**
  2870. * Gets the root container control
  2871. */
  2872. readonly rootContainer: Container;
  2873. /**
  2874. * Gets or sets the current focused control
  2875. */
  2876. focusedControl: BABYLON.Nullable<IFocusableControl>;
  2877. /**
  2878. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  2879. */
  2880. isForeground: boolean;
  2881. /**
  2882. * Creates a new AdvancedDynamicTexture
  2883. * @param name defines the name of the texture
  2884. * @param width defines the width of the texture
  2885. * @param height defines the height of the texture
  2886. * @param scene defines the hosting scene
  2887. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  2888. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  2889. */
  2890. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  2891. /**
  2892. * Function used to execute a function on all controls
  2893. * @param func defines the function to execute
  2894. * @param container defines the container where controls belong. If null the root container will be used
  2895. */
  2896. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  2897. /**
  2898. * Marks the texture as dirty forcing a complete update
  2899. */
  2900. markAsDirty(): void;
  2901. /**
  2902. * Helper function used to create a new style
  2903. * @returns a new style
  2904. * @see http://doc.babylonjs.com/how_to/gui#styles
  2905. */
  2906. createStyle(): Style;
  2907. /**
  2908. * Adds a new control to the root container
  2909. * @param control defines the control to add
  2910. * @returns the current texture
  2911. */
  2912. addControl(control: Control): AdvancedDynamicTexture;
  2913. /**
  2914. * Removes a control from the root container
  2915. * @param control defines the control to remove
  2916. * @returns the current texture
  2917. */
  2918. removeControl(control: Control): AdvancedDynamicTexture;
  2919. /**
  2920. * Release all resources
  2921. */
  2922. dispose(): void;
  2923. /** @hidden */
  2924. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  2925. /**
  2926. * Get screen coordinates for a vector3
  2927. * @param position defines the position to project
  2928. * @param worldMatrix defines the world matrix to use
  2929. * @returns the projected position
  2930. */
  2931. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  2932. /** @hidden */
  2933. _changeCursor(cursor: string): void;
  2934. /** @hidden */
  2935. _cleanControlAfterRemovalFromList(list: {
  2936. [pointerId: number]: Control;
  2937. }, control: Control): void;
  2938. /** @hidden */
  2939. _cleanControlAfterRemoval(control: Control): void;
  2940. /** Attach to all scene events required to support pointer events */
  2941. attach(): void;
  2942. /**
  2943. * Connect the texture to a hosting mesh to enable interactions
  2944. * @param mesh defines the mesh to attach to
  2945. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  2946. */
  2947. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  2948. /**
  2949. * Move the focus to a specific control
  2950. * @param control defines the control which will receive the focus
  2951. */
  2952. moveFocusToControl(control: IFocusableControl): void;
  2953. /**
  2954. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  2955. * @param mesh defines the mesh which will receive the texture
  2956. * @param width defines the texture width (1024 by default)
  2957. * @param height defines the texture height (1024 by default)
  2958. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  2959. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  2960. * @returns a new AdvancedDynamicTexture
  2961. */
  2962. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  2963. /**
  2964. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  2965. * In this mode the texture will rely on a layer for its rendering.
  2966. * This allows it to be treated like any other layer.
  2967. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  2968. * LayerMask is set through advancedTexture.layer.layerMask
  2969. * @param name defines name for the texture
  2970. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  2971. * @param scene defines the hsoting scene
  2972. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  2973. * @returns a new AdvancedDynamicTexture
  2974. */
  2975. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  2976. }
  2977. }
  2978. declare module BABYLON.GUI {
  2979. /**
  2980. * Class used to transport BABYLON.Vector2 information for pointer events
  2981. */
  2982. export class Vector2WithInfo extends BABYLON.Vector2 {
  2983. /** defines the current mouse button index */
  2984. buttonIndex: number;
  2985. /**
  2986. * Creates a new Vector2WithInfo
  2987. * @param source defines the vector2 data to transport
  2988. * @param buttonIndex defines the current mouse button index
  2989. */
  2990. constructor(source: BABYLON.Vector2,
  2991. /** defines the current mouse button index */
  2992. buttonIndex?: number);
  2993. }
  2994. /** Class used to provide 2D matrix features */
  2995. export class Matrix2D {
  2996. /** Gets the internal array of 6 floats used to store matrix data */
  2997. m: Float32Array;
  2998. /**
  2999. * Creates a new matrix
  3000. * @param m00 defines value for (0, 0)
  3001. * @param m01 defines value for (0, 1)
  3002. * @param m10 defines value for (1, 0)
  3003. * @param m11 defines value for (1, 1)
  3004. * @param m20 defines value for (2, 0)
  3005. * @param m21 defines value for (2, 1)
  3006. */
  3007. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  3008. /**
  3009. * Fills the matrix from direct values
  3010. * @param m00 defines value for (0, 0)
  3011. * @param m01 defines value for (0, 1)
  3012. * @param m10 defines value for (1, 0)
  3013. * @param m11 defines value for (1, 1)
  3014. * @param m20 defines value for (2, 0)
  3015. * @param m21 defines value for (2, 1)
  3016. * @returns the current modified matrix
  3017. */
  3018. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  3019. /**
  3020. * Gets matrix determinant
  3021. * @returns the determinant
  3022. */
  3023. determinant(): number;
  3024. /**
  3025. * Inverses the matrix and stores it in a target matrix
  3026. * @param result defines the target matrix
  3027. * @returns the current matrix
  3028. */
  3029. invertToRef(result: Matrix2D): Matrix2D;
  3030. /**
  3031. * Multiplies the current matrix with another one
  3032. * @param other defines the second operand
  3033. * @param result defines the target matrix
  3034. * @returns the current matrix
  3035. */
  3036. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  3037. /**
  3038. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  3039. * @param x defines the x coordinate to transform
  3040. * @param y defines the x coordinate to transform
  3041. * @param result defines the target vector2
  3042. * @returns the current matrix
  3043. */
  3044. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  3045. /**
  3046. * Creates an identity matrix
  3047. * @returns a new matrix
  3048. */
  3049. static Identity(): Matrix2D;
  3050. /**
  3051. * Creates a translation matrix and stores it in a target matrix
  3052. * @param x defines the x coordinate of the translation
  3053. * @param y defines the y coordinate of the translation
  3054. * @param result defines the target matrix
  3055. */
  3056. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  3057. /**
  3058. * Creates a scaling matrix and stores it in a target matrix
  3059. * @param x defines the x coordinate of the scaling
  3060. * @param y defines the y coordinate of the scaling
  3061. * @param result defines the target matrix
  3062. */
  3063. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  3064. /**
  3065. * Creates a rotation matrix and stores it in a target matrix
  3066. * @param angle defines the rotation angle
  3067. * @param result defines the target matrix
  3068. */
  3069. static RotationToRef(angle: number, result: Matrix2D): void;
  3070. /**
  3071. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  3072. * @param tx defines the x coordinate of the translation
  3073. * @param ty defines the y coordinate of the translation
  3074. * @param angle defines the rotation angle
  3075. * @param scaleX defines the x coordinate of the scaling
  3076. * @param scaleY defines the y coordinate of the scaling
  3077. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  3078. * @param result defines the target matrix
  3079. */
  3080. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  3081. }
  3082. }
  3083. declare module BABYLON.GUI {
  3084. /**
  3085. * Class used to store 2D control sizes
  3086. */
  3087. export class Measure {
  3088. /** defines left coordinate */
  3089. left: number;
  3090. /** defines top coordinate */
  3091. top: number;
  3092. /** defines width dimension */
  3093. width: number;
  3094. /** defines height dimension */
  3095. height: number;
  3096. /**
  3097. * Creates a new measure
  3098. * @param left defines left coordinate
  3099. * @param top defines top coordinate
  3100. * @param width defines width dimension
  3101. * @param height defines height dimension
  3102. */
  3103. constructor(
  3104. /** defines left coordinate */
  3105. left: number,
  3106. /** defines top coordinate */
  3107. top: number,
  3108. /** defines width dimension */
  3109. width: number,
  3110. /** defines height dimension */
  3111. height: number);
  3112. /**
  3113. * Copy from another measure
  3114. * @param other defines the other measure to copy from
  3115. */
  3116. copyFrom(other: Measure): void;
  3117. /**
  3118. * Check equality between this measure and another one
  3119. * @param other defines the other measures
  3120. * @returns true if both measures are equals
  3121. */
  3122. isEqualsTo(other: Measure): boolean;
  3123. /**
  3124. * Creates an empty measure
  3125. * @returns a new measure
  3126. */
  3127. static Empty(): Measure;
  3128. }
  3129. }
  3130. declare module BABYLON.GUI {
  3131. /**
  3132. * Class used to store a point for a MultiLine object.
  3133. * The point can be pure 2D coordinates, a mesh or a control
  3134. */
  3135. export class MultiLinePoint {
  3136. /** @hidden */
  3137. _point: BABYLON.Vector2;
  3138. /**
  3139. * Creates a new MultiLinePoint
  3140. * @param multiLine defines the source MultiLine object
  3141. */
  3142. constructor(multiLine: MultiLine);
  3143. /** Gets or sets x coordinate */
  3144. x: string | number;
  3145. /** Gets or sets y coordinate */
  3146. y: string | number;
  3147. /** Gets or sets the control associated with this point */
  3148. control: BABYLON.Nullable<Control>;
  3149. /** Gets or sets the mesh associated with this point */
  3150. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  3151. /** Resets links */
  3152. resetLinks(): void;
  3153. /**
  3154. * Gets a translation vector
  3155. * @returns the translation vector
  3156. */
  3157. translate(): BABYLON.Vector2;
  3158. /** Release associated resources */
  3159. dispose(): void;
  3160. }
  3161. }
  3162. declare module BABYLON.GUI {
  3163. /**
  3164. * Define a style used by control to automatically setup properties based on a template.
  3165. * Only support font related properties so far
  3166. */
  3167. export class Style implements BABYLON.IDisposable {
  3168. /** @hidden */
  3169. _host: AdvancedDynamicTexture;
  3170. /** @hidden */
  3171. _fontSize: ValueAndUnit;
  3172. /**
  3173. * BABYLON.Observable raised when the style values are changed
  3174. */
  3175. onChangedObservable: BABYLON.Observable<Style>;
  3176. /**
  3177. * Creates a new style object
  3178. * @param host defines the AdvancedDynamicTexture which hosts this style
  3179. */
  3180. constructor(host: AdvancedDynamicTexture);
  3181. /**
  3182. * Gets or sets the font size
  3183. */
  3184. fontSize: string | number;
  3185. /**
  3186. * Gets or sets the font family
  3187. */
  3188. fontFamily: string;
  3189. /**
  3190. * Gets or sets the font style
  3191. */
  3192. fontStyle: string;
  3193. /** Gets or sets font weight */
  3194. fontWeight: string;
  3195. /** Dispose all associated resources */
  3196. dispose(): void;
  3197. }
  3198. }
  3199. declare module BABYLON.GUI {
  3200. /**
  3201. * Class used to specific a value and its associated unit
  3202. */
  3203. export class ValueAndUnit {
  3204. /** defines the unit to store */
  3205. unit: number;
  3206. /** defines a boolean indicating if the value can be negative */
  3207. negativeValueAllowed: boolean;
  3208. /**
  3209. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  3210. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  3211. */
  3212. ignoreAdaptiveScaling: boolean;
  3213. /**
  3214. * Creates a new ValueAndUnit
  3215. * @param value defines the value to store
  3216. * @param unit defines the unit to store
  3217. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  3218. */
  3219. constructor(value: number,
  3220. /** defines the unit to store */
  3221. unit?: number,
  3222. /** defines a boolean indicating if the value can be negative */
  3223. negativeValueAllowed?: boolean);
  3224. /** Gets a boolean indicating if the value is a percentage */
  3225. readonly isPercentage: boolean;
  3226. /** Gets a boolean indicating if the value is store as pixel */
  3227. readonly isPixel: boolean;
  3228. /** Gets direct internal value */
  3229. readonly internalValue: number;
  3230. /**
  3231. * Gets value as pixel
  3232. * @param host defines the root host
  3233. * @param refValue defines the reference value for percentages
  3234. * @returns the value as pixel
  3235. */
  3236. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  3237. /**
  3238. * Gets the value accordingly to its unit
  3239. * @param host defines the root host
  3240. * @returns the value
  3241. */
  3242. getValue(host: AdvancedDynamicTexture): number;
  3243. /**
  3244. * Gets a string representation of the value
  3245. * @param host defines the root host
  3246. * @returns a string
  3247. */
  3248. toString(host: AdvancedDynamicTexture): string;
  3249. /**
  3250. * Store a value parsed from a string
  3251. * @param source defines the source string
  3252. * @returns true if the value was successfully parsed
  3253. */
  3254. fromString(source: string | number): boolean;
  3255. /** UNITMODE_PERCENTAGE */
  3256. static readonly UNITMODE_PERCENTAGE: number;
  3257. /** UNITMODE_PIXEL */
  3258. static readonly UNITMODE_PIXEL: number;
  3259. }
  3260. }
  3261. declare module BABYLON.GUI {
  3262. /**
  3263. * Class used to manage 3D user interface
  3264. * @see http://doc.babylonjs.com/how_to/gui3d
  3265. */
  3266. export class GUI3DManager implements BABYLON.IDisposable {
  3267. /** @hidden */
  3268. _lastPickedControl: Control3D;
  3269. /** @hidden */
  3270. _lastControlOver: {
  3271. [pointerId: number]: Control3D;
  3272. };
  3273. /** @hidden */
  3274. _lastControlDown: {
  3275. [pointerId: number]: Control3D;
  3276. };
  3277. /**
  3278. * BABYLON.Observable raised when the point picked by the pointer events changed
  3279. */
  3280. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  3281. /** @hidden */
  3282. _sharedMaterials: {
  3283. [key: string]: BABYLON.Material;
  3284. };
  3285. /** Gets the hosting scene */
  3286. readonly scene: BABYLON.Scene;
  3287. /** Gets associated utility layer */
  3288. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  3289. /**
  3290. * Creates a new GUI3DManager
  3291. * @param scene
  3292. */
  3293. constructor(scene?: BABYLON.Scene);
  3294. /**
  3295. * Gets the root container
  3296. */
  3297. readonly rootContainer: Container3D;
  3298. /**
  3299. * Gets a boolean indicating if the given control is in the root child list
  3300. * @param control defines the control to check
  3301. * @returns true if the control is in the root child list
  3302. */
  3303. containsControl(control: Control3D): boolean;
  3304. /**
  3305. * Adds a control to the root child list
  3306. * @param control defines the control to add
  3307. * @returns the current manager
  3308. */
  3309. addControl(control: Control3D): GUI3DManager;
  3310. /**
  3311. * Removes a control from the root child list
  3312. * @param control defines the control to remove
  3313. * @returns the current container
  3314. */
  3315. removeControl(control: Control3D): GUI3DManager;
  3316. /**
  3317. * Releases all associated resources
  3318. */
  3319. dispose(): void;
  3320. }
  3321. }
  3322. declare module BABYLON.GUI {
  3323. /**
  3324. * Class used to transport BABYLON.Vector3 information for pointer events
  3325. */
  3326. export class Vector3WithInfo extends BABYLON.Vector3 {
  3327. /** defines the current mouse button index */
  3328. buttonIndex: number;
  3329. /**
  3330. * Creates a new Vector3WithInfo
  3331. * @param source defines the vector3 data to transport
  3332. * @param buttonIndex defines the current mouse button index
  3333. */
  3334. constructor(source: BABYLON.Vector3,
  3335. /** defines the current mouse button index */
  3336. buttonIndex?: number);
  3337. }
  3338. }
  3339. declare module BABYLON.GUI {
  3340. /**
  3341. * Class used to create 2D buttons
  3342. */
  3343. export class Button extends Rectangle {
  3344. name?: string | undefined;
  3345. /**
  3346. * Function called to generate a pointer enter animation
  3347. */
  3348. pointerEnterAnimation: () => void;
  3349. /**
  3350. * Function called to generate a pointer out animation
  3351. */
  3352. pointerOutAnimation: () => void;
  3353. /**
  3354. * Function called to generate a pointer down animation
  3355. */
  3356. pointerDownAnimation: () => void;
  3357. /**
  3358. * Function called to generate a pointer up animation
  3359. */
  3360. pointerUpAnimation: () => void;
  3361. /**
  3362. * Creates a new Button
  3363. * @param name defines the name of the button
  3364. */
  3365. constructor(name?: string | undefined);
  3366. protected _getTypeName(): string;
  3367. /** @hidden */
  3368. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  3369. /** @hidden */
  3370. _onPointerEnter(target: Control): boolean;
  3371. /** @hidden */
  3372. _onPointerOut(target: Control): void;
  3373. /** @hidden */
  3374. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  3375. /** @hidden */
  3376. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3377. /**
  3378. * Creates a new button made with an image and a text
  3379. * @param name defines the name of the button
  3380. * @param text defines the text of the button
  3381. * @param imageUrl defines the url of the image
  3382. * @returns a new Button
  3383. */
  3384. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  3385. /**
  3386. * Creates a new button made with an image
  3387. * @param name defines the name of the button
  3388. * @param imageUrl defines the url of the image
  3389. * @returns a new Button
  3390. */
  3391. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  3392. /**
  3393. * Creates a new button made with a text
  3394. * @param name defines the name of the button
  3395. * @param text defines the text of the button
  3396. * @returns a new Button
  3397. */
  3398. static CreateSimpleButton(name: string, text: string): Button;
  3399. /**
  3400. * Creates a new button made with an image and a centered text
  3401. * @param name defines the name of the button
  3402. * @param text defines the text of the button
  3403. * @param imageUrl defines the url of the image
  3404. * @returns a new Button
  3405. */
  3406. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  3407. }
  3408. }
  3409. declare module BABYLON.GUI {
  3410. /**
  3411. * Class used to represent a 2D checkbox
  3412. */
  3413. export class Checkbox extends Control {
  3414. name?: string | undefined;
  3415. /** Gets or sets border thickness */
  3416. thickness: number;
  3417. /**
  3418. * BABYLON.Observable raised when isChecked property changes
  3419. */
  3420. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  3421. /** Gets or sets a value indicating the ratio between overall size and check size */
  3422. checkSizeRatio: number;
  3423. /** Gets or sets background color */
  3424. background: string;
  3425. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  3426. isChecked: boolean;
  3427. /**
  3428. * Creates a new CheckBox
  3429. * @param name defines the control name
  3430. */
  3431. constructor(name?: string | undefined);
  3432. protected _getTypeName(): string;
  3433. /** @hidden */
  3434. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3435. /** @hidden */
  3436. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  3437. /**
  3438. * Utility function to easily create a checkbox with a header
  3439. * @param title defines the label to use for the header
  3440. * @param onValueChanged defines the callback to call when value changes
  3441. * @returns a StackPanel containing the checkbox and a textBlock
  3442. */
  3443. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  3444. }
  3445. }
  3446. declare module BABYLON.GUI {
  3447. /** Class used to create color pickers */
  3448. export class ColorPicker extends Control {
  3449. name?: string | undefined;
  3450. /**
  3451. * BABYLON.Observable raised when the value changes
  3452. */
  3453. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  3454. /** Gets or sets the color of the color picker */
  3455. value: BABYLON.Color3;
  3456. /** Gets or sets control width */
  3457. width: string | number;
  3458. /** Gets or sets control height */
  3459. height: string | number;
  3460. /** Gets or sets control size */
  3461. size: string | number;
  3462. /**
  3463. * Creates a new ColorPicker
  3464. * @param name defines the control name
  3465. */
  3466. constructor(name?: string | undefined);
  3467. protected _getTypeName(): string;
  3468. /** @hidden */
  3469. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3470. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  3471. _onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  3472. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3473. }
  3474. }
  3475. declare module BABYLON.GUI {
  3476. /**
  3477. * Root class for 2D containers
  3478. * @see http://doc.babylonjs.com/how_to/gui#containers
  3479. */
  3480. export class Container extends Control {
  3481. name?: string | undefined;
  3482. /** @hidden */
  3483. protected _children: Control[];
  3484. /** @hidden */
  3485. protected _measureForChildren: Measure;
  3486. /** @hidden */
  3487. protected _background: string;
  3488. /** @hidden */
  3489. protected _adaptWidthToChildren: boolean;
  3490. /** @hidden */
  3491. protected _adaptHeightToChildren: boolean;
  3492. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3493. adaptHeightToChildren: boolean;
  3494. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3495. adaptWidthToChildren: boolean;
  3496. /** Gets or sets background color */
  3497. background: string;
  3498. /** Gets the list of children */
  3499. readonly children: Control[];
  3500. /**
  3501. * Creates a new Container
  3502. * @param name defines the name of the container
  3503. */
  3504. constructor(name?: string | undefined);
  3505. protected _getTypeName(): string;
  3506. _flagDescendantsAsMatrixDirty(): void;
  3507. /**
  3508. * Gets a child using its name
  3509. * @param name defines the child name to look for
  3510. * @returns the child control if found
  3511. */
  3512. getChildByName(name: string): BABYLON.Nullable<Control>;
  3513. /**
  3514. * Gets a child using its type and its name
  3515. * @param name defines the child name to look for
  3516. * @param type defines the child type to look for
  3517. * @returns the child control if found
  3518. */
  3519. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  3520. /**
  3521. * Search for a specific control in children
  3522. * @param control defines the control to look for
  3523. * @returns true if the control is in child list
  3524. */
  3525. containsControl(control: Control): boolean;
  3526. /**
  3527. * Adds a new control to the current container
  3528. * @param control defines the control to add
  3529. * @returns the current container
  3530. */
  3531. addControl(control: BABYLON.Nullable<Control>): Container;
  3532. /**
  3533. * Removes all controls from the current container
  3534. * @returns the current container
  3535. */
  3536. clearControls(): Container;
  3537. /**
  3538. * Removes a control from the current container
  3539. * @param control defines the control to remove
  3540. * @returns the current container
  3541. */
  3542. removeControl(control: Control): Container;
  3543. /** @hidden */
  3544. _reOrderControl(control: Control): void;
  3545. /** @hidden */
  3546. _markAllAsDirty(): void;
  3547. /** @hidden */
  3548. protected _localDraw(context: CanvasRenderingContext2D): void;
  3549. /** @hidden */
  3550. _link(root: BABYLON.Nullable<Container>, host: AdvancedDynamicTexture): void;
  3551. /** @hidden */
  3552. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3553. /** @hidden */
  3554. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  3555. /** @hidden */
  3556. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  3557. /** @hidden */
  3558. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3559. /** Releases associated resources */
  3560. dispose(): void;
  3561. }
  3562. }
  3563. declare module BABYLON.GUI {
  3564. /**
  3565. * Root class used for all 2D controls
  3566. * @see http://doc.babylonjs.com/how_to/gui#controls
  3567. */
  3568. export class Control {
  3569. /** defines the name of the control */
  3570. name?: string | undefined;
  3571. /** @hidden */
  3572. _root: BABYLON.Nullable<Container>;
  3573. /** @hidden */
  3574. _host: AdvancedDynamicTexture;
  3575. /** Gets or sets the control parent */
  3576. parent: BABYLON.Nullable<Container>;
  3577. /** @hidden */
  3578. _currentMeasure: Measure;
  3579. /** @hidden */
  3580. _width: ValueAndUnit;
  3581. /** @hidden */
  3582. _height: ValueAndUnit;
  3583. /** @hidden */
  3584. protected _fontOffset: {
  3585. ascent: number;
  3586. height: number;
  3587. descent: number;
  3588. };
  3589. /** @hidden */
  3590. protected _horizontalAlignment: number;
  3591. /** @hidden */
  3592. protected _verticalAlignment: number;
  3593. /** @hidden */
  3594. _tempParentMeasure: Measure;
  3595. /** @hidden */
  3596. protected _cachedParentMeasure: Measure;
  3597. /** @hidden */
  3598. _left: ValueAndUnit;
  3599. /** @hidden */
  3600. _top: ValueAndUnit;
  3601. /** @hidden */
  3602. protected _invertTransformMatrix: Matrix2D;
  3603. /** @hidden */
  3604. protected _transformedPosition: BABYLON.Vector2;
  3605. /** @hidden */
  3606. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  3607. protected _isEnabled: boolean;
  3608. protected _disabledColor: string;
  3609. /** @hidden */
  3610. _tag: any;
  3611. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3612. isHitTestVisible: boolean;
  3613. /** Gets or sets a boolean indicating if the control can block pointer events */
  3614. isPointerBlocker: boolean;
  3615. /** Gets or sets a boolean indicating if the control can be focusable */
  3616. isFocusInvisible: boolean;
  3617. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3618. shadowOffsetX: number;
  3619. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3620. shadowOffsetY: number;
  3621. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3622. shadowBlur: number;
  3623. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3624. shadowColor: string;
  3625. /** Gets or sets the cursor to use when the control is hovered */
  3626. hoverCursor: string;
  3627. /** @hidden */
  3628. protected _linkOffsetX: ValueAndUnit;
  3629. /** @hidden */
  3630. protected _linkOffsetY: ValueAndUnit;
  3631. /** Gets the control type name */
  3632. readonly typeName: string;
  3633. /**
  3634. * An event triggered when the pointer move over the control.
  3635. */
  3636. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  3637. /**
  3638. * An event triggered when the pointer move out of the control.
  3639. */
  3640. onPointerOutObservable: BABYLON.Observable<Control>;
  3641. /**
  3642. * An event triggered when the pointer taps the control
  3643. */
  3644. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  3645. /**
  3646. * An event triggered when pointer up
  3647. */
  3648. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  3649. /**
  3650. * An event triggered when a control is clicked on
  3651. */
  3652. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  3653. /**
  3654. * An event triggered when pointer enters the control
  3655. */
  3656. onPointerEnterObservable: BABYLON.Observable<Control>;
  3657. /**
  3658. * An event triggered when the control is marked as dirty
  3659. */
  3660. onDirtyObservable: BABYLON.Observable<Control>;
  3661. /**
  3662. * An event triggered after the control is drawn
  3663. */
  3664. onAfterDrawObservable: BABYLON.Observable<Control>;
  3665. /** Gets or set information about font offsets (used to render and align text) */
  3666. fontOffset: {
  3667. ascent: number;
  3668. height: number;
  3669. descent: number;
  3670. };
  3671. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3672. alpha: number;
  3673. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3674. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3675. */
  3676. scaleX: number;
  3677. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3678. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3679. */
  3680. scaleY: number;
  3681. /** Gets or sets the rotation angle (0 by default)
  3682. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3683. */
  3684. rotation: number;
  3685. /** Gets or sets the transformation center on Y axis (0 by default)
  3686. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3687. */
  3688. transformCenterY: number;
  3689. /** Gets or sets the transformation center on X axis (0 by default)
  3690. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3691. */
  3692. transformCenterX: number;
  3693. /**
  3694. * Gets or sets the horizontal alignment
  3695. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3696. */
  3697. horizontalAlignment: number;
  3698. /**
  3699. * Gets or sets the vertical alignment
  3700. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3701. */
  3702. verticalAlignment: number;
  3703. /**
  3704. * Gets or sets control width
  3705. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3706. */
  3707. width: string | number;
  3708. /**
  3709. * Gets control width in pixel
  3710. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3711. */
  3712. readonly widthInPixels: number;
  3713. /**
  3714. * Gets or sets control height
  3715. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3716. */
  3717. height: string | number;
  3718. /**
  3719. * Gets control height in pixel
  3720. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3721. */
  3722. readonly heightInPixels: number;
  3723. /** Gets or set font family */
  3724. fontFamily: string;
  3725. /** Gets or sets font style */
  3726. fontStyle: string;
  3727. /** Gets or sets font weight */
  3728. fontWeight: string;
  3729. /**
  3730. * Gets or sets style
  3731. * @see http://doc.babylonjs.com/how_to/gui#styles
  3732. */
  3733. style: BABYLON.Nullable<Style>;
  3734. /** @hidden */
  3735. readonly _isFontSizeInPercentage: boolean;
  3736. /** Gets font size in pixels */
  3737. readonly fontSizeInPixels: number;
  3738. /** Gets or sets font size */
  3739. fontSize: string | number;
  3740. /** Gets or sets foreground color */
  3741. color: string;
  3742. /** Gets or sets z index which is used to reorder controls on the z axis */
  3743. zIndex: number;
  3744. /** Gets or sets a boolean indicating if the control can be rendered */
  3745. notRenderable: boolean;
  3746. /** Gets or sets a boolean indicating if the control is visible */
  3747. isVisible: boolean;
  3748. /** Gets a boolean indicating that the control needs to update its rendering */
  3749. readonly isDirty: boolean;
  3750. /**
  3751. * Gets the current linked mesh (or null if none)
  3752. */
  3753. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  3754. /**
  3755. * Gets or sets a value indicating the padding to use on the left of the control
  3756. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3757. */
  3758. paddingLeft: string | number;
  3759. /**
  3760. * Gets a value indicating the padding in pixels to use on the left of the control
  3761. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3762. */
  3763. readonly paddingLeftInPixels: number;
  3764. /**
  3765. * Gets or sets a value indicating the padding to use on the right of the control
  3766. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3767. */
  3768. paddingRight: string | number;
  3769. /**
  3770. * Gets a value indicating the padding in pixels to use on the right of the control
  3771. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3772. */
  3773. readonly paddingRightInPixels: number;
  3774. /**
  3775. * Gets or sets a value indicating the padding to use on the top of the control
  3776. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3777. */
  3778. paddingTop: string | number;
  3779. /**
  3780. * Gets a value indicating the padding in pixels to use on the top of the control
  3781. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3782. */
  3783. readonly paddingTopInPixels: number;
  3784. /**
  3785. * Gets or sets a value indicating the padding to use on the bottom of the control
  3786. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3787. */
  3788. paddingBottom: string | number;
  3789. /**
  3790. * Gets a value indicating the padding in pixels to use on the bottom of the control
  3791. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3792. */
  3793. readonly paddingBottomInPixels: number;
  3794. /**
  3795. * Gets or sets a value indicating the left coordinate of the control
  3796. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3797. */
  3798. left: string | number;
  3799. /**
  3800. * Gets a value indicating the left coordinate in pixels of the control
  3801. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3802. */
  3803. readonly leftInPixels: number;
  3804. /**
  3805. * Gets or sets a value indicating the top coordinate of the control
  3806. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3807. */
  3808. top: string | number;
  3809. /**
  3810. * Gets a value indicating the top coordinate in pixels of the control
  3811. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3812. */
  3813. readonly topInPixels: number;
  3814. /**
  3815. * Gets or sets a value indicating the offset on X axis to the linked mesh
  3816. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  3817. */
  3818. linkOffsetX: string | number;
  3819. /**
  3820. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  3821. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  3822. */
  3823. readonly linkOffsetXInPixels: number;
  3824. /**
  3825. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  3826. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  3827. */
  3828. linkOffsetY: string | number;
  3829. /**
  3830. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  3831. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  3832. */
  3833. readonly linkOffsetYInPixels: number;
  3834. /** Gets the center coordinate on X axis */
  3835. readonly centerX: number;
  3836. /** Gets the center coordinate on Y axis */
  3837. readonly centerY: number;
  3838. /** Gets or sets if control is Enabled*/
  3839. isEnabled: boolean;
  3840. /** Gets or sets background color of control if it's disabled*/
  3841. disabledColor: string;
  3842. /**
  3843. * Creates a new control
  3844. * @param name defines the name of the control
  3845. */
  3846. constructor(
  3847. /** defines the name of the control */
  3848. name?: string | undefined);
  3849. /** @hidden */
  3850. protected _getTypeName(): string;
  3851. /** @hidden */
  3852. _resetFontCache(): void;
  3853. /**
  3854. * Determines if a container is an ascendant of the current control
  3855. * @param container defines the container to look for
  3856. * @returns true if the container is one of the ascendant of the control
  3857. */
  3858. isAscendant(container: Control): boolean;
  3859. /**
  3860. * Gets coordinates in local control space
  3861. * @param globalCoordinates defines the coordinates to transform
  3862. * @returns the new coordinates in local space
  3863. */
  3864. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  3865. /**
  3866. * Gets coordinates in local control space
  3867. * @param globalCoordinates defines the coordinates to transform
  3868. * @param result defines the target vector2 where to store the result
  3869. * @returns the current control
  3870. */
  3871. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  3872. /**
  3873. * Gets coordinates in parent local control space
  3874. * @param globalCoordinates defines the coordinates to transform
  3875. * @returns the new coordinates in parent local space
  3876. */
  3877. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  3878. /**
  3879. * Move the current control to a vector3 position projected onto the screen.
  3880. * @param position defines the target position
  3881. * @param scene defines the hosting scene
  3882. */
  3883. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  3884. /**
  3885. * Link current control with a target mesh
  3886. * @param mesh defines the mesh to link with
  3887. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  3888. */
  3889. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  3890. /** @hidden */
  3891. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  3892. /** @hidden */
  3893. _markMatrixAsDirty(): void;
  3894. /** @hidden */
  3895. _flagDescendantsAsMatrixDirty(): void;
  3896. /** @hidden */
  3897. _markAsDirty(force?: boolean): void;
  3898. /** @hidden */
  3899. _markAllAsDirty(): void;
  3900. /** @hidden */
  3901. _link(root: BABYLON.Nullable<Container>, host: AdvancedDynamicTexture): void;
  3902. /** @hidden */
  3903. protected _transform(context: CanvasRenderingContext2D): void;
  3904. /** @hidden */
  3905. protected _applyStates(context: CanvasRenderingContext2D): void;
  3906. /** @hidden */
  3907. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  3908. /** @hidden */
  3909. protected _clip(context: CanvasRenderingContext2D): void;
  3910. /** @hidden */
  3911. _measure(): void;
  3912. /** @hidden */
  3913. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3914. /** @hidden */
  3915. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3916. /** @hidden */
  3917. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3918. /** @hidden */
  3919. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3920. /**
  3921. * Tests if a given coordinates belong to the current control
  3922. * @param x defines x coordinate to test
  3923. * @param y defines y coordinate to test
  3924. * @returns true if the coordinates are inside the control
  3925. */
  3926. contains(x: number, y: number): boolean;
  3927. /** @hidden */
  3928. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  3929. /** @hidden */
  3930. _onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  3931. /** @hidden */
  3932. _onPointerEnter(target: Control): boolean;
  3933. /** @hidden */
  3934. _onPointerOut(target: Control): void;
  3935. /** @hidden */
  3936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  3937. /** @hidden */
  3938. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3939. /** @hidden */
  3940. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  3941. /** @hidden */
  3942. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  3943. /** Releases associated resources */
  3944. dispose(): void;
  3945. /** HORIZONTAL_ALIGNMENT_LEFT */
  3946. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  3947. /** HORIZONTAL_ALIGNMENT_RIGHT */
  3948. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  3949. /** HORIZONTAL_ALIGNMENT_CENTER */
  3950. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  3951. /** VERTICAL_ALIGNMENT_TOP */
  3952. static readonly VERTICAL_ALIGNMENT_TOP: number;
  3953. /** VERTICAL_ALIGNMENT_BOTTOM */
  3954. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  3955. /** VERTICAL_ALIGNMENT_CENTER */
  3956. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  3957. /** @hidden */
  3958. static _GetFontOffset(font: string): {
  3959. ascent: number;
  3960. height: number;
  3961. descent: number;
  3962. };
  3963. /**
  3964. * Creates a stack panel that can be used to render headers
  3965. * @param control defines the control to associate with the header
  3966. * @param text defines the text of the header
  3967. * @param size defines the size of the header
  3968. * @param options defines options used to configure the header
  3969. * @returns a new StackPanel
  3970. * @ignore
  3971. * @hidden
  3972. */
  3973. static AddHeader: (control: Control, text: string, size: string | number, options: {
  3974. isHorizontal: boolean;
  3975. controlFirst: boolean;
  3976. }) => any;
  3977. /** @hidden */
  3978. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  3979. }
  3980. }
  3981. declare module BABYLON.GUI {
  3982. /** Class used to create 2D ellipse containers */
  3983. export class Ellipse extends Container {
  3984. name?: string | undefined;
  3985. /** Gets or sets border thickness */
  3986. thickness: number;
  3987. /**
  3988. * Creates a new Ellipse
  3989. * @param name defines the control name
  3990. */
  3991. constructor(name?: string | undefined);
  3992. protected _getTypeName(): string;
  3993. protected _localDraw(context: CanvasRenderingContext2D): void;
  3994. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  3995. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  3996. }
  3997. }
  3998. declare module BABYLON.GUI {
  3999. /**
  4000. * Class used to create a 2D grid container
  4001. */
  4002. export class Grid extends Container {
  4003. name?: string | undefined;
  4004. /** Gets the list of children */
  4005. readonly children: Control[];
  4006. /**
  4007. * Adds a new row to the grid
  4008. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  4009. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  4010. * @returns the current grid
  4011. */
  4012. addRowDefinition(height: number, isPixel?: boolean): Grid;
  4013. /**
  4014. * Adds a new column to the grid
  4015. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  4016. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  4017. * @returns the current grid
  4018. */
  4019. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  4020. /**
  4021. * Update a row definition
  4022. * @param index defines the index of the row to update
  4023. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  4024. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  4025. * @returns the current grid
  4026. */
  4027. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  4028. /**
  4029. * Update a column definition
  4030. * @param index defines the index of the column to update
  4031. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  4032. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  4033. * @returns the current grid
  4034. */
  4035. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  4036. /**
  4037. * Remove a column definition at specified index
  4038. * @param index defines the index of the column to remove
  4039. * @returns the current grid
  4040. */
  4041. removeColumnDefinition(index: number): Grid;
  4042. /**
  4043. * Remove a row definition at specified index
  4044. * @param index defines the index of the row to remove
  4045. * @returns the current grid
  4046. */
  4047. removeRowDefinition(index: number): Grid;
  4048. /**
  4049. * Adds a new control to the current grid
  4050. * @param control defines the control to add
  4051. * @param row defines the row where to add the control (0 by default)
  4052. * @param column defines the column where to add the control (0 by default)
  4053. * @returns the current grid
  4054. */
  4055. addControl(control: Control, row?: number, column?: number): Grid;
  4056. /**
  4057. * Removes a control from the current container
  4058. * @param control defines the control to remove
  4059. * @returns the current container
  4060. */
  4061. removeControl(control: Control): Container;
  4062. /**
  4063. * Creates a new Grid
  4064. * @param name defines control name
  4065. */
  4066. constructor(name?: string | undefined);
  4067. protected _getTypeName(): string;
  4068. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4069. /** Releases associated resources */
  4070. dispose(): void;
  4071. }
  4072. }
  4073. declare module BABYLON.GUI {
  4074. /**
  4075. * Class used to create 2D images
  4076. */
  4077. export class Image extends Control {
  4078. name?: string | undefined;
  4079. /**
  4080. * Gets or sets the left coordinate in the source image
  4081. */
  4082. sourceLeft: number;
  4083. /**
  4084. * Gets or sets the top coordinate in the source image
  4085. */
  4086. sourceTop: number;
  4087. /**
  4088. * Gets or sets the width to capture in the source image
  4089. */
  4090. sourceWidth: number;
  4091. /**
  4092. * Gets or sets the height to capture in the source image
  4093. */
  4094. sourceHeight: number;
  4095. /**
  4096. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  4097. * @see http://doc.babylonjs.com/how_to/gui#image
  4098. */
  4099. autoScale: boolean;
  4100. /** Gets or sets the streching mode used by the image */
  4101. stretch: number;
  4102. /**
  4103. * Gets or sets the internal DOM image used to render the control
  4104. */
  4105. domImage: HTMLImageElement;
  4106. /**
  4107. * Gets or sets image source url
  4108. */
  4109. source: BABYLON.Nullable<string>;
  4110. /**
  4111. * Gets or sets the cell width to use when animation sheet is enabled
  4112. * @see http://doc.babylonjs.com/how_to/gui#image
  4113. */
  4114. cellWidth: number;
  4115. /**
  4116. * Gets or sets the cell height to use when animation sheet is enabled
  4117. * @see http://doc.babylonjs.com/how_to/gui#image
  4118. */
  4119. cellHeight: number;
  4120. /**
  4121. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  4122. * @see http://doc.babylonjs.com/how_to/gui#image
  4123. */
  4124. cellId: number;
  4125. /**
  4126. * Creates a new Image
  4127. * @param name defines the control name
  4128. * @param url defines the image url
  4129. */
  4130. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  4131. protected _getTypeName(): string;
  4132. /** Force the control to synchronize with its content */
  4133. synchronizeSizeWithContent(): void;
  4134. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4135. /** STRETCH_NONE */
  4136. static readonly STRETCH_NONE: number;
  4137. /** STRETCH_FILL */
  4138. static readonly STRETCH_FILL: number;
  4139. /** STRETCH_UNIFORM */
  4140. static readonly STRETCH_UNIFORM: number;
  4141. /** STRETCH_EXTEND */
  4142. static readonly STRETCH_EXTEND: number;
  4143. }
  4144. }
  4145. declare module BABYLON.GUI {
  4146. /**
  4147. * Class used to create input text control
  4148. */
  4149. export class InputText extends Control implements IFocusableControl {
  4150. name?: string | undefined;
  4151. /** @hidden */
  4152. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  4153. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  4154. promptMessage: string;
  4155. /** BABYLON.Observable raised when the text changes */
  4156. onTextChangedObservable: BABYLON.Observable<InputText>;
  4157. /** BABYLON.Observable raised just before an entered character is to be added */
  4158. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  4159. /** BABYLON.Observable raised when the control gets the focus */
  4160. onFocusObservable: BABYLON.Observable<InputText>;
  4161. /** BABYLON.Observable raised when the control loses the focus */
  4162. onBlurObservable: BABYLON.Observable<InputText>;
  4163. /** Gets or sets the maximum width allowed by the control */
  4164. maxWidth: string | number;
  4165. /** Gets the maximum width allowed by the control in pixels */
  4166. readonly maxWidthInPixels: number;
  4167. /** Gets or sets control margin */
  4168. margin: string;
  4169. /** Gets control margin in pixels */
  4170. readonly marginInPixels: number;
  4171. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  4172. autoStretchWidth: boolean;
  4173. /** Gets or sets border thickness */
  4174. thickness: number;
  4175. /** Gets or sets the background color when focused */
  4176. focusedBackground: string;
  4177. /** Gets or sets the background color */
  4178. background: string;
  4179. /** Gets or sets the placeholder color */
  4180. placeholderColor: string;
  4181. /** Gets or sets the text displayed when the control is empty */
  4182. placeholderText: string;
  4183. /** Gets or sets the dead key flag */
  4184. deadKey: boolean;
  4185. /** Gets or sets if the current key should be added */
  4186. addKey: boolean;
  4187. /** Gets or sets the value of the current key being entered */
  4188. currentKey: string;
  4189. /** Gets or sets the text displayed in the control */
  4190. text: string;
  4191. /** Gets or sets control width */
  4192. width: string | number;
  4193. /**
  4194. * Creates a new InputText
  4195. * @param name defines the control name
  4196. * @param text defines the text of the control
  4197. */
  4198. constructor(name?: string | undefined, text?: string);
  4199. /** @hidden */
  4200. onBlur(): void;
  4201. /** @hidden */
  4202. onFocus(): void;
  4203. protected _getTypeName(): string;
  4204. /**
  4205. * Function called to get the list of controls that should not steal the focus from this control
  4206. * @returns an array of controls
  4207. */
  4208. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  4209. /** @hidden */
  4210. processKey(keyCode: number, key?: string): void;
  4211. /** @hidden */
  4212. processKeyboard(evt: KeyboardEvent): void;
  4213. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4214. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  4215. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  4216. protected _beforeRenderText(text: string): string;
  4217. dispose(): void;
  4218. }
  4219. }
  4220. declare module BABYLON.GUI {
  4221. /**
  4222. * Class used to create a password control
  4223. */
  4224. export class InputPassword extends InputText {
  4225. protected _beforeRenderText(text: string): string;
  4226. }
  4227. }
  4228. declare module BABYLON.GUI {
  4229. /** Class used to render 2D lines */
  4230. export class Line extends Control {
  4231. name?: string | undefined;
  4232. /** Gets or sets the dash pattern */
  4233. dash: Array<number>;
  4234. /** Gets or sets the control connected with the line end */
  4235. connectedControl: Control;
  4236. /** Gets or sets start coordinates on X axis */
  4237. x1: string | number;
  4238. /** Gets or sets start coordinates on Y axis */
  4239. y1: string | number;
  4240. /** Gets or sets end coordinates on X axis */
  4241. x2: string | number;
  4242. /** Gets or sets end coordinates on Y axis */
  4243. y2: string | number;
  4244. /** Gets or sets line width */
  4245. lineWidth: number;
  4246. /** Gets or sets horizontal alignment */
  4247. horizontalAlignment: number;
  4248. /** Gets or sets vertical alignment */
  4249. verticalAlignment: number;
  4250. /**
  4251. * Creates a new Line
  4252. * @param name defines the control name
  4253. */
  4254. constructor(name?: string | undefined);
  4255. protected _getTypeName(): string;
  4256. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4257. _measure(): void;
  4258. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4259. /**
  4260. * Move one end of the line given 3D cartesian coordinates.
  4261. * @param position Targeted world position
  4262. * @param scene BABYLON.Scene
  4263. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  4264. */
  4265. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  4266. /**
  4267. * Move one end of the line to a position in screen absolute space.
  4268. * @param projectedPosition Position in screen absolute space (X, Y)
  4269. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  4270. */
  4271. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  4272. }
  4273. }
  4274. declare module BABYLON.GUI {
  4275. /**
  4276. * Class used to create multi line control
  4277. */
  4278. export class MultiLine extends Control {
  4279. name?: string | undefined;
  4280. /**
  4281. * Creates a new MultiLine
  4282. * @param name defines the control name
  4283. */
  4284. constructor(name?: string | undefined);
  4285. /** Gets or sets dash pattern */
  4286. dash: Array<number>;
  4287. /**
  4288. * Gets point stored at specified index
  4289. * @param index defines the index to look for
  4290. * @returns the requested point if found
  4291. */
  4292. getAt(index: number): MultiLinePoint;
  4293. /** Function called when a point is updated */
  4294. onPointUpdate: () => void;
  4295. /**
  4296. * Adds new points to the point collection
  4297. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  4298. * @returns the list of created MultiLinePoint
  4299. */
  4300. add(...items: (AbstractMesh | Control | {
  4301. x: string | number;
  4302. y: string | number;
  4303. })[]): MultiLinePoint[];
  4304. /**
  4305. * Adds a new point to the point collection
  4306. * @param item defines the item (mesh, control or 2d coordiantes) to add
  4307. * @returns the created MultiLinePoint
  4308. */
  4309. push(item?: (AbstractMesh | Control | {
  4310. x: string | number;
  4311. y: string | number;
  4312. })): MultiLinePoint;
  4313. /**
  4314. * Remove a specific value or point from the active point collection
  4315. * @param value defines the value or point to remove
  4316. */
  4317. remove(value: number | MultiLinePoint): void;
  4318. /**
  4319. * Resets this object to initial state (no point)
  4320. */
  4321. reset(): void;
  4322. /**
  4323. * Resets all links
  4324. */
  4325. resetLinks(): void;
  4326. /** Gets or sets line width */
  4327. lineWidth: number;
  4328. horizontalAlignment: number;
  4329. verticalAlignment: number;
  4330. protected _getTypeName(): string;
  4331. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4332. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4333. _measure(): void;
  4334. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4335. dispose(): void;
  4336. }
  4337. }
  4338. declare module BABYLON.GUI {
  4339. /**
  4340. * Class used to create radio button controls
  4341. */
  4342. export class RadioButton extends Control {
  4343. name?: string | undefined;
  4344. /** Gets or sets border thickness */
  4345. thickness: number;
  4346. /** Gets or sets group name */
  4347. group: string;
  4348. /** BABYLON.Observable raised when isChecked is changed */
  4349. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  4350. /** Gets or sets a value indicating the ratio between overall size and check size */
  4351. checkSizeRatio: number;
  4352. /** Gets or sets background color */
  4353. background: string;
  4354. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  4355. isChecked: boolean;
  4356. /**
  4357. * Creates a new RadioButton
  4358. * @param name defines the control name
  4359. */
  4360. constructor(name?: string | undefined);
  4361. protected _getTypeName(): string;
  4362. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4363. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  4364. /**
  4365. * Utility function to easily create a radio button with a header
  4366. * @param title defines the label to use for the header
  4367. * @param group defines the group to use for the radio button
  4368. * @param isChecked defines the initial state of the radio button
  4369. * @param onValueChanged defines the callback to call when value changes
  4370. * @returns a StackPanel containing the radio button and a textBlock
  4371. */
  4372. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  4373. }
  4374. }
  4375. declare module BABYLON.GUI {
  4376. /**
  4377. * Class used to create a 2D stack panel container
  4378. */
  4379. export class StackPanel extends Container {
  4380. name?: string | undefined;
  4381. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  4382. isVertical: boolean;
  4383. /** Gets or sets panel width */
  4384. width: string | number;
  4385. /** Gets or sets panel height */
  4386. height: string | number;
  4387. /**
  4388. * Creates a new StackPanel
  4389. * @param name defines control name
  4390. */
  4391. constructor(name?: string | undefined);
  4392. protected _getTypeName(): string;
  4393. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4394. }
  4395. }
  4396. declare module BABYLON.GUI {
  4397. /** Class used to create a RadioGroup
  4398. * which contains groups of radio buttons
  4399. */
  4400. export class SelectorGroup {
  4401. /** name of SelectorGroup */
  4402. name: string;
  4403. /**
  4404. * Creates a new SelectorGroup
  4405. * @param name of group, used as a group heading
  4406. */
  4407. constructor(
  4408. /** name of SelectorGroup */
  4409. name: string);
  4410. /** Gets the groupPanel of the SelectorGroup */
  4411. readonly groupPanel: StackPanel;
  4412. /** Gets the selectors array */
  4413. readonly selectors: StackPanel[];
  4414. /** Gets and sets the group header */
  4415. header: string;
  4416. /** @hidden*/
  4417. _getSelector(selectorNb: number): StackPanel | undefined;
  4418. /** Removes the selector at the given position
  4419. * @param selectorNb the position of the selector within the group
  4420. */
  4421. removeSelector(selectorNb: number): void;
  4422. }
  4423. /** Class used to create a CheckboxGroup
  4424. * which contains groups of checkbox buttons
  4425. */
  4426. export class CheckboxGroup extends SelectorGroup {
  4427. /** Adds a checkbox as a control
  4428. * @param text is the label for the selector
  4429. * @param func is the function called when the Selector is checked
  4430. * @param checked is true when Selector is checked
  4431. */
  4432. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  4433. /** @hidden */
  4434. _setSelectorLabel(selectorNb: number, label: string): void;
  4435. /** @hidden */
  4436. _setSelectorLabelColor(selectorNb: number, color: string): void;
  4437. /** @hidden */
  4438. _setSelectorButtonColor(selectorNb: number, color: string): void;
  4439. /** @hidden */
  4440. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  4441. }
  4442. /** Class used to create a RadioGroup
  4443. * which contains groups of radio buttons
  4444. */
  4445. export class RadioGroup extends SelectorGroup {
  4446. /** Adds a radio button as a control
  4447. * @param label is the label for the selector
  4448. * @param func is the function called when the Selector is checked
  4449. * @param checked is true when Selector is checked
  4450. */
  4451. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  4452. /** @hidden */
  4453. _setSelectorLabel(selectorNb: number, label: string): void;
  4454. /** @hidden */
  4455. _setSelectorLabelColor(selectorNb: number, color: string): void;
  4456. /** @hidden */
  4457. _setSelectorButtonColor(selectorNb: number, color: string): void;
  4458. /** @hidden */
  4459. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  4460. }
  4461. /** Class used to create a SliderGroup
  4462. * which contains groups of slider buttons
  4463. */
  4464. export class SliderGroup extends SelectorGroup {
  4465. /**
  4466. * Adds a slider to the SelectorGroup
  4467. * @param label is the label for the SliderBar
  4468. * @param func is the function called when the Slider moves
  4469. * @param unit is a string describing the units used, eg degrees or metres
  4470. * @param min is the minimum value for the Slider
  4471. * @param max is the maximum value for the Slider
  4472. * @param value is the start value for the Slider between min and max
  4473. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  4474. */
  4475. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  4476. /** @hidden */
  4477. _setSelectorLabel(selectorNb: number, label: string): void;
  4478. /** @hidden */
  4479. _setSelectorLabelColor(selectorNb: number, color: string): void;
  4480. /** @hidden */
  4481. _setSelectorButtonColor(selectorNb: number, color: string): void;
  4482. /** @hidden */
  4483. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  4484. }
  4485. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  4486. * @see http://doc.babylonjs.com/how_to/selector
  4487. */
  4488. export class SelectionPanel extends Rectangle {
  4489. /** name of SelectionPanel */
  4490. name: string;
  4491. /** an array of SelectionGroups */
  4492. groups: SelectorGroup[];
  4493. /**
  4494. * Creates a new SelectionPanel
  4495. * @param name of SelectionPanel
  4496. * @param groups is an array of SelectionGroups
  4497. */
  4498. constructor(
  4499. /** name of SelectionPanel */
  4500. name: string,
  4501. /** an array of SelectionGroups */
  4502. groups?: SelectorGroup[]);
  4503. protected _getTypeName(): string;
  4504. /** Gets or sets the headerColor */
  4505. headerColor: string;
  4506. /** Gets or sets the button color */
  4507. buttonColor: string;
  4508. /** Gets or sets the label color */
  4509. labelColor: string;
  4510. /** Gets or sets the button background */
  4511. buttonBackground: string;
  4512. /** Gets or sets the color of separator bar */
  4513. barColor: string;
  4514. /** Gets or sets the height of separator bar */
  4515. barHeight: string;
  4516. /** Gets or sets the height of spacers*/
  4517. spacerHeight: string;
  4518. /** Add a group to the selection panel
  4519. * @param group is the selector group to add
  4520. */
  4521. addGroup(group: SelectorGroup): void;
  4522. /** Remove the group from the given position
  4523. * @param groupNb is the position of the group in the list
  4524. */
  4525. removeGroup(groupNb: number): void;
  4526. /** Change a group header label
  4527. * @param label is the new group header label
  4528. * @param groupNb is the number of the group to relabel
  4529. * */
  4530. setHeaderName(label: string, groupNb: number): void;
  4531. /** Change selector label to the one given
  4532. * @param label is the new selector label
  4533. * @param groupNb is the number of the groupcontaining the selector
  4534. * @param selectorNb is the number of the selector within a group to relabel
  4535. * */
  4536. relabel(label: string, groupNb: number, selectorNb: number): void;
  4537. /** For a given group position remove the selector at the given position
  4538. * @param groupNb is the number of the group to remove the selector from
  4539. * @param selectorNb is the number of the selector within the group
  4540. */
  4541. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  4542. /** For a given group position of correct type add a checkbox button
  4543. * @param groupNb is the number of the group to remove the selector from
  4544. * @param label is the label for the selector
  4545. * @param func is the function called when the Selector is checked
  4546. * @param checked is true when Selector is checked
  4547. */
  4548. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  4549. /** For a given group position of correct type add a radio button
  4550. * @param groupNb is the number of the group to remove the selector from
  4551. * @param label is the label for the selector
  4552. * @param func is the function called when the Selector is checked
  4553. * @param checked is true when Selector is checked
  4554. */
  4555. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  4556. /**
  4557. * For a given slider group add a slider
  4558. * @param groupNb is the number of the group to add the slider to
  4559. * @param label is the label for the Slider
  4560. * @param func is the function called when the Slider moves
  4561. * @param unit is a string describing the units used, eg degrees or metres
  4562. * @param min is the minimum value for the Slider
  4563. * @param max is the maximum value for the Slider
  4564. * @param value is the start value for the Slider between min and max
  4565. * @param onVal is the function used to format the value displayed, eg radians to degrees
  4566. */
  4567. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  4568. }
  4569. }
  4570. declare module BABYLON.GUI {
  4571. /**
  4572. * Enum that determines the text-wrapping mode to use.
  4573. */
  4574. export enum TextWrapping {
  4575. /**
  4576. * Clip the text when it's larger than Control.width; this is the default mode.
  4577. */
  4578. Clip = 0,
  4579. /**
  4580. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  4581. */
  4582. WordWrap = 1,
  4583. /**
  4584. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  4585. */
  4586. Ellipsis = 2
  4587. }
  4588. /**
  4589. * Class used to create text block control
  4590. */
  4591. export class TextBlock extends Control {
  4592. /**
  4593. * Defines the name of the control
  4594. */
  4595. name?: string | undefined;
  4596. /**
  4597. * An event triggered after the text is changed
  4598. */
  4599. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  4600. /**
  4601. * An event triggered after the text was broken up into lines
  4602. */
  4603. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  4604. /**
  4605. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  4606. */
  4607. readonly lines: any[];
  4608. /**
  4609. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  4610. */
  4611. resizeToFit: boolean;
  4612. /**
  4613. * Gets or sets a boolean indicating if text must be wrapped
  4614. */
  4615. textWrapping: TextWrapping | boolean;
  4616. /**
  4617. * Gets or sets text to display
  4618. */
  4619. text: string;
  4620. /**
  4621. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  4622. */
  4623. textHorizontalAlignment: number;
  4624. /**
  4625. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  4626. */
  4627. textVerticalAlignment: number;
  4628. /**
  4629. * Gets or sets line spacing value
  4630. */
  4631. lineSpacing: string | number;
  4632. /**
  4633. * Gets or sets outlineWidth of the text to display
  4634. */
  4635. outlineWidth: number;
  4636. /**
  4637. * Gets or sets outlineColor of the text to display
  4638. */
  4639. outlineColor: string;
  4640. /**
  4641. * Creates a new TextBlock object
  4642. * @param name defines the name of the control
  4643. * @param text defines the text to display (emptry string by default)
  4644. */
  4645. constructor(
  4646. /**
  4647. * Defines the name of the control
  4648. */
  4649. name?: string | undefined, text?: string);
  4650. protected _getTypeName(): string;
  4651. /** @hidden */
  4652. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4653. protected _applyStates(context: CanvasRenderingContext2D): void;
  4654. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4655. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  4656. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  4657. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  4658. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  4659. protected _renderLines(context: CanvasRenderingContext2D): void;
  4660. /**
  4661. * Given a width constraint applied on the text block, find the expected height
  4662. * @returns expected height
  4663. */
  4664. computeExpectedHeight(): number;
  4665. dispose(): void;
  4666. }
  4667. }
  4668. declare module BABYLON.GUI {
  4669. /**
  4670. * Class used to store key control properties
  4671. */
  4672. export class KeyPropertySet {
  4673. /** Width */
  4674. width?: string;
  4675. /** Height */
  4676. height?: string;
  4677. /** Left padding */
  4678. paddingLeft?: string;
  4679. /** Right padding */
  4680. paddingRight?: string;
  4681. /** Top padding */
  4682. paddingTop?: string;
  4683. /** Bottom padding */
  4684. paddingBottom?: string;
  4685. /** Foreground color */
  4686. color?: string;
  4687. /** Background color */
  4688. background?: string;
  4689. }
  4690. /**
  4691. * Class used to create virtual keyboard
  4692. */
  4693. export class VirtualKeyboard extends StackPanel {
  4694. /** BABYLON.Observable raised when a key is pressed */
  4695. onKeyPressObservable: BABYLON.Observable<string>;
  4696. /** Gets or sets default key button width */
  4697. defaultButtonWidth: string;
  4698. /** Gets or sets default key button height */
  4699. defaultButtonHeight: string;
  4700. /** Gets or sets default key button left padding */
  4701. defaultButtonPaddingLeft: string;
  4702. /** Gets or sets default key button right padding */
  4703. defaultButtonPaddingRight: string;
  4704. /** Gets or sets default key button top padding */
  4705. defaultButtonPaddingTop: string;
  4706. /** Gets or sets default key button bottom padding */
  4707. defaultButtonPaddingBottom: string;
  4708. /** Gets or sets default key button foreground color */
  4709. defaultButtonColor: string;
  4710. /** Gets or sets default key button background color */
  4711. defaultButtonBackground: string;
  4712. /** Gets or sets shift button foreground color */
  4713. shiftButtonColor: string;
  4714. /** Gets or sets shift button thickness*/
  4715. selectedShiftThickness: number;
  4716. /** Gets shift key state */
  4717. shiftState: number;
  4718. protected _getTypeName(): string;
  4719. /**
  4720. * Adds a new row of keys
  4721. * @param keys defines the list of keys to add
  4722. * @param propertySets defines the associated property sets
  4723. */
  4724. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  4725. /**
  4726. * Set the shift key to a specific state
  4727. * @param shiftState defines the new shift state
  4728. */
  4729. applyShiftState(shiftState: number): void;
  4730. /** Gets the input text control currently attached to the keyboard */
  4731. readonly connectedInputText: BABYLON.Nullable<InputText>;
  4732. /**
  4733. * Connects the keyboard with an input text control
  4734. *
  4735. * @param input defines the target control
  4736. */
  4737. connect(input: InputText): void;
  4738. /**
  4739. * Disconnects the keyboard from connected InputText controls
  4740. *
  4741. * @param input optionally defines a target control, otherwise all are disconnected
  4742. */
  4743. disconnect(input?: InputText): void;
  4744. /**
  4745. * Release all resources
  4746. */
  4747. dispose(): void;
  4748. /**
  4749. * Creates a new keyboard using a default layout
  4750. *
  4751. * @param name defines control name
  4752. * @returns a new VirtualKeyboard
  4753. */
  4754. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  4755. }
  4756. }
  4757. declare module BABYLON.GUI {
  4758. /**
  4759. * Class used to create slider controls
  4760. */
  4761. export class Slider extends Control {
  4762. name?: string | undefined;
  4763. /** BABYLON.Observable raised when the sldier value changes */
  4764. onValueChangedObservable: BABYLON.Observable<number>;
  4765. /** Gets or sets border color */
  4766. borderColor: string;
  4767. /** Gets or sets background color */
  4768. background: string;
  4769. /** Gets or sets main bar offset */
  4770. barOffset: string | number;
  4771. /** Gets main bar offset in pixels*/
  4772. readonly barOffsetInPixels: number;
  4773. /** Gets or sets thumb width */
  4774. thumbWidth: string | number;
  4775. /** Gets thumb width in pixels */
  4776. readonly thumbWidthInPixels: number;
  4777. /** Gets or sets minimum value */
  4778. minimum: number;
  4779. /** Gets or sets maximum value */
  4780. maximum: number;
  4781. /** Gets or sets current value */
  4782. value: number;
  4783. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  4784. isVertical: boolean;
  4785. /** Gets or sets a boolean indicating if the thumb should be round or square */
  4786. isThumbCircle: boolean;
  4787. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  4788. isThumbClamped: boolean;
  4789. /**
  4790. * Creates a new Slider
  4791. * @param name defines the control name
  4792. */
  4793. constructor(name?: string | undefined);
  4794. protected _getTypeName(): string;
  4795. protected _getThumbThickness(type: string, backgroundLength: number): number;
  4796. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4797. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  4798. _onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  4799. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  4800. }
  4801. }
  4802. declare module BABYLON.GUI {
  4803. /** Class used to create rectangle container */
  4804. export class Rectangle extends Container {
  4805. name?: string | undefined;
  4806. /** Gets or sets border thickness */
  4807. thickness: number;
  4808. /** Gets or sets the corner radius angle */
  4809. cornerRadius: number;
  4810. /**
  4811. * Creates a new Rectangle
  4812. * @param name defines the control name
  4813. */
  4814. constructor(name?: string | undefined);
  4815. protected _getTypeName(): string;
  4816. protected _localDraw(context: CanvasRenderingContext2D): void;
  4817. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4818. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  4819. }
  4820. }
  4821. declare module BABYLON.GUI {
  4822. /** Class used to render a grid */
  4823. export class DisplayGrid extends Control {
  4824. name?: string | undefined;
  4825. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  4826. displayMinorLines: boolean;
  4827. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  4828. displayMajorLines: boolean;
  4829. /** Gets or sets background color (Black by default) */
  4830. background: string;
  4831. /** Gets or sets the width of each cell (20 by default) */
  4832. cellWidth: number;
  4833. /** Gets or sets the height of each cell (20 by default) */
  4834. cellHeight: number;
  4835. /** Gets or sets the tickness of minor lines (1 by default) */
  4836. minorLineTickness: number;
  4837. /** Gets or sets the color of minor lines (DarkGray by default) */
  4838. minorLineColor: string;
  4839. /** Gets or sets the tickness of major lines (2 by default) */
  4840. majorLineTickness: number;
  4841. /** Gets or sets the color of major lines (White by default) */
  4842. majorLineColor: string;
  4843. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  4844. majorLineFrequency: number;
  4845. /**
  4846. * Creates a new GridDisplayRectangle
  4847. * @param name defines the control name
  4848. */
  4849. constructor(name?: string | undefined);
  4850. _draw(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  4851. protected _getTypeName(): string;
  4852. }
  4853. }
  4854. declare module BABYLON.GUI {
  4855. /**
  4856. * Forcing an export so that this code will execute
  4857. * @hidden
  4858. */
  4859. const name = "Statics";
  4860. }
  4861. declare module BABYLON.GUI {
  4862. /**
  4863. * Class used as a root to all buttons
  4864. */
  4865. export class AbstractButton3D extends Control3D {
  4866. /**
  4867. * Creates a new button
  4868. * @param name defines the control name
  4869. */
  4870. constructor(name?: string);
  4871. protected _getTypeName(): string;
  4872. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  4873. }
  4874. }
  4875. declare module BABYLON.GUI {
  4876. /**
  4877. * Class used to create a button in 3D
  4878. */
  4879. export class Button3D extends AbstractButton3D {
  4880. /** @hidden */
  4881. protected _currentMaterial: BABYLON.Material;
  4882. /**
  4883. * Gets or sets the texture resolution used to render content (512 by default)
  4884. */
  4885. contentResolution: BABYLON.int;
  4886. /**
  4887. * Gets or sets the texture scale ratio used to render content (2 by default)
  4888. */
  4889. contentScaleRatio: number;
  4890. protected _disposeFacadeTexture(): void;
  4891. protected _resetContent(): void;
  4892. /**
  4893. * Creates a new button
  4894. * @param name defines the control name
  4895. */
  4896. constructor(name?: string);
  4897. /**
  4898. * Gets or sets the GUI 2D content used to display the button's facade
  4899. */
  4900. content: Control;
  4901. /**
  4902. * Apply the facade texture (created from the content property).
  4903. * This function can be overloaded by child classes
  4904. * @param facadeTexture defines the AdvancedDynamicTexture to use
  4905. */
  4906. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  4907. protected _getTypeName(): string;
  4908. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  4909. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  4910. /**
  4911. * Releases all associated resources
  4912. */
  4913. dispose(): void;
  4914. }
  4915. }
  4916. declare module BABYLON.GUI {
  4917. /**
  4918. * Class used to create containers for controls
  4919. */
  4920. export class Container3D extends Control3D {
  4921. /**
  4922. * Gets the list of child controls
  4923. */
  4924. protected _children: Control3D[];
  4925. /**
  4926. * Gets the list of child controls
  4927. */
  4928. readonly children: Array<Control3D>;
  4929. /**
  4930. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  4931. * This is helpful to optimize layout operation when adding multiple children in a row
  4932. */
  4933. blockLayout: boolean;
  4934. /**
  4935. * Creates a new container
  4936. * @param name defines the container name
  4937. */
  4938. constructor(name?: string);
  4939. /**
  4940. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  4941. * @returns the current container
  4942. */
  4943. updateLayout(): Container3D;
  4944. /**
  4945. * Gets a boolean indicating if the given control is in the children of this control
  4946. * @param control defines the control to check
  4947. * @returns true if the control is in the child list
  4948. */
  4949. containsControl(control: Control3D): boolean;
  4950. /**
  4951. * Adds a control to the children of this control
  4952. * @param control defines the control to add
  4953. * @returns the current container
  4954. */
  4955. addControl(control: Control3D): Container3D;
  4956. /**
  4957. * This function will be called everytime a new control is added
  4958. */
  4959. protected _arrangeChildren(): void;
  4960. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  4961. /**
  4962. * Removes a control from the children of this control
  4963. * @param control defines the control to remove
  4964. * @returns the current container
  4965. */
  4966. removeControl(control: Control3D): Container3D;
  4967. protected _getTypeName(): string;
  4968. /**
  4969. * Releases all associated resources
  4970. */
  4971. dispose(): void;
  4972. /** Control rotation will remain unchanged */
  4973. static readonly UNSET_ORIENTATION: number;
  4974. /** Control will rotate to make it look at sphere central axis */
  4975. static readonly FACEORIGIN_ORIENTATION: number;
  4976. /** Control will rotate to make it look back at sphere central axis */
  4977. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  4978. /** Control will rotate to look at z axis (0, 0, 1) */
  4979. static readonly FACEFORWARD_ORIENTATION: number;
  4980. /** Control will rotate to look at negative z axis (0, 0, -1) */
  4981. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  4982. }
  4983. }
  4984. declare module BABYLON.GUI {
  4985. /**
  4986. * Class used as base class for controls
  4987. */
  4988. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  4989. /** Defines the control name */
  4990. name?: string | undefined;
  4991. /** @hidden */
  4992. _host: GUI3DManager;
  4993. /** Gets or sets the control position in world space */
  4994. position: BABYLON.Vector3;
  4995. /** Gets or sets the control scaling in world space */
  4996. scaling: BABYLON.Vector3;
  4997. /** Callback used to start pointer enter animation */
  4998. pointerEnterAnimation: () => void;
  4999. /** Callback used to start pointer out animation */
  5000. pointerOutAnimation: () => void;
  5001. /** Callback used to start pointer down animation */
  5002. pointerDownAnimation: () => void;
  5003. /** Callback used to start pointer up animation */
  5004. pointerUpAnimation: () => void;
  5005. /**
  5006. * An event triggered when the pointer move over the control
  5007. */
  5008. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  5009. /**
  5010. * An event triggered when the pointer move out of the control
  5011. */
  5012. onPointerOutObservable: BABYLON.Observable<Control3D>;
  5013. /**
  5014. * An event triggered when the pointer taps the control
  5015. */
  5016. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  5017. /**
  5018. * An event triggered when pointer is up
  5019. */
  5020. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  5021. /**
  5022. * An event triggered when a control is clicked on (with a mouse)
  5023. */
  5024. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  5025. /**
  5026. * An event triggered when pointer enters the control
  5027. */
  5028. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  5029. /**
  5030. * Gets or sets the parent container
  5031. */
  5032. parent: BABYLON.Nullable<Container3D>;
  5033. /**
  5034. * Gets the list of attached behaviors
  5035. * @see http://doc.babylonjs.com/features/behaviour
  5036. */
  5037. readonly behaviors: BABYLON.Behavior<Control3D>[];
  5038. /**
  5039. * Attach a behavior to the control
  5040. * @see http://doc.babylonjs.com/features/behaviour
  5041. * @param behavior defines the behavior to attach
  5042. * @returns the current control
  5043. */
  5044. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  5045. /**
  5046. * Remove an attached behavior
  5047. * @see http://doc.babylonjs.com/features/behaviour
  5048. * @param behavior defines the behavior to attach
  5049. * @returns the current control
  5050. */
  5051. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  5052. /**
  5053. * Gets an attached behavior by name
  5054. * @param name defines the name of the behavior to look for
  5055. * @see http://doc.babylonjs.com/features/behaviour
  5056. * @returns null if behavior was not found else the requested behavior
  5057. */
  5058. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  5059. /** Gets or sets a boolean indicating if the control is visible */
  5060. isVisible: boolean;
  5061. /**
  5062. * Creates a new control
  5063. * @param name defines the control name
  5064. */
  5065. constructor(
  5066. /** Defines the control name */
  5067. name?: string | undefined);
  5068. /**
  5069. * Gets a string representing the class name
  5070. */
  5071. readonly typeName: string;
  5072. protected _getTypeName(): string;
  5073. /**
  5074. * Gets the transform node used by this control
  5075. */
  5076. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  5077. /**
  5078. * Gets the mesh used to render this control
  5079. */
  5080. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  5081. /**
  5082. * Link the control as child of the given node
  5083. * @param node defines the node to link to. Use null to unlink the control
  5084. * @returns the current control
  5085. */
  5086. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  5087. /** @hidden **/
  5088. _prepareNode(scene: BABYLON.Scene): void;
  5089. /**
  5090. * Node creation.
  5091. * Can be overriden by children
  5092. * @param scene defines the scene where the node must be attached
  5093. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  5094. */
  5095. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  5096. /**
  5097. * Affect a material to the given mesh
  5098. * @param mesh defines the mesh which will represent the control
  5099. */
  5100. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  5101. /** @hidden */
  5102. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  5103. /** @hidden */
  5104. _onPointerEnter(target: Control3D): boolean;
  5105. /** @hidden */
  5106. _onPointerOut(target: Control3D): void;
  5107. /** @hidden */
  5108. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  5109. /** @hidden */
  5110. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  5111. /** @hidden */
  5112. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  5113. /** @hidden */
  5114. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  5115. /** @hidden */
  5116. _disposeNode(): void;
  5117. /**
  5118. * Releases all associated resources
  5119. */
  5120. dispose(): void;
  5121. }
  5122. }
  5123. declare module BABYLON.GUI {
  5124. /**
  5125. * Class used to create a container panel deployed on the surface of a cylinder
  5126. */
  5127. export class CylinderPanel extends VolumeBasedPanel {
  5128. /**
  5129. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  5130. */
  5131. radius: BABYLON.float;
  5132. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  5133. }
  5134. }
  5135. declare module BABYLON.GUI {
  5136. /**
  5137. * Class used to create a holographic button in 3D
  5138. */
  5139. export class HolographicButton extends Button3D {
  5140. /**
  5141. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  5142. */
  5143. tooltipText: BABYLON.Nullable<string>;
  5144. /**
  5145. * Gets or sets text for the button
  5146. */
  5147. text: string;
  5148. /**
  5149. * Gets or sets the image url for the button
  5150. */
  5151. imageUrl: string;
  5152. /**
  5153. * Gets the back material used by this button
  5154. */
  5155. readonly backMaterial: FluentMaterial;
  5156. /**
  5157. * Gets the front material used by this button
  5158. */
  5159. readonly frontMaterial: FluentMaterial;
  5160. /**
  5161. * Gets the plate material used by this button
  5162. */
  5163. readonly plateMaterial: BABYLON.StandardMaterial;
  5164. /**
  5165. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  5166. */
  5167. readonly shareMaterials: boolean;
  5168. /**
  5169. * Creates a new button
  5170. * @param name defines the control name
  5171. */
  5172. constructor(name?: string, shareMaterials?: boolean);
  5173. protected _getTypeName(): string;
  5174. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  5175. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  5176. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  5177. /**
  5178. * Releases all associated resources
  5179. */
  5180. dispose(): void;
  5181. }
  5182. }
  5183. declare module BABYLON.GUI {
  5184. /**
  5185. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  5186. */
  5187. export class MeshButton3D extends Button3D {
  5188. /** @hidden */
  5189. protected _currentMesh: BABYLON.Mesh;
  5190. /**
  5191. * Creates a new 3D button based on a mesh
  5192. * @param mesh mesh to become a 3D button
  5193. * @param name defines the control name
  5194. */
  5195. constructor(mesh: BABYLON.Mesh, name?: string);
  5196. protected _getTypeName(): string;
  5197. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  5198. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  5199. }
  5200. }
  5201. declare module BABYLON.GUI {
  5202. /**
  5203. * Class used to create a container panel deployed on the surface of a plane
  5204. */
  5205. export class PlanePanel extends VolumeBasedPanel {
  5206. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  5207. }
  5208. }
  5209. declare module BABYLON.GUI {
  5210. /**
  5211. * Class used to create a container panel where items get randomized planar mapping
  5212. */
  5213. export class ScatterPanel extends VolumeBasedPanel {
  5214. /**
  5215. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  5216. */
  5217. iteration: BABYLON.float;
  5218. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  5219. protected _finalProcessing(): void;
  5220. }
  5221. }
  5222. declare module BABYLON.GUI {
  5223. /**
  5224. * Class used to create a container panel deployed on the surface of a sphere
  5225. */
  5226. export class SpherePanel extends VolumeBasedPanel {
  5227. /**
  5228. * Gets or sets the radius of the sphere where to project controls (5 by default)
  5229. */
  5230. radius: BABYLON.float;
  5231. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  5232. }
  5233. }
  5234. declare module BABYLON.GUI {
  5235. /**
  5236. * Class used to create a stack panel in 3D on XY plane
  5237. */
  5238. export class StackPanel3D extends Container3D {
  5239. /**
  5240. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  5241. */
  5242. isVertical: boolean;
  5243. /**
  5244. * Gets or sets the distance between elements
  5245. */
  5246. margin: number;
  5247. /**
  5248. * Creates new StackPanel
  5249. * @param isVertical
  5250. */
  5251. constructor(isVertical?: boolean);
  5252. protected _arrangeChildren(): void;
  5253. }
  5254. }
  5255. declare module BABYLON.GUI {
  5256. /**
  5257. * Abstract class used to create a container panel deployed on the surface of a volume
  5258. */
  5259. export abstract class VolumeBasedPanel extends Container3D {
  5260. protected _cellWidth: number;
  5261. protected _cellHeight: number;
  5262. /**
  5263. * Gets or sets the distance between elements
  5264. */
  5265. margin: number;
  5266. /**
  5267. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  5268. * | Value | Type | Description |
  5269. * | ----- | ----------------------------------- | ----------- |
  5270. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  5271. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  5272. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  5273. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  5274. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  5275. */
  5276. orientation: number;
  5277. /**
  5278. * Gets or sets the number of columns requested (10 by default).
  5279. * The panel will automatically compute the number of rows based on number of child controls.
  5280. */
  5281. columns: BABYLON.int;
  5282. /**
  5283. * Gets or sets a the number of rows requested.
  5284. * The panel will automatically compute the number of columns based on number of child controls.
  5285. */
  5286. rows: BABYLON.int;
  5287. /**
  5288. * Creates new VolumeBasedPanel
  5289. */
  5290. constructor();
  5291. protected _arrangeChildren(): void;
  5292. /** Child classes must implement this function to provide correct control positioning */
  5293. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  5294. /** Child classes can implement this function to provide additional processing */
  5295. protected _finalProcessing(): void;
  5296. }
  5297. }
  5298. declare module BABYLON.GUI {
  5299. /** @hidden */
  5300. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  5301. INNERGLOW: boolean;
  5302. BORDER: boolean;
  5303. HOVERLIGHT: boolean;
  5304. TEXTURE: boolean;
  5305. constructor();
  5306. }
  5307. /**
  5308. * Class used to render controls with fluent desgin
  5309. */
  5310. export class FluentMaterial extends BABYLON.PushMaterial {
  5311. /**
  5312. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  5313. */
  5314. innerGlowColorIntensity: number;
  5315. /**
  5316. * Gets or sets the inner glow color (white by default)
  5317. */
  5318. innerGlowColor: BABYLON.Color3;
  5319. /**
  5320. * Gets or sets alpha value (default is 1.0)
  5321. */
  5322. alpha: number;
  5323. /**
  5324. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  5325. */
  5326. albedoColor: BABYLON.Color3;
  5327. /**
  5328. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  5329. */
  5330. renderBorders: boolean;
  5331. /**
  5332. * Gets or sets border width (default is 0.5)
  5333. */
  5334. borderWidth: number;
  5335. /**
  5336. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  5337. */
  5338. edgeSmoothingValue: number;
  5339. /**
  5340. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  5341. */
  5342. borderMinValue: number;
  5343. /**
  5344. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  5345. */
  5346. renderHoverLight: boolean;
  5347. /**
  5348. * Gets or sets the radius used to render the hover light (default is 1.0)
  5349. */
  5350. hoverRadius: number;
  5351. /**
  5352. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  5353. */
  5354. hoverColor: BABYLON.Color4;
  5355. /**
  5356. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  5357. */
  5358. hoverPosition: BABYLON.Vector3;
  5359. /** Gets or sets the texture to use for albedo color */
  5360. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  5361. /**
  5362. * Creates a new Fluent material
  5363. * @param name defines the name of the material
  5364. * @param scene defines the hosting scene
  5365. */
  5366. constructor(name: string, scene: BABYLON.Scene);
  5367. needAlphaBlending(): boolean;
  5368. needAlphaTesting(): boolean;
  5369. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  5370. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  5371. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  5372. getActiveTextures(): BABYLON.BaseTexture[];
  5373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  5374. dispose(forceDisposeEffect?: boolean): void;
  5375. clone(name: string): FluentMaterial;
  5376. serialize(): any;
  5377. getClassName(): string;
  5378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  5379. }
  5380. }