babylon.gui.module.d.ts 316 KB

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