babylon.gui.module.d.ts 309 KB

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