babylon.gui.module.d.ts 315 KB

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