babylon.gui.module.d.ts 300 KB

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