babylon.gui.module.d.ts 310 KB

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