babylon.gui.module.d.ts 245 KB

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