babylon.gui.module.d.ts 307 KB

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