babylon.gui.module.d.ts 304 KB

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