babylon.gui.module.d.ts 302 KB

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