babylon.gui.module.d.ts 310 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623
  1. declare module "babylonjs-gui/2D/valueAndUnit" {
  2. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  3. /**
  4. * Class used to specific a value and its associated unit
  5. */
  6. export class ValueAndUnit {
  7. /** defines the unit to store */
  8. unit: number;
  9. /** defines a boolean indicating if the value can be negative */
  10. negativeValueAllowed: boolean;
  11. private _value;
  12. private _originalUnit;
  13. /**
  14. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  15. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  16. */
  17. ignoreAdaptiveScaling: boolean;
  18. /**
  19. * Creates a new ValueAndUnit
  20. * @param value defines the value to store
  21. * @param unit defines the unit to store
  22. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  23. */
  24. constructor(value: number,
  25. /** defines the unit to store */
  26. unit?: number,
  27. /** defines a boolean indicating if the value can be negative */
  28. negativeValueAllowed?: boolean);
  29. /** Gets a boolean indicating if the value is a percentage */
  30. readonly isPercentage: boolean;
  31. /** Gets a boolean indicating if the value is store as pixel */
  32. readonly isPixel: boolean;
  33. /** Gets direct internal value */
  34. readonly internalValue: number;
  35. /**
  36. * Gets value as pixel
  37. * @param host defines the root host
  38. * @param refValue defines the reference value for percentages
  39. * @returns the value as pixel
  40. */
  41. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  42. /**
  43. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  44. * @param value defines the value to store
  45. * @param unit defines the unit to store
  46. * @returns the current ValueAndUnit
  47. */
  48. updateInPlace(value: number, unit?: number): ValueAndUnit;
  49. /**
  50. * Gets the value accordingly to its unit
  51. * @param host defines the root host
  52. * @returns the value
  53. */
  54. getValue(host: AdvancedDynamicTexture): number;
  55. /**
  56. * Gets a string representation of the value
  57. * @param host defines the root host
  58. * @param decimals defines an optional number of decimals to display
  59. * @returns a string
  60. */
  61. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62. /**
  63. * Store a value parsed from a string
  64. * @param source defines the source string
  65. * @returns true if the value was successfully parsed
  66. */
  67. fromString(source: string | number): boolean;
  68. private static _Regex;
  69. private static _UNITMODE_PERCENTAGE;
  70. private static _UNITMODE_PIXEL;
  71. /** UNITMODE_PERCENTAGE */
  72. static readonly UNITMODE_PERCENTAGE: number;
  73. /** UNITMODE_PIXEL */
  74. static readonly UNITMODE_PIXEL: number;
  75. }
  76. }
  77. declare module "babylonjs-gui/2D/style" {
  78. import { Observable } from "babylonjs/Misc/observable";
  79. import { IDisposable } from "babylonjs/scene";
  80. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  81. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  82. /**
  83. * Define a style used by control to automatically setup properties based on a template.
  84. * Only support font related properties so far
  85. */
  86. export class Style implements IDisposable {
  87. private _fontFamily;
  88. private _fontStyle;
  89. private _fontWeight;
  90. /** @hidden */
  91. _host: AdvancedDynamicTexture;
  92. /** @hidden */
  93. _fontSize: ValueAndUnit;
  94. /**
  95. * Observable raised when the style values are changed
  96. */
  97. onChangedObservable: Observable<Style>;
  98. /**
  99. * Creates a new style object
  100. * @param host defines the AdvancedDynamicTexture which hosts this style
  101. */
  102. constructor(host: AdvancedDynamicTexture);
  103. /**
  104. * Gets or sets the font size
  105. */
  106. fontSize: string | number;
  107. /**
  108. * Gets or sets the font family
  109. */
  110. fontFamily: string;
  111. /**
  112. * Gets or sets the font style
  113. */
  114. fontStyle: string;
  115. /** Gets or sets font weight */
  116. fontWeight: string;
  117. /** Dispose all associated resources */
  118. dispose(): void;
  119. }
  120. }
  121. declare module "babylonjs-gui/2D/math2D" {
  122. import { Nullable } from "babylonjs/types";
  123. import { Vector2 } from "babylonjs/Maths/math";
  124. /**
  125. * Class used to transport Vector2 information for pointer events
  126. */
  127. export class Vector2WithInfo extends Vector2 {
  128. /** defines the current mouse button index */
  129. buttonIndex: number;
  130. /**
  131. * Creates a new Vector2WithInfo
  132. * @param source defines the vector2 data to transport
  133. * @param buttonIndex defines the current mouse button index
  134. */
  135. constructor(source: Vector2,
  136. /** defines the current mouse button index */
  137. buttonIndex?: number);
  138. }
  139. /** Class used to provide 2D matrix features */
  140. export class Matrix2D {
  141. /** Gets the internal array of 6 floats used to store matrix data */
  142. m: Float32Array;
  143. /**
  144. * Creates a new matrix
  145. * @param m00 defines value for (0, 0)
  146. * @param m01 defines value for (0, 1)
  147. * @param m10 defines value for (1, 0)
  148. * @param m11 defines value for (1, 1)
  149. * @param m20 defines value for (2, 0)
  150. * @param m21 defines value for (2, 1)
  151. */
  152. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  153. /**
  154. * Fills the matrix from direct values
  155. * @param m00 defines value for (0, 0)
  156. * @param m01 defines value for (0, 1)
  157. * @param m10 defines value for (1, 0)
  158. * @param m11 defines value for (1, 1)
  159. * @param m20 defines value for (2, 0)
  160. * @param m21 defines value for (2, 1)
  161. * @returns the current modified matrix
  162. */
  163. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  164. /**
  165. * Gets matrix determinant
  166. * @returns the determinant
  167. */
  168. determinant(): number;
  169. /**
  170. * Inverses the matrix and stores it in a target matrix
  171. * @param result defines the target matrix
  172. * @returns the current matrix
  173. */
  174. invertToRef(result: Matrix2D): Matrix2D;
  175. /**
  176. * Multiplies the current matrix with another one
  177. * @param other defines the second operand
  178. * @param result defines the target matrix
  179. * @returns the current matrix
  180. */
  181. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  182. /**
  183. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  184. * @param x defines the x coordinate to transform
  185. * @param y defines the x coordinate to transform
  186. * @param result defines the target vector2
  187. * @returns the current matrix
  188. */
  189. transformCoordinates(x: number, y: number, result: Vector2): Matrix2D;
  190. /**
  191. * Creates an identity matrix
  192. * @returns a new matrix
  193. */
  194. static Identity(): Matrix2D;
  195. /**
  196. * Creates a translation matrix and stores it in a target matrix
  197. * @param x defines the x coordinate of the translation
  198. * @param y defines the y coordinate of the translation
  199. * @param result defines the target matrix
  200. */
  201. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  202. /**
  203. * Creates a scaling matrix and stores it in a target matrix
  204. * @param x defines the x coordinate of the scaling
  205. * @param y defines the y coordinate of the scaling
  206. * @param result defines the target matrix
  207. */
  208. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  209. /**
  210. * Creates a rotation matrix and stores it in a target matrix
  211. * @param angle defines the rotation angle
  212. * @param result defines the target matrix
  213. */
  214. static RotationToRef(angle: number, result: Matrix2D): void;
  215. private static _TempPreTranslationMatrix;
  216. private static _TempPostTranslationMatrix;
  217. private static _TempRotationMatrix;
  218. private static _TempScalingMatrix;
  219. private static _TempCompose0;
  220. private static _TempCompose1;
  221. private static _TempCompose2;
  222. /**
  223. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  224. * @param tx defines the x coordinate of the translation
  225. * @param ty defines the y coordinate of the translation
  226. * @param angle defines the rotation angle
  227. * @param scaleX defines the x coordinate of the scaling
  228. * @param scaleY defines the y coordinate of the scaling
  229. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  230. * @param result defines the target matrix
  231. */
  232. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: Nullable<Matrix2D>, result: Matrix2D): void;
  233. }
  234. }
  235. declare module "babylonjs-gui/2D/measure" {
  236. import { Matrix2D } from "babylonjs-gui/2D/math2D";
  237. /**
  238. * Class used to store 2D control sizes
  239. */
  240. export class Measure {
  241. /** defines left coordinate */
  242. left: number;
  243. /** defines top coordinate */
  244. top: number;
  245. /** defines width dimension */
  246. width: number;
  247. /** defines height dimension */
  248. height: number;
  249. /**
  250. * Creates a new measure
  251. * @param left defines left coordinate
  252. * @param top defines top coordinate
  253. * @param width defines width dimension
  254. * @param height defines height dimension
  255. */
  256. constructor(
  257. /** defines left coordinate */
  258. left: number,
  259. /** defines top coordinate */
  260. top: number,
  261. /** defines width dimension */
  262. width: number,
  263. /** defines height dimension */
  264. height: number);
  265. /**
  266. * Copy from another measure
  267. * @param other defines the other measure to copy from
  268. */
  269. copyFrom(other: Measure): void;
  270. /**
  271. * Copy from a group of 4 floats
  272. * @param left defines left coordinate
  273. * @param top defines top coordinate
  274. * @param width defines width dimension
  275. * @param height defines height dimension
  276. */
  277. copyFromFloats(left: number, top: number, width: number, height: number): void;
  278. /**
  279. * Computes the axis aligned bounding box measure for two given measures
  280. * @param a Input measure
  281. * @param b Input measure
  282. * @param result the resulting bounding measure
  283. */
  284. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  285. /**
  286. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  287. * @param transform the matrix to transform the measure before computing the AABB
  288. * @param result the resulting AABB
  289. */
  290. transformToRef(transform: Matrix2D, result: Measure): void;
  291. /**
  292. * Check equality between this measure and another one
  293. * @param other defines the other measures
  294. * @returns true if both measures are equals
  295. */
  296. isEqualsTo(other: Measure): boolean;
  297. /**
  298. * Creates an empty measure
  299. * @returns a new measure
  300. */
  301. static Empty(): Measure;
  302. }
  303. }
  304. declare module "babylonjs-gui/2D/advancedDynamicTexture" {
  305. import { Nullable } from "babylonjs/types";
  306. import { Observable } from "babylonjs/Misc/observable";
  307. import { Viewport, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  308. import { ClipboardInfo } from "babylonjs/Events/clipboardEvents";
  309. import { DynamicTexture } from "babylonjs/Materials/Textures/dynamicTexture";
  310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  311. import { Layer } from "babylonjs/Layers/layer";
  312. import { Scene } from "babylonjs/scene";
  313. import { Container } from "babylonjs-gui/2D/controls/container";
  314. import { Control } from "babylonjs-gui/2D/controls/control";
  315. import { Style } from "babylonjs-gui/2D/style";
  316. /**
  317. * Interface used to define a control that can receive focus
  318. */
  319. export interface IFocusableControl {
  320. /**
  321. * Function called when the control receives the focus
  322. */
  323. onFocus(): void;
  324. /**
  325. * Function called when the control loses the focus
  326. */
  327. onBlur(): void;
  328. /**
  329. * Function called to let the control handle keyboard events
  330. * @param evt defines the current keyboard event
  331. */
  332. processKeyboard(evt: KeyboardEvent): void;
  333. /**
  334. * Function called to get the list of controls that should not steal the focus from this control
  335. * @returns an array of controls
  336. */
  337. keepsFocusWith(): Nullable<Control[]>;
  338. }
  339. /**
  340. * Class used to create texture to support 2D GUI elements
  341. * @see http://doc.babylonjs.com/how_to/gui
  342. */
  343. export class AdvancedDynamicTexture extends DynamicTexture {
  344. private _isDirty;
  345. private _renderObserver;
  346. private _resizeObserver;
  347. private _preKeyboardObserver;
  348. private _pointerMoveObserver;
  349. private _pointerObserver;
  350. private _canvasPointerOutObserver;
  351. private _background;
  352. /** @hidden */
  353. _rootContainer: Container;
  354. /** @hidden */
  355. _lastPickedControl: Control;
  356. /** @hidden */
  357. _lastControlOver: {
  358. [pointerId: number]: Control;
  359. };
  360. /** @hidden */
  361. _lastControlDown: {
  362. [pointerId: number]: Control;
  363. };
  364. /** @hidden */
  365. _capturingControl: {
  366. [pointerId: number]: Control;
  367. };
  368. /** @hidden */
  369. _shouldBlockPointer: boolean;
  370. /** @hidden */
  371. _layerToDispose: Nullable<Layer>;
  372. /** @hidden */
  373. _linkedControls: Control[];
  374. private _isFullscreen;
  375. private _fullscreenViewport;
  376. private _idealWidth;
  377. private _idealHeight;
  378. private _useSmallestIdeal;
  379. private _renderAtIdealSize;
  380. private _focusedControl;
  381. private _blockNextFocusCheck;
  382. private _renderScale;
  383. private _rootElement;
  384. private _cursorChanged;
  385. /**
  386. * Define type to string to ensure compatibility across browsers
  387. * Safari doesn't support DataTransfer constructor
  388. */
  389. private _clipboardData;
  390. /**
  391. * Observable event triggered each time an clipboard event is received from the rendering canvas
  392. */
  393. onClipboardObservable: Observable<ClipboardInfo>;
  394. /**
  395. * Observable event triggered each time a pointer down is intercepted by a control
  396. */
  397. onControlPickedObservable: Observable<Control>;
  398. /**
  399. * Observable event triggered before layout is evaluated
  400. */
  401. onBeginLayoutObservable: Observable<AdvancedDynamicTexture>;
  402. /**
  403. * Observable event triggered after the layout was evaluated
  404. */
  405. onEndLayoutObservable: Observable<AdvancedDynamicTexture>;
  406. /**
  407. * Observable event triggered before the texture is rendered
  408. */
  409. onBeginRenderObservable: Observable<AdvancedDynamicTexture>;
  410. /**
  411. * Observable event triggered after the texture was rendered
  412. */
  413. onEndRenderObservable: Observable<AdvancedDynamicTexture>;
  414. /**
  415. * Gets or sets a boolean defining if alpha is stored as premultiplied
  416. */
  417. premulAlpha: boolean;
  418. /**
  419. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  420. * Useful when you want more antialiasing
  421. */
  422. renderScale: number;
  423. /** Gets or sets the background color */
  424. background: string;
  425. /**
  426. * Gets or sets the ideal width used to design controls.
  427. * The GUI will then rescale everything accordingly
  428. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  429. */
  430. idealWidth: number;
  431. /**
  432. * Gets or sets the ideal height used to design controls.
  433. * The GUI will then rescale everything accordingly
  434. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  435. */
  436. idealHeight: number;
  437. /**
  438. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  439. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  440. */
  441. useSmallestIdeal: boolean;
  442. /**
  443. * Gets or sets a boolean indicating if adaptive scaling must be used
  444. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  445. */
  446. renderAtIdealSize: boolean;
  447. /**
  448. * Gets the underlying layer used to render the texture when in fullscreen mode
  449. */
  450. readonly layer: Nullable<Layer>;
  451. /**
  452. * Gets the root container control
  453. */
  454. readonly rootContainer: Container;
  455. /**
  456. * Returns an array containing the root container.
  457. * This is mostly used to let the Inspector introspects the ADT
  458. * @returns an array containing the rootContainer
  459. */
  460. getChildren(): Array<Container>;
  461. /**
  462. * Will return all controls that are inside this texture
  463. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  464. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  465. * @return all child controls
  466. */
  467. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  468. /**
  469. * Gets or sets the current focused control
  470. */
  471. focusedControl: Nullable<IFocusableControl>;
  472. /**
  473. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  474. */
  475. isForeground: boolean;
  476. /**
  477. * Gets or set information about clipboardData
  478. */
  479. clipboardData: string;
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. constructor(name: string, width: number | undefined, height: number | undefined, scene: Nullable<Scene>, generateMipMaps?: boolean, samplingMode?: number);
  490. /**
  491. * Get the current class name of the texture useful for serialization or dynamic coding.
  492. * @returns "AdvancedDynamicTexture"
  493. */
  494. getClassName(): string;
  495. /**
  496. * Function used to execute a function on all controls
  497. * @param func defines the function to execute
  498. * @param container defines the container where controls belong. If null the root container will be used
  499. */
  500. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  501. private _useInvalidateRectOptimization;
  502. /**
  503. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  504. */
  505. useInvalidateRectOptimization: boolean;
  506. private _invalidatedRectangle;
  507. /**
  508. * Invalidates a rectangle area on the gui texture
  509. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  510. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  511. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  512. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  513. */
  514. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  515. /**
  516. * Marks the texture as dirty forcing a complete update
  517. */
  518. markAsDirty(): void;
  519. /**
  520. * Helper function used to create a new style
  521. * @returns a new style
  522. * @see http://doc.babylonjs.com/how_to/gui#styles
  523. */
  524. createStyle(): Style;
  525. /**
  526. * Adds a new control to the root container
  527. * @param control defines the control to add
  528. * @returns the current texture
  529. */
  530. addControl(control: Control): AdvancedDynamicTexture;
  531. /**
  532. * Removes a control from the root container
  533. * @param control defines the control to remove
  534. * @returns the current texture
  535. */
  536. removeControl(control: Control): AdvancedDynamicTexture;
  537. /**
  538. * Release all resources
  539. */
  540. dispose(): void;
  541. private _onResize;
  542. /** @hidden */
  543. _getGlobalViewport(scene: Scene): Viewport;
  544. /**
  545. * Get screen coordinates for a vector3
  546. * @param position defines the position to project
  547. * @param worldMatrix defines the world matrix to use
  548. * @returns the projected position
  549. */
  550. getProjectedPosition(position: Vector3, worldMatrix: Matrix): Vector2;
  551. private _checkUpdate;
  552. private _clearMeasure;
  553. private _render;
  554. /** @hidden */
  555. _changeCursor(cursor: string): void;
  556. /** @hidden */
  557. _registerLastControlDown(control: Control, pointerId: number): void;
  558. private _doPicking;
  559. /** @hidden */
  560. _cleanControlAfterRemovalFromList(list: {
  561. [pointerId: number]: Control;
  562. }, control: Control): void;
  563. /** @hidden */
  564. _cleanControlAfterRemoval(control: Control): void;
  565. /** Attach to all scene events required to support pointer events */
  566. attach(): void;
  567. /** @hidden */
  568. private onClipboardCopy;
  569. /** @hidden */
  570. private onClipboardCut;
  571. /** @hidden */
  572. private onClipboardPaste;
  573. /**
  574. * Register the clipboard Events onto the canvas
  575. */
  576. registerClipboardEvents(): void;
  577. /**
  578. * Unregister the clipboard Events from the canvas
  579. */
  580. unRegisterClipboardEvents(): void;
  581. /**
  582. * Connect the texture to a hosting mesh to enable interactions
  583. * @param mesh defines the mesh to attach to
  584. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  585. */
  586. attachToMesh(mesh: AbstractMesh, supportPointerMove?: boolean): void;
  587. /**
  588. * Move the focus to a specific control
  589. * @param control defines the control which will receive the focus
  590. */
  591. moveFocusToControl(control: IFocusableControl): void;
  592. private _manageFocus;
  593. private _attachToOnPointerOut;
  594. /**
  595. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  596. * @param mesh defines the mesh which will receive the texture
  597. * @param width defines the texture width (1024 by default)
  598. * @param height defines the texture height (1024 by default)
  599. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  600. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  601. * @returns a new AdvancedDynamicTexture
  602. */
  603. static CreateForMesh(mesh: AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  604. /**
  605. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  606. * In this mode the texture will rely on a layer for its rendering.
  607. * This allows it to be treated like any other layer.
  608. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  609. * LayerMask is set through advancedTexture.layer.layerMask
  610. * @param name defines name for the texture
  611. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  612. * @param scene defines the hsoting scene
  613. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  614. * @returns a new AdvancedDynamicTexture
  615. */
  616. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: Nullable<Scene>, sampling?: number): AdvancedDynamicTexture;
  617. }
  618. }
  619. declare module "babylonjs-gui/2D/controls/control" {
  620. import { Nullable } from "babylonjs/types";
  621. import { Observable } from "babylonjs/Misc/observable";
  622. import { Vector2, Vector3 } from "babylonjs/Maths/math";
  623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  624. import { Scene } from "babylonjs/scene";
  625. import { Container } from "babylonjs-gui/2D/controls/container";
  626. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  627. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  628. import { Measure } from "babylonjs-gui/2D/measure";
  629. import { Style } from "babylonjs-gui/2D/style";
  630. import { Matrix2D, Vector2WithInfo } from "babylonjs-gui/2D/math2D";
  631. /**
  632. * Root class used for all 2D controls
  633. * @see http://doc.babylonjs.com/how_to/gui#controls
  634. */
  635. export class Control {
  636. /** defines the name of the control */
  637. name?: string | undefined;
  638. /**
  639. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  640. */
  641. static AllowAlphaInheritance: boolean;
  642. private _alpha;
  643. private _alphaSet;
  644. private _zIndex;
  645. /** @hidden */
  646. _host: AdvancedDynamicTexture;
  647. /** Gets or sets the control parent */
  648. parent: Nullable<Container>;
  649. /** @hidden */
  650. _currentMeasure: Measure;
  651. private _fontFamily;
  652. private _fontStyle;
  653. private _fontWeight;
  654. private _fontSize;
  655. private _font;
  656. /** @hidden */
  657. _width: ValueAndUnit;
  658. /** @hidden */
  659. _height: ValueAndUnit;
  660. /** @hidden */
  661. protected _fontOffset: {
  662. ascent: number;
  663. height: number;
  664. descent: number;
  665. };
  666. private _color;
  667. private _style;
  668. private _styleObserver;
  669. /** @hidden */
  670. protected _horizontalAlignment: number;
  671. /** @hidden */
  672. protected _verticalAlignment: number;
  673. /** @hidden */
  674. protected _isDirty: boolean;
  675. /** @hidden */
  676. protected _wasDirty: boolean;
  677. /** @hidden */
  678. _tempParentMeasure: Measure;
  679. /** @hidden */
  680. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  681. /** @hidden */
  682. protected _cachedParentMeasure: Measure;
  683. private _paddingLeft;
  684. private _paddingRight;
  685. private _paddingTop;
  686. private _paddingBottom;
  687. /** @hidden */
  688. _left: ValueAndUnit;
  689. /** @hidden */
  690. _top: ValueAndUnit;
  691. private _scaleX;
  692. private _scaleY;
  693. private _rotation;
  694. private _transformCenterX;
  695. private _transformCenterY;
  696. /** @hidden */
  697. _transformMatrix: Matrix2D;
  698. /** @hidden */
  699. protected _invertTransformMatrix: Matrix2D;
  700. /** @hidden */
  701. protected _transformedPosition: Vector2;
  702. private _isMatrixDirty;
  703. private _cachedOffsetX;
  704. private _cachedOffsetY;
  705. private _isVisible;
  706. private _isHighlighted;
  707. /** @hidden */
  708. _linkedMesh: Nullable<AbstractMesh>;
  709. private _fontSet;
  710. private _dummyVector2;
  711. private _downCount;
  712. private _enterCount;
  713. private _doNotRender;
  714. private _downPointerIds;
  715. protected _isEnabled: boolean;
  716. protected _disabledColor: string;
  717. /** @hidden */
  718. protected _rebuildLayout: boolean;
  719. /** @hidden */
  720. _isClipped: boolean;
  721. /** @hidden */
  722. _automaticSize: boolean;
  723. /** @hidden */
  724. _tag: any;
  725. /**
  726. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  727. */
  728. uniqueId: number;
  729. /**
  730. * Gets or sets an object used to store user defined information for the node
  731. */
  732. metadata: any;
  733. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  734. isHitTestVisible: boolean;
  735. /** Gets or sets a boolean indicating if the control can block pointer events */
  736. isPointerBlocker: boolean;
  737. /** Gets or sets a boolean indicating if the control can be focusable */
  738. isFocusInvisible: boolean;
  739. /**
  740. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  741. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  742. */
  743. clipChildren: boolean;
  744. /**
  745. * Gets or sets a boolean indicating that control content must be clipped
  746. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  747. */
  748. clipContent: boolean;
  749. /**
  750. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  751. */
  752. useBitmapCache: boolean;
  753. private _cacheData;
  754. private _shadowOffsetX;
  755. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  756. shadowOffsetX: number;
  757. private _shadowOffsetY;
  758. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  759. shadowOffsetY: number;
  760. private _shadowBlur;
  761. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  762. shadowBlur: number;
  763. private _shadowColor;
  764. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  765. shadowColor: string;
  766. /** Gets or sets the cursor to use when the control is hovered */
  767. hoverCursor: string;
  768. /** @hidden */
  769. protected _linkOffsetX: ValueAndUnit;
  770. /** @hidden */
  771. protected _linkOffsetY: ValueAndUnit;
  772. /** Gets the control type name */
  773. readonly typeName: string;
  774. /**
  775. * Get the current class name of the control.
  776. * @returns current class name
  777. */
  778. getClassName(): string;
  779. /**
  780. * An event triggered when the pointer move over the control.
  781. */
  782. onPointerMoveObservable: Observable<Vector2>;
  783. /**
  784. * An event triggered when the pointer move out of the control.
  785. */
  786. onPointerOutObservable: Observable<Control>;
  787. /**
  788. * An event triggered when the pointer taps the control
  789. */
  790. onPointerDownObservable: Observable<Vector2WithInfo>;
  791. /**
  792. * An event triggered when pointer up
  793. */
  794. onPointerUpObservable: Observable<Vector2WithInfo>;
  795. /**
  796. * An event triggered when a control is clicked on
  797. */
  798. onPointerClickObservable: Observable<Vector2WithInfo>;
  799. /**
  800. * An event triggered when pointer enters the control
  801. */
  802. onPointerEnterObservable: Observable<Control>;
  803. /**
  804. * An event triggered when the control is marked as dirty
  805. */
  806. onDirtyObservable: Observable<Control>;
  807. /**
  808. * An event triggered before drawing the control
  809. */
  810. onBeforeDrawObservable: Observable<Control>;
  811. /**
  812. * An event triggered after the control was drawn
  813. */
  814. onAfterDrawObservable: Observable<Control>;
  815. /**
  816. * Get the hosting AdvancedDynamicTexture
  817. */
  818. readonly host: AdvancedDynamicTexture;
  819. /** Gets or set information about font offsets (used to render and align text) */
  820. fontOffset: {
  821. ascent: number;
  822. height: number;
  823. descent: number;
  824. };
  825. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  826. alpha: number;
  827. /**
  828. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  829. */
  830. isHighlighted: boolean;
  831. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  832. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  833. */
  834. scaleX: number;
  835. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  836. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  837. */
  838. scaleY: number;
  839. /** Gets or sets the rotation angle (0 by default)
  840. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  841. */
  842. rotation: number;
  843. /** Gets or sets the transformation center on Y axis (0 by default)
  844. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  845. */
  846. transformCenterY: number;
  847. /** Gets or sets the transformation center on X axis (0 by default)
  848. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  849. */
  850. transformCenterX: number;
  851. /**
  852. * Gets or sets the horizontal alignment
  853. * @see http://doc.babylonjs.com/how_to/gui#alignments
  854. */
  855. horizontalAlignment: number;
  856. /**
  857. * Gets or sets the vertical alignment
  858. * @see http://doc.babylonjs.com/how_to/gui#alignments
  859. */
  860. verticalAlignment: number;
  861. /**
  862. * Gets or sets control width
  863. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  864. */
  865. width: string | number;
  866. /**
  867. * Gets or sets the control width in pixel
  868. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  869. */
  870. widthInPixels: number;
  871. /**
  872. * Gets or sets control height
  873. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  874. */
  875. height: string | number;
  876. /**
  877. * Gets or sets control height in pixel
  878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  879. */
  880. heightInPixels: number;
  881. /** Gets or set font family */
  882. fontFamily: string;
  883. /** Gets or sets font style */
  884. fontStyle: string;
  885. /** Gets or sets font weight */
  886. fontWeight: string;
  887. /**
  888. * Gets or sets style
  889. * @see http://doc.babylonjs.com/how_to/gui#styles
  890. */
  891. style: Nullable<Style>;
  892. /** @hidden */
  893. readonly _isFontSizeInPercentage: boolean;
  894. /** Gets or sets font size in pixels */
  895. fontSizeInPixels: number;
  896. /** Gets or sets font size */
  897. fontSize: string | number;
  898. /** Gets or sets foreground color */
  899. color: string;
  900. /** Gets or sets z index which is used to reorder controls on the z axis */
  901. zIndex: number;
  902. /** Gets or sets a boolean indicating if the control can be rendered */
  903. notRenderable: boolean;
  904. /** Gets or sets a boolean indicating if the control is visible */
  905. isVisible: boolean;
  906. /** Gets a boolean indicating that the control needs to update its rendering */
  907. readonly isDirty: boolean;
  908. /**
  909. * Gets the current linked mesh (or null if none)
  910. */
  911. readonly linkedMesh: Nullable<AbstractMesh>;
  912. /**
  913. * Gets or sets a value indicating the padding to use on the left of the control
  914. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  915. */
  916. paddingLeft: string | number;
  917. /**
  918. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  919. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  920. */
  921. paddingLeftInPixels: number;
  922. /**
  923. * Gets or sets a value indicating the padding to use on the right of the control
  924. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  925. */
  926. paddingRight: string | number;
  927. /**
  928. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  929. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  930. */
  931. paddingRightInPixels: number;
  932. /**
  933. * Gets or sets a value indicating the padding to use on the top of the control
  934. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  935. */
  936. paddingTop: string | number;
  937. /**
  938. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  939. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  940. */
  941. paddingTopInPixels: number;
  942. /**
  943. * Gets or sets a value indicating the padding to use on the bottom of the control
  944. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  945. */
  946. paddingBottom: string | number;
  947. /**
  948. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  949. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  950. */
  951. paddingBottomInPixels: number;
  952. /**
  953. * Gets or sets a value indicating the left coordinate of the control
  954. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  955. */
  956. left: string | number;
  957. /**
  958. * Gets or sets a value indicating the left coordinate in pixels of the control
  959. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  960. */
  961. leftInPixels: number;
  962. /**
  963. * Gets or sets a value indicating the top coordinate of the control
  964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  965. */
  966. top: string | number;
  967. /**
  968. * Gets or sets a value indicating the top coordinate in pixels of the control
  969. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  970. */
  971. topInPixels: number;
  972. /**
  973. * Gets or sets a value indicating the offset on X axis to the linked mesh
  974. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  975. */
  976. linkOffsetX: string | number;
  977. /**
  978. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  979. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  980. */
  981. linkOffsetXInPixels: number;
  982. /**
  983. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  984. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  985. */
  986. linkOffsetY: string | number;
  987. /**
  988. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  989. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  990. */
  991. linkOffsetYInPixels: number;
  992. /** Gets the center coordinate on X axis */
  993. readonly centerX: number;
  994. /** Gets the center coordinate on Y axis */
  995. readonly centerY: number;
  996. /** Gets or sets if control is Enabled*/
  997. isEnabled: boolean;
  998. /** Gets or sets background color of control if it's disabled*/
  999. disabledColor: string;
  1000. /**
  1001. * Creates a new control
  1002. * @param name defines the name of the control
  1003. */
  1004. constructor(
  1005. /** defines the name of the control */
  1006. name?: string | undefined);
  1007. /** @hidden */
  1008. protected _getTypeName(): string;
  1009. /**
  1010. * Gets the first ascendant in the hierarchy of the given type
  1011. * @param className defines the required type
  1012. * @returns the ascendant or null if not found
  1013. */
  1014. getAscendantOfClass(className: string): Nullable<Control>;
  1015. /** @hidden */
  1016. _resetFontCache(): void;
  1017. /**
  1018. * Determines if a container is an ascendant of the current control
  1019. * @param container defines the container to look for
  1020. * @returns true if the container is one of the ascendant of the control
  1021. */
  1022. isAscendant(container: Control): boolean;
  1023. /**
  1024. * Gets coordinates in local control space
  1025. * @param globalCoordinates defines the coordinates to transform
  1026. * @returns the new coordinates in local space
  1027. */
  1028. getLocalCoordinates(globalCoordinates: Vector2): Vector2;
  1029. /**
  1030. * Gets coordinates in local control space
  1031. * @param globalCoordinates defines the coordinates to transform
  1032. * @param result defines the target vector2 where to store the result
  1033. * @returns the current control
  1034. */
  1035. getLocalCoordinatesToRef(globalCoordinates: Vector2, result: Vector2): Control;
  1036. /**
  1037. * Gets coordinates in parent local control space
  1038. * @param globalCoordinates defines the coordinates to transform
  1039. * @returns the new coordinates in parent local space
  1040. */
  1041. getParentLocalCoordinates(globalCoordinates: Vector2): Vector2;
  1042. /**
  1043. * Move the current control to a vector3 position projected onto the screen.
  1044. * @param position defines the target position
  1045. * @param scene defines the hosting scene
  1046. */
  1047. moveToVector3(position: Vector3, scene: Scene): void;
  1048. /**
  1049. * Will store all controls that have this control as ascendant in a given array
  1050. * @param results defines the array where to store the descendants
  1051. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1052. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1053. */
  1054. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1055. /**
  1056. * Will return all controls that have this control as ascendant
  1057. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  1058. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  1059. * @return all child controls
  1060. */
  1061. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  1062. /**
  1063. * Link current control with a target mesh
  1064. * @param mesh defines the mesh to link with
  1065. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  1066. */
  1067. linkWithMesh(mesh: Nullable<AbstractMesh>): void;
  1068. /** @hidden */
  1069. _moveToProjectedPosition(projectedPosition: Vector3): void;
  1070. /** @hidden */
  1071. _offsetLeft(offset: number): void;
  1072. /** @hidden */
  1073. _offsetTop(offset: number): void;
  1074. /** @hidden */
  1075. _markMatrixAsDirty(): void;
  1076. /** @hidden */
  1077. _flagDescendantsAsMatrixDirty(): void;
  1078. /** @hidden */
  1079. _intersectsRect(rect: Measure): boolean;
  1080. /** @hidden */
  1081. protected invalidateRect(): void;
  1082. /** @hidden */
  1083. _markAsDirty(force?: boolean): void;
  1084. /** @hidden */
  1085. _markAllAsDirty(): void;
  1086. /** @hidden */
  1087. _link(host: AdvancedDynamicTexture): void;
  1088. /** @hidden */
  1089. protected _transform(context?: CanvasRenderingContext2D): void;
  1090. /** @hidden */
  1091. _renderHighlight(context: CanvasRenderingContext2D): void;
  1092. /** @hidden */
  1093. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  1094. /** @hidden */
  1095. protected _applyStates(context: CanvasRenderingContext2D): void;
  1096. /** @hidden */
  1097. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1098. /** @hidden */
  1099. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1100. protected _evaluateClippingState(parentMeasure: Measure): void;
  1101. /** @hidden */
  1102. _measure(): void;
  1103. /** @hidden */
  1104. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1105. /** @hidden */
  1106. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1107. /** @hidden */
  1108. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1109. /** @hidden */
  1110. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1111. private static _ClipMeasure;
  1112. private _tmpMeasureA;
  1113. private _clip;
  1114. /** @hidden */
  1115. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): boolean;
  1116. /** @hidden */
  1117. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  1118. /**
  1119. * Tests if a given coordinates belong to the current control
  1120. * @param x defines x coordinate to test
  1121. * @param y defines y coordinate to test
  1122. * @returns true if the coordinates are inside the control
  1123. */
  1124. contains(x: number, y: number): boolean;
  1125. /** @hidden */
  1126. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1127. /** @hidden */
  1128. _onPointerMove(target: Control, coordinates: Vector2, pointerId: number): void;
  1129. /** @hidden */
  1130. _onPointerEnter(target: Control): boolean;
  1131. /** @hidden */
  1132. _onPointerOut(target: Control, force?: boolean): void;
  1133. /** @hidden */
  1134. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1135. /** @hidden */
  1136. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1137. /** @hidden */
  1138. _forcePointerUp(pointerId?: Nullable<number>): void;
  1139. /** @hidden */
  1140. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  1141. private _prepareFont;
  1142. /** Releases associated resources */
  1143. dispose(): void;
  1144. private static _HORIZONTAL_ALIGNMENT_LEFT;
  1145. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  1146. private static _HORIZONTAL_ALIGNMENT_CENTER;
  1147. private static _VERTICAL_ALIGNMENT_TOP;
  1148. private static _VERTICAL_ALIGNMENT_BOTTOM;
  1149. private static _VERTICAL_ALIGNMENT_CENTER;
  1150. /** HORIZONTAL_ALIGNMENT_LEFT */
  1151. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  1152. /** HORIZONTAL_ALIGNMENT_RIGHT */
  1153. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  1154. /** HORIZONTAL_ALIGNMENT_CENTER */
  1155. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  1156. /** VERTICAL_ALIGNMENT_TOP */
  1157. static readonly VERTICAL_ALIGNMENT_TOP: number;
  1158. /** VERTICAL_ALIGNMENT_BOTTOM */
  1159. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  1160. /** VERTICAL_ALIGNMENT_CENTER */
  1161. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  1162. private static _FontHeightSizes;
  1163. /** @hidden */
  1164. static _GetFontOffset(font: string): {
  1165. ascent: number;
  1166. height: number;
  1167. descent: number;
  1168. };
  1169. /**
  1170. * Creates a stack panel that can be used to render headers
  1171. * @param control defines the control to associate with the header
  1172. * @param text defines the text of the header
  1173. * @param size defines the size of the header
  1174. * @param options defines options used to configure the header
  1175. * @returns a new StackPanel
  1176. * @ignore
  1177. * @hidden
  1178. */
  1179. static AddHeader: (control: Control, text: string, size: string | number, options: {
  1180. isHorizontal: boolean;
  1181. controlFirst: boolean;
  1182. }) => any;
  1183. /** @hidden */
  1184. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  1185. }
  1186. }
  1187. declare module "babylonjs-gui/2D/controls/container" {
  1188. import { Nullable } from "babylonjs/types";
  1189. import { Control } from "babylonjs-gui/2D/controls/control";
  1190. import { Measure } from "babylonjs-gui/2D/measure";
  1191. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  1192. /**
  1193. * Root class for 2D containers
  1194. * @see http://doc.babylonjs.com/how_to/gui#containers
  1195. */
  1196. export class Container extends Control {
  1197. name?: string | undefined;
  1198. /** @hidden */
  1199. protected _children: Control[];
  1200. /** @hidden */
  1201. protected _measureForChildren: Measure;
  1202. /** @hidden */
  1203. protected _background: string;
  1204. /** @hidden */
  1205. protected _adaptWidthToChildren: boolean;
  1206. /** @hidden */
  1207. protected _adaptHeightToChildren: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  1210. */
  1211. logLayoutCycleErrors: boolean;
  1212. /**
  1213. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  1214. */
  1215. maxLayoutCycle: number;
  1216. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  1217. adaptHeightToChildren: boolean;
  1218. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  1219. adaptWidthToChildren: boolean;
  1220. /** Gets or sets background color */
  1221. background: string;
  1222. /** Gets the list of children */
  1223. readonly children: Control[];
  1224. /**
  1225. * Creates a new Container
  1226. * @param name defines the name of the container
  1227. */
  1228. constructor(name?: string | undefined);
  1229. protected _getTypeName(): string;
  1230. _flagDescendantsAsMatrixDirty(): void;
  1231. /**
  1232. * Gets a child using its name
  1233. * @param name defines the child name to look for
  1234. * @returns the child control if found
  1235. */
  1236. getChildByName(name: string): Nullable<Control>;
  1237. /**
  1238. * Gets a child using its type and its name
  1239. * @param name defines the child name to look for
  1240. * @param type defines the child type to look for
  1241. * @returns the child control if found
  1242. */
  1243. getChildByType(name: string, type: string): Nullable<Control>;
  1244. /**
  1245. * Search for a specific control in children
  1246. * @param control defines the control to look for
  1247. * @returns true if the control is in child list
  1248. */
  1249. containsControl(control: Control): boolean;
  1250. /**
  1251. * Adds a new control to the current container
  1252. * @param control defines the control to add
  1253. * @returns the current container
  1254. */
  1255. addControl(control: Nullable<Control>): Container;
  1256. /**
  1257. * Removes all controls from the current container
  1258. * @returns the current container
  1259. */
  1260. clearControls(): Container;
  1261. /**
  1262. * Removes a control from the current container
  1263. * @param control defines the control to remove
  1264. * @returns the current container
  1265. */
  1266. removeControl(control: Control): Container;
  1267. /** @hidden */
  1268. _reOrderControl(control: Control): void;
  1269. /** @hidden */
  1270. _offsetLeft(offset: number): void;
  1271. /** @hidden */
  1272. _offsetTop(offset: number): void;
  1273. /** @hidden */
  1274. _markAllAsDirty(): void;
  1275. /** @hidden */
  1276. protected _localDraw(context: CanvasRenderingContext2D): void;
  1277. /** @hidden */
  1278. _link(host: AdvancedDynamicTexture): void;
  1279. /** @hidden */
  1280. protected _beforeLayout(): void;
  1281. /** @hidden */
  1282. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1283. /** @hidden */
  1284. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  1285. protected _postMeasure(): void;
  1286. /** @hidden */
  1287. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  1288. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  1289. /** @hidden */
  1290. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1291. /** @hidden */
  1292. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1293. /** Releases associated resources */
  1294. dispose(): void;
  1295. }
  1296. }
  1297. declare module "babylonjs-gui/2D/controls/rectangle" {
  1298. import { Container } from "babylonjs-gui/2D/controls/container";
  1299. import { Measure } from "babylonjs-gui/2D/measure";
  1300. /** Class used to create rectangle container */
  1301. export class Rectangle extends Container {
  1302. name?: string | undefined;
  1303. private _thickness;
  1304. private _cornerRadius;
  1305. /** Gets or sets border thickness */
  1306. thickness: number;
  1307. /** Gets or sets the corner radius angle */
  1308. cornerRadius: number;
  1309. /**
  1310. * Creates a new Rectangle
  1311. * @param name defines the control name
  1312. */
  1313. constructor(name?: string | undefined);
  1314. protected _getTypeName(): string;
  1315. protected _localDraw(context: CanvasRenderingContext2D): void;
  1316. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1317. private _drawRoundedRect;
  1318. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  1319. }
  1320. }
  1321. declare module "babylonjs-gui/2D/controls/textBlock" {
  1322. import { Observable } from "babylonjs/Misc/observable";
  1323. import { Measure } from "babylonjs-gui/2D/measure";
  1324. import { Control } from "babylonjs-gui/2D/controls/control";
  1325. import { Nullable } from 'babylonjs/types';
  1326. /**
  1327. * Enum that determines the text-wrapping mode to use.
  1328. */
  1329. export enum TextWrapping {
  1330. /**
  1331. * Clip the text when it's larger than Control.width; this is the default mode.
  1332. */
  1333. Clip = 0,
  1334. /**
  1335. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  1336. */
  1337. WordWrap = 1,
  1338. /**
  1339. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  1340. */
  1341. Ellipsis = 2
  1342. }
  1343. /**
  1344. * Class used to create text block control
  1345. */
  1346. export class TextBlock extends Control {
  1347. /**
  1348. * Defines the name of the control
  1349. */
  1350. name?: string | undefined;
  1351. private _text;
  1352. private _textWrapping;
  1353. private _textHorizontalAlignment;
  1354. private _textVerticalAlignment;
  1355. private _lines;
  1356. private _resizeToFit;
  1357. private _lineSpacing;
  1358. private _outlineWidth;
  1359. private _outlineColor;
  1360. /**
  1361. * An event triggered after the text is changed
  1362. */
  1363. onTextChangedObservable: Observable<TextBlock>;
  1364. /**
  1365. * An event triggered after the text was broken up into lines
  1366. */
  1367. onLinesReadyObservable: Observable<TextBlock>;
  1368. /**
  1369. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  1370. */
  1371. readonly lines: any[];
  1372. /**
  1373. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1374. */
  1375. /**
  1376. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  1377. */
  1378. resizeToFit: boolean;
  1379. /**
  1380. * Gets or sets a boolean indicating if text must be wrapped
  1381. */
  1382. /**
  1383. * Gets or sets a boolean indicating if text must be wrapped
  1384. */
  1385. textWrapping: TextWrapping | boolean;
  1386. /**
  1387. * Gets or sets text to display
  1388. */
  1389. /**
  1390. * Gets or sets text to display
  1391. */
  1392. text: string;
  1393. /**
  1394. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1395. */
  1396. /**
  1397. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  1398. */
  1399. textHorizontalAlignment: number;
  1400. /**
  1401. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1402. */
  1403. /**
  1404. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  1405. */
  1406. textVerticalAlignment: number;
  1407. /**
  1408. * Gets or sets line spacing value
  1409. */
  1410. /**
  1411. * Gets or sets line spacing value
  1412. */
  1413. lineSpacing: string | number;
  1414. /**
  1415. * Gets or sets outlineWidth of the text to display
  1416. */
  1417. /**
  1418. * Gets or sets outlineWidth of the text to display
  1419. */
  1420. outlineWidth: number;
  1421. /**
  1422. * Gets or sets outlineColor of the text to display
  1423. */
  1424. /**
  1425. * Gets or sets outlineColor of the text to display
  1426. */
  1427. outlineColor: string;
  1428. /**
  1429. * Creates a new TextBlock object
  1430. * @param name defines the name of the control
  1431. * @param text defines the text to display (emptry string by default)
  1432. */
  1433. constructor(
  1434. /**
  1435. * Defines the name of the control
  1436. */
  1437. name?: string | undefined, text?: string);
  1438. protected _getTypeName(): string;
  1439. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1440. private _drawText;
  1441. /** @hidden */
  1442. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  1443. protected _applyStates(context: CanvasRenderingContext2D): void;
  1444. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  1445. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  1446. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  1447. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  1448. protected _renderLines(context: CanvasRenderingContext2D): void;
  1449. /**
  1450. * Given a width constraint applied on the text block, find the expected height
  1451. * @returns expected height
  1452. */
  1453. computeExpectedHeight(): number;
  1454. dispose(): void;
  1455. }
  1456. }
  1457. declare module "babylonjs-gui/2D/controls/image" {
  1458. import { Nullable } from "babylonjs/types";
  1459. import { Observable } from "babylonjs/Misc/observable";
  1460. import { Control } from "babylonjs-gui/2D/controls/control";
  1461. import { Measure } from "babylonjs-gui/2D/measure";
  1462. /**
  1463. * Class used to create 2D images
  1464. */
  1465. export class Image extends Control {
  1466. name?: string | undefined;
  1467. private _workingCanvas;
  1468. private _domImage;
  1469. private _imageWidth;
  1470. private _imageHeight;
  1471. private _loaded;
  1472. private _stretch;
  1473. private _source;
  1474. private _autoScale;
  1475. private _sourceLeft;
  1476. private _sourceTop;
  1477. private _sourceWidth;
  1478. private _sourceHeight;
  1479. private _cellWidth;
  1480. private _cellHeight;
  1481. private _cellId;
  1482. private _populateNinePatchSlicesFromImage;
  1483. private _sliceLeft;
  1484. private _sliceRight;
  1485. private _sliceTop;
  1486. private _sliceBottom;
  1487. private _detectPointerOnOpaqueOnly;
  1488. /**
  1489. * Observable notified when the content is loaded
  1490. */
  1491. onImageLoadedObservable: Observable<Image>;
  1492. /**
  1493. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  1494. */
  1495. onSVGAttributesComputedObservable: Observable<Image>;
  1496. /**
  1497. * Gets a boolean indicating that the content is loaded
  1498. */
  1499. readonly isLoaded: boolean;
  1500. /**
  1501. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  1502. */
  1503. populateNinePatchSlicesFromImage: boolean;
  1504. /**
  1505. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  1506. * Beware using this as this will comsume more memory as the image has to be stored twice
  1507. */
  1508. detectPointerOnOpaqueOnly: boolean;
  1509. /**
  1510. * Gets or sets the left value for slicing (9-patch)
  1511. */
  1512. sliceLeft: number;
  1513. /**
  1514. * Gets or sets the right value for slicing (9-patch)
  1515. */
  1516. sliceRight: number;
  1517. /**
  1518. * Gets or sets the top value for slicing (9-patch)
  1519. */
  1520. sliceTop: number;
  1521. /**
  1522. * Gets or sets the bottom value for slicing (9-patch)
  1523. */
  1524. sliceBottom: number;
  1525. /**
  1526. * Gets or sets the left coordinate in the source image
  1527. */
  1528. sourceLeft: number;
  1529. /**
  1530. * Gets or sets the top coordinate in the source image
  1531. */
  1532. sourceTop: number;
  1533. /**
  1534. * Gets or sets the width to capture in the source image
  1535. */
  1536. sourceWidth: number;
  1537. /**
  1538. * Gets or sets the height to capture in the source image
  1539. */
  1540. sourceHeight: number;
  1541. /**
  1542. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  1543. * @see http://doc.babylonjs.com/how_to/gui#image
  1544. */
  1545. autoScale: boolean;
  1546. /** Gets or sets the streching mode used by the image */
  1547. stretch: number;
  1548. /**
  1549. * Gets or sets the internal DOM image used to render the control
  1550. */
  1551. domImage: HTMLImageElement;
  1552. private _onImageLoaded;
  1553. private _extractNinePatchSliceDataFromImage;
  1554. /**
  1555. * Gets or sets image source url
  1556. */
  1557. source: Nullable<string>;
  1558. /**
  1559. * Checks for svg document with icon id present
  1560. */
  1561. private _svgCheck;
  1562. /**
  1563. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  1564. * given external svg file and icon id
  1565. */
  1566. private _getSVGAttribs;
  1567. /**
  1568. * Gets or sets the cell width to use when animation sheet is enabled
  1569. * @see http://doc.babylonjs.com/how_to/gui#image
  1570. */
  1571. cellWidth: number;
  1572. /**
  1573. * Gets or sets the cell height to use when animation sheet is enabled
  1574. * @see http://doc.babylonjs.com/how_to/gui#image
  1575. */
  1576. cellHeight: number;
  1577. /**
  1578. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  1579. * @see http://doc.babylonjs.com/how_to/gui#image
  1580. */
  1581. cellId: number;
  1582. /**
  1583. * Creates a new Image
  1584. * @param name defines the control name
  1585. * @param url defines the image url
  1586. */
  1587. constructor(name?: string | undefined, url?: Nullable<string>);
  1588. /**
  1589. * Tests if a given coordinates belong to the current control
  1590. * @param x defines x coordinate to test
  1591. * @param y defines y coordinate to test
  1592. * @returns true if the coordinates are inside the control
  1593. */
  1594. contains(x: number, y: number): boolean;
  1595. protected _getTypeName(): string;
  1596. /** Force the control to synchronize with its content */
  1597. synchronizeSizeWithContent(): void;
  1598. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1599. private _prepareWorkingCanvasForOpaqueDetection;
  1600. private _drawImage;
  1601. _draw(context: CanvasRenderingContext2D): void;
  1602. private _renderCornerPatch;
  1603. private _renderNinePatch;
  1604. dispose(): void;
  1605. /** STRETCH_NONE */
  1606. static readonly STRETCH_NONE: number;
  1607. /** STRETCH_FILL */
  1608. static readonly STRETCH_FILL: number;
  1609. /** STRETCH_UNIFORM */
  1610. static readonly STRETCH_UNIFORM: number;
  1611. /** STRETCH_EXTEND */
  1612. static readonly STRETCH_EXTEND: number;
  1613. /** NINE_PATCH */
  1614. static readonly STRETCH_NINE_PATCH: number;
  1615. }
  1616. }
  1617. declare module "babylonjs-gui/2D/controls/button" {
  1618. import { Nullable } from "babylonjs/types";
  1619. import { Vector2 } from "babylonjs/Maths/math";
  1620. import { Rectangle } from "babylonjs-gui/2D/controls/rectangle";
  1621. import { Control } from "babylonjs-gui/2D/controls/control";
  1622. import { TextBlock } from "babylonjs-gui/2D/controls/textBlock";
  1623. import { Image } from "babylonjs-gui/2D/controls/image";
  1624. /**
  1625. * Class used to create 2D buttons
  1626. */
  1627. export class Button extends Rectangle {
  1628. name?: string | undefined;
  1629. /**
  1630. * Function called to generate a pointer enter animation
  1631. */
  1632. pointerEnterAnimation: () => void;
  1633. /**
  1634. * Function called to generate a pointer out animation
  1635. */
  1636. pointerOutAnimation: () => void;
  1637. /**
  1638. * Function called to generate a pointer down animation
  1639. */
  1640. pointerDownAnimation: () => void;
  1641. /**
  1642. * Function called to generate a pointer up animation
  1643. */
  1644. pointerUpAnimation: () => void;
  1645. /**
  1646. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1647. */
  1648. delegatePickingToChildren: boolean;
  1649. private _image;
  1650. /**
  1651. * Returns the image part of the button (if any)
  1652. */
  1653. readonly image: Nullable<Image>;
  1654. private _textBlock;
  1655. /**
  1656. * Returns the image part of the button (if any)
  1657. */
  1658. readonly textBlock: Nullable<TextBlock>;
  1659. /**
  1660. * Creates a new Button
  1661. * @param name defines the name of the button
  1662. */
  1663. constructor(name?: string | undefined);
  1664. protected _getTypeName(): string;
  1665. /** @hidden */
  1666. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  1667. /** @hidden */
  1668. _onPointerEnter(target: Control): boolean;
  1669. /** @hidden */
  1670. _onPointerOut(target: Control, force?: boolean): void;
  1671. /** @hidden */
  1672. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1673. /** @hidden */
  1674. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  1675. /**
  1676. * Creates a new button made with an image and a text
  1677. * @param name defines the name of the button
  1678. * @param text defines the text of the button
  1679. * @param imageUrl defines the url of the image
  1680. * @returns a new Button
  1681. */
  1682. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  1683. /**
  1684. * Creates a new button made with an image
  1685. * @param name defines the name of the button
  1686. * @param imageUrl defines the url of the image
  1687. * @returns a new Button
  1688. */
  1689. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  1690. /**
  1691. * Creates a new button made with a text
  1692. * @param name defines the name of the button
  1693. * @param text defines the text of the button
  1694. * @returns a new Button
  1695. */
  1696. static CreateSimpleButton(name: string, text: string): Button;
  1697. /**
  1698. * Creates a new button made with an image and a centered text
  1699. * @param name defines the name of the button
  1700. * @param text defines the text of the button
  1701. * @param imageUrl defines the url of the image
  1702. * @returns a new Button
  1703. */
  1704. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  1705. }
  1706. }
  1707. declare module "babylonjs-gui/2D/controls/stackPanel" {
  1708. import { Container } from "babylonjs-gui/2D/controls/container";
  1709. import { Measure } from "babylonjs-gui/2D/measure";
  1710. /**
  1711. * Class used to create a 2D stack panel container
  1712. */
  1713. export class StackPanel extends Container {
  1714. name?: string | undefined;
  1715. private _isVertical;
  1716. private _manualWidth;
  1717. private _manualHeight;
  1718. private _doNotTrackManualChanges;
  1719. /**
  1720. * Gets or sets a boolean indicating that layou warnings should be ignored
  1721. */
  1722. ignoreLayoutWarnings: boolean;
  1723. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  1724. isVertical: boolean;
  1725. /**
  1726. * Gets or sets panel width.
  1727. * This value should not be set when in horizontal mode as it will be computed automatically
  1728. */
  1729. width: string | number;
  1730. /**
  1731. * Gets or sets panel height.
  1732. * This value should not be set when in vertical mode as it will be computed automatically
  1733. */
  1734. height: string | number;
  1735. /**
  1736. * Creates a new StackPanel
  1737. * @param name defines control name
  1738. */
  1739. constructor(name?: string | undefined);
  1740. protected _getTypeName(): string;
  1741. /** @hidden */
  1742. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1743. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  1744. protected _postMeasure(): void;
  1745. }
  1746. }
  1747. declare module "babylonjs-gui/2D/controls/checkbox" {
  1748. import { Observable } from "babylonjs/Misc/observable";
  1749. import { Vector2 } from "babylonjs/Maths/math";
  1750. import { Control } from "babylonjs-gui/2D/controls/control";
  1751. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  1752. import { Nullable } from 'babylonjs/types';
  1753. import { Measure } from "babylonjs-gui/2D/measure";
  1754. /**
  1755. * Class used to represent a 2D checkbox
  1756. */
  1757. export class Checkbox extends Control {
  1758. name?: string | undefined;
  1759. private _isChecked;
  1760. private _background;
  1761. private _checkSizeRatio;
  1762. private _thickness;
  1763. /** Gets or sets border thickness */
  1764. thickness: number;
  1765. /**
  1766. * Observable raised when isChecked property changes
  1767. */
  1768. onIsCheckedChangedObservable: Observable<boolean>;
  1769. /** Gets or sets a value indicating the ratio between overall size and check size */
  1770. checkSizeRatio: number;
  1771. /** Gets or sets background color */
  1772. background: string;
  1773. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1774. isChecked: boolean;
  1775. /**
  1776. * Creates a new CheckBox
  1777. * @param name defines the control name
  1778. */
  1779. constructor(name?: string | undefined);
  1780. protected _getTypeName(): string;
  1781. /** @hidden */
  1782. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  1783. /** @hidden */
  1784. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  1785. /**
  1786. * Utility function to easily create a checkbox with a header
  1787. * @param title defines the label to use for the header
  1788. * @param onValueChanged defines the callback to call when value changes
  1789. * @returns a StackPanel containing the checkbox and a textBlock
  1790. */
  1791. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  1792. }
  1793. }
  1794. declare module "babylonjs-gui/2D/controls/virtualKeyboard" {
  1795. import { Nullable } from "babylonjs/types";
  1796. import { Observable } from "babylonjs/Misc/observable";
  1797. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  1798. import { InputText } from "babylonjs-gui/2D/controls/inputText";
  1799. /**
  1800. * Class used to store key control properties
  1801. */
  1802. export class KeyPropertySet {
  1803. /** Width */
  1804. width?: string;
  1805. /** Height */
  1806. height?: string;
  1807. /** Left padding */
  1808. paddingLeft?: string;
  1809. /** Right padding */
  1810. paddingRight?: string;
  1811. /** Top padding */
  1812. paddingTop?: string;
  1813. /** Bottom padding */
  1814. paddingBottom?: string;
  1815. /** Foreground color */
  1816. color?: string;
  1817. /** Background color */
  1818. background?: string;
  1819. }
  1820. /**
  1821. * Class used to create virtual keyboard
  1822. */
  1823. export class VirtualKeyboard extends StackPanel {
  1824. /** Observable raised when a key is pressed */
  1825. onKeyPressObservable: Observable<string>;
  1826. /** Gets or sets default key button width */
  1827. defaultButtonWidth: string;
  1828. /** Gets or sets default key button height */
  1829. defaultButtonHeight: string;
  1830. /** Gets or sets default key button left padding */
  1831. defaultButtonPaddingLeft: string;
  1832. /** Gets or sets default key button right padding */
  1833. defaultButtonPaddingRight: string;
  1834. /** Gets or sets default key button top padding */
  1835. defaultButtonPaddingTop: string;
  1836. /** Gets or sets default key button bottom padding */
  1837. defaultButtonPaddingBottom: string;
  1838. /** Gets or sets default key button foreground color */
  1839. defaultButtonColor: string;
  1840. /** Gets or sets default key button background color */
  1841. defaultButtonBackground: string;
  1842. /** Gets or sets shift button foreground color */
  1843. shiftButtonColor: string;
  1844. /** Gets or sets shift button thickness*/
  1845. selectedShiftThickness: number;
  1846. /** Gets shift key state */
  1847. shiftState: number;
  1848. protected _getTypeName(): string;
  1849. private _createKey;
  1850. /**
  1851. * Adds a new row of keys
  1852. * @param keys defines the list of keys to add
  1853. * @param propertySets defines the associated property sets
  1854. */
  1855. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  1856. /**
  1857. * Set the shift key to a specific state
  1858. * @param shiftState defines the new shift state
  1859. */
  1860. applyShiftState(shiftState: number): void;
  1861. private _currentlyConnectedInputText;
  1862. private _connectedInputTexts;
  1863. private _onKeyPressObserver;
  1864. /** Gets the input text control currently attached to the keyboard */
  1865. readonly connectedInputText: Nullable<InputText>;
  1866. /**
  1867. * Connects the keyboard with an input text control
  1868. *
  1869. * @param input defines the target control
  1870. */
  1871. connect(input: InputText): void;
  1872. /**
  1873. * Disconnects the keyboard from connected InputText controls
  1874. *
  1875. * @param input optionally defines a target control, otherwise all are disconnected
  1876. */
  1877. disconnect(input?: InputText): void;
  1878. private _removeConnectedInputObservables;
  1879. /**
  1880. * Release all resources
  1881. */
  1882. dispose(): void;
  1883. /**
  1884. * Creates a new keyboard using a default layout
  1885. *
  1886. * @param name defines control name
  1887. * @returns a new VirtualKeyboard
  1888. */
  1889. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  1890. }
  1891. }
  1892. declare module "babylonjs-gui/2D/controls/inputText" {
  1893. import { Nullable } from "babylonjs/types";
  1894. import { Observable } from "babylonjs/Misc/observable";
  1895. import { Vector2 } from "babylonjs/Maths/math";
  1896. import { Control } from "babylonjs-gui/2D/controls/control";
  1897. import { IFocusableControl } from "babylonjs-gui/2D/advancedDynamicTexture";
  1898. import { VirtualKeyboard } from "babylonjs-gui/2D/controls/virtualKeyboard";
  1899. import { Measure } from "babylonjs-gui/2D/measure";
  1900. /**
  1901. * Class used to create input text control
  1902. */
  1903. export class InputText extends Control implements IFocusableControl {
  1904. name?: string | undefined;
  1905. private _text;
  1906. private _placeholderText;
  1907. private _background;
  1908. private _focusedBackground;
  1909. private _focusedColor;
  1910. private _placeholderColor;
  1911. private _thickness;
  1912. private _margin;
  1913. private _autoStretchWidth;
  1914. private _maxWidth;
  1915. private _isFocused;
  1916. private _blinkTimeout;
  1917. private _blinkIsEven;
  1918. private _cursorOffset;
  1919. private _scrollLeft;
  1920. private _textWidth;
  1921. private _clickedCoordinate;
  1922. private _deadKey;
  1923. private _addKey;
  1924. private _currentKey;
  1925. private _isTextHighlightOn;
  1926. private _textHighlightColor;
  1927. private _highligherOpacity;
  1928. private _highlightedText;
  1929. private _startHighlightIndex;
  1930. private _endHighlightIndex;
  1931. private _cursorIndex;
  1932. private _onFocusSelectAll;
  1933. private _isPointerDown;
  1934. private _onClipboardObserver;
  1935. private _onPointerDblTapObserver;
  1936. /** @hidden */
  1937. _connectedVirtualKeyboard: Nullable<VirtualKeyboard>;
  1938. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  1939. promptMessage: string;
  1940. /** Force disable prompt on mobile device */
  1941. disableMobilePrompt: boolean;
  1942. /** Observable raised when the text changes */
  1943. onTextChangedObservable: Observable<InputText>;
  1944. /** Observable raised just before an entered character is to be added */
  1945. onBeforeKeyAddObservable: Observable<InputText>;
  1946. /** Observable raised when the control gets the focus */
  1947. onFocusObservable: Observable<InputText>;
  1948. /** Observable raised when the control loses the focus */
  1949. onBlurObservable: Observable<InputText>;
  1950. /**Observable raised when the text is highlighted */
  1951. onTextHighlightObservable: Observable<InputText>;
  1952. /**Observable raised when copy event is triggered */
  1953. onTextCopyObservable: Observable<InputText>;
  1954. /** Observable raised when cut event is triggered */
  1955. onTextCutObservable: Observable<InputText>;
  1956. /** Observable raised when paste event is triggered */
  1957. onTextPasteObservable: Observable<InputText>;
  1958. /** Observable raised when a key event was processed */
  1959. onKeyboardEventProcessedObservable: Observable<KeyboardEvent>;
  1960. /** Gets or sets the maximum width allowed by the control */
  1961. maxWidth: string | number;
  1962. /** Gets the maximum width allowed by the control in pixels */
  1963. readonly maxWidthInPixels: number;
  1964. /** Gets or sets the text highlighter transparency; default: 0.4 */
  1965. highligherOpacity: number;
  1966. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  1967. onFocusSelectAll: boolean;
  1968. /** Gets or sets the text hightlight color */
  1969. textHighlightColor: string;
  1970. /** Gets or sets control margin */
  1971. margin: string;
  1972. /** Gets control margin in pixels */
  1973. readonly marginInPixels: number;
  1974. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  1975. autoStretchWidth: boolean;
  1976. /** Gets or sets border thickness */
  1977. thickness: number;
  1978. /** Gets or sets the background color when focused */
  1979. focusedBackground: string;
  1980. /** Gets or sets the background color when focused */
  1981. focusedColor: string;
  1982. /** Gets or sets the background color */
  1983. background: string;
  1984. /** Gets or sets the placeholder color */
  1985. placeholderColor: string;
  1986. /** Gets or sets the text displayed when the control is empty */
  1987. placeholderText: string;
  1988. /** Gets or sets the dead key flag */
  1989. deadKey: boolean;
  1990. /** Gets or sets the highlight text */
  1991. highlightedText: string;
  1992. /** Gets or sets if the current key should be added */
  1993. addKey: boolean;
  1994. /** Gets or sets the value of the current key being entered */
  1995. currentKey: string;
  1996. /** Gets or sets the text displayed in the control */
  1997. text: string;
  1998. /** Gets or sets control width */
  1999. width: string | number;
  2000. /**
  2001. * Creates a new InputText
  2002. * @param name defines the control name
  2003. * @param text defines the text of the control
  2004. */
  2005. constructor(name?: string | undefined, text?: string);
  2006. /** @hidden */
  2007. onBlur(): void;
  2008. /** @hidden */
  2009. onFocus(): void;
  2010. protected _getTypeName(): string;
  2011. /**
  2012. * Function called to get the list of controls that should not steal the focus from this control
  2013. * @returns an array of controls
  2014. */
  2015. keepsFocusWith(): Nullable<Control[]>;
  2016. /** @hidden */
  2017. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  2018. /** @hidden */
  2019. private _updateValueFromCursorIndex;
  2020. /** @hidden */
  2021. private _processDblClick;
  2022. /** @hidden */
  2023. private _selectAllText;
  2024. /**
  2025. * Handles the keyboard event
  2026. * @param evt Defines the KeyboardEvent
  2027. */
  2028. processKeyboard(evt: KeyboardEvent): void;
  2029. /** @hidden */
  2030. private _onCopyText;
  2031. /** @hidden */
  2032. private _onCutText;
  2033. /** @hidden */
  2034. private _onPasteText;
  2035. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  2036. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2037. _onPointerMove(target: Control, coordinates: Vector2, pointerId: number): void;
  2038. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2039. protected _beforeRenderText(text: string): string;
  2040. dispose(): void;
  2041. }
  2042. }
  2043. declare module "babylonjs-gui/2D/controls/grid" {
  2044. import { Nullable } from "babylonjs/types";
  2045. import { Container } from "babylonjs-gui/2D/controls/container";
  2046. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  2047. import { Control } from "babylonjs-gui/2D/controls/control";
  2048. import { Measure } from "babylonjs-gui/2D/measure";
  2049. /**
  2050. * Class used to create a 2D grid container
  2051. */
  2052. export class Grid extends Container {
  2053. name?: string | undefined;
  2054. private _rowDefinitions;
  2055. private _columnDefinitions;
  2056. private _cells;
  2057. private _childControls;
  2058. /**
  2059. * Gets the number of columns
  2060. */
  2061. readonly columnCount: number;
  2062. /**
  2063. * Gets the number of rows
  2064. */
  2065. readonly rowCount: number;
  2066. /** Gets the list of children */
  2067. readonly children: Control[];
  2068. /** Gets the list of cells (e.g. the containers) */
  2069. readonly cells: {
  2070. [key: string]: Container;
  2071. };
  2072. /**
  2073. * Gets the definition of a specific row
  2074. * @param index defines the index of the row
  2075. * @returns the row definition
  2076. */
  2077. getRowDefinition(index: number): Nullable<ValueAndUnit>;
  2078. /**
  2079. * Gets the definition of a specific column
  2080. * @param index defines the index of the column
  2081. * @returns the column definition
  2082. */
  2083. getColumnDefinition(index: number): Nullable<ValueAndUnit>;
  2084. /**
  2085. * Adds a new row to the grid
  2086. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2087. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  2088. * @returns the current grid
  2089. */
  2090. addRowDefinition(height: number, isPixel?: boolean): Grid;
  2091. /**
  2092. * Adds a new column to the grid
  2093. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2094. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2095. * @returns the current grid
  2096. */
  2097. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  2098. /**
  2099. * Update a row definition
  2100. * @param index defines the index of the row to update
  2101. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  2102. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  2103. * @returns the current grid
  2104. */
  2105. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  2106. /**
  2107. * Update a column definition
  2108. * @param index defines the index of the column to update
  2109. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  2110. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  2111. * @returns the current grid
  2112. */
  2113. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  2114. /**
  2115. * Gets the list of children stored in a specific cell
  2116. * @param row defines the row to check
  2117. * @param column defines the column to check
  2118. * @returns the list of controls
  2119. */
  2120. getChildrenAt(row: number, column: number): Nullable<Array<Control>>;
  2121. /**
  2122. * Gets a string representing the child cell info (row x column)
  2123. * @param child defines the control to get info from
  2124. * @returns a string containing the child cell info (row x column)
  2125. */
  2126. getChildCellInfo(child: Control): string;
  2127. private _removeCell;
  2128. private _offsetCell;
  2129. /**
  2130. * Remove a column definition at specified index
  2131. * @param index defines the index of the column to remove
  2132. * @returns the current grid
  2133. */
  2134. removeColumnDefinition(index: number): Grid;
  2135. /**
  2136. * Remove a row definition at specified index
  2137. * @param index defines the index of the row to remove
  2138. * @returns the current grid
  2139. */
  2140. removeRowDefinition(index: number): Grid;
  2141. /**
  2142. * Adds a new control to the current grid
  2143. * @param control defines the control to add
  2144. * @param row defines the row where to add the control (0 by default)
  2145. * @param column defines the column where to add the control (0 by default)
  2146. * @returns the current grid
  2147. */
  2148. addControl(control: Control, row?: number, column?: number): Grid;
  2149. /**
  2150. * Removes a control from the current container
  2151. * @param control defines the control to remove
  2152. * @returns the current container
  2153. */
  2154. removeControl(control: Control): Container;
  2155. /**
  2156. * Creates a new Grid
  2157. * @param name defines control name
  2158. */
  2159. constructor(name?: string | undefined);
  2160. protected _getTypeName(): string;
  2161. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  2162. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2163. _flagDescendantsAsMatrixDirty(): void;
  2164. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  2165. /** Releases associated resources */
  2166. dispose(): void;
  2167. }
  2168. }
  2169. declare module "babylonjs-gui/2D/controls/colorpicker" {
  2170. import { Observable } from "babylonjs/Misc/observable";
  2171. import { Color3, Vector2 } from "babylonjs/Maths/math";
  2172. import { Control } from "babylonjs-gui/2D/controls/control";
  2173. import { Measure } from "babylonjs-gui/2D/measure";
  2174. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  2175. /** Class used to create color pickers */
  2176. export class ColorPicker extends Control {
  2177. name?: string | undefined;
  2178. private static _Epsilon;
  2179. private _colorWheelCanvas;
  2180. private _value;
  2181. private _tmpColor;
  2182. private _pointerStartedOnSquare;
  2183. private _pointerStartedOnWheel;
  2184. private _squareLeft;
  2185. private _squareTop;
  2186. private _squareSize;
  2187. private _h;
  2188. private _s;
  2189. private _v;
  2190. private _lastPointerDownID;
  2191. /**
  2192. * Observable raised when the value changes
  2193. */
  2194. onValueChangedObservable: Observable<Color3>;
  2195. /** Gets or sets the color of the color picker */
  2196. value: Color3;
  2197. /**
  2198. * Gets or sets control width
  2199. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  2200. */
  2201. width: string | number;
  2202. /**
  2203. * Gets or sets control height
  2204. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  2205. */
  2206. /** Gets or sets control height */
  2207. height: string | number;
  2208. /** Gets or sets control size */
  2209. size: string | number;
  2210. /**
  2211. * Creates a new ColorPicker
  2212. * @param name defines the control name
  2213. */
  2214. constructor(name?: string | undefined);
  2215. protected _getTypeName(): string;
  2216. /** @hidden */
  2217. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2218. private _updateSquareProps;
  2219. private _drawGradientSquare;
  2220. private _drawCircle;
  2221. private _createColorWheelCanvas;
  2222. /** @hidden */
  2223. _draw(context: CanvasRenderingContext2D): void;
  2224. private _pointerIsDown;
  2225. private _updateValueFromPointer;
  2226. private _isPointOnSquare;
  2227. private _isPointOnWheel;
  2228. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2229. _onPointerMove(target: Control, coordinates: Vector2, pointerId: number): void;
  2230. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2231. /**
  2232. * This function expands the color picker by creating a color picker dialog with manual
  2233. * color value input and the ability to save colors into an array to be used later in
  2234. * subsequent launches of the dialogue.
  2235. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2236. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2237. * @returns picked color as a hex string and the saved colors array as hex strings.
  2238. */
  2239. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  2240. pickerWidth?: string;
  2241. pickerHeight?: string;
  2242. headerHeight?: string;
  2243. lastColor?: string;
  2244. swatchLimit?: number;
  2245. numSwatchesPerLine?: number;
  2246. savedColors?: Array<string>;
  2247. }): Promise<{
  2248. savedColors?: string[];
  2249. pickedColor: string;
  2250. }>;
  2251. }
  2252. }
  2253. declare module "babylonjs-gui/2D/controls/ellipse" {
  2254. import { Container } from "babylonjs-gui/2D/controls/container";
  2255. import { Measure } from "babylonjs-gui/2D/measure";
  2256. /** Class used to create 2D ellipse containers */
  2257. export class Ellipse extends Container {
  2258. name?: string | undefined;
  2259. private _thickness;
  2260. /** Gets or sets border thickness */
  2261. thickness: number;
  2262. /**
  2263. * Creates a new Ellipse
  2264. * @param name defines the control name
  2265. */
  2266. constructor(name?: string | undefined);
  2267. protected _getTypeName(): string;
  2268. protected _localDraw(context: CanvasRenderingContext2D): void;
  2269. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2270. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  2271. }
  2272. }
  2273. declare module "babylonjs-gui/2D/controls/inputPassword" {
  2274. import { InputText } from "babylonjs-gui/2D/controls/inputText";
  2275. /**
  2276. * Class used to create a password control
  2277. */
  2278. export class InputPassword extends InputText {
  2279. protected _beforeRenderText(text: string): string;
  2280. }
  2281. }
  2282. declare module "babylonjs-gui/2D/controls/line" {
  2283. import { Vector3 } from "babylonjs/Maths/math";
  2284. import { Scene } from "babylonjs/scene";
  2285. import { Control } from "babylonjs-gui/2D/controls/control";
  2286. import { Measure } from "babylonjs-gui/2D/measure";
  2287. /** Class used to render 2D lines */
  2288. export class Line extends Control {
  2289. name?: string | undefined;
  2290. private _lineWidth;
  2291. private _x1;
  2292. private _y1;
  2293. private _x2;
  2294. private _y2;
  2295. private _dash;
  2296. private _connectedControl;
  2297. private _connectedControlDirtyObserver;
  2298. /** Gets or sets the dash pattern */
  2299. dash: Array<number>;
  2300. /** Gets or sets the control connected with the line end */
  2301. connectedControl: Control;
  2302. /** Gets or sets start coordinates on X axis */
  2303. x1: string | number;
  2304. /** Gets or sets start coordinates on Y axis */
  2305. y1: string | number;
  2306. /** Gets or sets end coordinates on X axis */
  2307. x2: string | number;
  2308. /** Gets or sets end coordinates on Y axis */
  2309. y2: string | number;
  2310. /** Gets or sets line width */
  2311. lineWidth: number;
  2312. /** Gets or sets horizontal alignment */
  2313. horizontalAlignment: number;
  2314. /** Gets or sets vertical alignment */
  2315. verticalAlignment: number;
  2316. private readonly _effectiveX2;
  2317. private readonly _effectiveY2;
  2318. /**
  2319. * Creates a new Line
  2320. * @param name defines the control name
  2321. */
  2322. constructor(name?: string | undefined);
  2323. protected _getTypeName(): string;
  2324. _draw(context: CanvasRenderingContext2D): void;
  2325. _measure(): void;
  2326. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2327. /**
  2328. * Move one end of the line given 3D cartesian coordinates.
  2329. * @param position Targeted world position
  2330. * @param scene Scene
  2331. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2332. */
  2333. moveToVector3(position: Vector3, scene: Scene, end?: boolean): void;
  2334. /**
  2335. * Move one end of the line to a position in screen absolute space.
  2336. * @param projectedPosition Position in screen absolute space (X, Y)
  2337. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  2338. */
  2339. _moveToProjectedPosition(projectedPosition: Vector3, end?: boolean): void;
  2340. }
  2341. }
  2342. declare module "babylonjs-gui/2D/multiLinePoint" {
  2343. import { Nullable } from "babylonjs/types";
  2344. import { Vector2 } from "babylonjs/Maths/math";
  2345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2346. import { MultiLine } from "babylonjs-gui/2D/controls/multiLine";
  2347. import { Control } from "babylonjs-gui/2D/controls/control";
  2348. /**
  2349. * Class used to store a point for a MultiLine object.
  2350. * The point can be pure 2D coordinates, a mesh or a control
  2351. */
  2352. export class MultiLinePoint {
  2353. private _multiLine;
  2354. private _x;
  2355. private _y;
  2356. private _control;
  2357. private _mesh;
  2358. private _controlObserver;
  2359. private _meshObserver;
  2360. /** @hidden */
  2361. _point: Vector2;
  2362. /**
  2363. * Creates a new MultiLinePoint
  2364. * @param multiLine defines the source MultiLine object
  2365. */
  2366. constructor(multiLine: MultiLine);
  2367. /** Gets or sets x coordinate */
  2368. x: string | number;
  2369. /** Gets or sets y coordinate */
  2370. y: string | number;
  2371. /** Gets or sets the control associated with this point */
  2372. control: Nullable<Control>;
  2373. /** Gets or sets the mesh associated with this point */
  2374. mesh: Nullable<AbstractMesh>;
  2375. /** Resets links */
  2376. resetLinks(): void;
  2377. /**
  2378. * Gets a translation vector
  2379. * @returns the translation vector
  2380. */
  2381. translate(): Vector2;
  2382. private _translatePoint;
  2383. /** Release associated resources */
  2384. dispose(): void;
  2385. }
  2386. }
  2387. declare module "babylonjs-gui/2D/controls/multiLine" {
  2388. import { Nullable } from "babylonjs/types";
  2389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2390. import { Control } from "babylonjs-gui/2D/controls/control";
  2391. import { MultiLinePoint } from "babylonjs-gui/2D/multiLinePoint";
  2392. import { Measure } from "babylonjs-gui/2D/measure";
  2393. /**
  2394. * Class used to create multi line control
  2395. */
  2396. export class MultiLine extends Control {
  2397. name?: string | undefined;
  2398. private _lineWidth;
  2399. private _dash;
  2400. private _points;
  2401. private _minX;
  2402. private _minY;
  2403. private _maxX;
  2404. private _maxY;
  2405. /**
  2406. * Creates a new MultiLine
  2407. * @param name defines the control name
  2408. */
  2409. constructor(name?: string | undefined);
  2410. /** Gets or sets dash pattern */
  2411. dash: Array<number>;
  2412. /**
  2413. * Gets point stored at specified index
  2414. * @param index defines the index to look for
  2415. * @returns the requested point if found
  2416. */
  2417. getAt(index: number): MultiLinePoint;
  2418. /** Function called when a point is updated */
  2419. onPointUpdate: () => void;
  2420. /**
  2421. * Adds new points to the point collection
  2422. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  2423. * @returns the list of created MultiLinePoint
  2424. */
  2425. add(...items: (AbstractMesh | Control | {
  2426. x: string | number;
  2427. y: string | number;
  2428. })[]): MultiLinePoint[];
  2429. /**
  2430. * Adds a new point to the point collection
  2431. * @param item defines the item (mesh, control or 2d coordiantes) to add
  2432. * @returns the created MultiLinePoint
  2433. */
  2434. push(item?: (AbstractMesh | Control | {
  2435. x: string | number;
  2436. y: string | number;
  2437. })): MultiLinePoint;
  2438. /**
  2439. * Remove a specific value or point from the active point collection
  2440. * @param value defines the value or point to remove
  2441. */
  2442. remove(value: number | MultiLinePoint): void;
  2443. /**
  2444. * Resets this object to initial state (no point)
  2445. */
  2446. reset(): void;
  2447. /**
  2448. * Resets all links
  2449. */
  2450. resetLinks(): void;
  2451. /** Gets or sets line width */
  2452. lineWidth: number;
  2453. horizontalAlignment: number;
  2454. verticalAlignment: number;
  2455. protected _getTypeName(): string;
  2456. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  2457. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2458. _measure(): void;
  2459. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2460. dispose(): void;
  2461. }
  2462. }
  2463. declare module "babylonjs-gui/2D/controls/radioButton" {
  2464. import { Observable } from "babylonjs/Misc/observable";
  2465. import { Vector2 } from "babylonjs/Maths/math";
  2466. import { Control } from "babylonjs-gui/2D/controls/control";
  2467. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  2468. /**
  2469. * Class used to create radio button controls
  2470. */
  2471. export class RadioButton extends Control {
  2472. name?: string | undefined;
  2473. private _isChecked;
  2474. private _background;
  2475. private _checkSizeRatio;
  2476. private _thickness;
  2477. /** Gets or sets border thickness */
  2478. thickness: number;
  2479. /** Gets or sets group name */
  2480. group: string;
  2481. /** Observable raised when isChecked is changed */
  2482. onIsCheckedChangedObservable: Observable<boolean>;
  2483. /** Gets or sets a value indicating the ratio between overall size and check size */
  2484. checkSizeRatio: number;
  2485. /** Gets or sets background color */
  2486. background: string;
  2487. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  2488. isChecked: boolean;
  2489. /**
  2490. * Creates a new RadioButton
  2491. * @param name defines the control name
  2492. */
  2493. constructor(name?: string | undefined);
  2494. protected _getTypeName(): string;
  2495. _draw(context: CanvasRenderingContext2D): void;
  2496. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2497. /**
  2498. * Utility function to easily create a radio button with a header
  2499. * @param title defines the label to use for the header
  2500. * @param group defines the group to use for the radio button
  2501. * @param isChecked defines the initial state of the radio button
  2502. * @param onValueChanged defines the callback to call when value changes
  2503. * @returns a StackPanel containing the radio button and a textBlock
  2504. */
  2505. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  2506. }
  2507. }
  2508. declare module "babylonjs-gui/2D/controls/sliders/baseSlider" {
  2509. import { Observable } from "babylonjs/Misc/observable";
  2510. import { Vector2 } from "babylonjs/Maths/math";
  2511. import { Control } from "babylonjs-gui/2D/controls/control";
  2512. import { ValueAndUnit } from "babylonjs-gui/2D/valueAndUnit";
  2513. /**
  2514. * Class used to create slider controls
  2515. */
  2516. export class BaseSlider extends Control {
  2517. name?: string | undefined;
  2518. protected _thumbWidth: ValueAndUnit;
  2519. private _minimum;
  2520. private _maximum;
  2521. private _value;
  2522. private _isVertical;
  2523. protected _barOffset: ValueAndUnit;
  2524. private _isThumbClamped;
  2525. protected _displayThumb: boolean;
  2526. private _step;
  2527. private _lastPointerDownID;
  2528. protected _effectiveBarOffset: number;
  2529. protected _renderLeft: number;
  2530. protected _renderTop: number;
  2531. protected _renderWidth: number;
  2532. protected _renderHeight: number;
  2533. protected _backgroundBoxLength: number;
  2534. protected _backgroundBoxThickness: number;
  2535. protected _effectiveThumbThickness: number;
  2536. /** Observable raised when the sldier value changes */
  2537. onValueChangedObservable: Observable<number>;
  2538. /** Gets or sets a boolean indicating if the thumb must be rendered */
  2539. displayThumb: boolean;
  2540. /** Gets or sets a step to apply to values (0 by default) */
  2541. step: number;
  2542. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  2543. barOffset: string | number;
  2544. /** Gets main bar offset in pixels*/
  2545. readonly barOffsetInPixels: number;
  2546. /** Gets or sets thumb width */
  2547. thumbWidth: string | number;
  2548. /** Gets thumb width in pixels */
  2549. readonly thumbWidthInPixels: number;
  2550. /** Gets or sets minimum value */
  2551. minimum: number;
  2552. /** Gets or sets maximum value */
  2553. maximum: number;
  2554. /** Gets or sets current value */
  2555. value: number;
  2556. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  2557. isVertical: boolean;
  2558. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  2559. isThumbClamped: boolean;
  2560. /**
  2561. * Creates a new BaseSlider
  2562. * @param name defines the control name
  2563. */
  2564. constructor(name?: string | undefined);
  2565. protected _getTypeName(): string;
  2566. protected _getThumbPosition(): number;
  2567. protected _getThumbThickness(type: string): number;
  2568. protected _prepareRenderingData(type: string): void;
  2569. private _pointerIsDown;
  2570. /** @hidden */
  2571. protected _updateValueFromPointer(x: number, y: number): void;
  2572. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2573. _onPointerMove(target: Control, coordinates: Vector2, pointerId: number): void;
  2574. _onPointerUp(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  2575. }
  2576. }
  2577. declare module "babylonjs-gui/2D/controls/sliders/slider" {
  2578. import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
  2579. import { Nullable } from 'babylonjs/types';
  2580. import { Measure } from "babylonjs-gui/2D/measure";
  2581. /**
  2582. * Class used to create slider controls
  2583. */
  2584. export class Slider extends BaseSlider {
  2585. name?: string | undefined;
  2586. private _background;
  2587. private _borderColor;
  2588. private _isThumbCircle;
  2589. protected _displayValueBar: boolean;
  2590. /** Gets or sets a boolean indicating if the value bar must be rendered */
  2591. displayValueBar: boolean;
  2592. /** Gets or sets border color */
  2593. borderColor: string;
  2594. /** Gets or sets background color */
  2595. background: string;
  2596. /** Gets or sets a boolean indicating if the thumb should be round or square */
  2597. isThumbCircle: boolean;
  2598. /**
  2599. * Creates a new Slider
  2600. * @param name defines the control name
  2601. */
  2602. constructor(name?: string | undefined);
  2603. protected _getTypeName(): string;
  2604. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  2605. }
  2606. }
  2607. declare module "babylonjs-gui/2D/controls/selector" {
  2608. import { Rectangle } from "babylonjs-gui/2D/controls/rectangle";
  2609. import { StackPanel } from "babylonjs-gui/2D/controls/stackPanel";
  2610. /** Class used to create a RadioGroup
  2611. * which contains groups of radio buttons
  2612. */
  2613. export class SelectorGroup {
  2614. /** name of SelectorGroup */
  2615. name: string;
  2616. private _groupPanel;
  2617. private _selectors;
  2618. private _groupHeader;
  2619. /**
  2620. * Creates a new SelectorGroup
  2621. * @param name of group, used as a group heading
  2622. */
  2623. constructor(
  2624. /** name of SelectorGroup */
  2625. name: string);
  2626. /** Gets the groupPanel of the SelectorGroup */
  2627. readonly groupPanel: StackPanel;
  2628. /** Gets the selectors array */
  2629. readonly selectors: StackPanel[];
  2630. /** Gets and sets the group header */
  2631. header: string;
  2632. /** @hidden */
  2633. private _addGroupHeader;
  2634. /** @hidden*/
  2635. _getSelector(selectorNb: number): StackPanel | undefined;
  2636. /** Removes the selector at the given position
  2637. * @param selectorNb the position of the selector within the group
  2638. */
  2639. removeSelector(selectorNb: number): void;
  2640. }
  2641. /** Class used to create a CheckboxGroup
  2642. * which contains groups of checkbox buttons
  2643. */
  2644. export class CheckboxGroup extends SelectorGroup {
  2645. /** Adds a checkbox as a control
  2646. * @param text is the label for the selector
  2647. * @param func is the function called when the Selector is checked
  2648. * @param checked is true when Selector is checked
  2649. */
  2650. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  2651. /** @hidden */
  2652. _setSelectorLabel(selectorNb: number, label: string): void;
  2653. /** @hidden */
  2654. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2655. /** @hidden */
  2656. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2657. /** @hidden */
  2658. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2659. }
  2660. /** Class used to create a RadioGroup
  2661. * which contains groups of radio buttons
  2662. */
  2663. export class RadioGroup extends SelectorGroup {
  2664. private _selectNb;
  2665. /** Adds a radio button as a control
  2666. * @param label is the label for the selector
  2667. * @param func is the function called when the Selector is checked
  2668. * @param checked is true when Selector is checked
  2669. */
  2670. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  2671. /** @hidden */
  2672. _setSelectorLabel(selectorNb: number, label: string): void;
  2673. /** @hidden */
  2674. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2675. /** @hidden */
  2676. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2677. /** @hidden */
  2678. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2679. }
  2680. /** Class used to create a SliderGroup
  2681. * which contains groups of slider buttons
  2682. */
  2683. export class SliderGroup extends SelectorGroup {
  2684. /**
  2685. * Adds a slider to the SelectorGroup
  2686. * @param label is the label for the SliderBar
  2687. * @param func is the function called when the Slider moves
  2688. * @param unit is a string describing the units used, eg degrees or metres
  2689. * @param min is the minimum value for the Slider
  2690. * @param max is the maximum value for the Slider
  2691. * @param value is the start value for the Slider between min and max
  2692. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  2693. */
  2694. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  2695. /** @hidden */
  2696. _setSelectorLabel(selectorNb: number, label: string): void;
  2697. /** @hidden */
  2698. _setSelectorLabelColor(selectorNb: number, color: string): void;
  2699. /** @hidden */
  2700. _setSelectorButtonColor(selectorNb: number, color: string): void;
  2701. /** @hidden */
  2702. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  2703. }
  2704. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  2705. * @see http://doc.babylonjs.com/how_to/selector
  2706. */
  2707. export class SelectionPanel extends Rectangle {
  2708. /** name of SelectionPanel */
  2709. name: string;
  2710. /** an array of SelectionGroups */
  2711. groups: SelectorGroup[];
  2712. private _panel;
  2713. private _buttonColor;
  2714. private _buttonBackground;
  2715. private _headerColor;
  2716. private _barColor;
  2717. private _barHeight;
  2718. private _spacerHeight;
  2719. private _labelColor;
  2720. private _groups;
  2721. private _bars;
  2722. /**
  2723. * Creates a new SelectionPanel
  2724. * @param name of SelectionPanel
  2725. * @param groups is an array of SelectionGroups
  2726. */
  2727. constructor(
  2728. /** name of SelectionPanel */
  2729. name: string,
  2730. /** an array of SelectionGroups */
  2731. groups?: SelectorGroup[]);
  2732. protected _getTypeName(): string;
  2733. /** Gets or sets the headerColor */
  2734. headerColor: string;
  2735. private _setHeaderColor;
  2736. /** Gets or sets the button color */
  2737. buttonColor: string;
  2738. private _setbuttonColor;
  2739. /** Gets or sets the label color */
  2740. labelColor: string;
  2741. private _setLabelColor;
  2742. /** Gets or sets the button background */
  2743. buttonBackground: string;
  2744. private _setButtonBackground;
  2745. /** Gets or sets the color of separator bar */
  2746. barColor: string;
  2747. private _setBarColor;
  2748. /** Gets or sets the height of separator bar */
  2749. barHeight: string;
  2750. private _setBarHeight;
  2751. /** Gets or sets the height of spacers*/
  2752. spacerHeight: string;
  2753. private _setSpacerHeight;
  2754. /** Adds a bar between groups */
  2755. private _addSpacer;
  2756. /** Add a group to the selection panel
  2757. * @param group is the selector group to add
  2758. */
  2759. addGroup(group: SelectorGroup): void;
  2760. /** Remove the group from the given position
  2761. * @param groupNb is the position of the group in the list
  2762. */
  2763. removeGroup(groupNb: number): void;
  2764. /** Change a group header label
  2765. * @param label is the new group header label
  2766. * @param groupNb is the number of the group to relabel
  2767. * */
  2768. setHeaderName(label: string, groupNb: number): void;
  2769. /** Change selector label to the one given
  2770. * @param label is the new selector label
  2771. * @param groupNb is the number of the groupcontaining the selector
  2772. * @param selectorNb is the number of the selector within a group to relabel
  2773. * */
  2774. relabel(label: string, groupNb: number, selectorNb: number): void;
  2775. /** For a given group position remove the selector at the given position
  2776. * @param groupNb is the number of the group to remove the selector from
  2777. * @param selectorNb is the number of the selector within the group
  2778. */
  2779. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  2780. /** For a given group position of correct type add a checkbox button
  2781. * @param groupNb is the number of the group to remove the selector from
  2782. * @param label is the label for the selector
  2783. * @param func is the function called when the Selector is checked
  2784. * @param checked is true when Selector is checked
  2785. */
  2786. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2787. /** For a given group position of correct type add a radio button
  2788. * @param groupNb is the number of the group to remove the selector from
  2789. * @param label is the label for the selector
  2790. * @param func is the function called when the Selector is checked
  2791. * @param checked is true when Selector is checked
  2792. */
  2793. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  2794. /**
  2795. * For a given slider group add a slider
  2796. * @param groupNb is the number of the group to add the slider to
  2797. * @param label is the label for the Slider
  2798. * @param func is the function called when the Slider moves
  2799. * @param unit is a string describing the units used, eg degrees or metres
  2800. * @param min is the minimum value for the Slider
  2801. * @param max is the maximum value for the Slider
  2802. * @param value is the start value for the Slider between min and max
  2803. * @param onVal is the function used to format the value displayed, eg radians to degrees
  2804. */
  2805. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  2806. }
  2807. }
  2808. declare module "babylonjs-gui/2D/controls/scrollViewers/scrollViewerWindow" {
  2809. import { Measure } from "babylonjs-gui/2D/measure";
  2810. import { Container } from "babylonjs-gui/2D/controls/container";
  2811. /**
  2812. * Class used to hold a the container for ScrollViewer
  2813. * @hidden
  2814. */
  2815. export class _ScrollViewerWindow extends Container {
  2816. parentClientWidth: number;
  2817. parentClientHeight: number;
  2818. /**
  2819. * Creates a new ScrollViewerWindow
  2820. * @param name of ScrollViewerWindow
  2821. */
  2822. constructor(name?: string);
  2823. protected _getTypeName(): string;
  2824. /** @hidden */
  2825. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2826. protected _postMeasure(): void;
  2827. }
  2828. }
  2829. declare module "babylonjs-gui/2D/controls/sliders/scrollBar" {
  2830. import { Vector2 } from "babylonjs/Maths/math";
  2831. import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
  2832. import { Control } from "babylonjs-gui/2D/controls/control";
  2833. /**
  2834. * Class used to create slider controls
  2835. */
  2836. export class ScrollBar extends BaseSlider {
  2837. name?: string | undefined;
  2838. private _background;
  2839. private _borderColor;
  2840. private _thumbMeasure;
  2841. /** Gets or sets border color */
  2842. borderColor: string;
  2843. /** Gets or sets background color */
  2844. background: string;
  2845. /**
  2846. * Creates a new Slider
  2847. * @param name defines the control name
  2848. */
  2849. constructor(name?: string | undefined);
  2850. protected _getTypeName(): string;
  2851. protected _getThumbThickness(): number;
  2852. _draw(context: CanvasRenderingContext2D): void;
  2853. private _first;
  2854. private _originX;
  2855. private _originY;
  2856. /** @hidden */
  2857. protected _updateValueFromPointer(x: number, y: number): void;
  2858. _onPointerDown(target: Control, coordinates: Vector2, pointerId: number, buttonIndex: number): boolean;
  2859. }
  2860. }
  2861. declare module "babylonjs-gui/2D/controls/scrollViewers/scrollViewer" {
  2862. import { Nullable } from "babylonjs/types";
  2863. import { Rectangle } from "babylonjs-gui/2D/controls/rectangle";
  2864. import { Control } from "babylonjs-gui/2D/controls/control";
  2865. import { Container } from "babylonjs-gui/2D/controls/container";
  2866. import { Measure } from "babylonjs-gui/2D/measure";
  2867. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  2868. import { ScrollBar } from "babylonjs-gui/2D/controls/sliders/scrollBar";
  2869. /**
  2870. * Class used to hold a viewer window and sliders in a grid
  2871. */
  2872. export class ScrollViewer extends Rectangle {
  2873. private _grid;
  2874. private _horizontalBarSpace;
  2875. private _verticalBarSpace;
  2876. private _dragSpace;
  2877. private _horizontalBar;
  2878. private _verticalBar;
  2879. private _barColor;
  2880. private _barBackground;
  2881. private _barSize;
  2882. private _endLeft;
  2883. private _endTop;
  2884. private _window;
  2885. private _pointerIsOver;
  2886. private _wheelPrecision;
  2887. private _onPointerObserver;
  2888. private _clientWidth;
  2889. private _clientHeight;
  2890. /**
  2891. * Gets the horizontal scrollbar
  2892. */
  2893. readonly horizontalBar: ScrollBar;
  2894. /**
  2895. * Gets the vertical scrollbar
  2896. */
  2897. readonly verticalBar: ScrollBar;
  2898. /**
  2899. * Adds a new control to the current container
  2900. * @param control defines the control to add
  2901. * @returns the current container
  2902. */
  2903. addControl(control: Nullable<Control>): Container;
  2904. /**
  2905. * Removes a control from the current container
  2906. * @param control defines the control to remove
  2907. * @returns the current container
  2908. */
  2909. removeControl(control: Control): Container;
  2910. /** Gets the list of children */
  2911. readonly children: Control[];
  2912. _flagDescendantsAsMatrixDirty(): void;
  2913. /**
  2914. * Creates a new ScrollViewer
  2915. * @param name of ScrollViewer
  2916. */
  2917. constructor(name?: string);
  2918. /** Reset the scroll viewer window to initial size */
  2919. resetWindow(): void;
  2920. protected _getTypeName(): string;
  2921. private _buildClientSizes;
  2922. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  2923. protected _postMeasure(): void;
  2924. /**
  2925. * Gets or sets the mouse wheel precision
  2926. * from 0 to 1 with a default value of 0.05
  2927. * */
  2928. wheelPrecision: number;
  2929. /** Gets or sets the bar color */
  2930. barColor: string;
  2931. /** Gets or sets the size of the bar */
  2932. barSize: number;
  2933. /** Gets or sets the bar background */
  2934. barBackground: string;
  2935. /** @hidden */
  2936. private _updateScroller;
  2937. _link(host: AdvancedDynamicTexture): void;
  2938. /** @hidden */
  2939. private _attachWheel;
  2940. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  2941. /** Releases associated resources */
  2942. dispose(): void;
  2943. }
  2944. }
  2945. declare module "babylonjs-gui/2D/controls/displayGrid" {
  2946. import { Control } from "babylonjs-gui/2D/controls/control";
  2947. import { Nullable } from 'babylonjs/types';
  2948. import { Measure } from "babylonjs-gui/2D/measure";
  2949. /** Class used to render a grid */
  2950. export class DisplayGrid extends Control {
  2951. name?: string | undefined;
  2952. private _cellWidth;
  2953. private _cellHeight;
  2954. private _minorLineTickness;
  2955. private _minorLineColor;
  2956. private _majorLineTickness;
  2957. private _majorLineColor;
  2958. private _majorLineFrequency;
  2959. private _background;
  2960. private _displayMajorLines;
  2961. private _displayMinorLines;
  2962. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  2963. displayMinorLines: boolean;
  2964. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  2965. displayMajorLines: boolean;
  2966. /** Gets or sets background color (Black by default) */
  2967. background: string;
  2968. /** Gets or sets the width of each cell (20 by default) */
  2969. cellWidth: number;
  2970. /** Gets or sets the height of each cell (20 by default) */
  2971. cellHeight: number;
  2972. /** Gets or sets the tickness of minor lines (1 by default) */
  2973. minorLineTickness: number;
  2974. /** Gets or sets the color of minor lines (DarkGray by default) */
  2975. minorLineColor: string;
  2976. /** Gets or sets the tickness of major lines (2 by default) */
  2977. majorLineTickness: number;
  2978. /** Gets or sets the color of major lines (White by default) */
  2979. majorLineColor: string;
  2980. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  2981. majorLineFrequency: number;
  2982. /**
  2983. * Creates a new GridDisplayRectangle
  2984. * @param name defines the control name
  2985. */
  2986. constructor(name?: string | undefined);
  2987. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  2988. protected _getTypeName(): string;
  2989. }
  2990. }
  2991. declare module "babylonjs-gui/2D/controls/sliders/imageBasedSlider" {
  2992. import { BaseSlider } from "babylonjs-gui/2D/controls/sliders/baseSlider";
  2993. import { Measure } from "babylonjs-gui/2D/measure";
  2994. import { Image } from "babylonjs-gui/2D/controls/image";
  2995. import { Nullable } from 'babylonjs/types';
  2996. /**
  2997. * Class used to create slider controls based on images
  2998. */
  2999. export class ImageBasedSlider extends BaseSlider {
  3000. name?: string | undefined;
  3001. private _backgroundImage;
  3002. private _thumbImage;
  3003. private _valueBarImage;
  3004. private _tempMeasure;
  3005. displayThumb: boolean;
  3006. /**
  3007. * Gets or sets the image used to render the background
  3008. */
  3009. backgroundImage: Image;
  3010. /**
  3011. * Gets or sets the image used to render the value bar
  3012. */
  3013. valueBarImage: Image;
  3014. /**
  3015. * Gets or sets the image used to render the thumb
  3016. */
  3017. thumbImage: Image;
  3018. /**
  3019. * Creates a new ImageBasedSlider
  3020. * @param name defines the control name
  3021. */
  3022. constructor(name?: string | undefined);
  3023. protected _getTypeName(): string;
  3024. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Nullable<Measure>): void;
  3025. }
  3026. }
  3027. declare module "babylonjs-gui/2D/controls/statics" {
  3028. /**
  3029. * Forcing an export so that this code will execute
  3030. * @hidden
  3031. */
  3032. const name = "Statics";
  3033. export { name };
  3034. }
  3035. declare module "babylonjs-gui/2D/controls/index" {
  3036. export * from "babylonjs-gui/2D/controls/button";
  3037. export * from "babylonjs-gui/2D/controls/checkbox";
  3038. export * from "babylonjs-gui/2D/controls/colorpicker";
  3039. export * from "babylonjs-gui/2D/controls/container";
  3040. export * from "babylonjs-gui/2D/controls/control";
  3041. export * from "babylonjs-gui/2D/controls/ellipse";
  3042. export * from "babylonjs-gui/2D/controls/grid";
  3043. export * from "babylonjs-gui/2D/controls/image";
  3044. export * from "babylonjs-gui/2D/controls/inputText";
  3045. export * from "babylonjs-gui/2D/controls/inputPassword";
  3046. export * from "babylonjs-gui/2D/controls/line";
  3047. export * from "babylonjs-gui/2D/controls/multiLine";
  3048. export * from "babylonjs-gui/2D/controls/radioButton";
  3049. export * from "babylonjs-gui/2D/controls/stackPanel";
  3050. export * from "babylonjs-gui/2D/controls/selector";
  3051. export * from "babylonjs-gui/2D/controls/scrollViewers/scrollViewer";
  3052. export * from "babylonjs-gui/2D/controls/textBlock";
  3053. export * from "babylonjs-gui/2D/controls/virtualKeyboard";
  3054. export * from "babylonjs-gui/2D/controls/rectangle";
  3055. export * from "babylonjs-gui/2D/controls/displayGrid";
  3056. export * from "babylonjs-gui/2D/controls/sliders/baseSlider";
  3057. export * from "babylonjs-gui/2D/controls/sliders/slider";
  3058. export * from "babylonjs-gui/2D/controls/sliders/imageBasedSlider";
  3059. export * from "babylonjs-gui/2D/controls/sliders/scrollBar";
  3060. export * from "babylonjs-gui/2D/controls/statics";
  3061. }
  3062. declare module "babylonjs-gui/2D/adtInstrumentation" {
  3063. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  3064. import { IDisposable } from "babylonjs/scene";
  3065. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  3066. /**
  3067. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  3068. */
  3069. export class AdvancedDynamicTextureInstrumentation implements IDisposable {
  3070. /**
  3071. * Define the instrumented AdvancedDynamicTexture.
  3072. */
  3073. texture: AdvancedDynamicTexture;
  3074. private _captureRenderTime;
  3075. private _renderTime;
  3076. private _captureLayoutTime;
  3077. private _layoutTime;
  3078. private _onBeginRenderObserver;
  3079. private _onEndRenderObserver;
  3080. private _onBeginLayoutObserver;
  3081. private _onEndLayoutObserver;
  3082. /**
  3083. * Gets the perf counter used to capture render time
  3084. */
  3085. readonly renderTimeCounter: PerfCounter;
  3086. /**
  3087. * Gets the perf counter used to capture layout time
  3088. */
  3089. readonly layoutTimeCounter: PerfCounter;
  3090. /**
  3091. * Enable or disable the render time capture
  3092. */
  3093. captureRenderTime: boolean;
  3094. /**
  3095. * Enable or disable the layout time capture
  3096. */
  3097. captureLayoutTime: boolean;
  3098. /**
  3099. * Instantiates a new advanced dynamic texture instrumentation.
  3100. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  3101. * @param texture Defines the AdvancedDynamicTexture to instrument
  3102. */
  3103. constructor(
  3104. /**
  3105. * Define the instrumented AdvancedDynamicTexture.
  3106. */
  3107. texture: AdvancedDynamicTexture);
  3108. /**
  3109. * Dispose and release associated resources.
  3110. */
  3111. dispose(): void;
  3112. }
  3113. }
  3114. declare module "babylonjs-gui/2D/xmlLoader" {
  3115. /**
  3116. * Class used to load GUI via XML.
  3117. */
  3118. export class XmlLoader {
  3119. private _nodes;
  3120. private _nodeTypes;
  3121. private _isLoaded;
  3122. private _objectAttributes;
  3123. private _parentClass;
  3124. /**
  3125. * Create a new xml loader
  3126. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  3127. */
  3128. constructor(parentClass?: null);
  3129. private _getChainElement;
  3130. private _getClassAttribute;
  3131. private _createGuiElement;
  3132. private _parseGrid;
  3133. private _parseElement;
  3134. private _prepareSourceElement;
  3135. private _parseElementsFromSource;
  3136. private _parseXml;
  3137. /**
  3138. * Gets if the loading has finished.
  3139. * @returns whether the loading has finished or not
  3140. */
  3141. isLoaded(): boolean;
  3142. /**
  3143. * Gets a loaded node / control by id.
  3144. * @param id the Controls id set in the xml
  3145. * @returns element of type Control
  3146. */
  3147. getNodeById(id: string): any;
  3148. /**
  3149. * Gets all loaded nodes / controls
  3150. * @returns Array of controls
  3151. */
  3152. getNodes(): any;
  3153. /**
  3154. * Initiates the xml layout loading
  3155. * @param xmlFile defines the xml layout to load
  3156. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  3157. * @param callback defines the callback called on layout load.
  3158. */
  3159. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  3160. }
  3161. }
  3162. declare module "babylonjs-gui/2D/index" {
  3163. export * from "babylonjs-gui/2D/controls/index";
  3164. export * from "babylonjs-gui/2D/advancedDynamicTexture";
  3165. export * from "babylonjs-gui/2D/adtInstrumentation";
  3166. export * from "babylonjs-gui/2D/math2D";
  3167. export * from "babylonjs-gui/2D/measure";
  3168. export * from "babylonjs-gui/2D/multiLinePoint";
  3169. export * from "babylonjs-gui/2D/style";
  3170. export * from "babylonjs-gui/2D/valueAndUnit";
  3171. export * from "babylonjs-gui/2D/xmlLoader";
  3172. }
  3173. declare module "babylonjs-gui/3D/controls/container3D" {
  3174. import { Nullable } from "babylonjs/types";
  3175. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3176. import { Scene } from "babylonjs/scene";
  3177. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3178. /**
  3179. * Class used to create containers for controls
  3180. */
  3181. export class Container3D extends Control3D {
  3182. private _blockLayout;
  3183. /**
  3184. * Gets the list of child controls
  3185. */
  3186. protected _children: Control3D[];
  3187. /**
  3188. * Gets the list of child controls
  3189. */
  3190. readonly children: Array<Control3D>;
  3191. /**
  3192. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  3193. * This is helpful to optimize layout operation when adding multiple children in a row
  3194. */
  3195. blockLayout: boolean;
  3196. /**
  3197. * Creates a new container
  3198. * @param name defines the container name
  3199. */
  3200. constructor(name?: string);
  3201. /**
  3202. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  3203. * @returns the current container
  3204. */
  3205. updateLayout(): Container3D;
  3206. /**
  3207. * Gets a boolean indicating if the given control is in the children of this control
  3208. * @param control defines the control to check
  3209. * @returns true if the control is in the child list
  3210. */
  3211. containsControl(control: Control3D): boolean;
  3212. /**
  3213. * Adds a control to the children of this control
  3214. * @param control defines the control to add
  3215. * @returns the current container
  3216. */
  3217. addControl(control: Control3D): Container3D;
  3218. /**
  3219. * This function will be called everytime a new control is added
  3220. */
  3221. protected _arrangeChildren(): void;
  3222. protected _createNode(scene: Scene): Nullable<TransformNode>;
  3223. /**
  3224. * Removes a control from the children of this control
  3225. * @param control defines the control to remove
  3226. * @returns the current container
  3227. */
  3228. removeControl(control: Control3D): Container3D;
  3229. protected _getTypeName(): string;
  3230. /**
  3231. * Releases all associated resources
  3232. */
  3233. dispose(): void;
  3234. /** Control rotation will remain unchanged */
  3235. static readonly UNSET_ORIENTATION: number;
  3236. /** Control will rotate to make it look at sphere central axis */
  3237. static readonly FACEORIGIN_ORIENTATION: number;
  3238. /** Control will rotate to make it look back at sphere central axis */
  3239. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  3240. /** Control will rotate to look at z axis (0, 0, 1) */
  3241. static readonly FACEFORWARD_ORIENTATION: number;
  3242. /** Control will rotate to look at negative z axis (0, 0, -1) */
  3243. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  3244. }
  3245. }
  3246. declare module "babylonjs-gui/3D/gui3DManager" {
  3247. import { Nullable } from "babylonjs/types";
  3248. import { Observable } from "babylonjs/Misc/observable";
  3249. import { Vector3 } from "babylonjs/Maths/math";
  3250. import { Material } from "babylonjs/Materials/material";
  3251. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  3252. import { IDisposable, Scene } from "babylonjs/scene";
  3253. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  3254. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3255. /**
  3256. * Class used to manage 3D user interface
  3257. * @see http://doc.babylonjs.com/how_to/gui3d
  3258. */
  3259. export class GUI3DManager implements IDisposable {
  3260. private _scene;
  3261. private _sceneDisposeObserver;
  3262. private _utilityLayer;
  3263. private _rootContainer;
  3264. private _pointerObserver;
  3265. private _pointerOutObserver;
  3266. /** @hidden */
  3267. _lastPickedControl: Control3D;
  3268. /** @hidden */
  3269. _lastControlOver: {
  3270. [pointerId: number]: Control3D;
  3271. };
  3272. /** @hidden */
  3273. _lastControlDown: {
  3274. [pointerId: number]: Control3D;
  3275. };
  3276. /**
  3277. * Observable raised when the point picked by the pointer events changed
  3278. */
  3279. onPickedPointChangedObservable: Observable<Nullable<Vector3>>;
  3280. /** @hidden */
  3281. _sharedMaterials: {
  3282. [key: string]: Material;
  3283. };
  3284. /** Gets the hosting scene */
  3285. readonly scene: Scene;
  3286. /** Gets associated utility layer */
  3287. readonly utilityLayer: Nullable<UtilityLayerRenderer>;
  3288. /**
  3289. * Creates a new GUI3DManager
  3290. * @param scene
  3291. */
  3292. constructor(scene?: Scene);
  3293. private _handlePointerOut;
  3294. private _doPicking;
  3295. /**
  3296. * Gets the root container
  3297. */
  3298. readonly rootContainer: Container3D;
  3299. /**
  3300. * Gets a boolean indicating if the given control is in the root child list
  3301. * @param control defines the control to check
  3302. * @returns true if the control is in the root child list
  3303. */
  3304. containsControl(control: Control3D): boolean;
  3305. /**
  3306. * Adds a control to the root child list
  3307. * @param control defines the control to add
  3308. * @returns the current manager
  3309. */
  3310. addControl(control: Control3D): GUI3DManager;
  3311. /**
  3312. * Removes a control from the root child list
  3313. * @param control defines the control to remove
  3314. * @returns the current container
  3315. */
  3316. removeControl(control: Control3D): GUI3DManager;
  3317. /**
  3318. * Releases all associated resources
  3319. */
  3320. dispose(): void;
  3321. }
  3322. }
  3323. declare module "babylonjs-gui/3D/vector3WithInfo" {
  3324. import { Vector3 } from "babylonjs/Maths/math";
  3325. /**
  3326. * Class used to transport Vector3 information for pointer events
  3327. */
  3328. export class Vector3WithInfo extends Vector3 {
  3329. /** defines the current mouse button index */
  3330. buttonIndex: number;
  3331. /**
  3332. * Creates a new Vector3WithInfo
  3333. * @param source defines the vector3 data to transport
  3334. * @param buttonIndex defines the current mouse button index
  3335. */
  3336. constructor(source: Vector3,
  3337. /** defines the current mouse button index */
  3338. buttonIndex?: number);
  3339. }
  3340. }
  3341. declare module "babylonjs-gui/3D/controls/control3D" {
  3342. import { Nullable } from "babylonjs/types";
  3343. import { Observable } from "babylonjs/Misc/observable";
  3344. import { Vector3 } from "babylonjs/Maths/math";
  3345. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  3347. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  3348. import { IDisposable, Scene } from "babylonjs/scene";
  3349. import { GUI3DManager } from "babylonjs-gui/3D/gui3DManager";
  3350. import { Vector3WithInfo } from "babylonjs-gui/3D/vector3WithInfo";
  3351. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  3352. /**
  3353. * Class used as base class for controls
  3354. */
  3355. export class Control3D implements IDisposable, IBehaviorAware<Control3D> {
  3356. /** Defines the control name */
  3357. name?: string | undefined;
  3358. /** @hidden */
  3359. _host: GUI3DManager;
  3360. private _node;
  3361. private _downCount;
  3362. private _enterCount;
  3363. private _downPointerIds;
  3364. private _isVisible;
  3365. /** Gets or sets the control position in world space */
  3366. position: Vector3;
  3367. /** Gets or sets the control scaling in world space */
  3368. scaling: Vector3;
  3369. /** Callback used to start pointer enter animation */
  3370. pointerEnterAnimation: () => void;
  3371. /** Callback used to start pointer out animation */
  3372. pointerOutAnimation: () => void;
  3373. /** Callback used to start pointer down animation */
  3374. pointerDownAnimation: () => void;
  3375. /** Callback used to start pointer up animation */
  3376. pointerUpAnimation: () => void;
  3377. /**
  3378. * An event triggered when the pointer move over the control
  3379. */
  3380. onPointerMoveObservable: Observable<Vector3>;
  3381. /**
  3382. * An event triggered when the pointer move out of the control
  3383. */
  3384. onPointerOutObservable: Observable<Control3D>;
  3385. /**
  3386. * An event triggered when the pointer taps the control
  3387. */
  3388. onPointerDownObservable: Observable<Vector3WithInfo>;
  3389. /**
  3390. * An event triggered when pointer is up
  3391. */
  3392. onPointerUpObservable: Observable<Vector3WithInfo>;
  3393. /**
  3394. * An event triggered when a control is clicked on (with a mouse)
  3395. */
  3396. onPointerClickObservable: Observable<Vector3WithInfo>;
  3397. /**
  3398. * An event triggered when pointer enters the control
  3399. */
  3400. onPointerEnterObservable: Observable<Control3D>;
  3401. /**
  3402. * Gets or sets the parent container
  3403. */
  3404. parent: Nullable<Container3D>;
  3405. private _behaviors;
  3406. /**
  3407. * Gets the list of attached behaviors
  3408. * @see http://doc.babylonjs.com/features/behaviour
  3409. */
  3410. readonly behaviors: Behavior<Control3D>[];
  3411. /**
  3412. * Attach a behavior to the control
  3413. * @see http://doc.babylonjs.com/features/behaviour
  3414. * @param behavior defines the behavior to attach
  3415. * @returns the current control
  3416. */
  3417. addBehavior(behavior: Behavior<Control3D>): Control3D;
  3418. /**
  3419. * Remove an attached behavior
  3420. * @see http://doc.babylonjs.com/features/behaviour
  3421. * @param behavior defines the behavior to attach
  3422. * @returns the current control
  3423. */
  3424. removeBehavior(behavior: Behavior<Control3D>): Control3D;
  3425. /**
  3426. * Gets an attached behavior by name
  3427. * @param name defines the name of the behavior to look for
  3428. * @see http://doc.babylonjs.com/features/behaviour
  3429. * @returns null if behavior was not found else the requested behavior
  3430. */
  3431. getBehaviorByName(name: string): Nullable<Behavior<Control3D>>;
  3432. /** Gets or sets a boolean indicating if the control is visible */
  3433. isVisible: boolean;
  3434. /**
  3435. * Creates a new control
  3436. * @param name defines the control name
  3437. */
  3438. constructor(
  3439. /** Defines the control name */
  3440. name?: string | undefined);
  3441. /**
  3442. * Gets a string representing the class name
  3443. */
  3444. readonly typeName: string;
  3445. /**
  3446. * Get the current class name of the control.
  3447. * @returns current class name
  3448. */
  3449. getClassName(): string;
  3450. protected _getTypeName(): string;
  3451. /**
  3452. * Gets the transform node used by this control
  3453. */
  3454. readonly node: Nullable<TransformNode>;
  3455. /**
  3456. * Gets the mesh used to render this control
  3457. */
  3458. readonly mesh: Nullable<AbstractMesh>;
  3459. /**
  3460. * Link the control as child of the given node
  3461. * @param node defines the node to link to. Use null to unlink the control
  3462. * @returns the current control
  3463. */
  3464. linkToTransformNode(node: Nullable<TransformNode>): Control3D;
  3465. /** @hidden **/
  3466. _prepareNode(scene: Scene): void;
  3467. /**
  3468. * Node creation.
  3469. * Can be overriden by children
  3470. * @param scene defines the scene where the node must be attached
  3471. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  3472. */
  3473. protected _createNode(scene: Scene): Nullable<TransformNode>;
  3474. /**
  3475. * Affect a material to the given mesh
  3476. * @param mesh defines the mesh which will represent the control
  3477. */
  3478. protected _affectMaterial(mesh: AbstractMesh): void;
  3479. /** @hidden */
  3480. _onPointerMove(target: Control3D, coordinates: Vector3): void;
  3481. /** @hidden */
  3482. _onPointerEnter(target: Control3D): boolean;
  3483. /** @hidden */
  3484. _onPointerOut(target: Control3D): void;
  3485. /** @hidden */
  3486. _onPointerDown(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number): boolean;
  3487. /** @hidden */
  3488. _onPointerUp(target: Control3D, coordinates: Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  3489. /** @hidden */
  3490. forcePointerUp(pointerId?: Nullable<number>): void;
  3491. /** @hidden */
  3492. _processObservables(type: number, pickedPoint: Vector3, pointerId: number, buttonIndex: number): boolean;
  3493. /** @hidden */
  3494. _disposeNode(): void;
  3495. /**
  3496. * Releases all associated resources
  3497. */
  3498. dispose(): void;
  3499. }
  3500. }
  3501. declare module "babylonjs-gui/3D/controls/abstractButton3D" {
  3502. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3503. import { Scene } from "babylonjs/scene";
  3504. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3505. /**
  3506. * Class used as a root to all buttons
  3507. */
  3508. export class AbstractButton3D extends Control3D {
  3509. /**
  3510. * Creates a new button
  3511. * @param name defines the control name
  3512. */
  3513. constructor(name?: string);
  3514. protected _getTypeName(): string;
  3515. protected _createNode(scene: Scene): TransformNode;
  3516. }
  3517. }
  3518. declare module "babylonjs-gui/3D/controls/button3D" {
  3519. import { int } from "babylonjs/types";
  3520. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  3522. import { Material } from "babylonjs/Materials/material";
  3523. import { Scene } from "babylonjs/scene";
  3524. import { AbstractButton3D } from "babylonjs-gui/3D/controls/abstractButton3D";
  3525. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  3526. import { Control } from "babylonjs-gui/2D/controls/control";
  3527. /**
  3528. * Class used to create a button in 3D
  3529. */
  3530. export class Button3D extends AbstractButton3D {
  3531. /** @hidden */
  3532. protected _currentMaterial: Material;
  3533. private _facadeTexture;
  3534. private _content;
  3535. private _contentResolution;
  3536. private _contentScaleRatio;
  3537. /**
  3538. * Gets or sets the texture resolution used to render content (512 by default)
  3539. */
  3540. contentResolution: int;
  3541. /**
  3542. * Gets or sets the texture scale ratio used to render content (2 by default)
  3543. */
  3544. contentScaleRatio: number;
  3545. protected _disposeFacadeTexture(): void;
  3546. protected _resetContent(): void;
  3547. /**
  3548. * Creates a new button
  3549. * @param name defines the control name
  3550. */
  3551. constructor(name?: string);
  3552. /**
  3553. * Gets or sets the GUI 2D content used to display the button's facade
  3554. */
  3555. content: Control;
  3556. /**
  3557. * Apply the facade texture (created from the content property).
  3558. * This function can be overloaded by child classes
  3559. * @param facadeTexture defines the AdvancedDynamicTexture to use
  3560. */
  3561. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3562. protected _getTypeName(): string;
  3563. protected _createNode(scene: Scene): TransformNode;
  3564. protected _affectMaterial(mesh: AbstractMesh): void;
  3565. /**
  3566. * Releases all associated resources
  3567. */
  3568. dispose(): void;
  3569. }
  3570. }
  3571. declare module "babylonjs-gui/3D/controls/volumeBasedPanel" {
  3572. import { Vector3 } from "babylonjs/Maths/math.vector";
  3573. import { int } from "babylonjs/types";
  3574. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  3575. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3576. /**
  3577. * Abstract class used to create a container panel deployed on the surface of a volume
  3578. */
  3579. export abstract class VolumeBasedPanel extends Container3D {
  3580. private _columns;
  3581. private _rows;
  3582. private _rowThenColum;
  3583. private _orientation;
  3584. protected _cellWidth: number;
  3585. protected _cellHeight: number;
  3586. /**
  3587. * Gets or sets the distance between elements
  3588. */
  3589. margin: number;
  3590. /**
  3591. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  3592. * | Value | Type | Description |
  3593. * | ----- | ----------------------------------- | ----------- |
  3594. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  3595. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  3596. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  3597. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  3598. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  3599. */
  3600. orientation: number;
  3601. /**
  3602. * Gets or sets the number of columns requested (10 by default).
  3603. * The panel will automatically compute the number of rows based on number of child controls.
  3604. */
  3605. columns: int;
  3606. /**
  3607. * Gets or sets a the number of rows requested.
  3608. * The panel will automatically compute the number of columns based on number of child controls.
  3609. */
  3610. rows: int;
  3611. /**
  3612. * Creates new VolumeBasedPanel
  3613. */
  3614. constructor();
  3615. protected _arrangeChildren(): void;
  3616. /** Child classes must implement this function to provide correct control positioning */
  3617. protected abstract _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  3618. /** Child classes can implement this function to provide additional processing */
  3619. protected _finalProcessing(): void;
  3620. }
  3621. }
  3622. declare module "babylonjs-gui/3D/controls/cylinderPanel" {
  3623. import { Vector3 } from "babylonjs/Maths/math.vector";
  3624. import { float } from "babylonjs/types";
  3625. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  3626. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3627. /**
  3628. * Class used to create a container panel deployed on the surface of a cylinder
  3629. */
  3630. export class CylinderPanel extends VolumeBasedPanel {
  3631. private _radius;
  3632. /**
  3633. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  3634. */
  3635. radius: float;
  3636. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  3637. private _cylindricalMapping;
  3638. }
  3639. }
  3640. declare module "babylonjs-gui/3D/materials/shaders/fluent.vertex" {
  3641. /** @hidden */
  3642. export var fluentVertexShader: {
  3643. name: string;
  3644. shader: string;
  3645. };
  3646. }
  3647. declare module "babylonjs-gui/3D/materials/shaders/fluent.fragment" {
  3648. /** @hidden */
  3649. export var fluentPixelShader: {
  3650. name: string;
  3651. shader: string;
  3652. };
  3653. }
  3654. declare module "babylonjs-gui/3D/materials/fluentMaterial" {
  3655. import { Nullable } from "babylonjs/types";
  3656. import { Color3, Vector3, Color4, Matrix } from "babylonjs/Maths/math";
  3657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  3658. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  3659. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  3660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  3661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  3662. import { Mesh } from "babylonjs/Meshes/mesh";
  3663. import { Scene } from "babylonjs/scene";
  3664. import "babylonjs-gui/3D/materials/shaders/fluent.vertex";
  3665. import "babylonjs-gui/3D/materials/shaders/fluent.fragment";
  3666. /** @hidden */
  3667. export class FluentMaterialDefines extends MaterialDefines {
  3668. INNERGLOW: boolean;
  3669. BORDER: boolean;
  3670. HOVERLIGHT: boolean;
  3671. TEXTURE: boolean;
  3672. constructor();
  3673. }
  3674. /**
  3675. * Class used to render controls with fluent desgin
  3676. */
  3677. export class FluentMaterial extends PushMaterial {
  3678. /**
  3679. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  3680. */
  3681. innerGlowColorIntensity: number;
  3682. /**
  3683. * Gets or sets the inner glow color (white by default)
  3684. */
  3685. innerGlowColor: Color3;
  3686. /**
  3687. * Gets or sets alpha value (default is 1.0)
  3688. */
  3689. alpha: number;
  3690. /**
  3691. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  3692. */
  3693. albedoColor: Color3;
  3694. /**
  3695. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  3696. */
  3697. renderBorders: boolean;
  3698. /**
  3699. * Gets or sets border width (default is 0.5)
  3700. */
  3701. borderWidth: number;
  3702. /**
  3703. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  3704. */
  3705. edgeSmoothingValue: number;
  3706. /**
  3707. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  3708. */
  3709. borderMinValue: number;
  3710. /**
  3711. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  3712. */
  3713. renderHoverLight: boolean;
  3714. /**
  3715. * Gets or sets the radius used to render the hover light (default is 1.0)
  3716. */
  3717. hoverRadius: number;
  3718. /**
  3719. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  3720. */
  3721. hoverColor: Color4;
  3722. /**
  3723. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  3724. */
  3725. hoverPosition: Vector3;
  3726. private _albedoTexture;
  3727. /** Gets or sets the texture to use for albedo color */
  3728. albedoTexture: Nullable<BaseTexture>;
  3729. /**
  3730. * Creates a new Fluent material
  3731. * @param name defines the name of the material
  3732. * @param scene defines the hosting scene
  3733. */
  3734. constructor(name: string, scene: Scene);
  3735. needAlphaBlending(): boolean;
  3736. needAlphaTesting(): boolean;
  3737. getAlphaTestTexture(): Nullable<BaseTexture>;
  3738. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  3739. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  3740. getActiveTextures(): BaseTexture[];
  3741. hasTexture(texture: BaseTexture): boolean;
  3742. dispose(forceDisposeEffect?: boolean): void;
  3743. clone(name: string): FluentMaterial;
  3744. serialize(): any;
  3745. getClassName(): string;
  3746. static Parse(source: any, scene: Scene, rootUrl: string): FluentMaterial;
  3747. }
  3748. }
  3749. declare module "babylonjs-gui/3D/controls/holographicButton" {
  3750. import { Button3D } from "babylonjs-gui/3D/controls/button3D";
  3751. import { Nullable } from "babylonjs/types";
  3752. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  3753. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3754. import { Mesh } from "babylonjs/Meshes/mesh";
  3755. import { Scene } from "babylonjs/scene";
  3756. import { FluentMaterial } from "babylonjs-gui/3D/materials/fluentMaterial";
  3757. import { AdvancedDynamicTexture } from "babylonjs-gui/2D/advancedDynamicTexture";
  3758. /**
  3759. * Class used to create a holographic button in 3D
  3760. */
  3761. export class HolographicButton extends Button3D {
  3762. private _backPlate;
  3763. private _textPlate;
  3764. private _frontPlate;
  3765. private _text;
  3766. private _imageUrl;
  3767. private _shareMaterials;
  3768. private _frontMaterial;
  3769. private _backMaterial;
  3770. private _plateMaterial;
  3771. private _pickedPointObserver;
  3772. private _tooltipFade;
  3773. private _tooltipTextBlock;
  3774. private _tooltipTexture;
  3775. private _tooltipMesh;
  3776. private _tooltipHoverObserver;
  3777. private _tooltipOutObserver;
  3778. private _disposeTooltip;
  3779. /**
  3780. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  3781. */
  3782. tooltipText: Nullable<string>;
  3783. /**
  3784. * Gets or sets text for the button
  3785. */
  3786. text: string;
  3787. /**
  3788. * Gets or sets the image url for the button
  3789. */
  3790. imageUrl: string;
  3791. /**
  3792. * Gets the back material used by this button
  3793. */
  3794. readonly backMaterial: FluentMaterial;
  3795. /**
  3796. * Gets the front material used by this button
  3797. */
  3798. readonly frontMaterial: FluentMaterial;
  3799. /**
  3800. * Gets the plate material used by this button
  3801. */
  3802. readonly plateMaterial: StandardMaterial;
  3803. /**
  3804. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  3805. */
  3806. readonly shareMaterials: boolean;
  3807. /**
  3808. * Creates a new button
  3809. * @param name defines the control name
  3810. */
  3811. constructor(name?: string, shareMaterials?: boolean);
  3812. protected _getTypeName(): string;
  3813. private _rebuildContent;
  3814. protected _createNode(scene: Scene): TransformNode;
  3815. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  3816. private _createBackMaterial;
  3817. private _createFrontMaterial;
  3818. private _createPlateMaterial;
  3819. protected _affectMaterial(mesh: Mesh): void;
  3820. /**
  3821. * Releases all associated resources
  3822. */
  3823. dispose(): void;
  3824. }
  3825. }
  3826. declare module "babylonjs-gui/3D/controls/meshButton3D" {
  3827. import { TransformNode } from "babylonjs/Meshes/transformNode";
  3828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  3829. import { Mesh } from "babylonjs/Meshes/mesh";
  3830. import { Scene } from "babylonjs/scene";
  3831. import { Button3D } from "babylonjs-gui/3D/controls/button3D";
  3832. /**
  3833. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  3834. */
  3835. export class MeshButton3D extends Button3D {
  3836. /** @hidden */
  3837. protected _currentMesh: Mesh;
  3838. /**
  3839. * Creates a new 3D button based on a mesh
  3840. * @param mesh mesh to become a 3D button
  3841. * @param name defines the control name
  3842. */
  3843. constructor(mesh: Mesh, name?: string);
  3844. protected _getTypeName(): string;
  3845. protected _createNode(scene: Scene): TransformNode;
  3846. protected _affectMaterial(mesh: AbstractMesh): void;
  3847. }
  3848. }
  3849. declare module "babylonjs-gui/3D/controls/planePanel" {
  3850. import { Vector3 } from "babylonjs/Maths/math";
  3851. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3852. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  3853. /**
  3854. * Class used to create a container panel deployed on the surface of a plane
  3855. */
  3856. export class PlanePanel extends VolumeBasedPanel {
  3857. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  3858. }
  3859. }
  3860. declare module "babylonjs-gui/3D/controls/scatterPanel" {
  3861. import { Vector3 } from "babylonjs/Maths/math";
  3862. import { float } from "babylonjs/types";
  3863. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  3864. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3865. /**
  3866. * Class used to create a container panel where items get randomized planar mapping
  3867. */
  3868. export class ScatterPanel extends VolumeBasedPanel {
  3869. private _iteration;
  3870. /**
  3871. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  3872. */
  3873. iteration: float;
  3874. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  3875. private _scatterMapping;
  3876. protected _finalProcessing(): void;
  3877. }
  3878. }
  3879. declare module "babylonjs-gui/3D/controls/spherePanel" {
  3880. import { Vector3 } from "babylonjs/Maths/math";
  3881. import { float } from "babylonjs/types";
  3882. import { VolumeBasedPanel } from "babylonjs-gui/3D/controls/volumeBasedPanel";
  3883. import { Control3D } from "babylonjs-gui/3D/controls/control3D";
  3884. /**
  3885. * Class used to create a container panel deployed on the surface of a sphere
  3886. */
  3887. export class SpherePanel extends VolumeBasedPanel {
  3888. private _radius;
  3889. /**
  3890. * Gets or sets the radius of the sphere where to project controls (5 by default)
  3891. */
  3892. radius: float;
  3893. protected _mapGridNode(control: Control3D, nodePosition: Vector3): void;
  3894. private _sphericalMapping;
  3895. }
  3896. }
  3897. declare module "babylonjs-gui/3D/controls/stackPanel3D" {
  3898. import { Container3D } from "babylonjs-gui/3D/controls/container3D";
  3899. /**
  3900. * Class used to create a stack panel in 3D on XY plane
  3901. */
  3902. export class StackPanel3D extends Container3D {
  3903. private _isVertical;
  3904. /**
  3905. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  3906. */
  3907. isVertical: boolean;
  3908. /**
  3909. * Gets or sets the distance between elements
  3910. */
  3911. margin: number;
  3912. /**
  3913. * Creates new StackPanel
  3914. * @param isVertical
  3915. */
  3916. constructor(isVertical?: boolean);
  3917. protected _arrangeChildren(): void;
  3918. }
  3919. }
  3920. declare module "babylonjs-gui/3D/controls/index" {
  3921. export * from "babylonjs-gui/3D/controls/abstractButton3D";
  3922. export * from "babylonjs-gui/3D/controls/button3D";
  3923. export * from "babylonjs-gui/3D/controls/container3D";
  3924. export * from "babylonjs-gui/3D/controls/control3D";
  3925. export * from "babylonjs-gui/3D/controls/cylinderPanel";
  3926. export * from "babylonjs-gui/3D/controls/holographicButton";
  3927. export * from "babylonjs-gui/3D/controls/meshButton3D";
  3928. export * from "babylonjs-gui/3D/controls/planePanel";
  3929. export * from "babylonjs-gui/3D/controls/scatterPanel";
  3930. export * from "babylonjs-gui/3D/controls/spherePanel";
  3931. export * from "babylonjs-gui/3D/controls/stackPanel3D";
  3932. export * from "babylonjs-gui/3D/controls/volumeBasedPanel";
  3933. }
  3934. declare module "babylonjs-gui/3D/materials/index" {
  3935. export * from "babylonjs-gui/3D/materials/fluentMaterial";
  3936. }
  3937. declare module "babylonjs-gui/3D/index" {
  3938. export * from "babylonjs-gui/3D/controls/index";
  3939. export * from "babylonjs-gui/3D/materials/index";
  3940. export * from "babylonjs-gui/3D/gui3DManager";
  3941. export * from "babylonjs-gui/3D/vector3WithInfo";
  3942. }
  3943. declare module "babylonjs-gui/index" {
  3944. export * from "babylonjs-gui/2D/index";
  3945. export * from "babylonjs-gui/3D/index";
  3946. }
  3947. declare module "babylonjs-gui/legacy/legacy" {
  3948. export * from "babylonjs-gui/index";
  3949. }
  3950. declare module "babylonjs-gui" {
  3951. export * from "babylonjs-gui/legacy/legacy";
  3952. }
  3953. declare module BABYLON.GUI {
  3954. /**
  3955. * Class used to specific a value and its associated unit
  3956. */
  3957. export class ValueAndUnit {
  3958. /** defines the unit to store */
  3959. unit: number;
  3960. /** defines a boolean indicating if the value can be negative */
  3961. negativeValueAllowed: boolean;
  3962. private _value;
  3963. private _originalUnit;
  3964. /**
  3965. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  3966. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  3967. */
  3968. ignoreAdaptiveScaling: boolean;
  3969. /**
  3970. * Creates a new ValueAndUnit
  3971. * @param value defines the value to store
  3972. * @param unit defines the unit to store
  3973. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  3974. */
  3975. constructor(value: number,
  3976. /** defines the unit to store */
  3977. unit?: number,
  3978. /** defines a boolean indicating if the value can be negative */
  3979. negativeValueAllowed?: boolean);
  3980. /** Gets a boolean indicating if the value is a percentage */
  3981. readonly isPercentage: boolean;
  3982. /** Gets a boolean indicating if the value is store as pixel */
  3983. readonly isPixel: boolean;
  3984. /** Gets direct internal value */
  3985. readonly internalValue: number;
  3986. /**
  3987. * Gets value as pixel
  3988. * @param host defines the root host
  3989. * @param refValue defines the reference value for percentages
  3990. * @returns the value as pixel
  3991. */
  3992. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  3993. /**
  3994. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  3995. * @param value defines the value to store
  3996. * @param unit defines the unit to store
  3997. * @returns the current ValueAndUnit
  3998. */
  3999. updateInPlace(value: number, unit?: number): ValueAndUnit;
  4000. /**
  4001. * Gets the value accordingly to its unit
  4002. * @param host defines the root host
  4003. * @returns the value
  4004. */
  4005. getValue(host: AdvancedDynamicTexture): number;
  4006. /**
  4007. * Gets a string representation of the value
  4008. * @param host defines the root host
  4009. * @param decimals defines an optional number of decimals to display
  4010. * @returns a string
  4011. */
  4012. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  4013. /**
  4014. * Store a value parsed from a string
  4015. * @param source defines the source string
  4016. * @returns true if the value was successfully parsed
  4017. */
  4018. fromString(source: string | number): boolean;
  4019. private static _Regex;
  4020. private static _UNITMODE_PERCENTAGE;
  4021. private static _UNITMODE_PIXEL;
  4022. /** UNITMODE_PERCENTAGE */
  4023. static readonly UNITMODE_PERCENTAGE: number;
  4024. /** UNITMODE_PIXEL */
  4025. static readonly UNITMODE_PIXEL: number;
  4026. }
  4027. }
  4028. declare module BABYLON.GUI {
  4029. /**
  4030. * Define a style used by control to automatically setup properties based on a template.
  4031. * Only support font related properties so far
  4032. */
  4033. export class Style implements BABYLON.IDisposable {
  4034. private _fontFamily;
  4035. private _fontStyle;
  4036. private _fontWeight;
  4037. /** @hidden */
  4038. _host: AdvancedDynamicTexture;
  4039. /** @hidden */
  4040. _fontSize: ValueAndUnit;
  4041. /**
  4042. * BABYLON.Observable raised when the style values are changed
  4043. */
  4044. onChangedObservable: BABYLON.Observable<Style>;
  4045. /**
  4046. * Creates a new style object
  4047. * @param host defines the AdvancedDynamicTexture which hosts this style
  4048. */
  4049. constructor(host: AdvancedDynamicTexture);
  4050. /**
  4051. * Gets or sets the font size
  4052. */
  4053. fontSize: string | number;
  4054. /**
  4055. * Gets or sets the font family
  4056. */
  4057. fontFamily: string;
  4058. /**
  4059. * Gets or sets the font style
  4060. */
  4061. fontStyle: string;
  4062. /** Gets or sets font weight */
  4063. fontWeight: string;
  4064. /** Dispose all associated resources */
  4065. dispose(): void;
  4066. }
  4067. }
  4068. declare module BABYLON.GUI {
  4069. /**
  4070. * Class used to transport BABYLON.Vector2 information for pointer events
  4071. */
  4072. export class Vector2WithInfo extends BABYLON.Vector2 {
  4073. /** defines the current mouse button index */
  4074. buttonIndex: number;
  4075. /**
  4076. * Creates a new Vector2WithInfo
  4077. * @param source defines the vector2 data to transport
  4078. * @param buttonIndex defines the current mouse button index
  4079. */
  4080. constructor(source: BABYLON.Vector2,
  4081. /** defines the current mouse button index */
  4082. buttonIndex?: number);
  4083. }
  4084. /** Class used to provide 2D matrix features */
  4085. export class Matrix2D {
  4086. /** Gets the internal array of 6 floats used to store matrix data */
  4087. m: Float32Array;
  4088. /**
  4089. * Creates a new matrix
  4090. * @param m00 defines value for (0, 0)
  4091. * @param m01 defines value for (0, 1)
  4092. * @param m10 defines value for (1, 0)
  4093. * @param m11 defines value for (1, 1)
  4094. * @param m20 defines value for (2, 0)
  4095. * @param m21 defines value for (2, 1)
  4096. */
  4097. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  4098. /**
  4099. * Fills the matrix from direct values
  4100. * @param m00 defines value for (0, 0)
  4101. * @param m01 defines value for (0, 1)
  4102. * @param m10 defines value for (1, 0)
  4103. * @param m11 defines value for (1, 1)
  4104. * @param m20 defines value for (2, 0)
  4105. * @param m21 defines value for (2, 1)
  4106. * @returns the current modified matrix
  4107. */
  4108. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  4109. /**
  4110. * Gets matrix determinant
  4111. * @returns the determinant
  4112. */
  4113. determinant(): number;
  4114. /**
  4115. * Inverses the matrix and stores it in a target matrix
  4116. * @param result defines the target matrix
  4117. * @returns the current matrix
  4118. */
  4119. invertToRef(result: Matrix2D): Matrix2D;
  4120. /**
  4121. * Multiplies the current matrix with another one
  4122. * @param other defines the second operand
  4123. * @param result defines the target matrix
  4124. * @returns the current matrix
  4125. */
  4126. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  4127. /**
  4128. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  4129. * @param x defines the x coordinate to transform
  4130. * @param y defines the x coordinate to transform
  4131. * @param result defines the target vector2
  4132. * @returns the current matrix
  4133. */
  4134. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  4135. /**
  4136. * Creates an identity matrix
  4137. * @returns a new matrix
  4138. */
  4139. static Identity(): Matrix2D;
  4140. /**
  4141. * Creates a translation matrix and stores it in a target matrix
  4142. * @param x defines the x coordinate of the translation
  4143. * @param y defines the y coordinate of the translation
  4144. * @param result defines the target matrix
  4145. */
  4146. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  4147. /**
  4148. * Creates a scaling matrix and stores it in a target matrix
  4149. * @param x defines the x coordinate of the scaling
  4150. * @param y defines the y coordinate of the scaling
  4151. * @param result defines the target matrix
  4152. */
  4153. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  4154. /**
  4155. * Creates a rotation matrix and stores it in a target matrix
  4156. * @param angle defines the rotation angle
  4157. * @param result defines the target matrix
  4158. */
  4159. static RotationToRef(angle: number, result: Matrix2D): void;
  4160. private static _TempPreTranslationMatrix;
  4161. private static _TempPostTranslationMatrix;
  4162. private static _TempRotationMatrix;
  4163. private static _TempScalingMatrix;
  4164. private static _TempCompose0;
  4165. private static _TempCompose1;
  4166. private static _TempCompose2;
  4167. /**
  4168. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  4169. * @param tx defines the x coordinate of the translation
  4170. * @param ty defines the y coordinate of the translation
  4171. * @param angle defines the rotation angle
  4172. * @param scaleX defines the x coordinate of the scaling
  4173. * @param scaleY defines the y coordinate of the scaling
  4174. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  4175. * @param result defines the target matrix
  4176. */
  4177. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  4178. }
  4179. }
  4180. declare module BABYLON.GUI {
  4181. /**
  4182. * Class used to store 2D control sizes
  4183. */
  4184. export class Measure {
  4185. /** defines left coordinate */
  4186. left: number;
  4187. /** defines top coordinate */
  4188. top: number;
  4189. /** defines width dimension */
  4190. width: number;
  4191. /** defines height dimension */
  4192. height: number;
  4193. /**
  4194. * Creates a new measure
  4195. * @param left defines left coordinate
  4196. * @param top defines top coordinate
  4197. * @param width defines width dimension
  4198. * @param height defines height dimension
  4199. */
  4200. constructor(
  4201. /** defines left coordinate */
  4202. left: number,
  4203. /** defines top coordinate */
  4204. top: number,
  4205. /** defines width dimension */
  4206. width: number,
  4207. /** defines height dimension */
  4208. height: number);
  4209. /**
  4210. * Copy from another measure
  4211. * @param other defines the other measure to copy from
  4212. */
  4213. copyFrom(other: Measure): void;
  4214. /**
  4215. * Copy from a group of 4 floats
  4216. * @param left defines left coordinate
  4217. * @param top defines top coordinate
  4218. * @param width defines width dimension
  4219. * @param height defines height dimension
  4220. */
  4221. copyFromFloats(left: number, top: number, width: number, height: number): void;
  4222. /**
  4223. * Computes the axis aligned bounding box measure for two given measures
  4224. * @param a Input measure
  4225. * @param b Input measure
  4226. * @param result the resulting bounding measure
  4227. */
  4228. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  4229. /**
  4230. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  4231. * @param transform the matrix to transform the measure before computing the AABB
  4232. * @param result the resulting AABB
  4233. */
  4234. transformToRef(transform: Matrix2D, result: Measure): void;
  4235. /**
  4236. * Check equality between this measure and another one
  4237. * @param other defines the other measures
  4238. * @returns true if both measures are equals
  4239. */
  4240. isEqualsTo(other: Measure): boolean;
  4241. /**
  4242. * Creates an empty measure
  4243. * @returns a new measure
  4244. */
  4245. static Empty(): Measure;
  4246. }
  4247. }
  4248. declare module BABYLON.GUI {
  4249. /**
  4250. * Interface used to define a control that can receive focus
  4251. */
  4252. export interface IFocusableControl {
  4253. /**
  4254. * Function called when the control receives the focus
  4255. */
  4256. onFocus(): void;
  4257. /**
  4258. * Function called when the control loses the focus
  4259. */
  4260. onBlur(): void;
  4261. /**
  4262. * Function called to let the control handle keyboard events
  4263. * @param evt defines the current keyboard event
  4264. */
  4265. processKeyboard(evt: KeyboardEvent): void;
  4266. /**
  4267. * Function called to get the list of controls that should not steal the focus from this control
  4268. * @returns an array of controls
  4269. */
  4270. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  4271. }
  4272. /**
  4273. * Class used to create texture to support 2D GUI elements
  4274. * @see http://doc.babylonjs.com/how_to/gui
  4275. */
  4276. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  4277. private _isDirty;
  4278. private _renderObserver;
  4279. private _resizeObserver;
  4280. private _preKeyboardObserver;
  4281. private _pointerMoveObserver;
  4282. private _pointerObserver;
  4283. private _canvasPointerOutObserver;
  4284. private _background;
  4285. /** @hidden */
  4286. _rootContainer: Container;
  4287. /** @hidden */
  4288. _lastPickedControl: Control;
  4289. /** @hidden */
  4290. _lastControlOver: {
  4291. [pointerId: number]: Control;
  4292. };
  4293. /** @hidden */
  4294. _lastControlDown: {
  4295. [pointerId: number]: Control;
  4296. };
  4297. /** @hidden */
  4298. _capturingControl: {
  4299. [pointerId: number]: Control;
  4300. };
  4301. /** @hidden */
  4302. _shouldBlockPointer: boolean;
  4303. /** @hidden */
  4304. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  4305. /** @hidden */
  4306. _linkedControls: Control[];
  4307. private _isFullscreen;
  4308. private _fullscreenViewport;
  4309. private _idealWidth;
  4310. private _idealHeight;
  4311. private _useSmallestIdeal;
  4312. private _renderAtIdealSize;
  4313. private _focusedControl;
  4314. private _blockNextFocusCheck;
  4315. private _renderScale;
  4316. private _rootElement;
  4317. private _cursorChanged;
  4318. /**
  4319. * Define type to string to ensure compatibility across browsers
  4320. * Safari doesn't support DataTransfer constructor
  4321. */
  4322. private _clipboardData;
  4323. /**
  4324. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  4325. */
  4326. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  4327. /**
  4328. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  4329. */
  4330. onControlPickedObservable: BABYLON.Observable<Control>;
  4331. /**
  4332. * BABYLON.Observable event triggered before layout is evaluated
  4333. */
  4334. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  4335. /**
  4336. * BABYLON.Observable event triggered after the layout was evaluated
  4337. */
  4338. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  4339. /**
  4340. * BABYLON.Observable event triggered before the texture is rendered
  4341. */
  4342. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  4343. /**
  4344. * BABYLON.Observable event triggered after the texture was rendered
  4345. */
  4346. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  4347. /**
  4348. * Gets or sets a boolean defining if alpha is stored as premultiplied
  4349. */
  4350. premulAlpha: boolean;
  4351. /**
  4352. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  4353. * Useful when you want more antialiasing
  4354. */
  4355. renderScale: number;
  4356. /** Gets or sets the background color */
  4357. background: string;
  4358. /**
  4359. * Gets or sets the ideal width used to design controls.
  4360. * The GUI will then rescale everything accordingly
  4361. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  4362. */
  4363. idealWidth: number;
  4364. /**
  4365. * Gets or sets the ideal height used to design controls.
  4366. * The GUI will then rescale everything accordingly
  4367. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  4368. */
  4369. idealHeight: number;
  4370. /**
  4371. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  4372. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  4373. */
  4374. useSmallestIdeal: boolean;
  4375. /**
  4376. * Gets or sets a boolean indicating if adaptive scaling must be used
  4377. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  4378. */
  4379. renderAtIdealSize: boolean;
  4380. /**
  4381. * Gets the underlying layer used to render the texture when in fullscreen mode
  4382. */
  4383. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  4384. /**
  4385. * Gets the root container control
  4386. */
  4387. readonly rootContainer: Container;
  4388. /**
  4389. * Returns an array containing the root container.
  4390. * This is mostly used to let the Inspector introspects the ADT
  4391. * @returns an array containing the rootContainer
  4392. */
  4393. getChildren(): Array<Container>;
  4394. /**
  4395. * Will return all controls that are inside this texture
  4396. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4397. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4398. * @return all child controls
  4399. */
  4400. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  4401. /**
  4402. * Gets or sets the current focused control
  4403. */
  4404. focusedControl: BABYLON.Nullable<IFocusableControl>;
  4405. /**
  4406. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  4407. */
  4408. isForeground: boolean;
  4409. /**
  4410. * Gets or set information about clipboardData
  4411. */
  4412. clipboardData: string;
  4413. /**
  4414. * Creates a new AdvancedDynamicTexture
  4415. * @param name defines the name of the texture
  4416. * @param width defines the width of the texture
  4417. * @param height defines the height of the texture
  4418. * @param scene defines the hosting scene
  4419. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  4420. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  4421. */
  4422. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  4423. /**
  4424. * Get the current class name of the texture useful for serialization or dynamic coding.
  4425. * @returns "AdvancedDynamicTexture"
  4426. */
  4427. getClassName(): string;
  4428. /**
  4429. * Function used to execute a function on all controls
  4430. * @param func defines the function to execute
  4431. * @param container defines the container where controls belong. If null the root container will be used
  4432. */
  4433. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  4434. private _useInvalidateRectOptimization;
  4435. /**
  4436. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  4437. */
  4438. useInvalidateRectOptimization: boolean;
  4439. private _invalidatedRectangle;
  4440. /**
  4441. * Invalidates a rectangle area on the gui texture
  4442. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  4443. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  4444. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  4445. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  4446. */
  4447. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  4448. /**
  4449. * Marks the texture as dirty forcing a complete update
  4450. */
  4451. markAsDirty(): void;
  4452. /**
  4453. * Helper function used to create a new style
  4454. * @returns a new style
  4455. * @see http://doc.babylonjs.com/how_to/gui#styles
  4456. */
  4457. createStyle(): Style;
  4458. /**
  4459. * Adds a new control to the root container
  4460. * @param control defines the control to add
  4461. * @returns the current texture
  4462. */
  4463. addControl(control: Control): AdvancedDynamicTexture;
  4464. /**
  4465. * Removes a control from the root container
  4466. * @param control defines the control to remove
  4467. * @returns the current texture
  4468. */
  4469. removeControl(control: Control): AdvancedDynamicTexture;
  4470. /**
  4471. * Release all resources
  4472. */
  4473. dispose(): void;
  4474. private _onResize;
  4475. /** @hidden */
  4476. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  4477. /**
  4478. * Get screen coordinates for a vector3
  4479. * @param position defines the position to project
  4480. * @param worldMatrix defines the world matrix to use
  4481. * @returns the projected position
  4482. */
  4483. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  4484. private _checkUpdate;
  4485. private _clearMeasure;
  4486. private _render;
  4487. /** @hidden */
  4488. _changeCursor(cursor: string): void;
  4489. /** @hidden */
  4490. _registerLastControlDown(control: Control, pointerId: number): void;
  4491. private _doPicking;
  4492. /** @hidden */
  4493. _cleanControlAfterRemovalFromList(list: {
  4494. [pointerId: number]: Control;
  4495. }, control: Control): void;
  4496. /** @hidden */
  4497. _cleanControlAfterRemoval(control: Control): void;
  4498. /** Attach to all scene events required to support pointer events */
  4499. attach(): void;
  4500. /** @hidden */
  4501. private onClipboardCopy;
  4502. /** @hidden */
  4503. private onClipboardCut;
  4504. /** @hidden */
  4505. private onClipboardPaste;
  4506. /**
  4507. * Register the clipboard Events onto the canvas
  4508. */
  4509. registerClipboardEvents(): void;
  4510. /**
  4511. * Unregister the clipboard Events from the canvas
  4512. */
  4513. unRegisterClipboardEvents(): void;
  4514. /**
  4515. * Connect the texture to a hosting mesh to enable interactions
  4516. * @param mesh defines the mesh to attach to
  4517. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  4518. */
  4519. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  4520. /**
  4521. * Move the focus to a specific control
  4522. * @param control defines the control which will receive the focus
  4523. */
  4524. moveFocusToControl(control: IFocusableControl): void;
  4525. private _manageFocus;
  4526. private _attachToOnPointerOut;
  4527. /**
  4528. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  4529. * @param mesh defines the mesh which will receive the texture
  4530. * @param width defines the texture width (1024 by default)
  4531. * @param height defines the texture height (1024 by default)
  4532. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  4533. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  4534. * @returns a new AdvancedDynamicTexture
  4535. */
  4536. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  4537. /**
  4538. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  4539. * In this mode the texture will rely on a layer for its rendering.
  4540. * This allows it to be treated like any other layer.
  4541. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  4542. * LayerMask is set through advancedTexture.layer.layerMask
  4543. * @param name defines name for the texture
  4544. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  4545. * @param scene defines the hsoting scene
  4546. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  4547. * @returns a new AdvancedDynamicTexture
  4548. */
  4549. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  4550. }
  4551. }
  4552. declare module BABYLON.GUI {
  4553. /**
  4554. * Root class used for all 2D controls
  4555. * @see http://doc.babylonjs.com/how_to/gui#controls
  4556. */
  4557. export class Control {
  4558. /** defines the name of the control */
  4559. name?: string | undefined;
  4560. /**
  4561. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  4562. */
  4563. static AllowAlphaInheritance: boolean;
  4564. private _alpha;
  4565. private _alphaSet;
  4566. private _zIndex;
  4567. /** @hidden */
  4568. _host: AdvancedDynamicTexture;
  4569. /** Gets or sets the control parent */
  4570. parent: BABYLON.Nullable<Container>;
  4571. /** @hidden */
  4572. _currentMeasure: Measure;
  4573. private _fontFamily;
  4574. private _fontStyle;
  4575. private _fontWeight;
  4576. private _fontSize;
  4577. private _font;
  4578. /** @hidden */
  4579. _width: ValueAndUnit;
  4580. /** @hidden */
  4581. _height: ValueAndUnit;
  4582. /** @hidden */
  4583. protected _fontOffset: {
  4584. ascent: number;
  4585. height: number;
  4586. descent: number;
  4587. };
  4588. private _color;
  4589. private _style;
  4590. private _styleObserver;
  4591. /** @hidden */
  4592. protected _horizontalAlignment: number;
  4593. /** @hidden */
  4594. protected _verticalAlignment: number;
  4595. /** @hidden */
  4596. protected _isDirty: boolean;
  4597. /** @hidden */
  4598. protected _wasDirty: boolean;
  4599. /** @hidden */
  4600. _tempParentMeasure: Measure;
  4601. /** @hidden */
  4602. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  4603. /** @hidden */
  4604. protected _cachedParentMeasure: Measure;
  4605. private _paddingLeft;
  4606. private _paddingRight;
  4607. private _paddingTop;
  4608. private _paddingBottom;
  4609. /** @hidden */
  4610. _left: ValueAndUnit;
  4611. /** @hidden */
  4612. _top: ValueAndUnit;
  4613. private _scaleX;
  4614. private _scaleY;
  4615. private _rotation;
  4616. private _transformCenterX;
  4617. private _transformCenterY;
  4618. /** @hidden */
  4619. _transformMatrix: Matrix2D;
  4620. /** @hidden */
  4621. protected _invertTransformMatrix: Matrix2D;
  4622. /** @hidden */
  4623. protected _transformedPosition: BABYLON.Vector2;
  4624. private _isMatrixDirty;
  4625. private _cachedOffsetX;
  4626. private _cachedOffsetY;
  4627. private _isVisible;
  4628. private _isHighlighted;
  4629. /** @hidden */
  4630. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  4631. private _fontSet;
  4632. private _dummyVector2;
  4633. private _downCount;
  4634. private _enterCount;
  4635. private _doNotRender;
  4636. private _downPointerIds;
  4637. protected _isEnabled: boolean;
  4638. protected _disabledColor: string;
  4639. /** @hidden */
  4640. protected _rebuildLayout: boolean;
  4641. /** @hidden */
  4642. _isClipped: boolean;
  4643. /** @hidden */
  4644. _automaticSize: boolean;
  4645. /** @hidden */
  4646. _tag: any;
  4647. /**
  4648. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  4649. */
  4650. uniqueId: number;
  4651. /**
  4652. * Gets or sets an object used to store user defined information for the node
  4653. */
  4654. metadata: any;
  4655. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  4656. isHitTestVisible: boolean;
  4657. /** Gets or sets a boolean indicating if the control can block pointer events */
  4658. isPointerBlocker: boolean;
  4659. /** Gets or sets a boolean indicating if the control can be focusable */
  4660. isFocusInvisible: boolean;
  4661. /**
  4662. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  4663. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  4664. */
  4665. clipChildren: boolean;
  4666. /**
  4667. * Gets or sets a boolean indicating that control content must be clipped
  4668. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  4669. */
  4670. clipContent: boolean;
  4671. /**
  4672. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  4673. */
  4674. useBitmapCache: boolean;
  4675. private _cacheData;
  4676. private _shadowOffsetX;
  4677. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  4678. shadowOffsetX: number;
  4679. private _shadowOffsetY;
  4680. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  4681. shadowOffsetY: number;
  4682. private _shadowBlur;
  4683. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  4684. shadowBlur: number;
  4685. private _shadowColor;
  4686. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  4687. shadowColor: string;
  4688. /** Gets or sets the cursor to use when the control is hovered */
  4689. hoverCursor: string;
  4690. /** @hidden */
  4691. protected _linkOffsetX: ValueAndUnit;
  4692. /** @hidden */
  4693. protected _linkOffsetY: ValueAndUnit;
  4694. /** Gets the control type name */
  4695. readonly typeName: string;
  4696. /**
  4697. * Get the current class name of the control.
  4698. * @returns current class name
  4699. */
  4700. getClassName(): string;
  4701. /**
  4702. * An event triggered when the pointer move over the control.
  4703. */
  4704. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  4705. /**
  4706. * An event triggered when the pointer move out of the control.
  4707. */
  4708. onPointerOutObservable: BABYLON.Observable<Control>;
  4709. /**
  4710. * An event triggered when the pointer taps the control
  4711. */
  4712. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  4713. /**
  4714. * An event triggered when pointer up
  4715. */
  4716. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  4717. /**
  4718. * An event triggered when a control is clicked on
  4719. */
  4720. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  4721. /**
  4722. * An event triggered when pointer enters the control
  4723. */
  4724. onPointerEnterObservable: BABYLON.Observable<Control>;
  4725. /**
  4726. * An event triggered when the control is marked as dirty
  4727. */
  4728. onDirtyObservable: BABYLON.Observable<Control>;
  4729. /**
  4730. * An event triggered before drawing the control
  4731. */
  4732. onBeforeDrawObservable: BABYLON.Observable<Control>;
  4733. /**
  4734. * An event triggered after the control was drawn
  4735. */
  4736. onAfterDrawObservable: BABYLON.Observable<Control>;
  4737. /**
  4738. * Get the hosting AdvancedDynamicTexture
  4739. */
  4740. readonly host: AdvancedDynamicTexture;
  4741. /** Gets or set information about font offsets (used to render and align text) */
  4742. fontOffset: {
  4743. ascent: number;
  4744. height: number;
  4745. descent: number;
  4746. };
  4747. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  4748. alpha: number;
  4749. /**
  4750. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  4751. */
  4752. isHighlighted: boolean;
  4753. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  4754. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4755. */
  4756. scaleX: number;
  4757. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  4758. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4759. */
  4760. scaleY: number;
  4761. /** Gets or sets the rotation angle (0 by default)
  4762. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4763. */
  4764. rotation: number;
  4765. /** Gets or sets the transformation center on Y axis (0 by default)
  4766. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4767. */
  4768. transformCenterY: number;
  4769. /** Gets or sets the transformation center on X axis (0 by default)
  4770. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4771. */
  4772. transformCenterX: number;
  4773. /**
  4774. * Gets or sets the horizontal alignment
  4775. * @see http://doc.babylonjs.com/how_to/gui#alignments
  4776. */
  4777. horizontalAlignment: number;
  4778. /**
  4779. * Gets or sets the vertical alignment
  4780. * @see http://doc.babylonjs.com/how_to/gui#alignments
  4781. */
  4782. verticalAlignment: number;
  4783. /**
  4784. * Gets or sets control width
  4785. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4786. */
  4787. width: string | number;
  4788. /**
  4789. * Gets or sets the control width in pixel
  4790. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4791. */
  4792. widthInPixels: number;
  4793. /**
  4794. * Gets or sets control height
  4795. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4796. */
  4797. height: string | number;
  4798. /**
  4799. * Gets or sets control height in pixel
  4800. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4801. */
  4802. heightInPixels: number;
  4803. /** Gets or set font family */
  4804. fontFamily: string;
  4805. /** Gets or sets font style */
  4806. fontStyle: string;
  4807. /** Gets or sets font weight */
  4808. fontWeight: string;
  4809. /**
  4810. * Gets or sets style
  4811. * @see http://doc.babylonjs.com/how_to/gui#styles
  4812. */
  4813. style: BABYLON.Nullable<Style>;
  4814. /** @hidden */
  4815. readonly _isFontSizeInPercentage: boolean;
  4816. /** Gets or sets font size in pixels */
  4817. fontSizeInPixels: number;
  4818. /** Gets or sets font size */
  4819. fontSize: string | number;
  4820. /** Gets or sets foreground color */
  4821. color: string;
  4822. /** Gets or sets z index which is used to reorder controls on the z axis */
  4823. zIndex: number;
  4824. /** Gets or sets a boolean indicating if the control can be rendered */
  4825. notRenderable: boolean;
  4826. /** Gets or sets a boolean indicating if the control is visible */
  4827. isVisible: boolean;
  4828. /** Gets a boolean indicating that the control needs to update its rendering */
  4829. readonly isDirty: boolean;
  4830. /**
  4831. * Gets the current linked mesh (or null if none)
  4832. */
  4833. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  4834. /**
  4835. * Gets or sets a value indicating the padding to use on the left of the control
  4836. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4837. */
  4838. paddingLeft: string | number;
  4839. /**
  4840. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4841. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4842. */
  4843. paddingLeftInPixels: number;
  4844. /**
  4845. * Gets or sets a value indicating the padding to use on the right of the control
  4846. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4847. */
  4848. paddingRight: string | number;
  4849. /**
  4850. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4851. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4852. */
  4853. paddingRightInPixels: number;
  4854. /**
  4855. * Gets or sets a value indicating the padding to use on the top of the control
  4856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4857. */
  4858. paddingTop: string | number;
  4859. /**
  4860. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4861. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4862. */
  4863. paddingTopInPixels: number;
  4864. /**
  4865. * Gets or sets a value indicating the padding to use on the bottom of the control
  4866. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4867. */
  4868. paddingBottom: string | number;
  4869. /**
  4870. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4871. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4872. */
  4873. paddingBottomInPixels: number;
  4874. /**
  4875. * Gets or sets a value indicating the left coordinate of the control
  4876. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4877. */
  4878. left: string | number;
  4879. /**
  4880. * Gets or sets a value indicating the left coordinate in pixels of the control
  4881. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4882. */
  4883. leftInPixels: number;
  4884. /**
  4885. * Gets or sets a value indicating the top coordinate of the control
  4886. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4887. */
  4888. top: string | number;
  4889. /**
  4890. * Gets or sets a value indicating the top coordinate in pixels of the control
  4891. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4892. */
  4893. topInPixels: number;
  4894. /**
  4895. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4896. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4897. */
  4898. linkOffsetX: string | number;
  4899. /**
  4900. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4901. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4902. */
  4903. linkOffsetXInPixels: number;
  4904. /**
  4905. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4906. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4907. */
  4908. linkOffsetY: string | number;
  4909. /**
  4910. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4911. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4912. */
  4913. linkOffsetYInPixels: number;
  4914. /** Gets the center coordinate on X axis */
  4915. readonly centerX: number;
  4916. /** Gets the center coordinate on Y axis */
  4917. readonly centerY: number;
  4918. /** Gets or sets if control is Enabled*/
  4919. isEnabled: boolean;
  4920. /** Gets or sets background color of control if it's disabled*/
  4921. disabledColor: string;
  4922. /**
  4923. * Creates a new control
  4924. * @param name defines the name of the control
  4925. */
  4926. constructor(
  4927. /** defines the name of the control */
  4928. name?: string | undefined);
  4929. /** @hidden */
  4930. protected _getTypeName(): string;
  4931. /**
  4932. * Gets the first ascendant in the hierarchy of the given type
  4933. * @param className defines the required type
  4934. * @returns the ascendant or null if not found
  4935. */
  4936. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  4937. /** @hidden */
  4938. _resetFontCache(): void;
  4939. /**
  4940. * Determines if a container is an ascendant of the current control
  4941. * @param container defines the container to look for
  4942. * @returns true if the container is one of the ascendant of the control
  4943. */
  4944. isAscendant(container: Control): boolean;
  4945. /**
  4946. * Gets coordinates in local control space
  4947. * @param globalCoordinates defines the coordinates to transform
  4948. * @returns the new coordinates in local space
  4949. */
  4950. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  4951. /**
  4952. * Gets coordinates in local control space
  4953. * @param globalCoordinates defines the coordinates to transform
  4954. * @param result defines the target vector2 where to store the result
  4955. * @returns the current control
  4956. */
  4957. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  4958. /**
  4959. * Gets coordinates in parent local control space
  4960. * @param globalCoordinates defines the coordinates to transform
  4961. * @returns the new coordinates in parent local space
  4962. */
  4963. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  4964. /**
  4965. * Move the current control to a vector3 position projected onto the screen.
  4966. * @param position defines the target position
  4967. * @param scene defines the hosting scene
  4968. */
  4969. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  4970. /**
  4971. * Will store all controls that have this control as ascendant in a given array
  4972. * @param results defines the array where to store the descendants
  4973. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4974. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4975. */
  4976. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  4977. /**
  4978. * Will return all controls that have this control as ascendant
  4979. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4980. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4981. * @return all child controls
  4982. */
  4983. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  4984. /**
  4985. * Link current control with a target mesh
  4986. * @param mesh defines the mesh to link with
  4987. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4988. */
  4989. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  4990. /** @hidden */
  4991. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  4992. /** @hidden */
  4993. _offsetLeft(offset: number): void;
  4994. /** @hidden */
  4995. _offsetTop(offset: number): void;
  4996. /** @hidden */
  4997. _markMatrixAsDirty(): void;
  4998. /** @hidden */
  4999. _flagDescendantsAsMatrixDirty(): void;
  5000. /** @hidden */
  5001. _intersectsRect(rect: Measure): boolean;
  5002. /** @hidden */
  5003. protected invalidateRect(): void;
  5004. /** @hidden */
  5005. _markAsDirty(force?: boolean): void;
  5006. /** @hidden */
  5007. _markAllAsDirty(): void;
  5008. /** @hidden */
  5009. _link(host: AdvancedDynamicTexture): void;
  5010. /** @hidden */
  5011. protected _transform(context?: CanvasRenderingContext2D): void;
  5012. /** @hidden */
  5013. _renderHighlight(context: CanvasRenderingContext2D): void;
  5014. /** @hidden */
  5015. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  5016. /** @hidden */
  5017. protected _applyStates(context: CanvasRenderingContext2D): void;
  5018. /** @hidden */
  5019. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  5020. /** @hidden */
  5021. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5022. protected _evaluateClippingState(parentMeasure: Measure): void;
  5023. /** @hidden */
  5024. _measure(): void;
  5025. /** @hidden */
  5026. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5027. /** @hidden */
  5028. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5029. /** @hidden */
  5030. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5031. /** @hidden */
  5032. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  5033. private static _ClipMeasure;
  5034. private _tmpMeasureA;
  5035. private _clip;
  5036. /** @hidden */
  5037. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  5038. /** @hidden */
  5039. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  5040. /**
  5041. * Tests if a given coordinates belong to the current control
  5042. * @param x defines x coordinate to test
  5043. * @param y defines y coordinate to test
  5044. * @returns true if the coordinates are inside the control
  5045. */
  5046. contains(x: number, y: number): boolean;
  5047. /** @hidden */
  5048. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  5049. /** @hidden */
  5050. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  5051. /** @hidden */
  5052. _onPointerEnter(target: Control): boolean;
  5053. /** @hidden */
  5054. _onPointerOut(target: Control, force?: boolean): void;
  5055. /** @hidden */
  5056. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  5057. /** @hidden */
  5058. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  5059. /** @hidden */
  5060. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  5061. /** @hidden */
  5062. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  5063. private _prepareFont;
  5064. /** Releases associated resources */
  5065. dispose(): void;
  5066. private static _HORIZONTAL_ALIGNMENT_LEFT;
  5067. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  5068. private static _HORIZONTAL_ALIGNMENT_CENTER;
  5069. private static _VERTICAL_ALIGNMENT_TOP;
  5070. private static _VERTICAL_ALIGNMENT_BOTTOM;
  5071. private static _VERTICAL_ALIGNMENT_CENTER;
  5072. /** HORIZONTAL_ALIGNMENT_LEFT */
  5073. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  5074. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5075. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  5076. /** HORIZONTAL_ALIGNMENT_CENTER */
  5077. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  5078. /** VERTICAL_ALIGNMENT_TOP */
  5079. static readonly VERTICAL_ALIGNMENT_TOP: number;
  5080. /** VERTICAL_ALIGNMENT_BOTTOM */
  5081. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  5082. /** VERTICAL_ALIGNMENT_CENTER */
  5083. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  5084. private static _FontHeightSizes;
  5085. /** @hidden */
  5086. static _GetFontOffset(font: string): {
  5087. ascent: number;
  5088. height: number;
  5089. descent: number;
  5090. };
  5091. /**
  5092. * Creates a stack panel that can be used to render headers
  5093. * @param control defines the control to associate with the header
  5094. * @param text defines the text of the header
  5095. * @param size defines the size of the header
  5096. * @param options defines options used to configure the header
  5097. * @returns a new StackPanel
  5098. * @ignore
  5099. * @hidden
  5100. */
  5101. static AddHeader: (control: Control, text: string, size: string | number, options: {
  5102. isHorizontal: boolean;
  5103. controlFirst: boolean;
  5104. }) => any;
  5105. /** @hidden */
  5106. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  5107. }
  5108. }
  5109. declare module BABYLON.GUI {
  5110. /**
  5111. * Root class for 2D containers
  5112. * @see http://doc.babylonjs.com/how_to/gui#containers
  5113. */
  5114. export class Container extends Control {
  5115. name?: string | undefined;
  5116. /** @hidden */
  5117. protected _children: Control[];
  5118. /** @hidden */
  5119. protected _measureForChildren: Measure;
  5120. /** @hidden */
  5121. protected _background: string;
  5122. /** @hidden */
  5123. protected _adaptWidthToChildren: boolean;
  5124. /** @hidden */
  5125. protected _adaptHeightToChildren: boolean;
  5126. /**
  5127. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  5128. */
  5129. logLayoutCycleErrors: boolean;
  5130. /**
  5131. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  5132. */
  5133. maxLayoutCycle: number;
  5134. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  5135. adaptHeightToChildren: boolean;
  5136. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  5137. adaptWidthToChildren: boolean;
  5138. /** Gets or sets background color */
  5139. background: string;
  5140. /** Gets the list of children */
  5141. readonly children: Control[];
  5142. /**
  5143. * Creates a new Container
  5144. * @param name defines the name of the container
  5145. */
  5146. constructor(name?: string | undefined);
  5147. protected _getTypeName(): string;
  5148. _flagDescendantsAsMatrixDirty(): void;
  5149. /**
  5150. * Gets a child using its name
  5151. * @param name defines the child name to look for
  5152. * @returns the child control if found
  5153. */
  5154. getChildByName(name: string): BABYLON.Nullable<Control>;
  5155. /**
  5156. * Gets a child using its type and its name
  5157. * @param name defines the child name to look for
  5158. * @param type defines the child type to look for
  5159. * @returns the child control if found
  5160. */
  5161. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  5162. /**
  5163. * Search for a specific control in children
  5164. * @param control defines the control to look for
  5165. * @returns true if the control is in child list
  5166. */
  5167. containsControl(control: Control): boolean;
  5168. /**
  5169. * Adds a new control to the current container
  5170. * @param control defines the control to add
  5171. * @returns the current container
  5172. */
  5173. addControl(control: BABYLON.Nullable<Control>): Container;
  5174. /**
  5175. * Removes all controls from the current container
  5176. * @returns the current container
  5177. */
  5178. clearControls(): Container;
  5179. /**
  5180. * Removes a control from the current container
  5181. * @param control defines the control to remove
  5182. * @returns the current container
  5183. */
  5184. removeControl(control: Control): Container;
  5185. /** @hidden */
  5186. _reOrderControl(control: Control): void;
  5187. /** @hidden */
  5188. _offsetLeft(offset: number): void;
  5189. /** @hidden */
  5190. _offsetTop(offset: number): void;
  5191. /** @hidden */
  5192. _markAllAsDirty(): void;
  5193. /** @hidden */
  5194. protected _localDraw(context: CanvasRenderingContext2D): void;
  5195. /** @hidden */
  5196. _link(host: AdvancedDynamicTexture): void;
  5197. /** @hidden */
  5198. protected _beforeLayout(): void;
  5199. /** @hidden */
  5200. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5201. /** @hidden */
  5202. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  5203. protected _postMeasure(): void;
  5204. /** @hidden */
  5205. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  5206. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  5207. /** @hidden */
  5208. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  5209. /** @hidden */
  5210. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5211. /** Releases associated resources */
  5212. dispose(): void;
  5213. }
  5214. }
  5215. declare module BABYLON.GUI {
  5216. /** Class used to create rectangle container */
  5217. export class Rectangle extends Container {
  5218. name?: string | undefined;
  5219. private _thickness;
  5220. private _cornerRadius;
  5221. /** Gets or sets border thickness */
  5222. thickness: number;
  5223. /** Gets or sets the corner radius angle */
  5224. cornerRadius: number;
  5225. /**
  5226. * Creates a new Rectangle
  5227. * @param name defines the control name
  5228. */
  5229. constructor(name?: string | undefined);
  5230. protected _getTypeName(): string;
  5231. protected _localDraw(context: CanvasRenderingContext2D): void;
  5232. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5233. private _drawRoundedRect;
  5234. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  5235. }
  5236. }
  5237. declare module BABYLON.GUI {
  5238. /**
  5239. * Enum that determines the text-wrapping mode to use.
  5240. */
  5241. export enum TextWrapping {
  5242. /**
  5243. * Clip the text when it's larger than Control.width; this is the default mode.
  5244. */
  5245. Clip = 0,
  5246. /**
  5247. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  5248. */
  5249. WordWrap = 1,
  5250. /**
  5251. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  5252. */
  5253. Ellipsis = 2
  5254. }
  5255. /**
  5256. * Class used to create text block control
  5257. */
  5258. export class TextBlock extends Control {
  5259. /**
  5260. * Defines the name of the control
  5261. */
  5262. name?: string | undefined;
  5263. private _text;
  5264. private _textWrapping;
  5265. private _textHorizontalAlignment;
  5266. private _textVerticalAlignment;
  5267. private _lines;
  5268. private _resizeToFit;
  5269. private _lineSpacing;
  5270. private _outlineWidth;
  5271. private _outlineColor;
  5272. /**
  5273. * An event triggered after the text is changed
  5274. */
  5275. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  5276. /**
  5277. * An event triggered after the text was broken up into lines
  5278. */
  5279. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  5280. /**
  5281. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  5282. */
  5283. readonly lines: any[];
  5284. /**
  5285. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  5286. */
  5287. /**
  5288. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  5289. */
  5290. resizeToFit: boolean;
  5291. /**
  5292. * Gets or sets a boolean indicating if text must be wrapped
  5293. */
  5294. /**
  5295. * Gets or sets a boolean indicating if text must be wrapped
  5296. */
  5297. textWrapping: TextWrapping | boolean;
  5298. /**
  5299. * Gets or sets text to display
  5300. */
  5301. /**
  5302. * Gets or sets text to display
  5303. */
  5304. text: string;
  5305. /**
  5306. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  5307. */
  5308. /**
  5309. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  5310. */
  5311. textHorizontalAlignment: number;
  5312. /**
  5313. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  5314. */
  5315. /**
  5316. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  5317. */
  5318. textVerticalAlignment: number;
  5319. /**
  5320. * Gets or sets line spacing value
  5321. */
  5322. /**
  5323. * Gets or sets line spacing value
  5324. */
  5325. lineSpacing: string | number;
  5326. /**
  5327. * Gets or sets outlineWidth of the text to display
  5328. */
  5329. /**
  5330. * Gets or sets outlineWidth of the text to display
  5331. */
  5332. outlineWidth: number;
  5333. /**
  5334. * Gets or sets outlineColor of the text to display
  5335. */
  5336. /**
  5337. * Gets or sets outlineColor of the text to display
  5338. */
  5339. outlineColor: string;
  5340. /**
  5341. * Creates a new TextBlock object
  5342. * @param name defines the name of the control
  5343. * @param text defines the text to display (emptry string by default)
  5344. */
  5345. constructor(
  5346. /**
  5347. * Defines the name of the control
  5348. */
  5349. name?: string | undefined, text?: string);
  5350. protected _getTypeName(): string;
  5351. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5352. private _drawText;
  5353. /** @hidden */
  5354. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  5355. protected _applyStates(context: CanvasRenderingContext2D): void;
  5356. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  5357. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  5358. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  5359. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  5360. protected _renderLines(context: CanvasRenderingContext2D): void;
  5361. /**
  5362. * Given a width constraint applied on the text block, find the expected height
  5363. * @returns expected height
  5364. */
  5365. computeExpectedHeight(): number;
  5366. dispose(): void;
  5367. }
  5368. }
  5369. declare module BABYLON.GUI {
  5370. /**
  5371. * Class used to create 2D images
  5372. */
  5373. export class Image extends Control {
  5374. name?: string | undefined;
  5375. private _workingCanvas;
  5376. private _domImage;
  5377. private _imageWidth;
  5378. private _imageHeight;
  5379. private _loaded;
  5380. private _stretch;
  5381. private _source;
  5382. private _autoScale;
  5383. private _sourceLeft;
  5384. private _sourceTop;
  5385. private _sourceWidth;
  5386. private _sourceHeight;
  5387. private _cellWidth;
  5388. private _cellHeight;
  5389. private _cellId;
  5390. private _populateNinePatchSlicesFromImage;
  5391. private _sliceLeft;
  5392. private _sliceRight;
  5393. private _sliceTop;
  5394. private _sliceBottom;
  5395. private _detectPointerOnOpaqueOnly;
  5396. /**
  5397. * BABYLON.Observable notified when the content is loaded
  5398. */
  5399. onImageLoadedObservable: BABYLON.Observable<Image>;
  5400. /**
  5401. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  5402. */
  5403. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  5404. /**
  5405. * Gets a boolean indicating that the content is loaded
  5406. */
  5407. readonly isLoaded: boolean;
  5408. /**
  5409. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  5410. */
  5411. populateNinePatchSlicesFromImage: boolean;
  5412. /**
  5413. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  5414. * Beware using this as this will comsume more memory as the image has to be stored twice
  5415. */
  5416. detectPointerOnOpaqueOnly: boolean;
  5417. /**
  5418. * Gets or sets the left value for slicing (9-patch)
  5419. */
  5420. sliceLeft: number;
  5421. /**
  5422. * Gets or sets the right value for slicing (9-patch)
  5423. */
  5424. sliceRight: number;
  5425. /**
  5426. * Gets or sets the top value for slicing (9-patch)
  5427. */
  5428. sliceTop: number;
  5429. /**
  5430. * Gets or sets the bottom value for slicing (9-patch)
  5431. */
  5432. sliceBottom: number;
  5433. /**
  5434. * Gets or sets the left coordinate in the source image
  5435. */
  5436. sourceLeft: number;
  5437. /**
  5438. * Gets or sets the top coordinate in the source image
  5439. */
  5440. sourceTop: number;
  5441. /**
  5442. * Gets or sets the width to capture in the source image
  5443. */
  5444. sourceWidth: number;
  5445. /**
  5446. * Gets or sets the height to capture in the source image
  5447. */
  5448. sourceHeight: number;
  5449. /**
  5450. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  5451. * @see http://doc.babylonjs.com/how_to/gui#image
  5452. */
  5453. autoScale: boolean;
  5454. /** Gets or sets the streching mode used by the image */
  5455. stretch: number;
  5456. /**
  5457. * Gets or sets the internal DOM image used to render the control
  5458. */
  5459. domImage: HTMLImageElement;
  5460. private _onImageLoaded;
  5461. private _extractNinePatchSliceDataFromImage;
  5462. /**
  5463. * Gets or sets image source url
  5464. */
  5465. source: BABYLON.Nullable<string>;
  5466. /**
  5467. * Checks for svg document with icon id present
  5468. */
  5469. private _svgCheck;
  5470. /**
  5471. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  5472. * given external svg file and icon id
  5473. */
  5474. private _getSVGAttribs;
  5475. /**
  5476. * Gets or sets the cell width to use when animation sheet is enabled
  5477. * @see http://doc.babylonjs.com/how_to/gui#image
  5478. */
  5479. cellWidth: number;
  5480. /**
  5481. * Gets or sets the cell height to use when animation sheet is enabled
  5482. * @see http://doc.babylonjs.com/how_to/gui#image
  5483. */
  5484. cellHeight: number;
  5485. /**
  5486. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  5487. * @see http://doc.babylonjs.com/how_to/gui#image
  5488. */
  5489. cellId: number;
  5490. /**
  5491. * Creates a new Image
  5492. * @param name defines the control name
  5493. * @param url defines the image url
  5494. */
  5495. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  5496. /**
  5497. * Tests if a given coordinates belong to the current control
  5498. * @param x defines x coordinate to test
  5499. * @param y defines y coordinate to test
  5500. * @returns true if the coordinates are inside the control
  5501. */
  5502. contains(x: number, y: number): boolean;
  5503. protected _getTypeName(): string;
  5504. /** Force the control to synchronize with its content */
  5505. synchronizeSizeWithContent(): void;
  5506. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5507. private _prepareWorkingCanvasForOpaqueDetection;
  5508. private _drawImage;
  5509. _draw(context: CanvasRenderingContext2D): void;
  5510. private _renderCornerPatch;
  5511. private _renderNinePatch;
  5512. dispose(): void;
  5513. /** STRETCH_NONE */
  5514. static readonly STRETCH_NONE: number;
  5515. /** STRETCH_FILL */
  5516. static readonly STRETCH_FILL: number;
  5517. /** STRETCH_UNIFORM */
  5518. static readonly STRETCH_UNIFORM: number;
  5519. /** STRETCH_EXTEND */
  5520. static readonly STRETCH_EXTEND: number;
  5521. /** NINE_PATCH */
  5522. static readonly STRETCH_NINE_PATCH: number;
  5523. }
  5524. }
  5525. declare module BABYLON.GUI {
  5526. /**
  5527. * Class used to create 2D buttons
  5528. */
  5529. export class Button extends Rectangle {
  5530. name?: string | undefined;
  5531. /**
  5532. * Function called to generate a pointer enter animation
  5533. */
  5534. pointerEnterAnimation: () => void;
  5535. /**
  5536. * Function called to generate a pointer out animation
  5537. */
  5538. pointerOutAnimation: () => void;
  5539. /**
  5540. * Function called to generate a pointer down animation
  5541. */
  5542. pointerDownAnimation: () => void;
  5543. /**
  5544. * Function called to generate a pointer up animation
  5545. */
  5546. pointerUpAnimation: () => void;
  5547. /**
  5548. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  5549. */
  5550. delegatePickingToChildren: boolean;
  5551. private _image;
  5552. /**
  5553. * Returns the image part of the button (if any)
  5554. */
  5555. readonly image: BABYLON.Nullable<Image>;
  5556. private _textBlock;
  5557. /**
  5558. * Returns the image part of the button (if any)
  5559. */
  5560. readonly textBlock: BABYLON.Nullable<TextBlock>;
  5561. /**
  5562. * Creates a new Button
  5563. * @param name defines the name of the button
  5564. */
  5565. constructor(name?: string | undefined);
  5566. protected _getTypeName(): string;
  5567. /** @hidden */
  5568. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  5569. /** @hidden */
  5570. _onPointerEnter(target: Control): boolean;
  5571. /** @hidden */
  5572. _onPointerOut(target: Control, force?: boolean): void;
  5573. /** @hidden */
  5574. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  5575. /** @hidden */
  5576. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  5577. /**
  5578. * Creates a new button made with an image and a text
  5579. * @param name defines the name of the button
  5580. * @param text defines the text of the button
  5581. * @param imageUrl defines the url of the image
  5582. * @returns a new Button
  5583. */
  5584. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  5585. /**
  5586. * Creates a new button made with an image
  5587. * @param name defines the name of the button
  5588. * @param imageUrl defines the url of the image
  5589. * @returns a new Button
  5590. */
  5591. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  5592. /**
  5593. * Creates a new button made with a text
  5594. * @param name defines the name of the button
  5595. * @param text defines the text of the button
  5596. * @returns a new Button
  5597. */
  5598. static CreateSimpleButton(name: string, text: string): Button;
  5599. /**
  5600. * Creates a new button made with an image and a centered text
  5601. * @param name defines the name of the button
  5602. * @param text defines the text of the button
  5603. * @param imageUrl defines the url of the image
  5604. * @returns a new Button
  5605. */
  5606. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  5607. }
  5608. }
  5609. declare module BABYLON.GUI {
  5610. /**
  5611. * Class used to create a 2D stack panel container
  5612. */
  5613. export class StackPanel extends Container {
  5614. name?: string | undefined;
  5615. private _isVertical;
  5616. private _manualWidth;
  5617. private _manualHeight;
  5618. private _doNotTrackManualChanges;
  5619. /**
  5620. * Gets or sets a boolean indicating that layou warnings should be ignored
  5621. */
  5622. ignoreLayoutWarnings: boolean;
  5623. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  5624. isVertical: boolean;
  5625. /**
  5626. * Gets or sets panel width.
  5627. * This value should not be set when in horizontal mode as it will be computed automatically
  5628. */
  5629. width: string | number;
  5630. /**
  5631. * Gets or sets panel height.
  5632. * This value should not be set when in vertical mode as it will be computed automatically
  5633. */
  5634. height: string | number;
  5635. /**
  5636. * Creates a new StackPanel
  5637. * @param name defines control name
  5638. */
  5639. constructor(name?: string | undefined);
  5640. protected _getTypeName(): string;
  5641. /** @hidden */
  5642. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5643. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  5644. protected _postMeasure(): void;
  5645. }
  5646. }
  5647. declare module BABYLON.GUI {
  5648. /**
  5649. * Class used to represent a 2D checkbox
  5650. */
  5651. export class Checkbox extends Control {
  5652. name?: string | undefined;
  5653. private _isChecked;
  5654. private _background;
  5655. private _checkSizeRatio;
  5656. private _thickness;
  5657. /** Gets or sets border thickness */
  5658. thickness: number;
  5659. /**
  5660. * BABYLON.Observable raised when isChecked property changes
  5661. */
  5662. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  5663. /** Gets or sets a value indicating the ratio between overall size and check size */
  5664. checkSizeRatio: number;
  5665. /** Gets or sets background color */
  5666. background: string;
  5667. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  5668. isChecked: boolean;
  5669. /**
  5670. * Creates a new CheckBox
  5671. * @param name defines the control name
  5672. */
  5673. constructor(name?: string | undefined);
  5674. protected _getTypeName(): string;
  5675. /** @hidden */
  5676. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  5677. /** @hidden */
  5678. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  5679. /**
  5680. * Utility function to easily create a checkbox with a header
  5681. * @param title defines the label to use for the header
  5682. * @param onValueChanged defines the callback to call when value changes
  5683. * @returns a StackPanel containing the checkbox and a textBlock
  5684. */
  5685. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  5686. }
  5687. }
  5688. declare module BABYLON.GUI {
  5689. /**
  5690. * Class used to store key control properties
  5691. */
  5692. export class KeyPropertySet {
  5693. /** Width */
  5694. width?: string;
  5695. /** Height */
  5696. height?: string;
  5697. /** Left padding */
  5698. paddingLeft?: string;
  5699. /** Right padding */
  5700. paddingRight?: string;
  5701. /** Top padding */
  5702. paddingTop?: string;
  5703. /** Bottom padding */
  5704. paddingBottom?: string;
  5705. /** Foreground color */
  5706. color?: string;
  5707. /** Background color */
  5708. background?: string;
  5709. }
  5710. /**
  5711. * Class used to create virtual keyboard
  5712. */
  5713. export class VirtualKeyboard extends StackPanel {
  5714. /** BABYLON.Observable raised when a key is pressed */
  5715. onKeyPressObservable: BABYLON.Observable<string>;
  5716. /** Gets or sets default key button width */
  5717. defaultButtonWidth: string;
  5718. /** Gets or sets default key button height */
  5719. defaultButtonHeight: string;
  5720. /** Gets or sets default key button left padding */
  5721. defaultButtonPaddingLeft: string;
  5722. /** Gets or sets default key button right padding */
  5723. defaultButtonPaddingRight: string;
  5724. /** Gets or sets default key button top padding */
  5725. defaultButtonPaddingTop: string;
  5726. /** Gets or sets default key button bottom padding */
  5727. defaultButtonPaddingBottom: string;
  5728. /** Gets or sets default key button foreground color */
  5729. defaultButtonColor: string;
  5730. /** Gets or sets default key button background color */
  5731. defaultButtonBackground: string;
  5732. /** Gets or sets shift button foreground color */
  5733. shiftButtonColor: string;
  5734. /** Gets or sets shift button thickness*/
  5735. selectedShiftThickness: number;
  5736. /** Gets shift key state */
  5737. shiftState: number;
  5738. protected _getTypeName(): string;
  5739. private _createKey;
  5740. /**
  5741. * Adds a new row of keys
  5742. * @param keys defines the list of keys to add
  5743. * @param propertySets defines the associated property sets
  5744. */
  5745. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  5746. /**
  5747. * Set the shift key to a specific state
  5748. * @param shiftState defines the new shift state
  5749. */
  5750. applyShiftState(shiftState: number): void;
  5751. private _currentlyConnectedInputText;
  5752. private _connectedInputTexts;
  5753. private _onKeyPressObserver;
  5754. /** Gets the input text control currently attached to the keyboard */
  5755. readonly connectedInputText: BABYLON.Nullable<InputText>;
  5756. /**
  5757. * Connects the keyboard with an input text control
  5758. *
  5759. * @param input defines the target control
  5760. */
  5761. connect(input: InputText): void;
  5762. /**
  5763. * Disconnects the keyboard from connected InputText controls
  5764. *
  5765. * @param input optionally defines a target control, otherwise all are disconnected
  5766. */
  5767. disconnect(input?: InputText): void;
  5768. private _removeConnectedInputObservables;
  5769. /**
  5770. * Release all resources
  5771. */
  5772. dispose(): void;
  5773. /**
  5774. * Creates a new keyboard using a default layout
  5775. *
  5776. * @param name defines control name
  5777. * @returns a new VirtualKeyboard
  5778. */
  5779. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  5780. }
  5781. }
  5782. declare module BABYLON.GUI {
  5783. /**
  5784. * Class used to create input text control
  5785. */
  5786. export class InputText extends Control implements IFocusableControl {
  5787. name?: string | undefined;
  5788. private _text;
  5789. private _placeholderText;
  5790. private _background;
  5791. private _focusedBackground;
  5792. private _focusedColor;
  5793. private _placeholderColor;
  5794. private _thickness;
  5795. private _margin;
  5796. private _autoStretchWidth;
  5797. private _maxWidth;
  5798. private _isFocused;
  5799. private _blinkTimeout;
  5800. private _blinkIsEven;
  5801. private _cursorOffset;
  5802. private _scrollLeft;
  5803. private _textWidth;
  5804. private _clickedCoordinate;
  5805. private _deadKey;
  5806. private _addKey;
  5807. private _currentKey;
  5808. private _isTextHighlightOn;
  5809. private _textHighlightColor;
  5810. private _highligherOpacity;
  5811. private _highlightedText;
  5812. private _startHighlightIndex;
  5813. private _endHighlightIndex;
  5814. private _cursorIndex;
  5815. private _onFocusSelectAll;
  5816. private _isPointerDown;
  5817. private _onClipboardObserver;
  5818. private _onPointerDblTapObserver;
  5819. /** @hidden */
  5820. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  5821. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  5822. promptMessage: string;
  5823. /** Force disable prompt on mobile device */
  5824. disableMobilePrompt: boolean;
  5825. /** BABYLON.Observable raised when the text changes */
  5826. onTextChangedObservable: BABYLON.Observable<InputText>;
  5827. /** BABYLON.Observable raised just before an entered character is to be added */
  5828. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  5829. /** BABYLON.Observable raised when the control gets the focus */
  5830. onFocusObservable: BABYLON.Observable<InputText>;
  5831. /** BABYLON.Observable raised when the control loses the focus */
  5832. onBlurObservable: BABYLON.Observable<InputText>;
  5833. /**Observable raised when the text is highlighted */
  5834. onTextHighlightObservable: BABYLON.Observable<InputText>;
  5835. /**Observable raised when copy event is triggered */
  5836. onTextCopyObservable: BABYLON.Observable<InputText>;
  5837. /** BABYLON.Observable raised when cut event is triggered */
  5838. onTextCutObservable: BABYLON.Observable<InputText>;
  5839. /** BABYLON.Observable raised when paste event is triggered */
  5840. onTextPasteObservable: BABYLON.Observable<InputText>;
  5841. /** BABYLON.Observable raised when a key event was processed */
  5842. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  5843. /** Gets or sets the maximum width allowed by the control */
  5844. maxWidth: string | number;
  5845. /** Gets the maximum width allowed by the control in pixels */
  5846. readonly maxWidthInPixels: number;
  5847. /** Gets or sets the text highlighter transparency; default: 0.4 */
  5848. highligherOpacity: number;
  5849. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  5850. onFocusSelectAll: boolean;
  5851. /** Gets or sets the text hightlight color */
  5852. textHighlightColor: string;
  5853. /** Gets or sets control margin */
  5854. margin: string;
  5855. /** Gets control margin in pixels */
  5856. readonly marginInPixels: number;
  5857. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  5858. autoStretchWidth: boolean;
  5859. /** Gets or sets border thickness */
  5860. thickness: number;
  5861. /** Gets or sets the background color when focused */
  5862. focusedBackground: string;
  5863. /** Gets or sets the background color when focused */
  5864. focusedColor: string;
  5865. /** Gets or sets the background color */
  5866. background: string;
  5867. /** Gets or sets the placeholder color */
  5868. placeholderColor: string;
  5869. /** Gets or sets the text displayed when the control is empty */
  5870. placeholderText: string;
  5871. /** Gets or sets the dead key flag */
  5872. deadKey: boolean;
  5873. /** Gets or sets the highlight text */
  5874. highlightedText: string;
  5875. /** Gets or sets if the current key should be added */
  5876. addKey: boolean;
  5877. /** Gets or sets the value of the current key being entered */
  5878. currentKey: string;
  5879. /** Gets or sets the text displayed in the control */
  5880. text: string;
  5881. /** Gets or sets control width */
  5882. width: string | number;
  5883. /**
  5884. * Creates a new InputText
  5885. * @param name defines the control name
  5886. * @param text defines the text of the control
  5887. */
  5888. constructor(name?: string | undefined, text?: string);
  5889. /** @hidden */
  5890. onBlur(): void;
  5891. /** @hidden */
  5892. onFocus(): void;
  5893. protected _getTypeName(): string;
  5894. /**
  5895. * Function called to get the list of controls that should not steal the focus from this control
  5896. * @returns an array of controls
  5897. */
  5898. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  5899. /** @hidden */
  5900. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  5901. /** @hidden */
  5902. private _updateValueFromCursorIndex;
  5903. /** @hidden */
  5904. private _processDblClick;
  5905. /** @hidden */
  5906. private _selectAllText;
  5907. /**
  5908. * Handles the keyboard event
  5909. * @param evt Defines the KeyboardEvent
  5910. */
  5911. processKeyboard(evt: KeyboardEvent): void;
  5912. /** @hidden */
  5913. private _onCopyText;
  5914. /** @hidden */
  5915. private _onCutText;
  5916. /** @hidden */
  5917. private _onPasteText;
  5918. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  5919. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  5920. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  5921. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  5922. protected _beforeRenderText(text: string): string;
  5923. dispose(): void;
  5924. }
  5925. }
  5926. declare module BABYLON.GUI {
  5927. /**
  5928. * Class used to create a 2D grid container
  5929. */
  5930. export class Grid extends Container {
  5931. name?: string | undefined;
  5932. private _rowDefinitions;
  5933. private _columnDefinitions;
  5934. private _cells;
  5935. private _childControls;
  5936. /**
  5937. * Gets the number of columns
  5938. */
  5939. readonly columnCount: number;
  5940. /**
  5941. * Gets the number of rows
  5942. */
  5943. readonly rowCount: number;
  5944. /** Gets the list of children */
  5945. readonly children: Control[];
  5946. /** Gets the list of cells (e.g. the containers) */
  5947. readonly cells: {
  5948. [key: string]: Container;
  5949. };
  5950. /**
  5951. * Gets the definition of a specific row
  5952. * @param index defines the index of the row
  5953. * @returns the row definition
  5954. */
  5955. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  5956. /**
  5957. * Gets the definition of a specific column
  5958. * @param index defines the index of the column
  5959. * @returns the column definition
  5960. */
  5961. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  5962. /**
  5963. * Adds a new row to the grid
  5964. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5965. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5966. * @returns the current grid
  5967. */
  5968. addRowDefinition(height: number, isPixel?: boolean): Grid;
  5969. /**
  5970. * Adds a new column to the grid
  5971. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5972. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5973. * @returns the current grid
  5974. */
  5975. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  5976. /**
  5977. * Update a row definition
  5978. * @param index defines the index of the row to update
  5979. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5980. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5981. * @returns the current grid
  5982. */
  5983. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  5984. /**
  5985. * Update a column definition
  5986. * @param index defines the index of the column to update
  5987. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5988. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5989. * @returns the current grid
  5990. */
  5991. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  5992. /**
  5993. * Gets the list of children stored in a specific cell
  5994. * @param row defines the row to check
  5995. * @param column defines the column to check
  5996. * @returns the list of controls
  5997. */
  5998. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  5999. /**
  6000. * Gets a string representing the child cell info (row x column)
  6001. * @param child defines the control to get info from
  6002. * @returns a string containing the child cell info (row x column)
  6003. */
  6004. getChildCellInfo(child: Control): string;
  6005. private _removeCell;
  6006. private _offsetCell;
  6007. /**
  6008. * Remove a column definition at specified index
  6009. * @param index defines the index of the column to remove
  6010. * @returns the current grid
  6011. */
  6012. removeColumnDefinition(index: number): Grid;
  6013. /**
  6014. * Remove a row definition at specified index
  6015. * @param index defines the index of the row to remove
  6016. * @returns the current grid
  6017. */
  6018. removeRowDefinition(index: number): Grid;
  6019. /**
  6020. * Adds a new control to the current grid
  6021. * @param control defines the control to add
  6022. * @param row defines the row where to add the control (0 by default)
  6023. * @param column defines the column where to add the control (0 by default)
  6024. * @returns the current grid
  6025. */
  6026. addControl(control: Control, row?: number, column?: number): Grid;
  6027. /**
  6028. * Removes a control from the current container
  6029. * @param control defines the control to remove
  6030. * @returns the current container
  6031. */
  6032. removeControl(control: Control): Container;
  6033. /**
  6034. * Creates a new Grid
  6035. * @param name defines control name
  6036. */
  6037. constructor(name?: string | undefined);
  6038. protected _getTypeName(): string;
  6039. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  6040. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6041. _flagDescendantsAsMatrixDirty(): void;
  6042. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  6043. /** Releases associated resources */
  6044. dispose(): void;
  6045. }
  6046. }
  6047. declare module BABYLON.GUI {
  6048. /** Class used to create color pickers */
  6049. export class ColorPicker extends Control {
  6050. name?: string | undefined;
  6051. private static _Epsilon;
  6052. private _colorWheelCanvas;
  6053. private _value;
  6054. private _tmpColor;
  6055. private _pointerStartedOnSquare;
  6056. private _pointerStartedOnWheel;
  6057. private _squareLeft;
  6058. private _squareTop;
  6059. private _squareSize;
  6060. private _h;
  6061. private _s;
  6062. private _v;
  6063. private _lastPointerDownID;
  6064. /**
  6065. * BABYLON.Observable raised when the value changes
  6066. */
  6067. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  6068. /** Gets or sets the color of the color picker */
  6069. value: BABYLON.Color3;
  6070. /**
  6071. * Gets or sets control width
  6072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  6073. */
  6074. width: string | number;
  6075. /**
  6076. * Gets or sets control height
  6077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  6078. */
  6079. /** Gets or sets control height */
  6080. height: string | number;
  6081. /** Gets or sets control size */
  6082. size: string | number;
  6083. /**
  6084. * Creates a new ColorPicker
  6085. * @param name defines the control name
  6086. */
  6087. constructor(name?: string | undefined);
  6088. protected _getTypeName(): string;
  6089. /** @hidden */
  6090. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6091. private _updateSquareProps;
  6092. private _drawGradientSquare;
  6093. private _drawCircle;
  6094. private _createColorWheelCanvas;
  6095. /** @hidden */
  6096. _draw(context: CanvasRenderingContext2D): void;
  6097. private _pointerIsDown;
  6098. private _updateValueFromPointer;
  6099. private _isPointOnSquare;
  6100. private _isPointOnWheel;
  6101. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  6102. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  6103. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  6104. /**
  6105. * This function expands the color picker by creating a color picker dialog with manual
  6106. * color value input and the ability to save colors into an array to be used later in
  6107. * subsequent launches of the dialogue.
  6108. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  6109. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  6110. * @returns picked color as a hex string and the saved colors array as hex strings.
  6111. */
  6112. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  6113. pickerWidth?: string;
  6114. pickerHeight?: string;
  6115. headerHeight?: string;
  6116. lastColor?: string;
  6117. swatchLimit?: number;
  6118. numSwatchesPerLine?: number;
  6119. savedColors?: Array<string>;
  6120. }): Promise<{
  6121. savedColors?: string[];
  6122. pickedColor: string;
  6123. }>;
  6124. }
  6125. }
  6126. declare module BABYLON.GUI {
  6127. /** Class used to create 2D ellipse containers */
  6128. export class Ellipse extends Container {
  6129. name?: string | undefined;
  6130. private _thickness;
  6131. /** Gets or sets border thickness */
  6132. thickness: number;
  6133. /**
  6134. * Creates a new Ellipse
  6135. * @param name defines the control name
  6136. */
  6137. constructor(name?: string | undefined);
  6138. protected _getTypeName(): string;
  6139. protected _localDraw(context: CanvasRenderingContext2D): void;
  6140. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6141. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  6142. }
  6143. }
  6144. declare module BABYLON.GUI {
  6145. /**
  6146. * Class used to create a password control
  6147. */
  6148. export class InputPassword extends InputText {
  6149. protected _beforeRenderText(text: string): string;
  6150. }
  6151. }
  6152. declare module BABYLON.GUI {
  6153. /** Class used to render 2D lines */
  6154. export class Line extends Control {
  6155. name?: string | undefined;
  6156. private _lineWidth;
  6157. private _x1;
  6158. private _y1;
  6159. private _x2;
  6160. private _y2;
  6161. private _dash;
  6162. private _connectedControl;
  6163. private _connectedControlDirtyObserver;
  6164. /** Gets or sets the dash pattern */
  6165. dash: Array<number>;
  6166. /** Gets or sets the control connected with the line end */
  6167. connectedControl: Control;
  6168. /** Gets or sets start coordinates on X axis */
  6169. x1: string | number;
  6170. /** Gets or sets start coordinates on Y axis */
  6171. y1: string | number;
  6172. /** Gets or sets end coordinates on X axis */
  6173. x2: string | number;
  6174. /** Gets or sets end coordinates on Y axis */
  6175. y2: string | number;
  6176. /** Gets or sets line width */
  6177. lineWidth: number;
  6178. /** Gets or sets horizontal alignment */
  6179. horizontalAlignment: number;
  6180. /** Gets or sets vertical alignment */
  6181. verticalAlignment: number;
  6182. private readonly _effectiveX2;
  6183. private readonly _effectiveY2;
  6184. /**
  6185. * Creates a new Line
  6186. * @param name defines the control name
  6187. */
  6188. constructor(name?: string | undefined);
  6189. protected _getTypeName(): string;
  6190. _draw(context: CanvasRenderingContext2D): void;
  6191. _measure(): void;
  6192. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6193. /**
  6194. * Move one end of the line given 3D cartesian coordinates.
  6195. * @param position Targeted world position
  6196. * @param scene BABYLON.Scene
  6197. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  6198. */
  6199. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  6200. /**
  6201. * Move one end of the line to a position in screen absolute space.
  6202. * @param projectedPosition Position in screen absolute space (X, Y)
  6203. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  6204. */
  6205. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  6206. }
  6207. }
  6208. declare module BABYLON.GUI {
  6209. /**
  6210. * Class used to store a point for a MultiLine object.
  6211. * The point can be pure 2D coordinates, a mesh or a control
  6212. */
  6213. export class MultiLinePoint {
  6214. private _multiLine;
  6215. private _x;
  6216. private _y;
  6217. private _control;
  6218. private _mesh;
  6219. private _controlObserver;
  6220. private _meshObserver;
  6221. /** @hidden */
  6222. _point: BABYLON.Vector2;
  6223. /**
  6224. * Creates a new MultiLinePoint
  6225. * @param multiLine defines the source MultiLine object
  6226. */
  6227. constructor(multiLine: MultiLine);
  6228. /** Gets or sets x coordinate */
  6229. x: string | number;
  6230. /** Gets or sets y coordinate */
  6231. y: string | number;
  6232. /** Gets or sets the control associated with this point */
  6233. control: BABYLON.Nullable<Control>;
  6234. /** Gets or sets the mesh associated with this point */
  6235. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  6236. /** Resets links */
  6237. resetLinks(): void;
  6238. /**
  6239. * Gets a translation vector
  6240. * @returns the translation vector
  6241. */
  6242. translate(): BABYLON.Vector2;
  6243. private _translatePoint;
  6244. /** Release associated resources */
  6245. dispose(): void;
  6246. }
  6247. }
  6248. declare module BABYLON.GUI {
  6249. /**
  6250. * Class used to create multi line control
  6251. */
  6252. export class MultiLine extends Control {
  6253. name?: string | undefined;
  6254. private _lineWidth;
  6255. private _dash;
  6256. private _points;
  6257. private _minX;
  6258. private _minY;
  6259. private _maxX;
  6260. private _maxY;
  6261. /**
  6262. * Creates a new MultiLine
  6263. * @param name defines the control name
  6264. */
  6265. constructor(name?: string | undefined);
  6266. /** Gets or sets dash pattern */
  6267. dash: Array<number>;
  6268. /**
  6269. * Gets point stored at specified index
  6270. * @param index defines the index to look for
  6271. * @returns the requested point if found
  6272. */
  6273. getAt(index: number): MultiLinePoint;
  6274. /** Function called when a point is updated */
  6275. onPointUpdate: () => void;
  6276. /**
  6277. * Adds new points to the point collection
  6278. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  6279. * @returns the list of created MultiLinePoint
  6280. */
  6281. add(...items: (AbstractMesh | Control | {
  6282. x: string | number;
  6283. y: string | number;
  6284. })[]): MultiLinePoint[];
  6285. /**
  6286. * Adds a new point to the point collection
  6287. * @param item defines the item (mesh, control or 2d coordiantes) to add
  6288. * @returns the created MultiLinePoint
  6289. */
  6290. push(item?: (AbstractMesh | Control | {
  6291. x: string | number;
  6292. y: string | number;
  6293. })): MultiLinePoint;
  6294. /**
  6295. * Remove a specific value or point from the active point collection
  6296. * @param value defines the value or point to remove
  6297. */
  6298. remove(value: number | MultiLinePoint): void;
  6299. /**
  6300. * Resets this object to initial state (no point)
  6301. */
  6302. reset(): void;
  6303. /**
  6304. * Resets all links
  6305. */
  6306. resetLinks(): void;
  6307. /** Gets or sets line width */
  6308. lineWidth: number;
  6309. horizontalAlignment: number;
  6310. verticalAlignment: number;
  6311. protected _getTypeName(): string;
  6312. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  6313. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6314. _measure(): void;
  6315. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6316. dispose(): void;
  6317. }
  6318. }
  6319. declare module BABYLON.GUI {
  6320. /**
  6321. * Class used to create radio button controls
  6322. */
  6323. export class RadioButton extends Control {
  6324. name?: string | undefined;
  6325. private _isChecked;
  6326. private _background;
  6327. private _checkSizeRatio;
  6328. private _thickness;
  6329. /** Gets or sets border thickness */
  6330. thickness: number;
  6331. /** Gets or sets group name */
  6332. group: string;
  6333. /** BABYLON.Observable raised when isChecked is changed */
  6334. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  6335. /** Gets or sets a value indicating the ratio between overall size and check size */
  6336. checkSizeRatio: number;
  6337. /** Gets or sets background color */
  6338. background: string;
  6339. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  6340. isChecked: boolean;
  6341. /**
  6342. * Creates a new RadioButton
  6343. * @param name defines the control name
  6344. */
  6345. constructor(name?: string | undefined);
  6346. protected _getTypeName(): string;
  6347. _draw(context: CanvasRenderingContext2D): void;
  6348. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  6349. /**
  6350. * Utility function to easily create a radio button with a header
  6351. * @param title defines the label to use for the header
  6352. * @param group defines the group to use for the radio button
  6353. * @param isChecked defines the initial state of the radio button
  6354. * @param onValueChanged defines the callback to call when value changes
  6355. * @returns a StackPanel containing the radio button and a textBlock
  6356. */
  6357. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  6358. }
  6359. }
  6360. declare module BABYLON.GUI {
  6361. /**
  6362. * Class used to create slider controls
  6363. */
  6364. export class BaseSlider extends Control {
  6365. name?: string | undefined;
  6366. protected _thumbWidth: ValueAndUnit;
  6367. private _minimum;
  6368. private _maximum;
  6369. private _value;
  6370. private _isVertical;
  6371. protected _barOffset: ValueAndUnit;
  6372. private _isThumbClamped;
  6373. protected _displayThumb: boolean;
  6374. private _step;
  6375. private _lastPointerDownID;
  6376. protected _effectiveBarOffset: number;
  6377. protected _renderLeft: number;
  6378. protected _renderTop: number;
  6379. protected _renderWidth: number;
  6380. protected _renderHeight: number;
  6381. protected _backgroundBoxLength: number;
  6382. protected _backgroundBoxThickness: number;
  6383. protected _effectiveThumbThickness: number;
  6384. /** BABYLON.Observable raised when the sldier value changes */
  6385. onValueChangedObservable: BABYLON.Observable<number>;
  6386. /** Gets or sets a boolean indicating if the thumb must be rendered */
  6387. displayThumb: boolean;
  6388. /** Gets or sets a step to apply to values (0 by default) */
  6389. step: number;
  6390. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  6391. barOffset: string | number;
  6392. /** Gets main bar offset in pixels*/
  6393. readonly barOffsetInPixels: number;
  6394. /** Gets or sets thumb width */
  6395. thumbWidth: string | number;
  6396. /** Gets thumb width in pixels */
  6397. readonly thumbWidthInPixels: number;
  6398. /** Gets or sets minimum value */
  6399. minimum: number;
  6400. /** Gets or sets maximum value */
  6401. maximum: number;
  6402. /** Gets or sets current value */
  6403. value: number;
  6404. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  6405. isVertical: boolean;
  6406. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  6407. isThumbClamped: boolean;
  6408. /**
  6409. * Creates a new BaseSlider
  6410. * @param name defines the control name
  6411. */
  6412. constructor(name?: string | undefined);
  6413. protected _getTypeName(): string;
  6414. protected _getThumbPosition(): number;
  6415. protected _getThumbThickness(type: string): number;
  6416. protected _prepareRenderingData(type: string): void;
  6417. private _pointerIsDown;
  6418. /** @hidden */
  6419. protected _updateValueFromPointer(x: number, y: number): void;
  6420. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  6421. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  6422. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  6423. }
  6424. }
  6425. declare module BABYLON.GUI {
  6426. /**
  6427. * Class used to create slider controls
  6428. */
  6429. export class Slider extends BaseSlider {
  6430. name?: string | undefined;
  6431. private _background;
  6432. private _borderColor;
  6433. private _isThumbCircle;
  6434. protected _displayValueBar: boolean;
  6435. /** Gets or sets a boolean indicating if the value bar must be rendered */
  6436. displayValueBar: boolean;
  6437. /** Gets or sets border color */
  6438. borderColor: string;
  6439. /** Gets or sets background color */
  6440. background: string;
  6441. /** Gets or sets a boolean indicating if the thumb should be round or square */
  6442. isThumbCircle: boolean;
  6443. /**
  6444. * Creates a new Slider
  6445. * @param name defines the control name
  6446. */
  6447. constructor(name?: string | undefined);
  6448. protected _getTypeName(): string;
  6449. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  6450. }
  6451. }
  6452. declare module BABYLON.GUI {
  6453. /** Class used to create a RadioGroup
  6454. * which contains groups of radio buttons
  6455. */
  6456. export class SelectorGroup {
  6457. /** name of SelectorGroup */
  6458. name: string;
  6459. private _groupPanel;
  6460. private _selectors;
  6461. private _groupHeader;
  6462. /**
  6463. * Creates a new SelectorGroup
  6464. * @param name of group, used as a group heading
  6465. */
  6466. constructor(
  6467. /** name of SelectorGroup */
  6468. name: string);
  6469. /** Gets the groupPanel of the SelectorGroup */
  6470. readonly groupPanel: StackPanel;
  6471. /** Gets the selectors array */
  6472. readonly selectors: StackPanel[];
  6473. /** Gets and sets the group header */
  6474. header: string;
  6475. /** @hidden */
  6476. private _addGroupHeader;
  6477. /** @hidden*/
  6478. _getSelector(selectorNb: number): StackPanel | undefined;
  6479. /** Removes the selector at the given position
  6480. * @param selectorNb the position of the selector within the group
  6481. */
  6482. removeSelector(selectorNb: number): void;
  6483. }
  6484. /** Class used to create a CheckboxGroup
  6485. * which contains groups of checkbox buttons
  6486. */
  6487. export class CheckboxGroup extends SelectorGroup {
  6488. /** Adds a checkbox as a control
  6489. * @param text is the label for the selector
  6490. * @param func is the function called when the Selector is checked
  6491. * @param checked is true when Selector is checked
  6492. */
  6493. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  6494. /** @hidden */
  6495. _setSelectorLabel(selectorNb: number, label: string): void;
  6496. /** @hidden */
  6497. _setSelectorLabelColor(selectorNb: number, color: string): void;
  6498. /** @hidden */
  6499. _setSelectorButtonColor(selectorNb: number, color: string): void;
  6500. /** @hidden */
  6501. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  6502. }
  6503. /** Class used to create a RadioGroup
  6504. * which contains groups of radio buttons
  6505. */
  6506. export class RadioGroup extends SelectorGroup {
  6507. private _selectNb;
  6508. /** Adds a radio button as a control
  6509. * @param label is the label for the selector
  6510. * @param func is the function called when the Selector is checked
  6511. * @param checked is true when Selector is checked
  6512. */
  6513. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  6514. /** @hidden */
  6515. _setSelectorLabel(selectorNb: number, label: string): void;
  6516. /** @hidden */
  6517. _setSelectorLabelColor(selectorNb: number, color: string): void;
  6518. /** @hidden */
  6519. _setSelectorButtonColor(selectorNb: number, color: string): void;
  6520. /** @hidden */
  6521. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  6522. }
  6523. /** Class used to create a SliderGroup
  6524. * which contains groups of slider buttons
  6525. */
  6526. export class SliderGroup extends SelectorGroup {
  6527. /**
  6528. * Adds a slider to the SelectorGroup
  6529. * @param label is the label for the SliderBar
  6530. * @param func is the function called when the Slider moves
  6531. * @param unit is a string describing the units used, eg degrees or metres
  6532. * @param min is the minimum value for the Slider
  6533. * @param max is the maximum value for the Slider
  6534. * @param value is the start value for the Slider between min and max
  6535. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  6536. */
  6537. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  6538. /** @hidden */
  6539. _setSelectorLabel(selectorNb: number, label: string): void;
  6540. /** @hidden */
  6541. _setSelectorLabelColor(selectorNb: number, color: string): void;
  6542. /** @hidden */
  6543. _setSelectorButtonColor(selectorNb: number, color: string): void;
  6544. /** @hidden */
  6545. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  6546. }
  6547. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  6548. * @see http://doc.babylonjs.com/how_to/selector
  6549. */
  6550. export class SelectionPanel extends Rectangle {
  6551. /** name of SelectionPanel */
  6552. name: string;
  6553. /** an array of SelectionGroups */
  6554. groups: SelectorGroup[];
  6555. private _panel;
  6556. private _buttonColor;
  6557. private _buttonBackground;
  6558. private _headerColor;
  6559. private _barColor;
  6560. private _barHeight;
  6561. private _spacerHeight;
  6562. private _labelColor;
  6563. private _groups;
  6564. private _bars;
  6565. /**
  6566. * Creates a new SelectionPanel
  6567. * @param name of SelectionPanel
  6568. * @param groups is an array of SelectionGroups
  6569. */
  6570. constructor(
  6571. /** name of SelectionPanel */
  6572. name: string,
  6573. /** an array of SelectionGroups */
  6574. groups?: SelectorGroup[]);
  6575. protected _getTypeName(): string;
  6576. /** Gets or sets the headerColor */
  6577. headerColor: string;
  6578. private _setHeaderColor;
  6579. /** Gets or sets the button color */
  6580. buttonColor: string;
  6581. private _setbuttonColor;
  6582. /** Gets or sets the label color */
  6583. labelColor: string;
  6584. private _setLabelColor;
  6585. /** Gets or sets the button background */
  6586. buttonBackground: string;
  6587. private _setButtonBackground;
  6588. /** Gets or sets the color of separator bar */
  6589. barColor: string;
  6590. private _setBarColor;
  6591. /** Gets or sets the height of separator bar */
  6592. barHeight: string;
  6593. private _setBarHeight;
  6594. /** Gets or sets the height of spacers*/
  6595. spacerHeight: string;
  6596. private _setSpacerHeight;
  6597. /** Adds a bar between groups */
  6598. private _addSpacer;
  6599. /** Add a group to the selection panel
  6600. * @param group is the selector group to add
  6601. */
  6602. addGroup(group: SelectorGroup): void;
  6603. /** Remove the group from the given position
  6604. * @param groupNb is the position of the group in the list
  6605. */
  6606. removeGroup(groupNb: number): void;
  6607. /** Change a group header label
  6608. * @param label is the new group header label
  6609. * @param groupNb is the number of the group to relabel
  6610. * */
  6611. setHeaderName(label: string, groupNb: number): void;
  6612. /** Change selector label to the one given
  6613. * @param label is the new selector label
  6614. * @param groupNb is the number of the groupcontaining the selector
  6615. * @param selectorNb is the number of the selector within a group to relabel
  6616. * */
  6617. relabel(label: string, groupNb: number, selectorNb: number): void;
  6618. /** For a given group position remove the selector at the given position
  6619. * @param groupNb is the number of the group to remove the selector from
  6620. * @param selectorNb is the number of the selector within the group
  6621. */
  6622. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  6623. /** For a given group position of correct type add a checkbox button
  6624. * @param groupNb is the number of the group to remove the selector from
  6625. * @param label is the label for the selector
  6626. * @param func is the function called when the Selector is checked
  6627. * @param checked is true when Selector is checked
  6628. */
  6629. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  6630. /** For a given group position of correct type add a radio button
  6631. * @param groupNb is the number of the group to remove the selector from
  6632. * @param label is the label for the selector
  6633. * @param func is the function called when the Selector is checked
  6634. * @param checked is true when Selector is checked
  6635. */
  6636. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  6637. /**
  6638. * For a given slider group add a slider
  6639. * @param groupNb is the number of the group to add the slider to
  6640. * @param label is the label for the Slider
  6641. * @param func is the function called when the Slider moves
  6642. * @param unit is a string describing the units used, eg degrees or metres
  6643. * @param min is the minimum value for the Slider
  6644. * @param max is the maximum value for the Slider
  6645. * @param value is the start value for the Slider between min and max
  6646. * @param onVal is the function used to format the value displayed, eg radians to degrees
  6647. */
  6648. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  6649. }
  6650. }
  6651. declare module BABYLON.GUI {
  6652. /**
  6653. * Class used to hold a the container for ScrollViewer
  6654. * @hidden
  6655. */
  6656. export class _ScrollViewerWindow extends Container {
  6657. parentClientWidth: number;
  6658. parentClientHeight: number;
  6659. /**
  6660. * Creates a new ScrollViewerWindow
  6661. * @param name of ScrollViewerWindow
  6662. */
  6663. constructor(name?: string);
  6664. protected _getTypeName(): string;
  6665. /** @hidden */
  6666. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6667. protected _postMeasure(): void;
  6668. }
  6669. }
  6670. declare module BABYLON.GUI {
  6671. /**
  6672. * Class used to create slider controls
  6673. */
  6674. export class ScrollBar extends BaseSlider {
  6675. name?: string | undefined;
  6676. private _background;
  6677. private _borderColor;
  6678. private _thumbMeasure;
  6679. /** Gets or sets border color */
  6680. borderColor: string;
  6681. /** Gets or sets background color */
  6682. background: string;
  6683. /**
  6684. * Creates a new Slider
  6685. * @param name defines the control name
  6686. */
  6687. constructor(name?: string | undefined);
  6688. protected _getTypeName(): string;
  6689. protected _getThumbThickness(): number;
  6690. _draw(context: CanvasRenderingContext2D): void;
  6691. private _first;
  6692. private _originX;
  6693. private _originY;
  6694. /** @hidden */
  6695. protected _updateValueFromPointer(x: number, y: number): void;
  6696. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  6697. }
  6698. }
  6699. declare module BABYLON.GUI {
  6700. /**
  6701. * Class used to hold a viewer window and sliders in a grid
  6702. */
  6703. export class ScrollViewer extends Rectangle {
  6704. private _grid;
  6705. private _horizontalBarSpace;
  6706. private _verticalBarSpace;
  6707. private _dragSpace;
  6708. private _horizontalBar;
  6709. private _verticalBar;
  6710. private _barColor;
  6711. private _barBackground;
  6712. private _barSize;
  6713. private _endLeft;
  6714. private _endTop;
  6715. private _window;
  6716. private _pointerIsOver;
  6717. private _wheelPrecision;
  6718. private _onPointerObserver;
  6719. private _clientWidth;
  6720. private _clientHeight;
  6721. /**
  6722. * Gets the horizontal scrollbar
  6723. */
  6724. readonly horizontalBar: ScrollBar;
  6725. /**
  6726. * Gets the vertical scrollbar
  6727. */
  6728. readonly verticalBar: ScrollBar;
  6729. /**
  6730. * Adds a new control to the current container
  6731. * @param control defines the control to add
  6732. * @returns the current container
  6733. */
  6734. addControl(control: BABYLON.Nullable<Control>): Container;
  6735. /**
  6736. * Removes a control from the current container
  6737. * @param control defines the control to remove
  6738. * @returns the current container
  6739. */
  6740. removeControl(control: Control): Container;
  6741. /** Gets the list of children */
  6742. readonly children: Control[];
  6743. _flagDescendantsAsMatrixDirty(): void;
  6744. /**
  6745. * Creates a new ScrollViewer
  6746. * @param name of ScrollViewer
  6747. */
  6748. constructor(name?: string);
  6749. /** Reset the scroll viewer window to initial size */
  6750. resetWindow(): void;
  6751. protected _getTypeName(): string;
  6752. private _buildClientSizes;
  6753. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  6754. protected _postMeasure(): void;
  6755. /**
  6756. * Gets or sets the mouse wheel precision
  6757. * from 0 to 1 with a default value of 0.05
  6758. * */
  6759. wheelPrecision: number;
  6760. /** Gets or sets the bar color */
  6761. barColor: string;
  6762. /** Gets or sets the size of the bar */
  6763. barSize: number;
  6764. /** Gets or sets the bar background */
  6765. barBackground: string;
  6766. /** @hidden */
  6767. private _updateScroller;
  6768. _link(host: AdvancedDynamicTexture): void;
  6769. /** @hidden */
  6770. private _attachWheel;
  6771. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  6772. /** Releases associated resources */
  6773. dispose(): void;
  6774. }
  6775. }
  6776. declare module BABYLON.GUI {
  6777. /** Class used to render a grid */
  6778. export class DisplayGrid extends Control {
  6779. name?: string | undefined;
  6780. private _cellWidth;
  6781. private _cellHeight;
  6782. private _minorLineTickness;
  6783. private _minorLineColor;
  6784. private _majorLineTickness;
  6785. private _majorLineColor;
  6786. private _majorLineFrequency;
  6787. private _background;
  6788. private _displayMajorLines;
  6789. private _displayMinorLines;
  6790. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  6791. displayMinorLines: boolean;
  6792. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  6793. displayMajorLines: boolean;
  6794. /** Gets or sets background color (Black by default) */
  6795. background: string;
  6796. /** Gets or sets the width of each cell (20 by default) */
  6797. cellWidth: number;
  6798. /** Gets or sets the height of each cell (20 by default) */
  6799. cellHeight: number;
  6800. /** Gets or sets the tickness of minor lines (1 by default) */
  6801. minorLineTickness: number;
  6802. /** Gets or sets the color of minor lines (DarkGray by default) */
  6803. minorLineColor: string;
  6804. /** Gets or sets the tickness of major lines (2 by default) */
  6805. majorLineTickness: number;
  6806. /** Gets or sets the color of major lines (White by default) */
  6807. majorLineColor: string;
  6808. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  6809. majorLineFrequency: number;
  6810. /**
  6811. * Creates a new GridDisplayRectangle
  6812. * @param name defines the control name
  6813. */
  6814. constructor(name?: string | undefined);
  6815. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  6816. protected _getTypeName(): string;
  6817. }
  6818. }
  6819. declare module BABYLON.GUI {
  6820. /**
  6821. * Class used to create slider controls based on images
  6822. */
  6823. export class ImageBasedSlider extends BaseSlider {
  6824. name?: string | undefined;
  6825. private _backgroundImage;
  6826. private _thumbImage;
  6827. private _valueBarImage;
  6828. private _tempMeasure;
  6829. displayThumb: boolean;
  6830. /**
  6831. * Gets or sets the image used to render the background
  6832. */
  6833. backgroundImage: Image;
  6834. /**
  6835. * Gets or sets the image used to render the value bar
  6836. */
  6837. valueBarImage: Image;
  6838. /**
  6839. * Gets or sets the image used to render the thumb
  6840. */
  6841. thumbImage: Image;
  6842. /**
  6843. * Creates a new ImageBasedSlider
  6844. * @param name defines the control name
  6845. */
  6846. constructor(name?: string | undefined);
  6847. protected _getTypeName(): string;
  6848. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  6849. }
  6850. }
  6851. declare module BABYLON.GUI {
  6852. /**
  6853. * Forcing an export so that this code will execute
  6854. * @hidden
  6855. */
  6856. const name = "Statics";
  6857. }
  6858. declare module BABYLON.GUI {
  6859. /**
  6860. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  6861. */
  6862. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  6863. /**
  6864. * Define the instrumented AdvancedDynamicTexture.
  6865. */
  6866. texture: AdvancedDynamicTexture;
  6867. private _captureRenderTime;
  6868. private _renderTime;
  6869. private _captureLayoutTime;
  6870. private _layoutTime;
  6871. private _onBeginRenderObserver;
  6872. private _onEndRenderObserver;
  6873. private _onBeginLayoutObserver;
  6874. private _onEndLayoutObserver;
  6875. /**
  6876. * Gets the perf counter used to capture render time
  6877. */
  6878. readonly renderTimeCounter: BABYLON.PerfCounter;
  6879. /**
  6880. * Gets the perf counter used to capture layout time
  6881. */
  6882. readonly layoutTimeCounter: BABYLON.PerfCounter;
  6883. /**
  6884. * Enable or disable the render time capture
  6885. */
  6886. captureRenderTime: boolean;
  6887. /**
  6888. * Enable or disable the layout time capture
  6889. */
  6890. captureLayoutTime: boolean;
  6891. /**
  6892. * Instantiates a new advanced dynamic texture instrumentation.
  6893. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  6894. * @param texture Defines the AdvancedDynamicTexture to instrument
  6895. */
  6896. constructor(
  6897. /**
  6898. * Define the instrumented AdvancedDynamicTexture.
  6899. */
  6900. texture: AdvancedDynamicTexture);
  6901. /**
  6902. * Dispose and release associated resources.
  6903. */
  6904. dispose(): void;
  6905. }
  6906. }
  6907. declare module BABYLON.GUI {
  6908. /**
  6909. * Class used to load GUI via XML.
  6910. */
  6911. export class XmlLoader {
  6912. private _nodes;
  6913. private _nodeTypes;
  6914. private _isLoaded;
  6915. private _objectAttributes;
  6916. private _parentClass;
  6917. /**
  6918. * Create a new xml loader
  6919. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  6920. */
  6921. constructor(parentClass?: null);
  6922. private _getChainElement;
  6923. private _getClassAttribute;
  6924. private _createGuiElement;
  6925. private _parseGrid;
  6926. private _parseElement;
  6927. private _prepareSourceElement;
  6928. private _parseElementsFromSource;
  6929. private _parseXml;
  6930. /**
  6931. * Gets if the loading has finished.
  6932. * @returns whether the loading has finished or not
  6933. */
  6934. isLoaded(): boolean;
  6935. /**
  6936. * Gets a loaded node / control by id.
  6937. * @param id the Controls id set in the xml
  6938. * @returns element of type Control
  6939. */
  6940. getNodeById(id: string): any;
  6941. /**
  6942. * Gets all loaded nodes / controls
  6943. * @returns Array of controls
  6944. */
  6945. getNodes(): any;
  6946. /**
  6947. * Initiates the xml layout loading
  6948. * @param xmlFile defines the xml layout to load
  6949. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  6950. * @param callback defines the callback called on layout load.
  6951. */
  6952. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  6953. }
  6954. }
  6955. declare module BABYLON.GUI {
  6956. /**
  6957. * Class used to create containers for controls
  6958. */
  6959. export class Container3D extends Control3D {
  6960. private _blockLayout;
  6961. /**
  6962. * Gets the list of child controls
  6963. */
  6964. protected _children: Control3D[];
  6965. /**
  6966. * Gets the list of child controls
  6967. */
  6968. readonly children: Array<Control3D>;
  6969. /**
  6970. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  6971. * This is helpful to optimize layout operation when adding multiple children in a row
  6972. */
  6973. blockLayout: boolean;
  6974. /**
  6975. * Creates a new container
  6976. * @param name defines the container name
  6977. */
  6978. constructor(name?: string);
  6979. /**
  6980. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  6981. * @returns the current container
  6982. */
  6983. updateLayout(): Container3D;
  6984. /**
  6985. * Gets a boolean indicating if the given control is in the children of this control
  6986. * @param control defines the control to check
  6987. * @returns true if the control is in the child list
  6988. */
  6989. containsControl(control: Control3D): boolean;
  6990. /**
  6991. * Adds a control to the children of this control
  6992. * @param control defines the control to add
  6993. * @returns the current container
  6994. */
  6995. addControl(control: Control3D): Container3D;
  6996. /**
  6997. * This function will be called everytime a new control is added
  6998. */
  6999. protected _arrangeChildren(): void;
  7000. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  7001. /**
  7002. * Removes a control from the children of this control
  7003. * @param control defines the control to remove
  7004. * @returns the current container
  7005. */
  7006. removeControl(control: Control3D): Container3D;
  7007. protected _getTypeName(): string;
  7008. /**
  7009. * Releases all associated resources
  7010. */
  7011. dispose(): void;
  7012. /** Control rotation will remain unchanged */
  7013. static readonly UNSET_ORIENTATION: number;
  7014. /** Control will rotate to make it look at sphere central axis */
  7015. static readonly FACEORIGIN_ORIENTATION: number;
  7016. /** Control will rotate to make it look back at sphere central axis */
  7017. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  7018. /** Control will rotate to look at z axis (0, 0, 1) */
  7019. static readonly FACEFORWARD_ORIENTATION: number;
  7020. /** Control will rotate to look at negative z axis (0, 0, -1) */
  7021. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  7022. }
  7023. }
  7024. declare module BABYLON.GUI {
  7025. /**
  7026. * Class used to manage 3D user interface
  7027. * @see http://doc.babylonjs.com/how_to/gui3d
  7028. */
  7029. export class GUI3DManager implements BABYLON.IDisposable {
  7030. private _scene;
  7031. private _sceneDisposeObserver;
  7032. private _utilityLayer;
  7033. private _rootContainer;
  7034. private _pointerObserver;
  7035. private _pointerOutObserver;
  7036. /** @hidden */
  7037. _lastPickedControl: Control3D;
  7038. /** @hidden */
  7039. _lastControlOver: {
  7040. [pointerId: number]: Control3D;
  7041. };
  7042. /** @hidden */
  7043. _lastControlDown: {
  7044. [pointerId: number]: Control3D;
  7045. };
  7046. /**
  7047. * BABYLON.Observable raised when the point picked by the pointer events changed
  7048. */
  7049. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  7050. /** @hidden */
  7051. _sharedMaterials: {
  7052. [key: string]: BABYLON.Material;
  7053. };
  7054. /** Gets the hosting scene */
  7055. readonly scene: BABYLON.Scene;
  7056. /** Gets associated utility layer */
  7057. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  7058. /**
  7059. * Creates a new GUI3DManager
  7060. * @param scene
  7061. */
  7062. constructor(scene?: BABYLON.Scene);
  7063. private _handlePointerOut;
  7064. private _doPicking;
  7065. /**
  7066. * Gets the root container
  7067. */
  7068. readonly rootContainer: Container3D;
  7069. /**
  7070. * Gets a boolean indicating if the given control is in the root child list
  7071. * @param control defines the control to check
  7072. * @returns true if the control is in the root child list
  7073. */
  7074. containsControl(control: Control3D): boolean;
  7075. /**
  7076. * Adds a control to the root child list
  7077. * @param control defines the control to add
  7078. * @returns the current manager
  7079. */
  7080. addControl(control: Control3D): GUI3DManager;
  7081. /**
  7082. * Removes a control from the root child list
  7083. * @param control defines the control to remove
  7084. * @returns the current container
  7085. */
  7086. removeControl(control: Control3D): GUI3DManager;
  7087. /**
  7088. * Releases all associated resources
  7089. */
  7090. dispose(): void;
  7091. }
  7092. }
  7093. declare module BABYLON.GUI {
  7094. /**
  7095. * Class used to transport BABYLON.Vector3 information for pointer events
  7096. */
  7097. export class Vector3WithInfo extends BABYLON.Vector3 {
  7098. /** defines the current mouse button index */
  7099. buttonIndex: number;
  7100. /**
  7101. * Creates a new Vector3WithInfo
  7102. * @param source defines the vector3 data to transport
  7103. * @param buttonIndex defines the current mouse button index
  7104. */
  7105. constructor(source: BABYLON.Vector3,
  7106. /** defines the current mouse button index */
  7107. buttonIndex?: number);
  7108. }
  7109. }
  7110. declare module BABYLON.GUI {
  7111. /**
  7112. * Class used as base class for controls
  7113. */
  7114. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  7115. /** Defines the control name */
  7116. name?: string | undefined;
  7117. /** @hidden */
  7118. _host: GUI3DManager;
  7119. private _node;
  7120. private _downCount;
  7121. private _enterCount;
  7122. private _downPointerIds;
  7123. private _isVisible;
  7124. /** Gets or sets the control position in world space */
  7125. position: BABYLON.Vector3;
  7126. /** Gets or sets the control scaling in world space */
  7127. scaling: BABYLON.Vector3;
  7128. /** Callback used to start pointer enter animation */
  7129. pointerEnterAnimation: () => void;
  7130. /** Callback used to start pointer out animation */
  7131. pointerOutAnimation: () => void;
  7132. /** Callback used to start pointer down animation */
  7133. pointerDownAnimation: () => void;
  7134. /** Callback used to start pointer up animation */
  7135. pointerUpAnimation: () => void;
  7136. /**
  7137. * An event triggered when the pointer move over the control
  7138. */
  7139. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  7140. /**
  7141. * An event triggered when the pointer move out of the control
  7142. */
  7143. onPointerOutObservable: BABYLON.Observable<Control3D>;
  7144. /**
  7145. * An event triggered when the pointer taps the control
  7146. */
  7147. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  7148. /**
  7149. * An event triggered when pointer is up
  7150. */
  7151. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  7152. /**
  7153. * An event triggered when a control is clicked on (with a mouse)
  7154. */
  7155. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  7156. /**
  7157. * An event triggered when pointer enters the control
  7158. */
  7159. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  7160. /**
  7161. * Gets or sets the parent container
  7162. */
  7163. parent: BABYLON.Nullable<Container3D>;
  7164. private _behaviors;
  7165. /**
  7166. * Gets the list of attached behaviors
  7167. * @see http://doc.babylonjs.com/features/behaviour
  7168. */
  7169. readonly behaviors: BABYLON.Behavior<Control3D>[];
  7170. /**
  7171. * Attach a behavior to the control
  7172. * @see http://doc.babylonjs.com/features/behaviour
  7173. * @param behavior defines the behavior to attach
  7174. * @returns the current control
  7175. */
  7176. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  7177. /**
  7178. * Remove an attached behavior
  7179. * @see http://doc.babylonjs.com/features/behaviour
  7180. * @param behavior defines the behavior to attach
  7181. * @returns the current control
  7182. */
  7183. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  7184. /**
  7185. * Gets an attached behavior by name
  7186. * @param name defines the name of the behavior to look for
  7187. * @see http://doc.babylonjs.com/features/behaviour
  7188. * @returns null if behavior was not found else the requested behavior
  7189. */
  7190. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  7191. /** Gets or sets a boolean indicating if the control is visible */
  7192. isVisible: boolean;
  7193. /**
  7194. * Creates a new control
  7195. * @param name defines the control name
  7196. */
  7197. constructor(
  7198. /** Defines the control name */
  7199. name?: string | undefined);
  7200. /**
  7201. * Gets a string representing the class name
  7202. */
  7203. readonly typeName: string;
  7204. /**
  7205. * Get the current class name of the control.
  7206. * @returns current class name
  7207. */
  7208. getClassName(): string;
  7209. protected _getTypeName(): string;
  7210. /**
  7211. * Gets the transform node used by this control
  7212. */
  7213. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  7214. /**
  7215. * Gets the mesh used to render this control
  7216. */
  7217. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  7218. /**
  7219. * Link the control as child of the given node
  7220. * @param node defines the node to link to. Use null to unlink the control
  7221. * @returns the current control
  7222. */
  7223. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  7224. /** @hidden **/
  7225. _prepareNode(scene: BABYLON.Scene): void;
  7226. /**
  7227. * Node creation.
  7228. * Can be overriden by children
  7229. * @param scene defines the scene where the node must be attached
  7230. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  7231. */
  7232. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  7233. /**
  7234. * Affect a material to the given mesh
  7235. * @param mesh defines the mesh which will represent the control
  7236. */
  7237. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  7238. /** @hidden */
  7239. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  7240. /** @hidden */
  7241. _onPointerEnter(target: Control3D): boolean;
  7242. /** @hidden */
  7243. _onPointerOut(target: Control3D): void;
  7244. /** @hidden */
  7245. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  7246. /** @hidden */
  7247. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  7248. /** @hidden */
  7249. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  7250. /** @hidden */
  7251. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  7252. /** @hidden */
  7253. _disposeNode(): void;
  7254. /**
  7255. * Releases all associated resources
  7256. */
  7257. dispose(): void;
  7258. }
  7259. }
  7260. declare module BABYLON.GUI {
  7261. /**
  7262. * Class used as a root to all buttons
  7263. */
  7264. export class AbstractButton3D extends Control3D {
  7265. /**
  7266. * Creates a new button
  7267. * @param name defines the control name
  7268. */
  7269. constructor(name?: string);
  7270. protected _getTypeName(): string;
  7271. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  7272. }
  7273. }
  7274. declare module BABYLON.GUI {
  7275. /**
  7276. * Class used to create a button in 3D
  7277. */
  7278. export class Button3D extends AbstractButton3D {
  7279. /** @hidden */
  7280. protected _currentMaterial: BABYLON.Material;
  7281. private _facadeTexture;
  7282. private _content;
  7283. private _contentResolution;
  7284. private _contentScaleRatio;
  7285. /**
  7286. * Gets or sets the texture resolution used to render content (512 by default)
  7287. */
  7288. contentResolution: BABYLON.int;
  7289. /**
  7290. * Gets or sets the texture scale ratio used to render content (2 by default)
  7291. */
  7292. contentScaleRatio: number;
  7293. protected _disposeFacadeTexture(): void;
  7294. protected _resetContent(): void;
  7295. /**
  7296. * Creates a new button
  7297. * @param name defines the control name
  7298. */
  7299. constructor(name?: string);
  7300. /**
  7301. * Gets or sets the GUI 2D content used to display the button's facade
  7302. */
  7303. content: Control;
  7304. /**
  7305. * Apply the facade texture (created from the content property).
  7306. * This function can be overloaded by child classes
  7307. * @param facadeTexture defines the AdvancedDynamicTexture to use
  7308. */
  7309. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  7310. protected _getTypeName(): string;
  7311. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  7312. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  7313. /**
  7314. * Releases all associated resources
  7315. */
  7316. dispose(): void;
  7317. }
  7318. }
  7319. declare module BABYLON.GUI {
  7320. /**
  7321. * Abstract class used to create a container panel deployed on the surface of a volume
  7322. */
  7323. export abstract class VolumeBasedPanel extends Container3D {
  7324. private _columns;
  7325. private _rows;
  7326. private _rowThenColum;
  7327. private _orientation;
  7328. protected _cellWidth: number;
  7329. protected _cellHeight: number;
  7330. /**
  7331. * Gets or sets the distance between elements
  7332. */
  7333. margin: number;
  7334. /**
  7335. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  7336. * | Value | Type | Description |
  7337. * | ----- | ----------------------------------- | ----------- |
  7338. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  7339. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  7340. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  7341. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  7342. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  7343. */
  7344. orientation: number;
  7345. /**
  7346. * Gets or sets the number of columns requested (10 by default).
  7347. * The panel will automatically compute the number of rows based on number of child controls.
  7348. */
  7349. columns: BABYLON.int;
  7350. /**
  7351. * Gets or sets a the number of rows requested.
  7352. * The panel will automatically compute the number of columns based on number of child controls.
  7353. */
  7354. rows: BABYLON.int;
  7355. /**
  7356. * Creates new VolumeBasedPanel
  7357. */
  7358. constructor();
  7359. protected _arrangeChildren(): void;
  7360. /** Child classes must implement this function to provide correct control positioning */
  7361. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  7362. /** Child classes can implement this function to provide additional processing */
  7363. protected _finalProcessing(): void;
  7364. }
  7365. }
  7366. declare module BABYLON.GUI {
  7367. /**
  7368. * Class used to create a container panel deployed on the surface of a cylinder
  7369. */
  7370. export class CylinderPanel extends VolumeBasedPanel {
  7371. private _radius;
  7372. /**
  7373. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  7374. */
  7375. radius: BABYLON.float;
  7376. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  7377. private _cylindricalMapping;
  7378. }
  7379. }
  7380. declare module BABYLON.GUI {
  7381. /** @hidden */
  7382. export var fluentVertexShader: {
  7383. name: string;
  7384. shader: string;
  7385. };
  7386. }
  7387. declare module BABYLON.GUI {
  7388. /** @hidden */
  7389. export var fluentPixelShader: {
  7390. name: string;
  7391. shader: string;
  7392. };
  7393. }
  7394. declare module BABYLON.GUI {
  7395. /** @hidden */
  7396. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  7397. INNERGLOW: boolean;
  7398. BORDER: boolean;
  7399. HOVERLIGHT: boolean;
  7400. TEXTURE: boolean;
  7401. constructor();
  7402. }
  7403. /**
  7404. * Class used to render controls with fluent desgin
  7405. */
  7406. export class FluentMaterial extends BABYLON.PushMaterial {
  7407. /**
  7408. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  7409. */
  7410. innerGlowColorIntensity: number;
  7411. /**
  7412. * Gets or sets the inner glow color (white by default)
  7413. */
  7414. innerGlowColor: BABYLON.Color3;
  7415. /**
  7416. * Gets or sets alpha value (default is 1.0)
  7417. */
  7418. alpha: number;
  7419. /**
  7420. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  7421. */
  7422. albedoColor: BABYLON.Color3;
  7423. /**
  7424. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  7425. */
  7426. renderBorders: boolean;
  7427. /**
  7428. * Gets or sets border width (default is 0.5)
  7429. */
  7430. borderWidth: number;
  7431. /**
  7432. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  7433. */
  7434. edgeSmoothingValue: number;
  7435. /**
  7436. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  7437. */
  7438. borderMinValue: number;
  7439. /**
  7440. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  7441. */
  7442. renderHoverLight: boolean;
  7443. /**
  7444. * Gets or sets the radius used to render the hover light (default is 1.0)
  7445. */
  7446. hoverRadius: number;
  7447. /**
  7448. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  7449. */
  7450. hoverColor: BABYLON.Color4;
  7451. /**
  7452. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  7453. */
  7454. hoverPosition: BABYLON.Vector3;
  7455. private _albedoTexture;
  7456. /** Gets or sets the texture to use for albedo color */
  7457. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  7458. /**
  7459. * Creates a new Fluent material
  7460. * @param name defines the name of the material
  7461. * @param scene defines the hosting scene
  7462. */
  7463. constructor(name: string, scene: BABYLON.Scene);
  7464. needAlphaBlending(): boolean;
  7465. needAlphaTesting(): boolean;
  7466. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  7467. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  7468. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  7469. getActiveTextures(): BABYLON.BaseTexture[];
  7470. hasTexture(texture: BABYLON.BaseTexture): boolean;
  7471. dispose(forceDisposeEffect?: boolean): void;
  7472. clone(name: string): FluentMaterial;
  7473. serialize(): any;
  7474. getClassName(): string;
  7475. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  7476. }
  7477. }
  7478. declare module BABYLON.GUI {
  7479. /**
  7480. * Class used to create a holographic button in 3D
  7481. */
  7482. export class HolographicButton extends Button3D {
  7483. private _backPlate;
  7484. private _textPlate;
  7485. private _frontPlate;
  7486. private _text;
  7487. private _imageUrl;
  7488. private _shareMaterials;
  7489. private _frontMaterial;
  7490. private _backMaterial;
  7491. private _plateMaterial;
  7492. private _pickedPointObserver;
  7493. private _tooltipFade;
  7494. private _tooltipTextBlock;
  7495. private _tooltipTexture;
  7496. private _tooltipMesh;
  7497. private _tooltipHoverObserver;
  7498. private _tooltipOutObserver;
  7499. private _disposeTooltip;
  7500. /**
  7501. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  7502. */
  7503. tooltipText: BABYLON.Nullable<string>;
  7504. /**
  7505. * Gets or sets text for the button
  7506. */
  7507. text: string;
  7508. /**
  7509. * Gets or sets the image url for the button
  7510. */
  7511. imageUrl: string;
  7512. /**
  7513. * Gets the back material used by this button
  7514. */
  7515. readonly backMaterial: FluentMaterial;
  7516. /**
  7517. * Gets the front material used by this button
  7518. */
  7519. readonly frontMaterial: FluentMaterial;
  7520. /**
  7521. * Gets the plate material used by this button
  7522. */
  7523. readonly plateMaterial: BABYLON.StandardMaterial;
  7524. /**
  7525. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  7526. */
  7527. readonly shareMaterials: boolean;
  7528. /**
  7529. * Creates a new button
  7530. * @param name defines the control name
  7531. */
  7532. constructor(name?: string, shareMaterials?: boolean);
  7533. protected _getTypeName(): string;
  7534. private _rebuildContent;
  7535. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  7536. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  7537. private _createBackMaterial;
  7538. private _createFrontMaterial;
  7539. private _createPlateMaterial;
  7540. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  7541. /**
  7542. * Releases all associated resources
  7543. */
  7544. dispose(): void;
  7545. }
  7546. }
  7547. declare module BABYLON.GUI {
  7548. /**
  7549. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  7550. */
  7551. export class MeshButton3D extends Button3D {
  7552. /** @hidden */
  7553. protected _currentMesh: BABYLON.Mesh;
  7554. /**
  7555. * Creates a new 3D button based on a mesh
  7556. * @param mesh mesh to become a 3D button
  7557. * @param name defines the control name
  7558. */
  7559. constructor(mesh: BABYLON.Mesh, name?: string);
  7560. protected _getTypeName(): string;
  7561. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  7562. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  7563. }
  7564. }
  7565. declare module BABYLON.GUI {
  7566. /**
  7567. * Class used to create a container panel deployed on the surface of a plane
  7568. */
  7569. export class PlanePanel extends VolumeBasedPanel {
  7570. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  7571. }
  7572. }
  7573. declare module BABYLON.GUI {
  7574. /**
  7575. * Class used to create a container panel where items get randomized planar mapping
  7576. */
  7577. export class ScatterPanel extends VolumeBasedPanel {
  7578. private _iteration;
  7579. /**
  7580. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  7581. */
  7582. iteration: BABYLON.float;
  7583. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  7584. private _scatterMapping;
  7585. protected _finalProcessing(): void;
  7586. }
  7587. }
  7588. declare module BABYLON.GUI {
  7589. /**
  7590. * Class used to create a container panel deployed on the surface of a sphere
  7591. */
  7592. export class SpherePanel extends VolumeBasedPanel {
  7593. private _radius;
  7594. /**
  7595. * Gets or sets the radius of the sphere where to project controls (5 by default)
  7596. */
  7597. radius: BABYLON.float;
  7598. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  7599. private _sphericalMapping;
  7600. }
  7601. }
  7602. declare module BABYLON.GUI {
  7603. /**
  7604. * Class used to create a stack panel in 3D on XY plane
  7605. */
  7606. export class StackPanel3D extends Container3D {
  7607. private _isVertical;
  7608. /**
  7609. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  7610. */
  7611. isVertical: boolean;
  7612. /**
  7613. * Gets or sets the distance between elements
  7614. */
  7615. margin: number;
  7616. /**
  7617. * Creates new StackPanel
  7618. * @param isVertical
  7619. */
  7620. constructor(isVertical?: boolean);
  7621. protected _arrangeChildren(): void;
  7622. }
  7623. }