babylon.gui.module.d.ts 315 KB

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