babylon.gui.js 722 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** E:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  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. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootElement = scene.getEngine().getInputElement();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootElement = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootElement) {
  1064. this._rootElement.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  1360. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1361. /**
  1362. * Class used to create 2D buttons
  1363. */
  1364. var Button = /** @class */ (function (_super) {
  1365. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1366. /**
  1367. * Creates a new Button
  1368. * @param name defines the name of the button
  1369. */
  1370. function Button(name) {
  1371. var _this = _super.call(this, name) || this;
  1372. _this.name = name;
  1373. /**
  1374. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1375. */
  1376. _this.delegatePickingToChildren = false;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. if (this.delegatePickingToChildren) {
  1432. var contains = false;
  1433. for (var index = this._children.length - 1; index >= 0; index--) {
  1434. var child = this._children[index];
  1435. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1436. contains = true;
  1437. break;
  1438. }
  1439. }
  1440. if (!contains) {
  1441. return false;
  1442. }
  1443. }
  1444. this._processObservables(type, x, y, pointerId, buttonIndex);
  1445. return true;
  1446. };
  1447. /** @hidden */
  1448. Button.prototype._onPointerEnter = function (target) {
  1449. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1450. return false;
  1451. }
  1452. if (this.pointerEnterAnimation) {
  1453. this.pointerEnterAnimation();
  1454. }
  1455. return true;
  1456. };
  1457. /** @hidden */
  1458. Button.prototype._onPointerOut = function (target, force) {
  1459. if (force === void 0) { force = false; }
  1460. if (this.pointerOutAnimation) {
  1461. this.pointerOutAnimation();
  1462. }
  1463. _super.prototype._onPointerOut.call(this, target, force);
  1464. };
  1465. /** @hidden */
  1466. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1467. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1468. return false;
  1469. }
  1470. if (this.pointerDownAnimation) {
  1471. this.pointerDownAnimation();
  1472. }
  1473. return true;
  1474. };
  1475. /** @hidden */
  1476. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1477. if (this.pointerUpAnimation) {
  1478. this.pointerUpAnimation();
  1479. }
  1480. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1481. };
  1482. // Statics
  1483. /**
  1484. * Creates a new button made with an image and a text
  1485. * @param name defines the name of the button
  1486. * @param text defines the text of the button
  1487. * @param imageUrl defines the url of the image
  1488. * @returns a new Button
  1489. */
  1490. Button.CreateImageButton = function (name, text, imageUrl) {
  1491. var result = new Button(name);
  1492. // Adding text
  1493. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1494. textBlock.textWrapping = true;
  1495. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1496. textBlock.paddingLeft = "20%";
  1497. result.addControl(textBlock);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.width = "20%";
  1501. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1502. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1503. result.addControl(iconImage);
  1504. // Store
  1505. result._image = iconImage;
  1506. result._textBlock = textBlock;
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new button made with an image
  1511. * @param name defines the name of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1521. result.addControl(iconImage);
  1522. // Store
  1523. result._image = iconImage;
  1524. return result;
  1525. };
  1526. /**
  1527. * Creates a new button made with a text
  1528. * @param name defines the name of the button
  1529. * @param text defines the text of the button
  1530. * @returns a new Button
  1531. */
  1532. Button.CreateSimpleButton = function (name, text) {
  1533. var result = new Button(name);
  1534. // Adding text
  1535. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1536. textBlock.textWrapping = true;
  1537. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1538. result.addControl(textBlock);
  1539. // Store
  1540. result._textBlock = textBlock;
  1541. return result;
  1542. };
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding image
  1553. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1554. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1555. result.addControl(iconImage);
  1556. // Adding text
  1557. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1558. textBlock.textWrapping = true;
  1559. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1560. result.addControl(textBlock);
  1561. // Store
  1562. result._image = iconImage;
  1563. result._textBlock = textBlock;
  1564. return result;
  1565. };
  1566. return Button;
  1567. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1568. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1569. /***/ }),
  1570. /***/ "./2D/controls/checkbox.ts":
  1571. /*!*********************************!*\
  1572. !*** ./2D/controls/checkbox.ts ***!
  1573. \*********************************/
  1574. /*! exports provided: Checkbox */
  1575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1576. "use strict";
  1577. __webpack_require__.r(__webpack_exports__);
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1582. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1583. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1584. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1585. /**
  1586. * Class used to represent a 2D checkbox
  1587. */
  1588. var Checkbox = /** @class */ (function (_super) {
  1589. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1590. /**
  1591. * Creates a new CheckBox
  1592. * @param name defines the control name
  1593. */
  1594. function Checkbox(name) {
  1595. var _this = _super.call(this, name) || this;
  1596. _this.name = name;
  1597. _this._isChecked = false;
  1598. _this._background = "black";
  1599. _this._checkSizeRatio = 0.8;
  1600. _this._thickness = 1;
  1601. /**
  1602. * Observable raised when isChecked property changes
  1603. */
  1604. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1605. _this.isPointerBlocker = true;
  1606. return _this;
  1607. }
  1608. Object.defineProperty(Checkbox.prototype, "thickness", {
  1609. /** Gets or sets border thickness */
  1610. get: function () {
  1611. return this._thickness;
  1612. },
  1613. set: function (value) {
  1614. if (this._thickness === value) {
  1615. return;
  1616. }
  1617. this._thickness = value;
  1618. this._markAsDirty();
  1619. },
  1620. enumerable: true,
  1621. configurable: true
  1622. });
  1623. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1624. /** Gets or sets a value indicating the ratio between overall size and check size */
  1625. get: function () {
  1626. return this._checkSizeRatio;
  1627. },
  1628. set: function (value) {
  1629. value = Math.max(Math.min(1, value), 0);
  1630. if (this._checkSizeRatio === value) {
  1631. return;
  1632. }
  1633. this._checkSizeRatio = value;
  1634. this._markAsDirty();
  1635. },
  1636. enumerable: true,
  1637. configurable: true
  1638. });
  1639. Object.defineProperty(Checkbox.prototype, "background", {
  1640. /** Gets or sets background color */
  1641. get: function () {
  1642. return this._background;
  1643. },
  1644. set: function (value) {
  1645. if (this._background === value) {
  1646. return;
  1647. }
  1648. this._background = value;
  1649. this._markAsDirty();
  1650. },
  1651. enumerable: true,
  1652. configurable: true
  1653. });
  1654. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1655. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1656. get: function () {
  1657. return this._isChecked;
  1658. },
  1659. set: function (value) {
  1660. if (this._isChecked === value) {
  1661. return;
  1662. }
  1663. this._isChecked = value;
  1664. this._markAsDirty();
  1665. this.onIsCheckedChangedObservable.notifyObservers(value);
  1666. },
  1667. enumerable: true,
  1668. configurable: true
  1669. });
  1670. Checkbox.prototype._getTypeName = function () {
  1671. return "Checkbox";
  1672. };
  1673. /** @hidden */
  1674. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1675. context.save();
  1676. this._applyStates(context);
  1677. var actualWidth = this._currentMeasure.width - this._thickness;
  1678. var actualHeight = this._currentMeasure.height - this._thickness;
  1679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1680. context.shadowColor = this.shadowColor;
  1681. context.shadowBlur = this.shadowBlur;
  1682. context.shadowOffsetX = this.shadowOffsetX;
  1683. context.shadowOffsetY = this.shadowOffsetY;
  1684. }
  1685. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1687. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1688. context.shadowBlur = 0;
  1689. context.shadowOffsetX = 0;
  1690. context.shadowOffsetY = 0;
  1691. }
  1692. if (this._isChecked) {
  1693. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1694. var offsetWidth = actualWidth * this._checkSizeRatio;
  1695. var offseHeight = actualHeight * this._checkSizeRatio;
  1696. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1697. }
  1698. context.strokeStyle = this.color;
  1699. context.lineWidth = this._thickness;
  1700. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1701. context.restore();
  1702. };
  1703. // Events
  1704. /** @hidden */
  1705. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1706. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1707. return false;
  1708. }
  1709. this.isChecked = !this.isChecked;
  1710. return true;
  1711. };
  1712. /**
  1713. * Utility function to easily create a checkbox with a header
  1714. * @param title defines the label to use for the header
  1715. * @param onValueChanged defines the callback to call when value changes
  1716. * @returns a StackPanel containing the checkbox and a textBlock
  1717. */
  1718. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1720. panel.isVertical = false;
  1721. panel.height = "30px";
  1722. var checkbox = new Checkbox();
  1723. checkbox.width = "20px";
  1724. checkbox.height = "20px";
  1725. checkbox.isChecked = true;
  1726. checkbox.color = "green";
  1727. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1728. panel.addControl(checkbox);
  1729. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1730. header.text = title;
  1731. header.width = "180px";
  1732. header.paddingLeft = "5px";
  1733. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1734. header.color = "white";
  1735. panel.addControl(header);
  1736. return panel;
  1737. };
  1738. return Checkbox;
  1739. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1740. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1741. /***/ }),
  1742. /***/ "./2D/controls/colorpicker.ts":
  1743. /*!************************************!*\
  1744. !*** ./2D/controls/colorpicker.ts ***!
  1745. \************************************/
  1746. /*! exports provided: ColorPicker */
  1747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1748. "use strict";
  1749. __webpack_require__.r(__webpack_exports__);
  1750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1752. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1754. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1755. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1756. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1757. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1758. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1759. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1760. /** Class used to create color pickers */
  1761. var ColorPicker = /** @class */ (function (_super) {
  1762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1763. /**
  1764. * Creates a new ColorPicker
  1765. * @param name defines the control name
  1766. */
  1767. function ColorPicker(name) {
  1768. var _this = _super.call(this, name) || this;
  1769. _this.name = name;
  1770. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1771. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1772. _this._pointerStartedOnSquare = false;
  1773. _this._pointerStartedOnWheel = false;
  1774. _this._squareLeft = 0;
  1775. _this._squareTop = 0;
  1776. _this._squareSize = 0;
  1777. _this._h = 360;
  1778. _this._s = 1;
  1779. _this._v = 1;
  1780. _this._lastPointerDownID = -1;
  1781. /**
  1782. * Observable raised when the value changes
  1783. */
  1784. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1785. // Events
  1786. _this._pointerIsDown = false;
  1787. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1788. _this.size = "200px";
  1789. _this.isPointerBlocker = true;
  1790. return _this;
  1791. }
  1792. Object.defineProperty(ColorPicker.prototype, "value", {
  1793. /** Gets or sets the color of the color picker */
  1794. get: function () {
  1795. return this._value;
  1796. },
  1797. set: function (value) {
  1798. if (this._value.equals(value)) {
  1799. return;
  1800. }
  1801. this._value.copyFrom(value);
  1802. this._value.toHSVToRef(this._tmpColor);
  1803. this._h = this._tmpColor.r;
  1804. this._s = Math.max(this._tmpColor.g, 0.00001);
  1805. this._v = Math.max(this._tmpColor.b, 0.00001);
  1806. this._markAsDirty();
  1807. if (this._value.r <= ColorPicker._Epsilon) {
  1808. this._value.r = 0;
  1809. }
  1810. if (this._value.g <= ColorPicker._Epsilon) {
  1811. this._value.g = 0;
  1812. }
  1813. if (this._value.b <= ColorPicker._Epsilon) {
  1814. this._value.b = 0;
  1815. }
  1816. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1817. this._value.r = 1.0;
  1818. }
  1819. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1820. this._value.g = 1.0;
  1821. }
  1822. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1823. this._value.b = 1.0;
  1824. }
  1825. this.onValueChangedObservable.notifyObservers(this._value);
  1826. },
  1827. enumerable: true,
  1828. configurable: true
  1829. });
  1830. Object.defineProperty(ColorPicker.prototype, "width", {
  1831. /**
  1832. * Gets or sets control width
  1833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1834. */
  1835. get: function () {
  1836. return this._width.toString(this._host);
  1837. },
  1838. set: function (value) {
  1839. if (this._width.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._width.fromString(value)) {
  1843. this._height.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "height", {
  1851. /**
  1852. * Gets or sets control height
  1853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1854. */
  1855. get: function () {
  1856. return this._height.toString(this._host);
  1857. },
  1858. /** Gets or sets control height */
  1859. set: function (value) {
  1860. if (this._height.toString(this._host) === value) {
  1861. return;
  1862. }
  1863. if (this._height.fromString(value)) {
  1864. this._width.fromString(value);
  1865. this._markAsDirty();
  1866. }
  1867. },
  1868. enumerable: true,
  1869. configurable: true
  1870. });
  1871. Object.defineProperty(ColorPicker.prototype, "size", {
  1872. /** Gets or sets control size */
  1873. get: function () {
  1874. return this.width;
  1875. },
  1876. set: function (value) {
  1877. this.width = value;
  1878. },
  1879. enumerable: true,
  1880. configurable: true
  1881. });
  1882. ColorPicker.prototype._getTypeName = function () {
  1883. return "ColorPicker";
  1884. };
  1885. /** @hidden */
  1886. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1887. if (parentMeasure.width < parentMeasure.height) {
  1888. this._currentMeasure.height = parentMeasure.width;
  1889. }
  1890. else {
  1891. this._currentMeasure.width = parentMeasure.height;
  1892. }
  1893. };
  1894. ColorPicker.prototype._updateSquareProps = function () {
  1895. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1896. var wheelThickness = radius * .2;
  1897. var innerDiameter = (radius - wheelThickness) * 2;
  1898. var squareSize = innerDiameter / (Math.sqrt(2));
  1899. var offset = radius - squareSize * .5;
  1900. this._squareLeft = this._currentMeasure.left + offset;
  1901. this._squareTop = this._currentMeasure.top + offset;
  1902. this._squareSize = squareSize;
  1903. };
  1904. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1905. var lgh = context.createLinearGradient(left, top, width + left, top);
  1906. lgh.addColorStop(0, '#fff');
  1907. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1908. context.fillStyle = lgh;
  1909. context.fillRect(left, top, width, height);
  1910. var lgv = context.createLinearGradient(left, top, left, height + top);
  1911. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1912. lgv.addColorStop(1, '#000');
  1913. context.fillStyle = lgv;
  1914. context.fillRect(left, top, width, height);
  1915. };
  1916. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1917. context.beginPath();
  1918. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1919. context.lineWidth = 3;
  1920. context.strokeStyle = '#333333';
  1921. context.stroke();
  1922. context.beginPath();
  1923. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1924. context.lineWidth = 3;
  1925. context.strokeStyle = '#ffffff';
  1926. context.stroke();
  1927. };
  1928. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1929. var canvas = document.createElement("canvas");
  1930. canvas.width = radius * 2;
  1931. canvas.height = radius * 2;
  1932. var context = canvas.getContext("2d");
  1933. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1934. var data = image.data;
  1935. var color = this._tmpColor;
  1936. var maxDistSq = radius * radius;
  1937. var innerRadius = radius - thickness;
  1938. var minDistSq = innerRadius * innerRadius;
  1939. for (var x = -radius; x < radius; x++) {
  1940. for (var y = -radius; y < radius; y++) {
  1941. var distSq = x * x + y * y;
  1942. if (distSq > maxDistSq || distSq < minDistSq) {
  1943. continue;
  1944. }
  1945. var dist = Math.sqrt(distSq);
  1946. var ang = Math.atan2(y, x);
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1948. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1949. data[index] = color.r * 255;
  1950. data[index + 1] = color.g * 255;
  1951. data[index + 2] = color.b * 255;
  1952. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1953. //apply less alpha to bigger color pickers
  1954. var alphaAmount = .2;
  1955. var maxAlpha = .2;
  1956. var minAlpha = .04;
  1957. var lowerRadius = 50;
  1958. var upperRadius = 150;
  1959. if (radius < lowerRadius) {
  1960. alphaAmount = maxAlpha;
  1961. }
  1962. else if (radius > upperRadius) {
  1963. alphaAmount = minAlpha;
  1964. }
  1965. else {
  1966. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1967. }
  1968. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1969. if (alphaRatio < alphaAmount) {
  1970. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1971. }
  1972. else if (alphaRatio > 1 - alphaAmount) {
  1973. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1974. }
  1975. else {
  1976. data[index + 3] = 255;
  1977. }
  1978. }
  1979. }
  1980. context.putImageData(image, 0, 0);
  1981. return canvas;
  1982. };
  1983. /** @hidden */
  1984. ColorPicker.prototype._draw = function (context) {
  1985. context.save();
  1986. this._applyStates(context);
  1987. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1988. var wheelThickness = radius * .2;
  1989. var left = this._currentMeasure.left;
  1990. var top = this._currentMeasure.top;
  1991. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1992. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1993. }
  1994. this._updateSquareProps();
  1995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1996. context.shadowColor = this.shadowColor;
  1997. context.shadowBlur = this.shadowBlur;
  1998. context.shadowOffsetX = this.shadowOffsetX;
  1999. context.shadowOffsetY = this.shadowOffsetY;
  2000. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2001. }
  2002. context.drawImage(this._colorWheelCanvas, left, top);
  2003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2004. context.shadowBlur = 0;
  2005. context.shadowOffsetX = 0;
  2006. context.shadowOffsetY = 0;
  2007. }
  2008. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2009. var cx = this._squareLeft + this._squareSize * this._s;
  2010. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2011. this._drawCircle(cx, cy, radius * .04, context);
  2012. var dist = radius - wheelThickness * .5;
  2013. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2014. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2015. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2016. context.restore();
  2017. };
  2018. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2019. if (this._pointerStartedOnWheel) {
  2020. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2021. var centerX = radius + this._currentMeasure.left;
  2022. var centerY = radius + this._currentMeasure.top;
  2023. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2024. }
  2025. else if (this._pointerStartedOnSquare) {
  2026. this._updateSquareProps();
  2027. this._s = (x - this._squareLeft) / this._squareSize;
  2028. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2029. this._s = Math.min(this._s, 1);
  2030. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2031. this._v = Math.min(this._v, 1);
  2032. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2033. }
  2034. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2035. this.value = this._tmpColor;
  2036. };
  2037. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2038. this._updateSquareProps();
  2039. var left = this._squareLeft;
  2040. var top = this._squareTop;
  2041. var size = this._squareSize;
  2042. if (x >= left && x <= left + size &&
  2043. y >= top && y <= top + size) {
  2044. return true;
  2045. }
  2046. return false;
  2047. };
  2048. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2049. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2050. var centerX = radius + this._currentMeasure.left;
  2051. var centerY = radius + this._currentMeasure.top;
  2052. var wheelThickness = radius * .2;
  2053. var innerRadius = radius - wheelThickness;
  2054. var radiusSq = radius * radius;
  2055. var innerRadiusSq = innerRadius * innerRadius;
  2056. var dx = x - centerX;
  2057. var dy = y - centerY;
  2058. var distSq = dx * dx + dy * dy;
  2059. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2060. return true;
  2061. }
  2062. return false;
  2063. };
  2064. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2065. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2066. return false;
  2067. }
  2068. this._pointerIsDown = true;
  2069. this._pointerStartedOnSquare = false;
  2070. this._pointerStartedOnWheel = false;
  2071. // Invert transform
  2072. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2073. var x = this._transformedPosition.x;
  2074. var y = this._transformedPosition.y;
  2075. if (this._isPointOnSquare(x, y)) {
  2076. this._pointerStartedOnSquare = true;
  2077. }
  2078. else if (this._isPointOnWheel(x, y)) {
  2079. this._pointerStartedOnWheel = true;
  2080. }
  2081. this._updateValueFromPointer(x, y);
  2082. this._host._capturingControl[pointerId] = this;
  2083. this._lastPointerDownID = pointerId;
  2084. return true;
  2085. };
  2086. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2087. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2088. if (pointerId != this._lastPointerDownID) {
  2089. return;
  2090. }
  2091. // Invert transform
  2092. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2093. var x = this._transformedPosition.x;
  2094. var y = this._transformedPosition.y;
  2095. if (this._pointerIsDown) {
  2096. this._updateValueFromPointer(x, y);
  2097. }
  2098. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2099. };
  2100. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2101. this._pointerIsDown = false;
  2102. delete this._host._capturingControl[pointerId];
  2103. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2104. };
  2105. /**
  2106. * This function expands the color picker by creating a color picker dialog with manual
  2107. * color value input and the ability to save colors into an array to be used later in
  2108. * subsequent launches of the dialogue.
  2109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2110. * @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.
  2111. * @returns picked color as a hex string and the saved colors array as hex strings.
  2112. */
  2113. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2114. return new Promise(function (resolve, reject) {
  2115. // Default options
  2116. options.pickerWidth = options.pickerWidth || "640px";
  2117. options.pickerHeight = options.pickerHeight || "400px";
  2118. options.headerHeight = options.headerHeight || "35px";
  2119. options.lastColor = options.lastColor || "#000000";
  2120. options.swatchLimit = options.swatchLimit || 20;
  2121. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2122. // Window size settings
  2123. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2124. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2125. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2126. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2127. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2128. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2129. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2130. // Button Colors
  2131. var buttonColor = "#c0c0c0";
  2132. var buttonBackgroundColor = "#535353";
  2133. var buttonBackgroundHoverColor = "#414141";
  2134. var buttonBackgroundClickColor = "515151";
  2135. var buttonDisabledColor = "#555555";
  2136. var buttonDisabledBackgroundColor = "#454545";
  2137. var currentSwatchesOutlineColor = "#404040";
  2138. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2139. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2140. var iconColorDark = "#aaaaaa";
  2141. var iconColorLight = "#ffffff";
  2142. var closeIconColor;
  2143. // Button settings
  2144. var buttonFontSize;
  2145. var butEdit;
  2146. var buttonWidth;
  2147. var buttonHeight;
  2148. // Input Text Colors
  2149. var inputFieldLabels = ["R", "G", "B"];
  2150. var inputTextBackgroundColor = "#454545";
  2151. var inputTextColor = "#f0f0f0";
  2152. // This is the current color as set by either the picker or by entering a value
  2153. var currentColor;
  2154. // This int is used for naming swatches and serves as the index for calling them from the list
  2155. var swatchNumber;
  2156. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2157. var swatchDrawer;
  2158. var editSwatchMode = false;
  2159. // Color InputText fields that will be updated upon value change
  2160. var picker;
  2161. var rValInt;
  2162. var gValInt;
  2163. var bValInt;
  2164. var rValDec;
  2165. var gValDec;
  2166. var bValDec;
  2167. var hexVal;
  2168. var newSwatch;
  2169. var lastVal;
  2170. var activeField;
  2171. /**
  2172. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2173. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2174. * are will receive no update. This is to prevent the input from the user being overwritten.
  2175. */
  2176. function updateValues(value, inputField) {
  2177. activeField = inputField;
  2178. var pickedColor = value.toHexString();
  2179. newSwatch.background = pickedColor;
  2180. if (rValInt.name != activeField) {
  2181. rValInt.text = Math.floor(value.r * 255).toString();
  2182. }
  2183. if (gValInt.name != activeField) {
  2184. gValInt.text = Math.floor(value.g * 255).toString();
  2185. }
  2186. if (bValInt.name != activeField) {
  2187. bValInt.text = Math.floor(value.b * 255).toString();
  2188. }
  2189. if (rValDec.name != activeField) {
  2190. rValDec.text = value.r.toString();
  2191. }
  2192. if (gValDec.name != activeField) {
  2193. gValDec.text = value.g.toString();
  2194. }
  2195. if (bValDec.name != activeField) {
  2196. bValDec.text = value.b.toString();
  2197. }
  2198. if (hexVal.name != activeField) {
  2199. var minusPound = pickedColor.split("#");
  2200. hexVal.text = minusPound[1];
  2201. }
  2202. if (picker.name != activeField) {
  2203. picker.value = value;
  2204. }
  2205. }
  2206. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2207. function updateInt(field, channel) {
  2208. var newValue = field.text;
  2209. var checkVal = /[^0-9]/g.test(newValue);
  2210. if (checkVal) {
  2211. field.text = lastVal;
  2212. return;
  2213. }
  2214. else {
  2215. if (newValue != "") {
  2216. if (Math.floor(parseInt(newValue)) < 0) {
  2217. newValue = "0";
  2218. }
  2219. else if (Math.floor(parseInt(newValue)) > 255) {
  2220. newValue = "255";
  2221. }
  2222. else if (isNaN(parseInt(newValue))) {
  2223. newValue = "0";
  2224. }
  2225. }
  2226. if (activeField == field.name) {
  2227. lastVal = newValue;
  2228. }
  2229. }
  2230. if (newValue != "") {
  2231. newValue = parseInt(newValue).toString();
  2232. field.text = newValue;
  2233. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2234. if (activeField == field.name) {
  2235. if (channel == "r") {
  2236. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2237. }
  2238. else if (channel == "g") {
  2239. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2240. }
  2241. else {
  2242. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2243. }
  2244. }
  2245. }
  2246. }
  2247. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2248. function updateFloat(field, channel) {
  2249. var newValue = field.text;
  2250. var checkVal = /[^0-9\.]/g.test(newValue);
  2251. if (checkVal) {
  2252. field.text = lastVal;
  2253. return;
  2254. }
  2255. else {
  2256. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2257. if (parseFloat(newValue) < 0.0) {
  2258. newValue = "0.0";
  2259. }
  2260. else if (parseFloat(newValue) > 1.0) {
  2261. newValue = "1.0";
  2262. }
  2263. else if (isNaN(parseFloat(newValue))) {
  2264. newValue = "0.0";
  2265. }
  2266. }
  2267. if (activeField == field.name) {
  2268. lastVal = newValue;
  2269. }
  2270. }
  2271. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2272. newValue = parseFloat(newValue).toString();
  2273. field.text = newValue;
  2274. }
  2275. else {
  2276. newValue = "0.0";
  2277. }
  2278. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2279. if (activeField == field.name) {
  2280. if (channel == "r") {
  2281. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2282. }
  2283. else if (channel == "g") {
  2284. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2285. }
  2286. else {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2288. }
  2289. }
  2290. }
  2291. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2292. function deleteSwatch(index) {
  2293. if (options.savedColors) {
  2294. options.savedColors.splice(index, 1);
  2295. }
  2296. if (options.savedColors && options.savedColors.length == 0) {
  2297. setEditButtonVisibility(false);
  2298. editSwatchMode = false;
  2299. }
  2300. }
  2301. // Creates and styles an individual swatch when updateSwatches is called.
  2302. function createSwatch() {
  2303. if (options.savedColors && options.savedColors[swatchNumber]) {
  2304. if (editSwatchMode) {
  2305. var icon = "b";
  2306. }
  2307. else {
  2308. var icon = "";
  2309. }
  2310. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2311. swatch.fontFamily = "BabylonJSglyphs";
  2312. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2313. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2314. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2315. if (swatchLuminence > luminanceLimit) {
  2316. swatch.color = iconColorDark;
  2317. }
  2318. else {
  2319. swatch.color = iconColorLight;
  2320. }
  2321. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2322. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2323. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2324. swatch.background = options.savedColors[swatchNumber];
  2325. swatch.thickness = 2;
  2326. var metadata_1 = swatchNumber;
  2327. swatch.pointerDownAnimation = function () {
  2328. swatch.thickness = 4;
  2329. };
  2330. swatch.pointerUpAnimation = function () {
  2331. swatch.thickness = 3;
  2332. };
  2333. swatch.pointerEnterAnimation = function () {
  2334. swatch.thickness = 3;
  2335. };
  2336. swatch.pointerOutAnimation = function () {
  2337. swatch.thickness = 2;
  2338. };
  2339. swatch.onPointerClickObservable.add(function () {
  2340. if (!editSwatchMode) {
  2341. if (options.savedColors) {
  2342. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2343. }
  2344. }
  2345. else {
  2346. deleteSwatch(metadata_1);
  2347. updateSwatches("", butSave);
  2348. }
  2349. });
  2350. return swatch;
  2351. }
  2352. else {
  2353. return null;
  2354. }
  2355. }
  2356. // Mode switch to render button text and close symbols on swatch controls
  2357. function editSwatches(mode) {
  2358. if (mode !== undefined) {
  2359. editSwatchMode = mode;
  2360. }
  2361. if (editSwatchMode) {
  2362. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2363. var thisButton = swatchDrawer.children[i];
  2364. thisButton.textBlock.text = "b";
  2365. }
  2366. if (butEdit !== undefined) {
  2367. butEdit.textBlock.text = "Done";
  2368. }
  2369. }
  2370. else {
  2371. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2372. var thisButton = swatchDrawer.children[i];
  2373. thisButton.textBlock.text = "";
  2374. }
  2375. if (butEdit !== undefined) {
  2376. butEdit.textBlock.text = "Edit";
  2377. }
  2378. }
  2379. }
  2380. /**
  2381. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2382. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2383. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2384. * saved colors there are and how many can be stored per row.
  2385. */
  2386. function updateSwatches(color, button) {
  2387. if (options.savedColors) {
  2388. if (color != "") {
  2389. options.savedColors.push(color);
  2390. }
  2391. swatchNumber = 0;
  2392. swatchDrawer.clearControls();
  2393. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2394. if (rowCount == 0) {
  2395. var gutterCount = 0;
  2396. }
  2397. else {
  2398. var gutterCount = rowCount + 1;
  2399. }
  2400. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2401. var currentRows = swatchDrawer.rowCount;
  2402. for (var i = 0; i < currentRows; i++) {
  2403. swatchDrawer.removeRowDefinition(0);
  2404. }
  2405. for (var i = 0; i < rowCount + gutterCount; i++) {
  2406. if (i % 2) {
  2407. swatchDrawer.addRowDefinition(swatchSize, true);
  2408. }
  2409. else {
  2410. swatchDrawer.addRowDefinition(gutterSize, true);
  2411. }
  2412. }
  2413. }
  2414. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2415. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2416. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2417. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2418. var totalButtonsThisRow = options.numSwatchesPerLine;
  2419. }
  2420. else {
  2421. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2422. }
  2423. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2424. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2425. if (x > options.numSwatchesPerLine) {
  2426. continue;
  2427. }
  2428. var swatch = createSwatch();
  2429. if (swatch != null) {
  2430. swatchDrawer.addControl(swatch, y, w);
  2431. w += 2;
  2432. swatchNumber++;
  2433. }
  2434. else {
  2435. continue;
  2436. }
  2437. }
  2438. }
  2439. if (options.savedColors.length >= options.swatchLimit) {
  2440. disableButton(button, true);
  2441. }
  2442. else {
  2443. disableButton(button, false);
  2444. }
  2445. }
  2446. }
  2447. // Shows or hides edit swatches button depending on if there are saved swatches
  2448. function setEditButtonVisibility(enableButton) {
  2449. if (enableButton) {
  2450. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2451. butEdit.width = buttonWidth;
  2452. butEdit.height = buttonHeight;
  2453. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2454. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2455. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2456. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2457. butEdit.thickness = 2;
  2458. butEdit.color = buttonColor;
  2459. butEdit.fontSize = buttonFontSize;
  2460. butEdit.background = buttonBackgroundColor;
  2461. butEdit.onPointerEnterObservable.add(function () {
  2462. butEdit.background = buttonBackgroundHoverColor;
  2463. });
  2464. butEdit.onPointerOutObservable.add(function () {
  2465. butEdit.background = buttonBackgroundColor;
  2466. });
  2467. butEdit.pointerDownAnimation = function () {
  2468. butEdit.background = buttonBackgroundClickColor;
  2469. };
  2470. butEdit.pointerUpAnimation = function () {
  2471. butEdit.background = buttonBackgroundHoverColor;
  2472. };
  2473. butEdit.onPointerClickObservable.add(function () {
  2474. if (editSwatchMode) {
  2475. editSwatchMode = false;
  2476. }
  2477. else {
  2478. editSwatchMode = true;
  2479. }
  2480. editSwatches();
  2481. });
  2482. pickerGrid.addControl(butEdit, 1, 0);
  2483. }
  2484. else {
  2485. pickerGrid.removeControl(butEdit);
  2486. }
  2487. }
  2488. // Called when the user hits the limit of saved colors in the drawer.
  2489. function disableButton(button, disabled) {
  2490. if (disabled) {
  2491. button.color = buttonDisabledColor;
  2492. button.background = buttonDisabledBackgroundColor;
  2493. }
  2494. else {
  2495. button.color = buttonColor;
  2496. button.background = buttonBackgroundColor;
  2497. }
  2498. }
  2499. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2500. function closePicker(color) {
  2501. if (options.savedColors && options.savedColors.length > 0) {
  2502. resolve({
  2503. savedColors: options.savedColors,
  2504. pickedColor: color
  2505. });
  2506. }
  2507. else {
  2508. resolve({
  2509. pickedColor: color
  2510. });
  2511. }
  2512. advancedTexture.removeControl(dialogContainer);
  2513. }
  2514. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2515. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2516. dialogContainer.name = "Dialog Container";
  2517. dialogContainer.width = options.pickerWidth;
  2518. if (options.savedColors) {
  2519. dialogContainer.height = containerSize;
  2520. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2521. dialogContainer.addRowDefinition(topRow, false);
  2522. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2523. }
  2524. else {
  2525. dialogContainer.height = options.pickerHeight;
  2526. dialogContainer.addRowDefinition(1.0, false);
  2527. }
  2528. advancedTexture.addControl(dialogContainer);
  2529. // Swatch drawer which contains all saved color buttons
  2530. if (options.savedColors) {
  2531. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2532. swatchDrawer.name = "Swatch Drawer";
  2533. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2534. swatchDrawer.background = buttonBackgroundColor;
  2535. swatchDrawer.width = options.pickerWidth;
  2536. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2537. if (initialRows == 0) {
  2538. var gutterCount = 0;
  2539. }
  2540. else {
  2541. var gutterCount = initialRows + 1;
  2542. }
  2543. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2544. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2545. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2546. if (i % 2 != 0) {
  2547. swatchDrawer.addRowDefinition(swatchSize, true);
  2548. }
  2549. else {
  2550. swatchDrawer.addRowDefinition(gutterSize, true);
  2551. }
  2552. }
  2553. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2554. if (i % 2 != 0) {
  2555. swatchDrawer.addColumnDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addColumnDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. dialogContainer.addControl(swatchDrawer, 1, 0);
  2562. }
  2563. // Picker container
  2564. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2565. pickerPanel.name = "Picker Panel";
  2566. pickerPanel.height = options.pickerHeight;
  2567. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2568. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2569. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2570. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2571. dialogContainer.addControl(pickerPanel, 0, 0);
  2572. // Picker container header
  2573. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2574. header.name = "Dialogue Header Bar";
  2575. header.background = "#cccccc";
  2576. header.thickness = 0;
  2577. pickerPanel.addControl(header, 0, 0);
  2578. // Header close button
  2579. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2580. closeButton.fontFamily = "BabylonJSglyphs";
  2581. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2582. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2583. closeButton.color = closeIconColor.toHexString();
  2584. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2585. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2586. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2587. closeButton.height = closeButton.width = options.headerHeight;
  2588. closeButton.background = header.background;
  2589. closeButton.thickness = 0;
  2590. closeButton.pointerDownAnimation = function () {
  2591. };
  2592. closeButton.pointerUpAnimation = function () {
  2593. closeButton.background = header.background;
  2594. };
  2595. closeButton.pointerEnterAnimation = function () {
  2596. closeButton.color = header.background;
  2597. closeButton.background = "red";
  2598. };
  2599. closeButton.pointerOutAnimation = function () {
  2600. closeButton.color = closeIconColor.toHexString();
  2601. closeButton.background = header.background;
  2602. };
  2603. closeButton.onPointerClickObservable.add(function () {
  2604. closePicker(currentSwatch.background);
  2605. });
  2606. pickerPanel.addControl(closeButton, 0, 0);
  2607. // Dialog container body
  2608. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2609. dialogBody.name = "Dialogue Body";
  2610. dialogBody.background = buttonBackgroundColor;
  2611. var dialogBodyCols = [0.4375, 0.5625];
  2612. dialogBody.addRowDefinition(1.0, false);
  2613. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2614. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2615. pickerPanel.addControl(dialogBody, 1, 0);
  2616. // Picker grid
  2617. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2618. pickerGrid.name = "Picker Grid";
  2619. pickerGrid.addRowDefinition(0.85, false);
  2620. pickerGrid.addRowDefinition(0.15, false);
  2621. dialogBody.addControl(pickerGrid, 0, 0);
  2622. // Picker control
  2623. picker = new ColorPicker();
  2624. picker.name = "GUI Color Picker";
  2625. if (options.pickerHeight < options.pickerWidth) {
  2626. picker.width = 0.89;
  2627. }
  2628. else {
  2629. picker.height = 0.89;
  2630. }
  2631. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2632. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2633. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2634. picker.onPointerDownObservable.add(function () {
  2635. activeField = picker.name;
  2636. lastVal = "";
  2637. editSwatches(false);
  2638. });
  2639. picker.onValueChangedObservable.add(function (value) {
  2640. if (activeField == picker.name) {
  2641. updateValues(value, picker.name);
  2642. }
  2643. });
  2644. pickerGrid.addControl(picker, 0, 0);
  2645. // Picker body right quarant
  2646. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerBodyRight.name = "Dialogue Right Half";
  2648. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2649. var pickerBodyRightRows = [0.514, 0.486];
  2650. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2651. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2652. dialogBody.addControl(pickerBodyRight, 1, 1);
  2653. // Picker container swatches and buttons
  2654. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerSwatchesButtons.name = "Swatches and Buttons";
  2656. var pickerButtonsCol = [0.417, 0.583];
  2657. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2658. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2659. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2660. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2661. // Picker Swatches quadrant
  2662. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2663. pickerSwatches.name = "New and Current Swatches";
  2664. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2665. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2666. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2667. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2668. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2669. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2670. // Active swatches
  2671. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2672. activeSwatches.name = "Active Swatches";
  2673. activeSwatches.width = 0.67;
  2674. activeSwatches.addRowDefinition(0.5, false);
  2675. activeSwatches.addRowDefinition(0.5, false);
  2676. pickerSwatches.addControl(activeSwatches, 2, 0);
  2677. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2678. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2679. if (options.pickerWidth > options.pickerHeight) {
  2680. var labelTextSize = labelHeight;
  2681. }
  2682. else {
  2683. var labelTextSize = labelWidth;
  2684. }
  2685. // New color swatch and previous color button
  2686. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. newText.text = "new";
  2688. newText.name = "New Color Label";
  2689. newText.color = buttonColor;
  2690. newText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(newText, 1, 0);
  2692. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2693. newSwatch.name = "New Color Swatch";
  2694. newSwatch.background = options.lastColor;
  2695. newSwatch.thickness = 0;
  2696. activeSwatches.addControl(newSwatch, 0, 0);
  2697. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2698. currentSwatch.background = options.lastColor;
  2699. currentSwatch.thickness = 0;
  2700. currentSwatch.onPointerClickObservable.add(function () {
  2701. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2702. updateValues(revertColor, currentSwatch.name);
  2703. editSwatches(false);
  2704. });
  2705. currentSwatch.pointerDownAnimation = function () { };
  2706. currentSwatch.pointerUpAnimation = function () { };
  2707. currentSwatch.pointerEnterAnimation = function () { };
  2708. currentSwatch.pointerOutAnimation = function () { };
  2709. activeSwatches.addControl(currentSwatch, 1, 0);
  2710. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2711. swatchOutline.name = "Swatch Outline";
  2712. swatchOutline.width = 0.67;
  2713. swatchOutline.thickness = 2;
  2714. swatchOutline.color = currentSwatchesOutlineColor;
  2715. swatchOutline.isHitTestVisible = false;
  2716. pickerSwatches.addControl(swatchOutline, 2, 0);
  2717. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2718. currentText.name = "Current Color Label";
  2719. currentText.text = "current";
  2720. currentText.color = buttonColor;
  2721. currentText.fontSize = labelTextSize;
  2722. pickerSwatches.addControl(currentText, 3, 0);
  2723. // Buttons grid
  2724. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2725. buttonGrid.name = "Button Grid";
  2726. buttonGrid.height = 0.8;
  2727. var buttonGridRows = 1 / 3;
  2728. buttonGrid.addRowDefinition(buttonGridRows, false);
  2729. buttonGrid.addRowDefinition(buttonGridRows, false);
  2730. buttonGrid.addRowDefinition(buttonGridRows, false);
  2731. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2732. // Determine pixel width and height for all buttons from overall panel dimensions
  2733. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2734. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2735. // Determine button type size
  2736. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2737. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2738. }
  2739. else {
  2740. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2741. }
  2742. // Panel Buttons
  2743. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2744. butOK.width = buttonWidth;
  2745. butOK.height = buttonHeight;
  2746. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butOK.thickness = 2;
  2748. butOK.color = buttonColor;
  2749. butOK.fontSize = buttonFontSize;
  2750. butOK.background = buttonBackgroundColor;
  2751. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2752. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2753. butOK.pointerDownAnimation = function () {
  2754. butOK.background = buttonBackgroundClickColor;
  2755. };
  2756. butOK.pointerUpAnimation = function () {
  2757. butOK.background = buttonBackgroundHoverColor;
  2758. };
  2759. butOK.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(newSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butOK, 0, 0);
  2764. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2765. butCancel.width = buttonWidth;
  2766. butCancel.height = buttonHeight;
  2767. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2768. butCancel.thickness = 2;
  2769. butCancel.color = buttonColor;
  2770. butCancel.fontSize = buttonFontSize;
  2771. butCancel.background = buttonBackgroundColor;
  2772. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2773. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2774. butCancel.pointerDownAnimation = function () {
  2775. butCancel.background = buttonBackgroundClickColor;
  2776. };
  2777. butCancel.pointerUpAnimation = function () {
  2778. butCancel.background = buttonBackgroundHoverColor;
  2779. };
  2780. butCancel.onPointerClickObservable.add(function () {
  2781. editSwatches(false);
  2782. closePicker(currentSwatch.background);
  2783. });
  2784. buttonGrid.addControl(butCancel, 1, 0);
  2785. if (options.savedColors) {
  2786. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2787. butSave.width = buttonWidth;
  2788. butSave.height = buttonHeight;
  2789. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butSave.thickness = 2;
  2791. butSave.fontSize = buttonFontSize;
  2792. if (options.savedColors.length < options.swatchLimit) {
  2793. butSave.color = buttonColor;
  2794. butSave.background = buttonBackgroundColor;
  2795. }
  2796. else {
  2797. disableButton(butSave, true);
  2798. }
  2799. butSave.onPointerEnterObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.onPointerOutObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundColor;
  2810. }
  2811. }
  2812. });
  2813. butSave.pointerDownAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundClickColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.pointerUpAnimation = function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length < options.swatchLimit) {
  2823. butSave.background = buttonBackgroundHoverColor;
  2824. }
  2825. }
  2826. };
  2827. butSave.onPointerClickObservable.add(function () {
  2828. if (options.savedColors) {
  2829. if (options.savedColors.length == 0) {
  2830. setEditButtonVisibility(true);
  2831. }
  2832. if (options.savedColors.length < options.swatchLimit) {
  2833. updateSwatches(newSwatch.background, butSave);
  2834. }
  2835. editSwatches(false);
  2836. }
  2837. });
  2838. if (options.savedColors.length > 0) {
  2839. setEditButtonVisibility(true);
  2840. }
  2841. buttonGrid.addControl(butSave, 2, 0);
  2842. }
  2843. // Picker color values input
  2844. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2845. pickerColorValues.name = "Dialog Lower Right";
  2846. pickerColorValues.addRowDefinition(0.02, false);
  2847. pickerColorValues.addRowDefinition(0.63, false);
  2848. pickerColorValues.addRowDefinition(0.21, false);
  2849. pickerColorValues.addRowDefinition(0.14, false);
  2850. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2851. // RGB values text boxes
  2852. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2853. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2854. rgbValuesQuadrant.name = "RGB Values";
  2855. rgbValuesQuadrant.width = 0.82;
  2856. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2857. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2858. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2859. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2860. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2861. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2862. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2863. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2864. for (var i = 0; i < inputFieldLabels.length; i++) {
  2865. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. labelText.text = inputFieldLabels[i];
  2867. labelText.color = buttonColor;
  2868. labelText.fontSize = buttonFontSize;
  2869. rgbValuesQuadrant.addControl(labelText, i, 0);
  2870. }
  2871. // Input fields for RGB values
  2872. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2873. rValInt.width = 0.83;
  2874. rValInt.height = 0.72;
  2875. rValInt.name = "rIntField";
  2876. rValInt.fontSize = buttonFontSize;
  2877. rValInt.text = (currentColor.r * 255).toString();
  2878. rValInt.color = inputTextColor;
  2879. rValInt.background = inputTextBackgroundColor;
  2880. rValInt.onFocusObservable.add(function () {
  2881. activeField = rValInt.name;
  2882. lastVal = rValInt.text;
  2883. editSwatches(false);
  2884. });
  2885. rValInt.onBlurObservable.add(function () {
  2886. if (rValInt.text == "") {
  2887. rValInt.text = "0";
  2888. }
  2889. updateInt(rValInt, "r");
  2890. if (activeField == rValInt.name) {
  2891. activeField = "";
  2892. }
  2893. });
  2894. rValInt.onTextChangedObservable.add(function () {
  2895. if (activeField == rValInt.name) {
  2896. updateInt(rValInt, "r");
  2897. }
  2898. });
  2899. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2900. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2901. gValInt.width = 0.83;
  2902. gValInt.height = 0.72;
  2903. gValInt.name = "gIntField";
  2904. gValInt.fontSize = buttonFontSize;
  2905. gValInt.text = (currentColor.g * 255).toString();
  2906. gValInt.color = inputTextColor;
  2907. gValInt.background = inputTextBackgroundColor;
  2908. gValInt.onFocusObservable.add(function () {
  2909. activeField = gValInt.name;
  2910. lastVal = gValInt.text;
  2911. editSwatches(false);
  2912. });
  2913. gValInt.onBlurObservable.add(function () {
  2914. if (gValInt.text == "") {
  2915. gValInt.text = "0";
  2916. }
  2917. updateInt(gValInt, "g");
  2918. if (activeField == gValInt.name) {
  2919. activeField = "";
  2920. }
  2921. });
  2922. gValInt.onTextChangedObservable.add(function () {
  2923. if (activeField == gValInt.name) {
  2924. updateInt(gValInt, "g");
  2925. }
  2926. });
  2927. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2928. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. bValInt.width = 0.83;
  2930. bValInt.height = 0.72;
  2931. bValInt.name = "bIntField";
  2932. bValInt.fontSize = buttonFontSize;
  2933. bValInt.text = (currentColor.b * 255).toString();
  2934. bValInt.color = inputTextColor;
  2935. bValInt.background = inputTextBackgroundColor;
  2936. bValInt.onFocusObservable.add(function () {
  2937. activeField = bValInt.name;
  2938. lastVal = bValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. bValInt.onBlurObservable.add(function () {
  2942. if (bValInt.text == "") {
  2943. bValInt.text = "0";
  2944. }
  2945. updateInt(bValInt, "b");
  2946. if (activeField == bValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. bValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == bValInt.name) {
  2952. updateInt(bValInt, "b");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2956. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. rValDec.width = 0.95;
  2958. rValDec.height = 0.72;
  2959. rValDec.name = "rDecField";
  2960. rValDec.fontSize = buttonFontSize;
  2961. rValDec.text = currentColor.r.toString();
  2962. rValDec.color = inputTextColor;
  2963. rValDec.background = inputTextBackgroundColor;
  2964. rValDec.onFocusObservable.add(function () {
  2965. activeField = rValDec.name;
  2966. lastVal = rValDec.text;
  2967. editSwatches(false);
  2968. });
  2969. rValDec.onBlurObservable.add(function () {
  2970. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2971. rValDec.text = "0";
  2972. updateFloat(rValDec, "r");
  2973. }
  2974. if (activeField == rValDec.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. rValDec.onTextChangedObservable.add(function () {
  2979. if (activeField == rValDec.name) {
  2980. updateFloat(rValDec, "r");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2984. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. gValDec.width = 0.95;
  2986. gValDec.height = 0.72;
  2987. gValDec.name = "gDecField";
  2988. gValDec.fontSize = buttonFontSize;
  2989. gValDec.text = currentColor.g.toString();
  2990. gValDec.color = inputTextColor;
  2991. gValDec.background = inputTextBackgroundColor;
  2992. gValDec.onFocusObservable.add(function () {
  2993. activeField = gValDec.name;
  2994. lastVal = gValDec.text;
  2995. editSwatches(false);
  2996. });
  2997. gValDec.onBlurObservable.add(function () {
  2998. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2999. gValDec.text = "0";
  3000. updateFloat(gValDec, "g");
  3001. }
  3002. if (activeField == gValDec.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. gValDec.onTextChangedObservable.add(function () {
  3007. if (activeField == gValDec.name) {
  3008. updateFloat(gValDec, "g");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3012. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. bValDec.width = 0.95;
  3014. bValDec.height = 0.72;
  3015. bValDec.name = "bDecField";
  3016. bValDec.fontSize = buttonFontSize;
  3017. bValDec.text = currentColor.b.toString();
  3018. bValDec.color = inputTextColor;
  3019. bValDec.background = inputTextBackgroundColor;
  3020. bValDec.onFocusObservable.add(function () {
  3021. activeField = bValDec.name;
  3022. lastVal = bValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. bValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3027. bValDec.text = "0";
  3028. updateFloat(bValDec, "b");
  3029. }
  3030. if (activeField == bValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. bValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == bValDec.name) {
  3036. updateFloat(bValDec, "b");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3040. // Hex value input
  3041. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3042. hexValueQuadrant.name = "Hex Value";
  3043. hexValueQuadrant.width = 0.82;
  3044. hexValueQuadrant.addRowDefinition(1.0, false);
  3045. hexValueQuadrant.addColumnDefinition(0.1, false);
  3046. hexValueQuadrant.addColumnDefinition(0.9, false);
  3047. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3048. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3049. labelText.text = "#";
  3050. labelText.color = buttonColor;
  3051. labelText.fontSize = buttonFontSize;
  3052. hexValueQuadrant.addControl(labelText, 0, 0);
  3053. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3054. hexVal.width = 0.96;
  3055. hexVal.height = 0.72;
  3056. hexVal.name = "hexField";
  3057. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3058. hexVal.fontSize = buttonFontSize;
  3059. var minusPound = options.lastColor.split("#");
  3060. hexVal.text = minusPound[1];
  3061. hexVal.color = inputTextColor;
  3062. hexVal.background = inputTextBackgroundColor;
  3063. hexVal.onFocusObservable.add(function () {
  3064. activeField = hexVal.name;
  3065. lastVal = hexVal.text;
  3066. editSwatches(false);
  3067. });
  3068. hexVal.onBlurObservable.add(function () {
  3069. if (hexVal.text.length == 3) {
  3070. var val = hexVal.text.split("");
  3071. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3072. }
  3073. if (hexVal.text == "") {
  3074. hexVal.text = "000000";
  3075. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3076. }
  3077. if (activeField == hexVal.name) {
  3078. activeField = "";
  3079. }
  3080. });
  3081. hexVal.onTextChangedObservable.add(function () {
  3082. var newHexValue = hexVal.text;
  3083. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3084. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3085. hexVal.text = lastVal;
  3086. }
  3087. else {
  3088. if (hexVal.text.length < 6) {
  3089. var leadingZero = 6 - hexVal.text.length;
  3090. for (var i = 0; i < leadingZero; i++) {
  3091. newHexValue = "0" + newHexValue;
  3092. }
  3093. }
  3094. if (hexVal.text.length == 3) {
  3095. var val = hexVal.text.split("");
  3096. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3097. }
  3098. newHexValue = "#" + newHexValue;
  3099. if (activeField == hexVal.name) {
  3100. lastVal = hexVal.text;
  3101. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3102. }
  3103. }
  3104. });
  3105. hexValueQuadrant.addControl(hexVal, 0, 1);
  3106. if (options.savedColors && options.savedColors.length > 0) {
  3107. updateSwatches("", butSave);
  3108. }
  3109. });
  3110. };
  3111. ColorPicker._Epsilon = 0.000001;
  3112. return ColorPicker;
  3113. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3115. /***/ }),
  3116. /***/ "./2D/controls/container.ts":
  3117. /*!**********************************!*\
  3118. !*** ./2D/controls/container.ts ***!
  3119. \**********************************/
  3120. /*! exports provided: Container */
  3121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3122. "use strict";
  3123. __webpack_require__.r(__webpack_exports__);
  3124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3126. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3127. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3129. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3130. /**
  3131. * Root class for 2D containers
  3132. * @see http://doc.babylonjs.com/how_to/gui#containers
  3133. */
  3134. var Container = /** @class */ (function (_super) {
  3135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3136. /**
  3137. * Creates a new Container
  3138. * @param name defines the name of the container
  3139. */
  3140. function Container(name) {
  3141. var _this = _super.call(this, name) || this;
  3142. _this.name = name;
  3143. /** @hidden */
  3144. _this._children = new Array();
  3145. /** @hidden */
  3146. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3147. /** @hidden */
  3148. _this._background = "";
  3149. /** @hidden */
  3150. _this._adaptWidthToChildren = false;
  3151. /** @hidden */
  3152. _this._adaptHeightToChildren = false;
  3153. /**
  3154. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3155. */
  3156. _this.logLayoutCycleErrors = false;
  3157. /**
  3158. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3159. */
  3160. _this.maxLayoutCycle = 3;
  3161. return _this;
  3162. }
  3163. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3164. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3165. get: function () {
  3166. return this._adaptHeightToChildren;
  3167. },
  3168. set: function (value) {
  3169. if (this._adaptHeightToChildren === value) {
  3170. return;
  3171. }
  3172. this._adaptHeightToChildren = value;
  3173. if (value) {
  3174. this.height = "100%";
  3175. }
  3176. this._markAsDirty();
  3177. },
  3178. enumerable: true,
  3179. configurable: true
  3180. });
  3181. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3182. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3183. get: function () {
  3184. return this._adaptWidthToChildren;
  3185. },
  3186. set: function (value) {
  3187. if (this._adaptWidthToChildren === value) {
  3188. return;
  3189. }
  3190. this._adaptWidthToChildren = value;
  3191. if (value) {
  3192. this.width = "100%";
  3193. }
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "background", {
  3200. /** Gets or sets background color */
  3201. get: function () {
  3202. return this._background;
  3203. },
  3204. set: function (value) {
  3205. if (this._background === value) {
  3206. return;
  3207. }
  3208. this._background = value;
  3209. this._markAsDirty();
  3210. },
  3211. enumerable: true,
  3212. configurable: true
  3213. });
  3214. Object.defineProperty(Container.prototype, "children", {
  3215. /** Gets the list of children */
  3216. get: function () {
  3217. return this._children;
  3218. },
  3219. enumerable: true,
  3220. configurable: true
  3221. });
  3222. Container.prototype._getTypeName = function () {
  3223. return "Container";
  3224. };
  3225. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3226. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3227. var child = _a[_i];
  3228. child._markMatrixAsDirty();
  3229. }
  3230. };
  3231. /**
  3232. * Gets a child using its name
  3233. * @param name defines the child name to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByName = function (name) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.name === name) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Gets a child using its type and its name
  3247. * @param name defines the child name to look for
  3248. * @param type defines the child type to look for
  3249. * @returns the child control if found
  3250. */
  3251. Container.prototype.getChildByType = function (name, type) {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. if (child.typeName === type) {
  3255. return child;
  3256. }
  3257. }
  3258. return null;
  3259. };
  3260. /**
  3261. * Search for a specific control in children
  3262. * @param control defines the control to look for
  3263. * @returns true if the control is in child list
  3264. */
  3265. Container.prototype.containsControl = function (control) {
  3266. return this.children.indexOf(control) !== -1;
  3267. };
  3268. /**
  3269. * Adds a new control to the current container
  3270. * @param control defines the control to add
  3271. * @returns the current container
  3272. */
  3273. Container.prototype.addControl = function (control) {
  3274. if (!control) {
  3275. return this;
  3276. }
  3277. var index = this._children.indexOf(control);
  3278. if (index !== -1) {
  3279. return this;
  3280. }
  3281. control._link(this._host);
  3282. control._markAllAsDirty();
  3283. this._reOrderControl(control);
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes all controls from the current container
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.clearControls = function () {
  3292. var children = this.children.slice();
  3293. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3294. var child = children_1[_i];
  3295. this.removeControl(child);
  3296. }
  3297. return this;
  3298. };
  3299. /**
  3300. * Removes a control from the current container
  3301. * @param control defines the control to remove
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.removeControl = function (control) {
  3305. var index = this._children.indexOf(control);
  3306. if (index !== -1) {
  3307. this._children.splice(index, 1);
  3308. control.parent = null;
  3309. }
  3310. control.linkWithMesh(null);
  3311. if (this._host) {
  3312. this._host._cleanControlAfterRemoval(control);
  3313. }
  3314. this._markAsDirty();
  3315. return this;
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._reOrderControl = function (control) {
  3319. this.removeControl(control);
  3320. var wasAdded = false;
  3321. for (var index = 0; index < this._children.length; index++) {
  3322. if (this._children[index].zIndex > control.zIndex) {
  3323. this._children.splice(index, 0, control);
  3324. wasAdded = true;
  3325. break;
  3326. }
  3327. }
  3328. if (!wasAdded) {
  3329. this._children.push(control);
  3330. }
  3331. control.parent = this;
  3332. this._markAsDirty();
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._offsetLeft = function (offset) {
  3336. _super.prototype._offsetLeft.call(this, offset);
  3337. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._offsetLeft(offset);
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._offsetTop = function (offset) {
  3344. _super.prototype._offsetTop.call(this, offset);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._offsetTop(offset);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._markAllAsDirty = function () {
  3352. _super.prototype._markAllAsDirty.call(this);
  3353. for (var index = 0; index < this._children.length; index++) {
  3354. this._children[index]._markAllAsDirty();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._localDraw = function (context) {
  3359. if (this._background) {
  3360. context.save();
  3361. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3362. context.shadowColor = this.shadowColor;
  3363. context.shadowBlur = this.shadowBlur;
  3364. context.shadowOffsetX = this.shadowOffsetX;
  3365. context.shadowOffsetY = this.shadowOffsetY;
  3366. }
  3367. context.fillStyle = this._background;
  3368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3369. context.restore();
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._link = function (host) {
  3374. _super.prototype._link.call(this, host);
  3375. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3376. var child = _a[_i];
  3377. child._link(host);
  3378. }
  3379. };
  3380. /** @hidden */
  3381. Container.prototype._beforeLayout = function () {
  3382. // Do nothing
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._processMeasures = function (parentMeasure, context) {
  3386. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3387. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3388. this._evaluateClippingState(parentMeasure);
  3389. }
  3390. };
  3391. /** @hidden */
  3392. Container.prototype._layout = function (parentMeasure, context) {
  3393. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3394. return false;
  3395. }
  3396. if (this._isDirty) {
  3397. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3398. }
  3399. var rebuildCount = 0;
  3400. context.save();
  3401. this._applyStates(context);
  3402. this._beforeLayout();
  3403. do {
  3404. var computedWidth = -1;
  3405. var computedHeight = -1;
  3406. this._rebuildLayout = false;
  3407. this._processMeasures(parentMeasure, context);
  3408. if (!this._isClipped) {
  3409. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3410. var child = _a[_i];
  3411. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3412. if (child._layout(this._measureForChildren, context)) {
  3413. if (this.adaptWidthToChildren && child._width.isPixel) {
  3414. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3415. }
  3416. if (this.adaptHeightToChildren && child._height.isPixel) {
  3417. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3418. }
  3419. }
  3420. }
  3421. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3422. if (this.width !== computedWidth + "px") {
  3423. this.width = computedWidth + "px";
  3424. this._rebuildLayout = true;
  3425. }
  3426. }
  3427. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3428. if (this.height !== computedHeight + "px") {
  3429. this.height = computedHeight + "px";
  3430. this._rebuildLayout = true;
  3431. }
  3432. }
  3433. this._postMeasure();
  3434. }
  3435. rebuildCount++;
  3436. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3437. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3438. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3439. }
  3440. context.restore();
  3441. if (this._isDirty) {
  3442. this.invalidateRect();
  3443. this._isDirty = false;
  3444. }
  3445. return true;
  3446. };
  3447. Container.prototype._postMeasure = function () {
  3448. // Do nothing by default
  3449. };
  3450. /** @hidden */
  3451. Container.prototype._draw = function (context, invalidatedRectangle) {
  3452. this._localDraw(context);
  3453. if (this.clipChildren) {
  3454. this._clipForChildren(context);
  3455. }
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. // Only redraw parts of the screen that are invalidated
  3459. if (invalidatedRectangle) {
  3460. if (!child._intersectsRect(invalidatedRectangle)) {
  3461. continue;
  3462. }
  3463. }
  3464. child._render(context, invalidatedRectangle);
  3465. }
  3466. };
  3467. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3468. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3469. if (!this.children) {
  3470. return;
  3471. }
  3472. for (var index = 0; index < this.children.length; index++) {
  3473. var item = this.children[index];
  3474. if (!predicate || predicate(item)) {
  3475. results.push(item);
  3476. }
  3477. if (!directDescendantsOnly) {
  3478. item.getDescendantsToRef(results, false, predicate);
  3479. }
  3480. }
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3484. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3485. return false;
  3486. }
  3487. if (!_super.prototype.contains.call(this, x, y)) {
  3488. return false;
  3489. }
  3490. // Checking backwards to pick closest first
  3491. for (var index = this._children.length - 1; index >= 0; index--) {
  3492. var child = this._children[index];
  3493. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3494. if (child.hoverCursor) {
  3495. this._host._changeCursor(child.hoverCursor);
  3496. }
  3497. return true;
  3498. }
  3499. }
  3500. if (!this.isHitTestVisible) {
  3501. return false;
  3502. }
  3503. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3507. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3508. this._measureForChildren.copyFrom(this._currentMeasure);
  3509. };
  3510. /** Releases associated resources */
  3511. Container.prototype.dispose = function () {
  3512. _super.prototype.dispose.call(this);
  3513. for (var index = this.children.length - 1; index >= 0; index--) {
  3514. this.children[index].dispose();
  3515. }
  3516. };
  3517. return Container;
  3518. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3519. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3520. /***/ }),
  3521. /***/ "./2D/controls/control.ts":
  3522. /*!********************************!*\
  3523. !*** ./2D/controls/control.ts ***!
  3524. \********************************/
  3525. /*! exports provided: Control */
  3526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3527. "use strict";
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3532. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3534. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3535. /**
  3536. * Root class used for all 2D controls
  3537. * @see http://doc.babylonjs.com/how_to/gui#controls
  3538. */
  3539. var Control = /** @class */ (function () {
  3540. // Functions
  3541. /**
  3542. * Creates a new control
  3543. * @param name defines the name of the control
  3544. */
  3545. function Control(
  3546. /** defines the name of the control */
  3547. name) {
  3548. this.name = name;
  3549. this._alpha = 1;
  3550. this._alphaSet = false;
  3551. this._zIndex = 0;
  3552. /** @hidden */
  3553. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3554. this._fontFamily = "Arial";
  3555. this._fontStyle = "";
  3556. this._fontWeight = "";
  3557. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3558. /** @hidden */
  3559. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3560. /** @hidden */
  3561. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3562. this._color = "";
  3563. this._style = null;
  3564. /** @hidden */
  3565. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3566. /** @hidden */
  3567. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3568. /** @hidden */
  3569. this._isDirty = true;
  3570. /** @hidden */
  3571. this._wasDirty = false;
  3572. /** @hidden */
  3573. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. /** @hidden */
  3575. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3576. /** @hidden */
  3577. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3578. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. /** @hidden */
  3583. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3584. /** @hidden */
  3585. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3586. this._scaleX = 1.0;
  3587. this._scaleY = 1.0;
  3588. this._rotation = 0;
  3589. this._transformCenterX = 0.5;
  3590. this._transformCenterY = 0.5;
  3591. /** @hidden */
  3592. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3593. /** @hidden */
  3594. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3595. /** @hidden */
  3596. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._isMatrixDirty = true;
  3598. this._isVisible = true;
  3599. this._isHighlighted = false;
  3600. this._fontSet = false;
  3601. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3602. this._downCount = 0;
  3603. this._enterCount = -1;
  3604. this._doNotRender = false;
  3605. this._downPointerIds = {};
  3606. this._isEnabled = true;
  3607. this._disabledColor = "#9a9a9a";
  3608. /** @hidden */
  3609. this._rebuildLayout = false;
  3610. /** @hidden */
  3611. this._isClipped = false;
  3612. /** @hidden */
  3613. this._automaticSize = false;
  3614. /**
  3615. * Gets or sets an object used to store user defined information for the node
  3616. */
  3617. this.metadata = null;
  3618. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3619. this.isHitTestVisible = true;
  3620. /** Gets or sets a boolean indicating if the control can block pointer events */
  3621. this.isPointerBlocker = false;
  3622. /** Gets or sets a boolean indicating if the control can be focusable */
  3623. this.isFocusInvisible = false;
  3624. /**
  3625. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3626. * 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
  3627. */
  3628. this.clipChildren = true;
  3629. /**
  3630. * Gets or sets a boolean indicating that control content must be clipped
  3631. * 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
  3632. */
  3633. this.clipContent = true;
  3634. /**
  3635. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3636. */
  3637. this.useBitmapCache = false;
  3638. this._shadowOffsetX = 0;
  3639. this._shadowOffsetY = 0;
  3640. this._shadowBlur = 0;
  3641. this._shadowColor = 'black';
  3642. /** Gets or sets the cursor to use when the control is hovered */
  3643. this.hoverCursor = "";
  3644. /** @hidden */
  3645. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3646. /** @hidden */
  3647. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3648. /**
  3649. * An event triggered when the pointer move over the control.
  3650. */
  3651. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3652. /**
  3653. * An event triggered when the pointer move out of the control.
  3654. */
  3655. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3656. /**
  3657. * An event triggered when the pointer taps the control
  3658. */
  3659. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3660. /**
  3661. * An event triggered when pointer up
  3662. */
  3663. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3664. /**
  3665. * An event triggered when a control is clicked on
  3666. */
  3667. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3668. /**
  3669. * An event triggered when pointer enters the control
  3670. */
  3671. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3672. /**
  3673. * An event triggered when the control is marked as dirty
  3674. */
  3675. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3676. /**
  3677. * An event triggered before drawing the control
  3678. */
  3679. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3680. /**
  3681. * An event triggered after the control was drawn
  3682. */
  3683. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3684. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3685. }
  3686. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3687. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3688. get: function () {
  3689. return this._shadowOffsetX;
  3690. },
  3691. set: function (value) {
  3692. if (this._shadowOffsetX === value) {
  3693. return;
  3694. }
  3695. this._shadowOffsetX = value;
  3696. this._markAsDirty();
  3697. },
  3698. enumerable: true,
  3699. configurable: true
  3700. });
  3701. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3702. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3703. get: function () {
  3704. return this._shadowOffsetY;
  3705. },
  3706. set: function (value) {
  3707. if (this._shadowOffsetY === value) {
  3708. return;
  3709. }
  3710. this._shadowOffsetY = value;
  3711. this._markAsDirty();
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. Object.defineProperty(Control.prototype, "shadowBlur", {
  3717. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3718. get: function () {
  3719. return this._shadowBlur;
  3720. },
  3721. set: function (value) {
  3722. if (this._shadowBlur === value) {
  3723. return;
  3724. }
  3725. this._shadowBlur = value;
  3726. this._markAsDirty();
  3727. },
  3728. enumerable: true,
  3729. configurable: true
  3730. });
  3731. Object.defineProperty(Control.prototype, "shadowColor", {
  3732. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3733. get: function () {
  3734. return this._shadowColor;
  3735. },
  3736. set: function (value) {
  3737. if (this._shadowColor === value) {
  3738. return;
  3739. }
  3740. this._shadowColor = value;
  3741. this._markAsDirty();
  3742. },
  3743. enumerable: true,
  3744. configurable: true
  3745. });
  3746. Object.defineProperty(Control.prototype, "typeName", {
  3747. // Properties
  3748. /** Gets the control type name */
  3749. get: function () {
  3750. return this._getTypeName();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. /**
  3756. * Get the current class name of the control.
  3757. * @returns current class name
  3758. */
  3759. Control.prototype.getClassName = function () {
  3760. return this._getTypeName();
  3761. };
  3762. Object.defineProperty(Control.prototype, "host", {
  3763. /**
  3764. * Get the hosting AdvancedDynamicTexture
  3765. */
  3766. get: function () {
  3767. return this._host;
  3768. },
  3769. enumerable: true,
  3770. configurable: true
  3771. });
  3772. Object.defineProperty(Control.prototype, "fontOffset", {
  3773. /** Gets or set information about font offsets (used to render and align text) */
  3774. get: function () {
  3775. return this._fontOffset;
  3776. },
  3777. set: function (offset) {
  3778. this._fontOffset = offset;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Control.prototype, "alpha", {
  3784. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3785. get: function () {
  3786. return this._alpha;
  3787. },
  3788. set: function (value) {
  3789. if (this._alpha === value) {
  3790. return;
  3791. }
  3792. this._alphaSet = true;
  3793. this._alpha = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "isHighlighted", {
  3800. /**
  3801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3802. */
  3803. get: function () {
  3804. return this._isHighlighted;
  3805. },
  3806. set: function (value) {
  3807. if (this._isHighlighted === value) {
  3808. return;
  3809. }
  3810. this._isHighlighted = value;
  3811. this._markAsDirty();
  3812. },
  3813. enumerable: true,
  3814. configurable: true
  3815. });
  3816. Object.defineProperty(Control.prototype, "scaleX", {
  3817. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3818. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3819. */
  3820. get: function () {
  3821. return this._scaleX;
  3822. },
  3823. set: function (value) {
  3824. if (this._scaleX === value) {
  3825. return;
  3826. }
  3827. this._scaleX = value;
  3828. this._markAsDirty();
  3829. this._markMatrixAsDirty();
  3830. },
  3831. enumerable: true,
  3832. configurable: true
  3833. });
  3834. Object.defineProperty(Control.prototype, "scaleY", {
  3835. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3836. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3837. */
  3838. get: function () {
  3839. return this._scaleY;
  3840. },
  3841. set: function (value) {
  3842. if (this._scaleY === value) {
  3843. return;
  3844. }
  3845. this._scaleY = value;
  3846. this._markAsDirty();
  3847. this._markMatrixAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "rotation", {
  3853. /** Gets or sets the rotation angle (0 by default)
  3854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3855. */
  3856. get: function () {
  3857. return this._rotation;
  3858. },
  3859. set: function (value) {
  3860. if (this._rotation === value) {
  3861. return;
  3862. }
  3863. this._rotation = value;
  3864. this._markAsDirty();
  3865. this._markMatrixAsDirty();
  3866. },
  3867. enumerable: true,
  3868. configurable: true
  3869. });
  3870. Object.defineProperty(Control.prototype, "transformCenterY", {
  3871. /** Gets or sets the transformation center on Y axis (0 by default)
  3872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3873. */
  3874. get: function () {
  3875. return this._transformCenterY;
  3876. },
  3877. set: function (value) {
  3878. if (this._transformCenterY === value) {
  3879. return;
  3880. }
  3881. this._transformCenterY = value;
  3882. this._markAsDirty();
  3883. this._markMatrixAsDirty();
  3884. },
  3885. enumerable: true,
  3886. configurable: true
  3887. });
  3888. Object.defineProperty(Control.prototype, "transformCenterX", {
  3889. /** Gets or sets the transformation center on X axis (0 by default)
  3890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3891. */
  3892. get: function () {
  3893. return this._transformCenterX;
  3894. },
  3895. set: function (value) {
  3896. if (this._transformCenterX === value) {
  3897. return;
  3898. }
  3899. this._transformCenterX = value;
  3900. this._markAsDirty();
  3901. this._markMatrixAsDirty();
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3907. /**
  3908. * Gets or sets the horizontal alignment
  3909. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3910. */
  3911. get: function () {
  3912. return this._horizontalAlignment;
  3913. },
  3914. set: function (value) {
  3915. if (this._horizontalAlignment === value) {
  3916. return;
  3917. }
  3918. this._horizontalAlignment = value;
  3919. this._markAsDirty();
  3920. },
  3921. enumerable: true,
  3922. configurable: true
  3923. });
  3924. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3925. /**
  3926. * Gets or sets the vertical alignment
  3927. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3928. */
  3929. get: function () {
  3930. return this._verticalAlignment;
  3931. },
  3932. set: function (value) {
  3933. if (this._verticalAlignment === value) {
  3934. return;
  3935. }
  3936. this._verticalAlignment = value;
  3937. this._markAsDirty();
  3938. },
  3939. enumerable: true,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "width", {
  3943. /**
  3944. * Gets or sets control width
  3945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3946. */
  3947. get: function () {
  3948. return this._width.toString(this._host);
  3949. },
  3950. set: function (value) {
  3951. if (this._width.toString(this._host) === value) {
  3952. return;
  3953. }
  3954. if (this._width.fromString(value)) {
  3955. this._markAsDirty();
  3956. }
  3957. },
  3958. enumerable: true,
  3959. configurable: true
  3960. });
  3961. Object.defineProperty(Control.prototype, "widthInPixels", {
  3962. /**
  3963. * Gets or sets the control width in pixel
  3964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3965. */
  3966. get: function () {
  3967. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3968. },
  3969. set: function (value) {
  3970. if (isNaN(value)) {
  3971. return;
  3972. }
  3973. this.width = value + "px";
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets or sets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. set: function (value) {
  4006. if (isNaN(value)) {
  4007. return;
  4008. }
  4009. this.height = value + "px";
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "fontFamily", {
  4015. /** Gets or set font family */
  4016. get: function () {
  4017. if (!this._fontSet) {
  4018. return "";
  4019. }
  4020. return this._fontFamily;
  4021. },
  4022. set: function (value) {
  4023. if (this._fontFamily === value) {
  4024. return;
  4025. }
  4026. this._fontFamily = value;
  4027. this._resetFontCache();
  4028. },
  4029. enumerable: true,
  4030. configurable: true
  4031. });
  4032. Object.defineProperty(Control.prototype, "fontStyle", {
  4033. /** Gets or sets font style */
  4034. get: function () {
  4035. return this._fontStyle;
  4036. },
  4037. set: function (value) {
  4038. if (this._fontStyle === value) {
  4039. return;
  4040. }
  4041. this._fontStyle = value;
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "fontWeight", {
  4048. /** Gets or sets font weight */
  4049. get: function () {
  4050. return this._fontWeight;
  4051. },
  4052. set: function (value) {
  4053. if (this._fontWeight === value) {
  4054. return;
  4055. }
  4056. this._fontWeight = value;
  4057. this._resetFontCache();
  4058. },
  4059. enumerable: true,
  4060. configurable: true
  4061. });
  4062. Object.defineProperty(Control.prototype, "style", {
  4063. /**
  4064. * Gets or sets style
  4065. * @see http://doc.babylonjs.com/how_to/gui#styles
  4066. */
  4067. get: function () {
  4068. return this._style;
  4069. },
  4070. set: function (value) {
  4071. var _this = this;
  4072. if (this._style) {
  4073. this._style.onChangedObservable.remove(this._styleObserver);
  4074. this._styleObserver = null;
  4075. }
  4076. this._style = value;
  4077. if (this._style) {
  4078. this._styleObserver = this._style.onChangedObservable.add(function () {
  4079. _this._markAsDirty();
  4080. _this._resetFontCache();
  4081. });
  4082. }
  4083. this._markAsDirty();
  4084. this._resetFontCache();
  4085. },
  4086. enumerable: true,
  4087. configurable: true
  4088. });
  4089. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4090. /** @hidden */
  4091. get: function () {
  4092. return this._fontSize.isPercentage;
  4093. },
  4094. enumerable: true,
  4095. configurable: true
  4096. });
  4097. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4098. /** Gets or sets font size in pixels */
  4099. get: function () {
  4100. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4101. if (fontSizeToUse.isPixel) {
  4102. return fontSizeToUse.getValue(this._host);
  4103. }
  4104. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4105. },
  4106. set: function (value) {
  4107. if (isNaN(value)) {
  4108. return;
  4109. }
  4110. this.fontSize = value + "px";
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "fontSize", {
  4116. /** Gets or sets font size */
  4117. get: function () {
  4118. return this._fontSize.toString(this._host);
  4119. },
  4120. set: function (value) {
  4121. if (this._fontSize.toString(this._host) === value) {
  4122. return;
  4123. }
  4124. if (this._fontSize.fromString(value)) {
  4125. this._markAsDirty();
  4126. this._resetFontCache();
  4127. }
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "color", {
  4133. /** Gets or sets foreground color */
  4134. get: function () {
  4135. return this._color;
  4136. },
  4137. set: function (value) {
  4138. if (this._color === value) {
  4139. return;
  4140. }
  4141. this._color = value;
  4142. this._markAsDirty();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "zIndex", {
  4148. /** Gets or sets z index which is used to reorder controls on the z axis */
  4149. get: function () {
  4150. return this._zIndex;
  4151. },
  4152. set: function (value) {
  4153. if (this.zIndex === value) {
  4154. return;
  4155. }
  4156. this._zIndex = value;
  4157. if (this.parent) {
  4158. this.parent._reOrderControl(this);
  4159. }
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "notRenderable", {
  4165. /** Gets or sets a boolean indicating if the control can be rendered */
  4166. get: function () {
  4167. return this._doNotRender;
  4168. },
  4169. set: function (value) {
  4170. if (this._doNotRender === value) {
  4171. return;
  4172. }
  4173. this._doNotRender = value;
  4174. this._markAsDirty();
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "isVisible", {
  4180. /** Gets or sets a boolean indicating if the control is visible */
  4181. get: function () {
  4182. return this._isVisible;
  4183. },
  4184. set: function (value) {
  4185. if (this._isVisible === value) {
  4186. return;
  4187. }
  4188. this._isVisible = value;
  4189. this._markAsDirty(true);
  4190. },
  4191. enumerable: true,
  4192. configurable: true
  4193. });
  4194. Object.defineProperty(Control.prototype, "isDirty", {
  4195. /** Gets a boolean indicating that the control needs to update its rendering */
  4196. get: function () {
  4197. return this._isDirty;
  4198. },
  4199. enumerable: true,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "linkedMesh", {
  4203. /**
  4204. * Gets the current linked mesh (or null if none)
  4205. */
  4206. get: function () {
  4207. return this._linkedMesh;
  4208. },
  4209. enumerable: true,
  4210. configurable: true
  4211. });
  4212. Object.defineProperty(Control.prototype, "paddingLeft", {
  4213. /**
  4214. * Gets or sets a value indicating the padding to use on the left of the control
  4215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4216. */
  4217. get: function () {
  4218. return this._paddingLeft.toString(this._host);
  4219. },
  4220. set: function (value) {
  4221. if (this._paddingLeft.fromString(value)) {
  4222. this._markAsDirty();
  4223. }
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4229. /**
  4230. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4235. },
  4236. set: function (value) {
  4237. if (isNaN(value)) {
  4238. return;
  4239. }
  4240. this.paddingLeft = value + "px";
  4241. },
  4242. enumerable: true,
  4243. configurable: true
  4244. });
  4245. Object.defineProperty(Control.prototype, "paddingRight", {
  4246. /**
  4247. * Gets or sets a value indicating the padding to use on the right of the control
  4248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4249. */
  4250. get: function () {
  4251. return this._paddingRight.toString(this._host);
  4252. },
  4253. set: function (value) {
  4254. if (this._paddingRight.fromString(value)) {
  4255. this._markAsDirty();
  4256. }
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4262. /**
  4263. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4268. },
  4269. set: function (value) {
  4270. if (isNaN(value)) {
  4271. return;
  4272. }
  4273. this.paddingRight = value + "px";
  4274. },
  4275. enumerable: true,
  4276. configurable: true
  4277. });
  4278. Object.defineProperty(Control.prototype, "paddingTop", {
  4279. /**
  4280. * Gets or sets a value indicating the padding to use on the top of the control
  4281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4282. */
  4283. get: function () {
  4284. return this._paddingTop.toString(this._host);
  4285. },
  4286. set: function (value) {
  4287. if (this._paddingTop.fromString(value)) {
  4288. this._markAsDirty();
  4289. }
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4295. /**
  4296. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4298. */
  4299. get: function () {
  4300. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4301. },
  4302. set: function (value) {
  4303. if (isNaN(value)) {
  4304. return;
  4305. }
  4306. this.paddingTop = value + "px";
  4307. },
  4308. enumerable: true,
  4309. configurable: true
  4310. });
  4311. Object.defineProperty(Control.prototype, "paddingBottom", {
  4312. /**
  4313. * Gets or sets a value indicating the padding to use on the bottom of the control
  4314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4315. */
  4316. get: function () {
  4317. return this._paddingBottom.toString(this._host);
  4318. },
  4319. set: function (value) {
  4320. if (this._paddingBottom.fromString(value)) {
  4321. this._markAsDirty();
  4322. }
  4323. },
  4324. enumerable: true,
  4325. configurable: true
  4326. });
  4327. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4328. /**
  4329. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4331. */
  4332. get: function () {
  4333. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4334. },
  4335. set: function (value) {
  4336. if (isNaN(value)) {
  4337. return;
  4338. }
  4339. this.paddingBottom = value + "px";
  4340. },
  4341. enumerable: true,
  4342. configurable: true
  4343. });
  4344. Object.defineProperty(Control.prototype, "left", {
  4345. /**
  4346. * Gets or sets a value indicating the left coordinate of the control
  4347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4348. */
  4349. get: function () {
  4350. return this._left.toString(this._host);
  4351. },
  4352. set: function (value) {
  4353. if (this._left.fromString(value)) {
  4354. this._markAsDirty();
  4355. }
  4356. },
  4357. enumerable: true,
  4358. configurable: true
  4359. });
  4360. Object.defineProperty(Control.prototype, "leftInPixels", {
  4361. /**
  4362. * Gets or sets a value indicating the left coordinate in pixels of the control
  4363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4364. */
  4365. get: function () {
  4366. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4367. },
  4368. set: function (value) {
  4369. if (isNaN(value)) {
  4370. return;
  4371. }
  4372. this.left = value + "px";
  4373. },
  4374. enumerable: true,
  4375. configurable: true
  4376. });
  4377. Object.defineProperty(Control.prototype, "top", {
  4378. /**
  4379. * Gets or sets a value indicating the top coordinate of the control
  4380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4381. */
  4382. get: function () {
  4383. return this._top.toString(this._host);
  4384. },
  4385. set: function (value) {
  4386. if (this._top.fromString(value)) {
  4387. this._markAsDirty();
  4388. }
  4389. },
  4390. enumerable: true,
  4391. configurable: true
  4392. });
  4393. Object.defineProperty(Control.prototype, "topInPixels", {
  4394. /**
  4395. * Gets or sets a value indicating the top coordinate in pixels of the control
  4396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4397. */
  4398. get: function () {
  4399. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4400. },
  4401. set: function (value) {
  4402. if (isNaN(value)) {
  4403. return;
  4404. }
  4405. this.top = value + "px";
  4406. },
  4407. enumerable: true,
  4408. configurable: true
  4409. });
  4410. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4411. /**
  4412. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4414. */
  4415. get: function () {
  4416. return this._linkOffsetX.toString(this._host);
  4417. },
  4418. set: function (value) {
  4419. if (this._linkOffsetX.fromString(value)) {
  4420. this._markAsDirty();
  4421. }
  4422. },
  4423. enumerable: true,
  4424. configurable: true
  4425. });
  4426. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4427. /**
  4428. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4429. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4430. */
  4431. get: function () {
  4432. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4433. },
  4434. set: function (value) {
  4435. if (isNaN(value)) {
  4436. return;
  4437. }
  4438. this.linkOffsetX = value + "px";
  4439. },
  4440. enumerable: true,
  4441. configurable: true
  4442. });
  4443. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4444. /**
  4445. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4447. */
  4448. get: function () {
  4449. return this._linkOffsetY.toString(this._host);
  4450. },
  4451. set: function (value) {
  4452. if (this._linkOffsetY.fromString(value)) {
  4453. this._markAsDirty();
  4454. }
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4460. /**
  4461. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4463. */
  4464. get: function () {
  4465. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4466. },
  4467. set: function (value) {
  4468. if (isNaN(value)) {
  4469. return;
  4470. }
  4471. this.linkOffsetY = value + "px";
  4472. },
  4473. enumerable: true,
  4474. configurable: true
  4475. });
  4476. Object.defineProperty(Control.prototype, "centerX", {
  4477. /** Gets the center coordinate on X axis */
  4478. get: function () {
  4479. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "centerY", {
  4485. /** Gets the center coordinate on Y axis */
  4486. get: function () {
  4487. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4488. },
  4489. enumerable: true,
  4490. configurable: true
  4491. });
  4492. Object.defineProperty(Control.prototype, "isEnabled", {
  4493. /** Gets or sets if control is Enabled*/
  4494. get: function () {
  4495. return this._isEnabled;
  4496. },
  4497. set: function (value) {
  4498. if (this._isEnabled === value) {
  4499. return;
  4500. }
  4501. this._isEnabled = value;
  4502. this._markAsDirty();
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "disabledColor", {
  4508. /** Gets or sets background color of control if it's disabled*/
  4509. get: function () {
  4510. return this._disabledColor;
  4511. },
  4512. set: function (value) {
  4513. if (this._disabledColor === value) {
  4514. return;
  4515. }
  4516. this._disabledColor = value;
  4517. this._markAsDirty();
  4518. },
  4519. enumerable: true,
  4520. configurable: true
  4521. });
  4522. /** @hidden */
  4523. Control.prototype._getTypeName = function () {
  4524. return "Control";
  4525. };
  4526. /**
  4527. * Gets the first ascendant in the hierarchy of the given type
  4528. * @param className defines the required type
  4529. * @returns the ascendant or null if not found
  4530. */
  4531. Control.prototype.getAscendantOfClass = function (className) {
  4532. if (!this.parent) {
  4533. return null;
  4534. }
  4535. if (this.parent.getClassName() === className) {
  4536. return this.parent;
  4537. }
  4538. return this.parent.getAscendantOfClass(className);
  4539. };
  4540. /** @hidden */
  4541. Control.prototype._resetFontCache = function () {
  4542. this._fontSet = true;
  4543. this._markAsDirty();
  4544. };
  4545. /**
  4546. * Determines if a container is an ascendant of the current control
  4547. * @param container defines the container to look for
  4548. * @returns true if the container is one of the ascendant of the control
  4549. */
  4550. Control.prototype.isAscendant = function (container) {
  4551. if (!this.parent) {
  4552. return false;
  4553. }
  4554. if (this.parent === container) {
  4555. return true;
  4556. }
  4557. return this.parent.isAscendant(container);
  4558. };
  4559. /**
  4560. * Gets coordinates in local control space
  4561. * @param globalCoordinates defines the coordinates to transform
  4562. * @returns the new coordinates in local space
  4563. */
  4564. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4565. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4566. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4567. return result;
  4568. };
  4569. /**
  4570. * Gets coordinates in local control space
  4571. * @param globalCoordinates defines the coordinates to transform
  4572. * @param result defines the target vector2 where to store the result
  4573. * @returns the current control
  4574. */
  4575. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4576. result.x = globalCoordinates.x - this._currentMeasure.left;
  4577. result.y = globalCoordinates.y - this._currentMeasure.top;
  4578. return this;
  4579. };
  4580. /**
  4581. * Gets coordinates in parent local control space
  4582. * @param globalCoordinates defines the coordinates to transform
  4583. * @returns the new coordinates in parent local space
  4584. */
  4585. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4586. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4587. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4588. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4589. return result;
  4590. };
  4591. /**
  4592. * Move the current control to a vector3 position projected onto the screen.
  4593. * @param position defines the target position
  4594. * @param scene defines the hosting scene
  4595. */
  4596. Control.prototype.moveToVector3 = function (position, scene) {
  4597. if (!this._host || this.parent !== this._host._rootContainer) {
  4598. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4599. return;
  4600. }
  4601. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4602. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4603. var globalViewport = this._host._getGlobalViewport(scene);
  4604. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4605. this._moveToProjectedPosition(projectedPosition);
  4606. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4607. this.notRenderable = true;
  4608. return;
  4609. }
  4610. this.notRenderable = false;
  4611. };
  4612. /**
  4613. * Will store all controls that have this control as ascendant in a given array
  4614. * @param results defines the array where to store the descendants
  4615. * @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
  4616. * @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
  4617. */
  4618. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4619. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4620. // Do nothing by default
  4621. };
  4622. /**
  4623. * Will return all controls that have this control as ascendant
  4624. * @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
  4625. * @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
  4626. * @return all child controls
  4627. */
  4628. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4629. var results = new Array();
  4630. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4631. return results;
  4632. };
  4633. /**
  4634. * Link current control with a target mesh
  4635. * @param mesh defines the mesh to link with
  4636. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4637. */
  4638. Control.prototype.linkWithMesh = function (mesh) {
  4639. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4640. if (mesh) {
  4641. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4642. }
  4643. return;
  4644. }
  4645. var index = this._host._linkedControls.indexOf(this);
  4646. if (index !== -1) {
  4647. this._linkedMesh = mesh;
  4648. if (!mesh) {
  4649. this._host._linkedControls.splice(index, 1);
  4650. }
  4651. return;
  4652. }
  4653. else if (!mesh) {
  4654. return;
  4655. }
  4656. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4657. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4658. this._linkedMesh = mesh;
  4659. this._host._linkedControls.push(this);
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4663. var oldLeft = this._left.getValue(this._host);
  4664. var oldTop = this._top.getValue(this._host);
  4665. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4666. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4667. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4668. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4669. newLeft = oldLeft;
  4670. }
  4671. if (Math.abs(newTop - oldTop) < 0.5) {
  4672. newTop = oldTop;
  4673. }
  4674. }
  4675. this.left = newLeft + "px";
  4676. this.top = newTop + "px";
  4677. this._left.ignoreAdaptiveScaling = true;
  4678. this._top.ignoreAdaptiveScaling = true;
  4679. this._markAsDirty();
  4680. };
  4681. /** @hidden */
  4682. Control.prototype._offsetLeft = function (offset) {
  4683. this._isDirty = true;
  4684. this._currentMeasure.left += offset;
  4685. };
  4686. /** @hidden */
  4687. Control.prototype._offsetTop = function (offset) {
  4688. this._isDirty = true;
  4689. this._currentMeasure.top += offset;
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._markMatrixAsDirty = function () {
  4693. this._isMatrixDirty = true;
  4694. this._flagDescendantsAsMatrixDirty();
  4695. };
  4696. /** @hidden */
  4697. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4698. // No child
  4699. };
  4700. /** @hidden */
  4701. Control.prototype._intersectsRect = function (rect) {
  4702. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4703. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4704. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4708. return false;
  4709. }
  4710. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4711. return false;
  4712. }
  4713. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4714. return false;
  4715. }
  4716. return true;
  4717. };
  4718. /** @hidden */
  4719. Control.prototype.invalidateRect = function () {
  4720. this._transform();
  4721. if (this.host && this.host.useInvalidateRectOptimization) {
  4722. // Rotate by transform to get the measure transformed to global space
  4723. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4724. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4725. // the previous measure is used to properly clear a control that is scaled down
  4726. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4728. // Expand rect based on shadows
  4729. var shadowOffsetX = this.shadowOffsetX;
  4730. var shadowOffsetY = this.shadowOffsetY;
  4731. var shadowBlur = this.shadowBlur;
  4732. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4733. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4734. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4735. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4736. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4737. }
  4738. else {
  4739. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4740. }
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAsDirty = function (force) {
  4745. if (force === void 0) { force = false; }
  4746. if (!this._isVisible && !force) {
  4747. return;
  4748. }
  4749. this._isDirty = true;
  4750. // Redraw only this rectangle
  4751. if (this._host) {
  4752. this._host.markAsDirty();
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._markAllAsDirty = function () {
  4757. this._markAsDirty();
  4758. if (this._font) {
  4759. this._prepareFont();
  4760. }
  4761. };
  4762. /** @hidden */
  4763. Control.prototype._link = function (host) {
  4764. this._host = host;
  4765. if (this._host) {
  4766. this.uniqueId = this._host.getScene().getUniqueId();
  4767. }
  4768. };
  4769. /** @hidden */
  4770. Control.prototype._transform = function (context) {
  4771. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4772. return;
  4773. }
  4774. // postTranslate
  4775. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4776. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4777. if (context) {
  4778. context.translate(offsetX, offsetY);
  4779. // rotate
  4780. context.rotate(this._rotation);
  4781. // scale
  4782. context.scale(this._scaleX, this._scaleY);
  4783. // preTranslate
  4784. context.translate(-offsetX, -offsetY);
  4785. }
  4786. // Need to update matrices?
  4787. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4788. this._cachedOffsetX = offsetX;
  4789. this._cachedOffsetY = offsetY;
  4790. this._isMatrixDirty = false;
  4791. this._flagDescendantsAsMatrixDirty();
  4792. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4793. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._renderHighlight = function (context) {
  4798. if (!this.isHighlighted) {
  4799. return;
  4800. }
  4801. context.save();
  4802. context.strokeStyle = "#4affff";
  4803. context.lineWidth = 2;
  4804. this._renderHighlightSpecific(context);
  4805. context.restore();
  4806. };
  4807. /** @hidden */
  4808. Control.prototype._renderHighlightSpecific = function (context) {
  4809. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._applyStates = function (context) {
  4813. if (this._isFontSizeInPercentage) {
  4814. this._fontSet = true;
  4815. }
  4816. if (this._fontSet) {
  4817. this._prepareFont();
  4818. this._fontSet = false;
  4819. }
  4820. if (this._font) {
  4821. context.font = this._font;
  4822. }
  4823. if (this._color) {
  4824. context.fillStyle = this._color;
  4825. }
  4826. if (Control.AllowAlphaInheritance) {
  4827. context.globalAlpha *= this._alpha;
  4828. }
  4829. else if (this._alphaSet) {
  4830. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4831. }
  4832. };
  4833. /** @hidden */
  4834. Control.prototype._layout = function (parentMeasure, context) {
  4835. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4836. return false;
  4837. }
  4838. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4839. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4840. context.save();
  4841. this._applyStates(context);
  4842. var rebuildCount = 0;
  4843. do {
  4844. this._rebuildLayout = false;
  4845. this._processMeasures(parentMeasure, context);
  4846. rebuildCount++;
  4847. } while (this._rebuildLayout && rebuildCount < 3);
  4848. if (rebuildCount >= 3) {
  4849. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4850. }
  4851. context.restore();
  4852. this.invalidateRect();
  4853. this._evaluateClippingState(parentMeasure);
  4854. }
  4855. this._wasDirty = this._isDirty;
  4856. this._isDirty = false;
  4857. return true;
  4858. };
  4859. /** @hidden */
  4860. Control.prototype._processMeasures = function (parentMeasure, context) {
  4861. this._currentMeasure.copyFrom(parentMeasure);
  4862. // Let children take some pre-measurement actions
  4863. this._preMeasure(parentMeasure, context);
  4864. this._measure();
  4865. this._computeAlignment(parentMeasure, context);
  4866. // Convert to int values
  4867. this._currentMeasure.left = this._currentMeasure.left | 0;
  4868. this._currentMeasure.top = this._currentMeasure.top | 0;
  4869. this._currentMeasure.width = this._currentMeasure.width | 0;
  4870. this._currentMeasure.height = this._currentMeasure.height | 0;
  4871. // Let children add more features
  4872. this._additionalProcessing(parentMeasure, context);
  4873. this._cachedParentMeasure.copyFrom(parentMeasure);
  4874. if (this.onDirtyObservable.hasObservers()) {
  4875. this.onDirtyObservable.notifyObservers(this);
  4876. }
  4877. };
  4878. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4879. if (this.parent && this.parent.clipChildren) {
  4880. // Early clip
  4881. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4886. this._isClipped = true;
  4887. return;
  4888. }
  4889. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4890. this._isClipped = true;
  4891. return;
  4892. }
  4893. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4894. this._isClipped = true;
  4895. return;
  4896. }
  4897. }
  4898. this._isClipped = false;
  4899. };
  4900. /** @hidden */
  4901. Control.prototype._measure = function () {
  4902. // Width / Height
  4903. if (this._width.isPixel) {
  4904. this._currentMeasure.width = this._width.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.width *= this._width.getValue(this._host);
  4908. }
  4909. if (this._height.isPixel) {
  4910. this._currentMeasure.height = this._height.getValue(this._host);
  4911. }
  4912. else {
  4913. this._currentMeasure.height *= this._height.getValue(this._host);
  4914. }
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4918. var width = this._currentMeasure.width;
  4919. var height = this._currentMeasure.height;
  4920. var parentWidth = parentMeasure.width;
  4921. var parentHeight = parentMeasure.height;
  4922. // Left / top
  4923. var x = 0;
  4924. var y = 0;
  4925. switch (this.horizontalAlignment) {
  4926. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4927. x = 0;
  4928. break;
  4929. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4930. x = parentWidth - width;
  4931. break;
  4932. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4933. x = (parentWidth - width) / 2;
  4934. break;
  4935. }
  4936. switch (this.verticalAlignment) {
  4937. case Control.VERTICAL_ALIGNMENT_TOP:
  4938. y = 0;
  4939. break;
  4940. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4941. y = parentHeight - height;
  4942. break;
  4943. case Control.VERTICAL_ALIGNMENT_CENTER:
  4944. y = (parentHeight - height) / 2;
  4945. break;
  4946. }
  4947. if (this._paddingLeft.isPixel) {
  4948. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4949. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4950. }
  4951. else {
  4952. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4953. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4954. }
  4955. if (this._paddingRight.isPixel) {
  4956. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4957. }
  4958. else {
  4959. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4960. }
  4961. if (this._paddingTop.isPixel) {
  4962. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4963. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4964. }
  4965. else {
  4966. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4967. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4968. }
  4969. if (this._paddingBottom.isPixel) {
  4970. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4974. }
  4975. if (this._left.isPixel) {
  4976. this._currentMeasure.left += this._left.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4980. }
  4981. if (this._top.isPixel) {
  4982. this._currentMeasure.top += this._top.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4986. }
  4987. this._currentMeasure.left += x;
  4988. this._currentMeasure.top += y;
  4989. };
  4990. /** @hidden */
  4991. Control.prototype._preMeasure = function (parentMeasure, context) {
  4992. // Do nothing
  4993. };
  4994. /** @hidden */
  4995. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4996. // Do nothing
  4997. };
  4998. /** @hidden */
  4999. Control.prototype._clipForChildren = function (context) {
  5000. // DO nothing
  5001. };
  5002. Control.prototype._clip = function (context, invalidatedRectangle) {
  5003. context.beginPath();
  5004. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5005. if (invalidatedRectangle) {
  5006. // Rotate the invalidated rect into the control's space
  5007. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5008. // Get the intersection of the rect in context space and the current context
  5009. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5010. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5011. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5012. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5013. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5014. Control._ClipMeasure.copyFrom(intersection);
  5015. }
  5016. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5017. var shadowOffsetX = this.shadowOffsetX;
  5018. var shadowOffsetY = this.shadowOffsetY;
  5019. var shadowBlur = this.shadowBlur;
  5020. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5021. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5022. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5023. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5024. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5025. }
  5026. else {
  5027. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5028. }
  5029. context.clip();
  5030. };
  5031. /** @hidden */
  5032. Control.prototype._render = function (context, invalidatedRectangle) {
  5033. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5034. this._isDirty = false;
  5035. return false;
  5036. }
  5037. context.save();
  5038. this._applyStates(context);
  5039. // Transform
  5040. this._transform(context);
  5041. // Clip
  5042. if (this.clipContent) {
  5043. this._clip(context, invalidatedRectangle);
  5044. }
  5045. if (this.onBeforeDrawObservable.hasObservers()) {
  5046. this.onBeforeDrawObservable.notifyObservers(this);
  5047. }
  5048. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5049. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5050. }
  5051. else {
  5052. this._draw(context, invalidatedRectangle);
  5053. }
  5054. if (this.useBitmapCache && this._wasDirty) {
  5055. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5056. }
  5057. this._renderHighlight(context);
  5058. if (this.onAfterDrawObservable.hasObservers()) {
  5059. this.onAfterDrawObservable.notifyObservers(this);
  5060. }
  5061. context.restore();
  5062. return true;
  5063. };
  5064. /** @hidden */
  5065. Control.prototype._draw = function (context, invalidatedRectangle) {
  5066. // Do nothing
  5067. };
  5068. /**
  5069. * Tests if a given coordinates belong to the current control
  5070. * @param x defines x coordinate to test
  5071. * @param y defines y coordinate to test
  5072. * @returns true if the coordinates are inside the control
  5073. */
  5074. Control.prototype.contains = function (x, y) {
  5075. // Invert transform
  5076. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5077. x = this._transformedPosition.x;
  5078. y = this._transformedPosition.y;
  5079. // Check
  5080. if (x < this._currentMeasure.left) {
  5081. return false;
  5082. }
  5083. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5084. return false;
  5085. }
  5086. if (y < this._currentMeasure.top) {
  5087. return false;
  5088. }
  5089. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5090. return false;
  5091. }
  5092. if (this.isPointerBlocker) {
  5093. this._host._shouldBlockPointer = true;
  5094. }
  5095. return true;
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5099. if (!this._isEnabled) {
  5100. return false;
  5101. }
  5102. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5103. return false;
  5104. }
  5105. if (!this.contains(x, y)) {
  5106. return false;
  5107. }
  5108. this._processObservables(type, x, y, pointerId, buttonIndex);
  5109. return true;
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5113. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5114. if (canNotify && this.parent != null) {
  5115. this.parent._onPointerMove(target, coordinates, pointerId);
  5116. }
  5117. };
  5118. /** @hidden */
  5119. Control.prototype._onPointerEnter = function (target) {
  5120. if (!this._isEnabled) {
  5121. return false;
  5122. }
  5123. if (this._enterCount > 0) {
  5124. return false;
  5125. }
  5126. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5127. this._enterCount = 0;
  5128. }
  5129. this._enterCount++;
  5130. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5131. if (canNotify && this.parent != null) {
  5132. this.parent._onPointerEnter(target);
  5133. }
  5134. return true;
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._onPointerOut = function (target, force) {
  5138. if (force === void 0) { force = false; }
  5139. if (!force && (!this._isEnabled || target === this)) {
  5140. return;
  5141. }
  5142. this._enterCount = 0;
  5143. var canNotify = true;
  5144. if (!target.isAscendant(this)) {
  5145. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5146. }
  5147. if (canNotify && this.parent != null) {
  5148. this.parent._onPointerOut(target, force);
  5149. }
  5150. };
  5151. /** @hidden */
  5152. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5153. // Prevent pointerout to lose control context.
  5154. // Event redundancy is checked inside the function.
  5155. this._onPointerEnter(this);
  5156. if (this._downCount !== 0) {
  5157. return false;
  5158. }
  5159. this._downCount++;
  5160. this._downPointerIds[pointerId] = true;
  5161. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5162. if (canNotify && this.parent != null) {
  5163. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5164. }
  5165. return true;
  5166. };
  5167. /** @hidden */
  5168. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5169. if (!this._isEnabled) {
  5170. return;
  5171. }
  5172. this._downCount = 0;
  5173. delete this._downPointerIds[pointerId];
  5174. var canNotifyClick = notifyClick;
  5175. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5176. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5177. }
  5178. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5179. if (canNotify && this.parent != null) {
  5180. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._forcePointerUp = function (pointerId) {
  5185. if (pointerId === void 0) { pointerId = null; }
  5186. if (pointerId !== null) {
  5187. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5188. }
  5189. else {
  5190. for (var key in this._downPointerIds) {
  5191. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5192. }
  5193. }
  5194. };
  5195. /** @hidden */
  5196. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5197. if (!this._isEnabled) {
  5198. return false;
  5199. }
  5200. this._dummyVector2.copyFromFloats(x, y);
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5202. this._onPointerMove(this, this._dummyVector2, pointerId);
  5203. var previousControlOver = this._host._lastControlOver[pointerId];
  5204. if (previousControlOver && previousControlOver !== this) {
  5205. previousControlOver._onPointerOut(this);
  5206. }
  5207. if (previousControlOver !== this) {
  5208. this._onPointerEnter(this);
  5209. }
  5210. this._host._lastControlOver[pointerId] = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5214. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5215. this._host._registerLastControlDown(this, pointerId);
  5216. this._host._lastPickedControl = this;
  5217. return true;
  5218. }
  5219. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5220. if (this._host._lastControlDown[pointerId]) {
  5221. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5222. }
  5223. delete this._host._lastControlDown[pointerId];
  5224. return true;
  5225. }
  5226. return false;
  5227. };
  5228. Control.prototype._prepareFont = function () {
  5229. if (!this._font && !this._fontSet) {
  5230. return;
  5231. }
  5232. if (this._style) {
  5233. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5234. }
  5235. else {
  5236. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5237. }
  5238. this._fontOffset = Control._GetFontOffset(this._font);
  5239. };
  5240. /** Releases associated resources */
  5241. Control.prototype.dispose = function () {
  5242. this.onDirtyObservable.clear();
  5243. this.onBeforeDrawObservable.clear();
  5244. this.onAfterDrawObservable.clear();
  5245. this.onPointerDownObservable.clear();
  5246. this.onPointerEnterObservable.clear();
  5247. this.onPointerMoveObservable.clear();
  5248. this.onPointerOutObservable.clear();
  5249. this.onPointerUpObservable.clear();
  5250. this.onPointerClickObservable.clear();
  5251. if (this._styleObserver && this._style) {
  5252. this._style.onChangedObservable.remove(this._styleObserver);
  5253. this._styleObserver = null;
  5254. }
  5255. if (this.parent) {
  5256. this.parent.removeControl(this);
  5257. this.parent = null;
  5258. }
  5259. if (this._host) {
  5260. var index = this._host._linkedControls.indexOf(this);
  5261. if (index > -1) {
  5262. this.linkWithMesh(null);
  5263. }
  5264. }
  5265. };
  5266. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5267. /** HORIZONTAL_ALIGNMENT_LEFT */
  5268. get: function () {
  5269. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5270. },
  5271. enumerable: true,
  5272. configurable: true
  5273. });
  5274. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5275. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5276. get: function () {
  5277. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5278. },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5283. /** HORIZONTAL_ALIGNMENT_CENTER */
  5284. get: function () {
  5285. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5286. },
  5287. enumerable: true,
  5288. configurable: true
  5289. });
  5290. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5291. /** VERTICAL_ALIGNMENT_TOP */
  5292. get: function () {
  5293. return Control._VERTICAL_ALIGNMENT_TOP;
  5294. },
  5295. enumerable: true,
  5296. configurable: true
  5297. });
  5298. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5299. /** VERTICAL_ALIGNMENT_BOTTOM */
  5300. get: function () {
  5301. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5302. },
  5303. enumerable: true,
  5304. configurable: true
  5305. });
  5306. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5307. /** VERTICAL_ALIGNMENT_CENTER */
  5308. get: function () {
  5309. return Control._VERTICAL_ALIGNMENT_CENTER;
  5310. },
  5311. enumerable: true,
  5312. configurable: true
  5313. });
  5314. /** @hidden */
  5315. Control._GetFontOffset = function (font) {
  5316. if (Control._FontHeightSizes[font]) {
  5317. return Control._FontHeightSizes[font];
  5318. }
  5319. var text = document.createElement("span");
  5320. text.innerHTML = "Hg";
  5321. text.style.font = font;
  5322. var block = document.createElement("div");
  5323. block.style.display = "inline-block";
  5324. block.style.width = "1px";
  5325. block.style.height = "0px";
  5326. block.style.verticalAlign = "bottom";
  5327. var div = document.createElement("div");
  5328. div.appendChild(text);
  5329. div.appendChild(block);
  5330. document.body.appendChild(div);
  5331. var fontAscent = 0;
  5332. var fontHeight = 0;
  5333. try {
  5334. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5335. block.style.verticalAlign = "baseline";
  5336. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5337. }
  5338. finally {
  5339. document.body.removeChild(div);
  5340. }
  5341. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5342. Control._FontHeightSizes[font] = result;
  5343. return result;
  5344. };
  5345. /** @hidden */
  5346. Control.drawEllipse = function (x, y, width, height, context) {
  5347. context.translate(x, y);
  5348. context.scale(width, height);
  5349. context.beginPath();
  5350. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5351. context.closePath();
  5352. context.scale(1 / width, 1 / height);
  5353. context.translate(-x, -y);
  5354. };
  5355. /**
  5356. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5357. */
  5358. Control.AllowAlphaInheritance = false;
  5359. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5360. // Statics
  5361. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5362. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5363. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5364. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5365. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5366. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5367. Control._FontHeightSizes = {};
  5368. /**
  5369. * Creates a stack panel that can be used to render headers
  5370. * @param control defines the control to associate with the header
  5371. * @param text defines the text of the header
  5372. * @param size defines the size of the header
  5373. * @param options defines options used to configure the header
  5374. * @returns a new StackPanel
  5375. * @ignore
  5376. * @hidden
  5377. */
  5378. Control.AddHeader = function () { };
  5379. return Control;
  5380. }());
  5381. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5382. /***/ }),
  5383. /***/ "./2D/controls/displayGrid.ts":
  5384. /*!************************************!*\
  5385. !*** ./2D/controls/displayGrid.ts ***!
  5386. \************************************/
  5387. /*! exports provided: DisplayGrid */
  5388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5389. "use strict";
  5390. __webpack_require__.r(__webpack_exports__);
  5391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5393. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5394. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5395. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5396. /** Class used to render a grid */
  5397. var DisplayGrid = /** @class */ (function (_super) {
  5398. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5399. /**
  5400. * Creates a new GridDisplayRectangle
  5401. * @param name defines the control name
  5402. */
  5403. function DisplayGrid(name) {
  5404. var _this = _super.call(this, name) || this;
  5405. _this.name = name;
  5406. _this._cellWidth = 20;
  5407. _this._cellHeight = 20;
  5408. _this._minorLineTickness = 1;
  5409. _this._minorLineColor = "DarkGray";
  5410. _this._majorLineTickness = 2;
  5411. _this._majorLineColor = "White";
  5412. _this._majorLineFrequency = 5;
  5413. _this._background = "Black";
  5414. _this._displayMajorLines = true;
  5415. _this._displayMinorLines = true;
  5416. return _this;
  5417. }
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5419. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMinorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMinorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMinorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5434. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5435. get: function () {
  5436. return this._displayMajorLines;
  5437. },
  5438. set: function (value) {
  5439. if (this._displayMajorLines === value) {
  5440. return;
  5441. }
  5442. this._displayMajorLines = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "background", {
  5449. /** Gets or sets background color (Black by default) */
  5450. get: function () {
  5451. return this._background;
  5452. },
  5453. set: function (value) {
  5454. if (this._background === value) {
  5455. return;
  5456. }
  5457. this._background = value;
  5458. this._markAsDirty();
  5459. },
  5460. enumerable: true,
  5461. configurable: true
  5462. });
  5463. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5464. /** Gets or sets the width of each cell (20 by default) */
  5465. get: function () {
  5466. return this._cellWidth;
  5467. },
  5468. set: function (value) {
  5469. this._cellWidth = value;
  5470. this._markAsDirty();
  5471. },
  5472. enumerable: true,
  5473. configurable: true
  5474. });
  5475. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5476. /** Gets or sets the height of each cell (20 by default) */
  5477. get: function () {
  5478. return this._cellHeight;
  5479. },
  5480. set: function (value) {
  5481. this._cellHeight = value;
  5482. this._markAsDirty();
  5483. },
  5484. enumerable: true,
  5485. configurable: true
  5486. });
  5487. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5488. /** Gets or sets the tickness of minor lines (1 by default) */
  5489. get: function () {
  5490. return this._minorLineTickness;
  5491. },
  5492. set: function (value) {
  5493. this._minorLineTickness = value;
  5494. this._markAsDirty();
  5495. },
  5496. enumerable: true,
  5497. configurable: true
  5498. });
  5499. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5500. /** Gets or sets the color of minor lines (DarkGray by default) */
  5501. get: function () {
  5502. return this._minorLineColor;
  5503. },
  5504. set: function (value) {
  5505. this._minorLineColor = value;
  5506. this._markAsDirty();
  5507. },
  5508. enumerable: true,
  5509. configurable: true
  5510. });
  5511. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5512. /** Gets or sets the tickness of major lines (2 by default) */
  5513. get: function () {
  5514. return this._majorLineTickness;
  5515. },
  5516. set: function (value) {
  5517. this._majorLineTickness = value;
  5518. this._markAsDirty();
  5519. },
  5520. enumerable: true,
  5521. configurable: true
  5522. });
  5523. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5524. /** Gets or sets the color of major lines (White by default) */
  5525. get: function () {
  5526. return this._majorLineColor;
  5527. },
  5528. set: function (value) {
  5529. this._majorLineColor = value;
  5530. this._markAsDirty();
  5531. },
  5532. enumerable: true,
  5533. configurable: true
  5534. });
  5535. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5536. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5537. get: function () {
  5538. return this._majorLineFrequency;
  5539. },
  5540. set: function (value) {
  5541. this._majorLineFrequency = value;
  5542. this._markAsDirty();
  5543. },
  5544. enumerable: true,
  5545. configurable: true
  5546. });
  5547. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5548. context.save();
  5549. this._applyStates(context);
  5550. if (this._isEnabled) {
  5551. if (this._background) {
  5552. context.fillStyle = this._background;
  5553. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5554. }
  5555. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5556. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5557. // Minor lines
  5558. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5559. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5560. if (this._displayMinorLines) {
  5561. context.strokeStyle = this._minorLineColor;
  5562. context.lineWidth = this._minorLineTickness;
  5563. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5564. var cellX = left + x * this.cellWidth;
  5565. context.beginPath();
  5566. context.moveTo(cellX, this._currentMeasure.top);
  5567. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5568. context.stroke();
  5569. }
  5570. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5571. var cellY = top_1 + y * this.cellHeight;
  5572. context.beginPath();
  5573. context.moveTo(this._currentMeasure.left, cellY);
  5574. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5575. context.stroke();
  5576. }
  5577. }
  5578. // Major lines
  5579. if (this._displayMajorLines) {
  5580. context.strokeStyle = this._majorLineColor;
  5581. context.lineWidth = this._majorLineTickness;
  5582. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5583. var cellX = left + x * this.cellWidth;
  5584. context.beginPath();
  5585. context.moveTo(cellX, this._currentMeasure.top);
  5586. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5587. context.stroke();
  5588. }
  5589. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5590. var cellY = top_1 + y * this.cellHeight;
  5591. context.moveTo(this._currentMeasure.left, cellY);
  5592. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5593. context.closePath();
  5594. context.stroke();
  5595. }
  5596. }
  5597. }
  5598. context.restore();
  5599. };
  5600. DisplayGrid.prototype._getTypeName = function () {
  5601. return "DisplayGrid";
  5602. };
  5603. return DisplayGrid;
  5604. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5605. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5606. /***/ }),
  5607. /***/ "./2D/controls/ellipse.ts":
  5608. /*!********************************!*\
  5609. !*** ./2D/controls/ellipse.ts ***!
  5610. \********************************/
  5611. /*! exports provided: Ellipse */
  5612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5613. "use strict";
  5614. __webpack_require__.r(__webpack_exports__);
  5615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5617. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5618. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5619. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5620. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5621. /** Class used to create 2D ellipse containers */
  5622. var Ellipse = /** @class */ (function (_super) {
  5623. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5624. /**
  5625. * Creates a new Ellipse
  5626. * @param name defines the control name
  5627. */
  5628. function Ellipse(name) {
  5629. var _this = _super.call(this, name) || this;
  5630. _this.name = name;
  5631. _this._thickness = 1;
  5632. return _this;
  5633. }
  5634. Object.defineProperty(Ellipse.prototype, "thickness", {
  5635. /** Gets or sets border thickness */
  5636. get: function () {
  5637. return this._thickness;
  5638. },
  5639. set: function (value) {
  5640. if (this._thickness === value) {
  5641. return;
  5642. }
  5643. this._thickness = value;
  5644. this._markAsDirty();
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Ellipse.prototype._getTypeName = function () {
  5650. return "Ellipse";
  5651. };
  5652. Ellipse.prototype._localDraw = function (context) {
  5653. context.save();
  5654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5655. context.shadowColor = this.shadowColor;
  5656. context.shadowBlur = this.shadowBlur;
  5657. context.shadowOffsetX = this.shadowOffsetX;
  5658. context.shadowOffsetY = this.shadowOffsetY;
  5659. }
  5660. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5661. if (this._background) {
  5662. context.fillStyle = this._background;
  5663. context.fill();
  5664. }
  5665. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5666. context.shadowBlur = 0;
  5667. context.shadowOffsetX = 0;
  5668. context.shadowOffsetY = 0;
  5669. }
  5670. if (this._thickness) {
  5671. if (this.color) {
  5672. context.strokeStyle = this.color;
  5673. }
  5674. context.lineWidth = this._thickness;
  5675. context.stroke();
  5676. }
  5677. context.restore();
  5678. };
  5679. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5680. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5681. this._measureForChildren.width -= 2 * this._thickness;
  5682. this._measureForChildren.height -= 2 * this._thickness;
  5683. this._measureForChildren.left += this._thickness;
  5684. this._measureForChildren.top += this._thickness;
  5685. };
  5686. Ellipse.prototype._clipForChildren = function (context) {
  5687. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5688. context.clip();
  5689. };
  5690. return Ellipse;
  5691. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5692. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5693. /***/ }),
  5694. /***/ "./2D/controls/grid.ts":
  5695. /*!*****************************!*\
  5696. !*** ./2D/controls/grid.ts ***!
  5697. \*****************************/
  5698. /*! exports provided: Grid */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5704. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5705. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5709. /**
  5710. * Class used to create a 2D grid container
  5711. */
  5712. var Grid = /** @class */ (function (_super) {
  5713. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5714. /**
  5715. * Creates a new Grid
  5716. * @param name defines control name
  5717. */
  5718. function Grid(name) {
  5719. var _this = _super.call(this, name) || this;
  5720. _this.name = name;
  5721. _this._rowDefinitions = new Array();
  5722. _this._columnDefinitions = new Array();
  5723. _this._cells = {};
  5724. _this._childControls = new Array();
  5725. return _this;
  5726. }
  5727. Object.defineProperty(Grid.prototype, "columnCount", {
  5728. /**
  5729. * Gets the number of columns
  5730. */
  5731. get: function () {
  5732. return this._columnDefinitions.length;
  5733. },
  5734. enumerable: true,
  5735. configurable: true
  5736. });
  5737. Object.defineProperty(Grid.prototype, "rowCount", {
  5738. /**
  5739. * Gets the number of rows
  5740. */
  5741. get: function () {
  5742. return this._rowDefinitions.length;
  5743. },
  5744. enumerable: true,
  5745. configurable: true
  5746. });
  5747. Object.defineProperty(Grid.prototype, "children", {
  5748. /** Gets the list of children */
  5749. get: function () {
  5750. return this._childControls;
  5751. },
  5752. enumerable: true,
  5753. configurable: true
  5754. });
  5755. Object.defineProperty(Grid.prototype, "cells", {
  5756. /** Gets the list of cells (e.g. the containers) */
  5757. get: function () {
  5758. return this._cells;
  5759. },
  5760. enumerable: true,
  5761. configurable: true
  5762. });
  5763. /**
  5764. * Gets the definition of a specific row
  5765. * @param index defines the index of the row
  5766. * @returns the row definition
  5767. */
  5768. Grid.prototype.getRowDefinition = function (index) {
  5769. if (index < 0 || index >= this._rowDefinitions.length) {
  5770. return null;
  5771. }
  5772. return this._rowDefinitions[index];
  5773. };
  5774. /**
  5775. * Gets the definition of a specific column
  5776. * @param index defines the index of the column
  5777. * @returns the column definition
  5778. */
  5779. Grid.prototype.getColumnDefinition = function (index) {
  5780. if (index < 0 || index >= this._columnDefinitions.length) {
  5781. return null;
  5782. }
  5783. return this._columnDefinitions[index];
  5784. };
  5785. /**
  5786. * Adds a new row to the grid
  5787. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5788. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5789. * @returns the current grid
  5790. */
  5791. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5792. if (isPixel === void 0) { isPixel = false; }
  5793. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5794. this._markAsDirty();
  5795. return this;
  5796. };
  5797. /**
  5798. * Adds a new column to the grid
  5799. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5800. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5801. * @returns the current grid
  5802. */
  5803. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5804. if (isPixel === void 0) { isPixel = false; }
  5805. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5806. this._markAsDirty();
  5807. return this;
  5808. };
  5809. /**
  5810. * Update a row definition
  5811. * @param index defines the index of the row to update
  5812. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5813. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5814. * @returns the current grid
  5815. */
  5816. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5817. if (isPixel === void 0) { isPixel = false; }
  5818. if (index < 0 || index >= this._rowDefinitions.length) {
  5819. return this;
  5820. }
  5821. var current = this._rowDefinitions[index];
  5822. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5823. return this;
  5824. }
  5825. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5826. this._markAsDirty();
  5827. return this;
  5828. };
  5829. /**
  5830. * Update a column definition
  5831. * @param index defines the index of the column to update
  5832. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5833. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5834. * @returns the current grid
  5835. */
  5836. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5837. if (isPixel === void 0) { isPixel = false; }
  5838. if (index < 0 || index >= this._columnDefinitions.length) {
  5839. return this;
  5840. }
  5841. var current = this._columnDefinitions[index];
  5842. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5843. return this;
  5844. }
  5845. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Gets the list of children stored in a specific cell
  5851. * @param row defines the row to check
  5852. * @param column defines the column to check
  5853. * @returns the list of controls
  5854. */
  5855. Grid.prototype.getChildrenAt = function (row, column) {
  5856. var cell = this._cells[row + ":" + column];
  5857. if (!cell) {
  5858. return null;
  5859. }
  5860. return cell.children;
  5861. };
  5862. /**
  5863. * Gets a string representing the child cell info (row x column)
  5864. * @param child defines the control to get info from
  5865. * @returns a string containing the child cell info (row x column)
  5866. */
  5867. Grid.prototype.getChildCellInfo = function (child) {
  5868. return child._tag;
  5869. };
  5870. Grid.prototype._removeCell = function (cell, key) {
  5871. if (!cell) {
  5872. return;
  5873. }
  5874. _super.prototype.removeControl.call(this, cell);
  5875. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5876. var control = _a[_i];
  5877. var childIndex = this._childControls.indexOf(control);
  5878. if (childIndex !== -1) {
  5879. this._childControls.splice(childIndex, 1);
  5880. }
  5881. }
  5882. delete this._cells[key];
  5883. };
  5884. Grid.prototype._offsetCell = function (previousKey, key) {
  5885. if (!this._cells[key]) {
  5886. return;
  5887. }
  5888. this._cells[previousKey] = this._cells[key];
  5889. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5890. var control = _a[_i];
  5891. control._tag = previousKey;
  5892. }
  5893. delete this._cells[key];
  5894. };
  5895. /**
  5896. * Remove a column definition at specified index
  5897. * @param index defines the index of the column to remove
  5898. * @returns the current grid
  5899. */
  5900. Grid.prototype.removeColumnDefinition = function (index) {
  5901. if (index < 0 || index >= this._columnDefinitions.length) {
  5902. return this;
  5903. }
  5904. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5905. var key = x + ":" + index;
  5906. var cell = this._cells[key];
  5907. this._removeCell(cell, key);
  5908. }
  5909. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5910. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5911. var previousKey = x + ":" + (y - 1);
  5912. var key = x + ":" + y;
  5913. this._offsetCell(previousKey, key);
  5914. }
  5915. }
  5916. this._columnDefinitions.splice(index, 1);
  5917. this._markAsDirty();
  5918. return this;
  5919. };
  5920. /**
  5921. * Remove a row definition at specified index
  5922. * @param index defines the index of the row to remove
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.removeRowDefinition = function (index) {
  5926. if (index < 0 || index >= this._rowDefinitions.length) {
  5927. return this;
  5928. }
  5929. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5930. var key = index + ":" + y;
  5931. var cell = this._cells[key];
  5932. this._removeCell(cell, key);
  5933. }
  5934. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5935. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5936. var previousKey = x - 1 + ":" + y;
  5937. var key = x + ":" + y;
  5938. this._offsetCell(previousKey, key);
  5939. }
  5940. }
  5941. this._rowDefinitions.splice(index, 1);
  5942. this._markAsDirty();
  5943. return this;
  5944. };
  5945. /**
  5946. * Adds a new control to the current grid
  5947. * @param control defines the control to add
  5948. * @param row defines the row where to add the control (0 by default)
  5949. * @param column defines the column where to add the control (0 by default)
  5950. * @returns the current grid
  5951. */
  5952. Grid.prototype.addControl = function (control, row, column) {
  5953. if (row === void 0) { row = 0; }
  5954. if (column === void 0) { column = 0; }
  5955. if (this._rowDefinitions.length === 0) {
  5956. // Add default row definition
  5957. this.addRowDefinition(1, false);
  5958. }
  5959. if (this._columnDefinitions.length === 0) {
  5960. // Add default column definition
  5961. this.addColumnDefinition(1, false);
  5962. }
  5963. if (this._childControls.indexOf(control) !== -1) {
  5964. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  5965. return this;
  5966. }
  5967. var x = Math.min(row, this._rowDefinitions.length - 1);
  5968. var y = Math.min(column, this._columnDefinitions.length - 1);
  5969. var key = x + ":" + y;
  5970. var goodContainer = this._cells[key];
  5971. if (!goodContainer) {
  5972. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5973. this._cells[key] = goodContainer;
  5974. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5975. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5976. _super.prototype.addControl.call(this, goodContainer);
  5977. }
  5978. goodContainer.addControl(control);
  5979. this._childControls.push(control);
  5980. control._tag = key;
  5981. control.parent = this;
  5982. this._markAsDirty();
  5983. return this;
  5984. };
  5985. /**
  5986. * Removes a control from the current container
  5987. * @param control defines the control to remove
  5988. * @returns the current container
  5989. */
  5990. Grid.prototype.removeControl = function (control) {
  5991. var index = this._childControls.indexOf(control);
  5992. if (index !== -1) {
  5993. this._childControls.splice(index, 1);
  5994. }
  5995. var cell = this._cells[control._tag];
  5996. if (cell) {
  5997. cell.removeControl(control);
  5998. control._tag = null;
  5999. }
  6000. this._markAsDirty();
  6001. return this;
  6002. };
  6003. Grid.prototype._getTypeName = function () {
  6004. return "Grid";
  6005. };
  6006. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6007. var widths = [];
  6008. var heights = [];
  6009. var lefts = [];
  6010. var tops = [];
  6011. var availableWidth = this._currentMeasure.width;
  6012. var globalWidthPercentage = 0;
  6013. var availableHeight = this._currentMeasure.height;
  6014. var globalHeightPercentage = 0;
  6015. // Heights
  6016. var index = 0;
  6017. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6018. var value = _a[_i];
  6019. if (value.isPixel) {
  6020. var height = value.getValue(this._host);
  6021. availableHeight -= height;
  6022. heights[index] = height;
  6023. }
  6024. else {
  6025. globalHeightPercentage += value.internalValue;
  6026. }
  6027. index++;
  6028. }
  6029. var top = 0;
  6030. index = 0;
  6031. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6032. var value = _c[_b];
  6033. tops.push(top);
  6034. if (!value.isPixel) {
  6035. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6036. top += height;
  6037. heights[index] = height;
  6038. }
  6039. else {
  6040. top += value.getValue(this._host);
  6041. }
  6042. index++;
  6043. }
  6044. // Widths
  6045. index = 0;
  6046. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6047. var value = _e[_d];
  6048. if (value.isPixel) {
  6049. var width = value.getValue(this._host);
  6050. availableWidth -= width;
  6051. widths[index] = width;
  6052. }
  6053. else {
  6054. globalWidthPercentage += value.internalValue;
  6055. }
  6056. index++;
  6057. }
  6058. var left = 0;
  6059. index = 0;
  6060. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6061. var value = _g[_f];
  6062. lefts.push(left);
  6063. if (!value.isPixel) {
  6064. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6065. left += width;
  6066. widths[index] = width;
  6067. }
  6068. else {
  6069. left += value.getValue(this._host);
  6070. }
  6071. index++;
  6072. }
  6073. definitionCallback(lefts, tops, widths, heights);
  6074. };
  6075. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6076. var _this = this;
  6077. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6078. // Setting child sizes
  6079. for (var key in _this._cells) {
  6080. if (!_this._cells.hasOwnProperty(key)) {
  6081. continue;
  6082. }
  6083. var split = key.split(":");
  6084. var x = parseInt(split[0]);
  6085. var y = parseInt(split[1]);
  6086. var cell = _this._cells[key];
  6087. cell.left = lefts[y] + "px";
  6088. cell.top = tops[x] + "px";
  6089. cell.width = widths[y] + "px";
  6090. cell.height = heights[x] + "px";
  6091. cell._left.ignoreAdaptiveScaling = true;
  6092. cell._top.ignoreAdaptiveScaling = true;
  6093. cell._width.ignoreAdaptiveScaling = true;
  6094. cell._height.ignoreAdaptiveScaling = true;
  6095. }
  6096. });
  6097. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6098. };
  6099. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6100. for (var key in this._cells) {
  6101. if (!this._cells.hasOwnProperty(key)) {
  6102. continue;
  6103. }
  6104. var child = this._cells[key];
  6105. child._markMatrixAsDirty();
  6106. }
  6107. };
  6108. Grid.prototype._renderHighlightSpecific = function (context) {
  6109. var _this = this;
  6110. _super.prototype._renderHighlightSpecific.call(this, context);
  6111. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6112. // Columns
  6113. for (var index = 0; index < lefts.length; index++) {
  6114. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6115. context.beginPath();
  6116. context.moveTo(left, _this._currentMeasure.top);
  6117. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6118. context.stroke();
  6119. }
  6120. // Rows
  6121. for (var index = 0; index < tops.length; index++) {
  6122. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6123. context.beginPath();
  6124. context.moveTo(_this._currentMeasure.left, top_1);
  6125. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6126. context.stroke();
  6127. }
  6128. });
  6129. context.restore();
  6130. };
  6131. /** Releases associated resources */
  6132. Grid.prototype.dispose = function () {
  6133. _super.prototype.dispose.call(this);
  6134. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6135. var control = _a[_i];
  6136. control.dispose();
  6137. }
  6138. this._childControls = [];
  6139. };
  6140. return Grid;
  6141. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6142. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6143. /***/ }),
  6144. /***/ "./2D/controls/image.ts":
  6145. /*!******************************!*\
  6146. !*** ./2D/controls/image.ts ***!
  6147. \******************************/
  6148. /*! exports provided: Image */
  6149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6150. "use strict";
  6151. __webpack_require__.r(__webpack_exports__);
  6152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6154. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6157. /**
  6158. * Class used to create 2D images
  6159. */
  6160. var Image = /** @class */ (function (_super) {
  6161. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6162. /**
  6163. * Creates a new Image
  6164. * @param name defines the control name
  6165. * @param url defines the image url
  6166. */
  6167. function Image(name, url) {
  6168. if (url === void 0) { url = null; }
  6169. var _this = _super.call(this, name) || this;
  6170. _this.name = name;
  6171. _this._workingCanvas = null;
  6172. _this._loaded = false;
  6173. _this._stretch = Image.STRETCH_FILL;
  6174. _this._autoScale = false;
  6175. _this._sourceLeft = 0;
  6176. _this._sourceTop = 0;
  6177. _this._sourceWidth = 0;
  6178. _this._sourceHeight = 0;
  6179. _this._cellWidth = 0;
  6180. _this._cellHeight = 0;
  6181. _this._cellId = -1;
  6182. _this._populateNinePatchSlicesFromImage = false;
  6183. /**
  6184. * Observable notified when the content is loaded
  6185. */
  6186. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6187. /**
  6188. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6189. */
  6190. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6191. _this.source = url;
  6192. return _this;
  6193. }
  6194. Object.defineProperty(Image.prototype, "isLoaded", {
  6195. /**
  6196. * Gets a boolean indicating that the content is loaded
  6197. */
  6198. get: function () {
  6199. return this._loaded;
  6200. },
  6201. enumerable: true,
  6202. configurable: true
  6203. });
  6204. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6205. /**
  6206. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6207. */
  6208. get: function () {
  6209. return this._populateNinePatchSlicesFromImage;
  6210. },
  6211. set: function (value) {
  6212. if (this._populateNinePatchSlicesFromImage === value) {
  6213. return;
  6214. }
  6215. this._populateNinePatchSlicesFromImage = value;
  6216. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6217. this._extractNinePatchSliceDataFromImage();
  6218. }
  6219. },
  6220. enumerable: true,
  6221. configurable: true
  6222. });
  6223. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6224. /**
  6225. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6226. * Beware using this as this will comsume more memory as the image has to be stored twice
  6227. */
  6228. get: function () {
  6229. return this._detectPointerOnOpaqueOnly;
  6230. },
  6231. set: function (value) {
  6232. if (this._detectPointerOnOpaqueOnly === value) {
  6233. return;
  6234. }
  6235. this._detectPointerOnOpaqueOnly = value;
  6236. },
  6237. enumerable: true,
  6238. configurable: true
  6239. });
  6240. Object.defineProperty(Image.prototype, "sliceLeft", {
  6241. /**
  6242. * Gets or sets the left value for slicing (9-patch)
  6243. */
  6244. get: function () {
  6245. return this._sliceLeft;
  6246. },
  6247. set: function (value) {
  6248. if (this._sliceLeft === value) {
  6249. return;
  6250. }
  6251. this._sliceLeft = value;
  6252. this._markAsDirty();
  6253. },
  6254. enumerable: true,
  6255. configurable: true
  6256. });
  6257. Object.defineProperty(Image.prototype, "sliceRight", {
  6258. /**
  6259. * Gets or sets the right value for slicing (9-patch)
  6260. */
  6261. get: function () {
  6262. return this._sliceRight;
  6263. },
  6264. set: function (value) {
  6265. if (this._sliceRight === value) {
  6266. return;
  6267. }
  6268. this._sliceRight = value;
  6269. this._markAsDirty();
  6270. },
  6271. enumerable: true,
  6272. configurable: true
  6273. });
  6274. Object.defineProperty(Image.prototype, "sliceTop", {
  6275. /**
  6276. * Gets or sets the top value for slicing (9-patch)
  6277. */
  6278. get: function () {
  6279. return this._sliceTop;
  6280. },
  6281. set: function (value) {
  6282. if (this._sliceTop === value) {
  6283. return;
  6284. }
  6285. this._sliceTop = value;
  6286. this._markAsDirty();
  6287. },
  6288. enumerable: true,
  6289. configurable: true
  6290. });
  6291. Object.defineProperty(Image.prototype, "sliceBottom", {
  6292. /**
  6293. * Gets or sets the bottom value for slicing (9-patch)
  6294. */
  6295. get: function () {
  6296. return this._sliceBottom;
  6297. },
  6298. set: function (value) {
  6299. if (this._sliceBottom === value) {
  6300. return;
  6301. }
  6302. this._sliceBottom = value;
  6303. this._markAsDirty();
  6304. },
  6305. enumerable: true,
  6306. configurable: true
  6307. });
  6308. Object.defineProperty(Image.prototype, "sourceLeft", {
  6309. /**
  6310. * Gets or sets the left coordinate in the source image
  6311. */
  6312. get: function () {
  6313. return this._sourceLeft;
  6314. },
  6315. set: function (value) {
  6316. if (this._sourceLeft === value) {
  6317. return;
  6318. }
  6319. this._sourceLeft = value;
  6320. this._markAsDirty();
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. Object.defineProperty(Image.prototype, "sourceTop", {
  6326. /**
  6327. * Gets or sets the top coordinate in the source image
  6328. */
  6329. get: function () {
  6330. return this._sourceTop;
  6331. },
  6332. set: function (value) {
  6333. if (this._sourceTop === value) {
  6334. return;
  6335. }
  6336. this._sourceTop = value;
  6337. this._markAsDirty();
  6338. },
  6339. enumerable: true,
  6340. configurable: true
  6341. });
  6342. Object.defineProperty(Image.prototype, "sourceWidth", {
  6343. /**
  6344. * Gets or sets the width to capture in the source image
  6345. */
  6346. get: function () {
  6347. return this._sourceWidth;
  6348. },
  6349. set: function (value) {
  6350. if (this._sourceWidth === value) {
  6351. return;
  6352. }
  6353. this._sourceWidth = value;
  6354. this._markAsDirty();
  6355. },
  6356. enumerable: true,
  6357. configurable: true
  6358. });
  6359. Object.defineProperty(Image.prototype, "sourceHeight", {
  6360. /**
  6361. * Gets or sets the height to capture in the source image
  6362. */
  6363. get: function () {
  6364. return this._sourceHeight;
  6365. },
  6366. set: function (value) {
  6367. if (this._sourceHeight === value) {
  6368. return;
  6369. }
  6370. this._sourceHeight = value;
  6371. this._markAsDirty();
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "autoScale", {
  6377. /**
  6378. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6379. * @see http://doc.babylonjs.com/how_to/gui#image
  6380. */
  6381. get: function () {
  6382. return this._autoScale;
  6383. },
  6384. set: function (value) {
  6385. if (this._autoScale === value) {
  6386. return;
  6387. }
  6388. this._autoScale = value;
  6389. if (value && this._loaded) {
  6390. this.synchronizeSizeWithContent();
  6391. }
  6392. },
  6393. enumerable: true,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(Image.prototype, "stretch", {
  6397. /** Gets or sets the streching mode used by the image */
  6398. get: function () {
  6399. return this._stretch;
  6400. },
  6401. set: function (value) {
  6402. if (this._stretch === value) {
  6403. return;
  6404. }
  6405. this._stretch = value;
  6406. this._markAsDirty();
  6407. },
  6408. enumerable: true,
  6409. configurable: true
  6410. });
  6411. /** @hidden */
  6412. Image.prototype._rotate90 = function (n) {
  6413. var canvas = document.createElement('canvas');
  6414. var context = canvas.getContext('2d');
  6415. var width = this._domImage.width;
  6416. var height = this._domImage.height;
  6417. canvas.width = height;
  6418. canvas.height = width;
  6419. context.translate(canvas.width / 2, canvas.height / 2);
  6420. context.rotate(n * Math.PI / 2);
  6421. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6422. var dataUrl = canvas.toDataURL("image/jpg");
  6423. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6424. return rotatedImage;
  6425. };
  6426. Object.defineProperty(Image.prototype, "domImage", {
  6427. get: function () {
  6428. return this._domImage;
  6429. },
  6430. /**
  6431. * Gets or sets the internal DOM image used to render the control
  6432. */
  6433. set: function (value) {
  6434. var _this = this;
  6435. this._domImage = value;
  6436. this._loaded = false;
  6437. if (this._domImage.width) {
  6438. this._onImageLoaded();
  6439. }
  6440. else {
  6441. this._domImage.onload = function () {
  6442. _this._onImageLoaded();
  6443. };
  6444. }
  6445. },
  6446. enumerable: true,
  6447. configurable: true
  6448. });
  6449. Image.prototype._onImageLoaded = function () {
  6450. this._imageWidth = this._domImage.width;
  6451. this._imageHeight = this._domImage.height;
  6452. this._loaded = true;
  6453. if (this._populateNinePatchSlicesFromImage) {
  6454. this._extractNinePatchSliceDataFromImage();
  6455. }
  6456. if (this._autoScale) {
  6457. this.synchronizeSizeWithContent();
  6458. }
  6459. this.onImageLoadedObservable.notifyObservers(this);
  6460. this._markAsDirty();
  6461. };
  6462. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6463. if (!this._workingCanvas) {
  6464. this._workingCanvas = document.createElement('canvas');
  6465. }
  6466. var canvas = this._workingCanvas;
  6467. var context = canvas.getContext('2d');
  6468. var width = this._domImage.width;
  6469. var height = this._domImage.height;
  6470. canvas.width = width;
  6471. canvas.height = height;
  6472. context.drawImage(this._domImage, 0, 0, width, height);
  6473. var imageData = context.getImageData(0, 0, width, height);
  6474. // Left and right
  6475. this._sliceLeft = -1;
  6476. this._sliceRight = -1;
  6477. for (var x = 0; x < width; x++) {
  6478. var alpha = imageData.data[x * 4 + 3];
  6479. if (alpha > 127 && this._sliceLeft === -1) {
  6480. this._sliceLeft = x;
  6481. continue;
  6482. }
  6483. if (alpha < 127 && this._sliceLeft > -1) {
  6484. this._sliceRight = x;
  6485. break;
  6486. }
  6487. }
  6488. // top and bottom
  6489. this._sliceTop = -1;
  6490. this._sliceBottom = -1;
  6491. for (var y = 0; y < height; y++) {
  6492. var alpha = imageData.data[y * width * 4 + 3];
  6493. if (alpha > 127 && this._sliceTop === -1) {
  6494. this._sliceTop = y;
  6495. continue;
  6496. }
  6497. if (alpha < 127 && this._sliceTop > -1) {
  6498. this._sliceBottom = y;
  6499. break;
  6500. }
  6501. }
  6502. };
  6503. Object.defineProperty(Image.prototype, "source", {
  6504. /**
  6505. * Gets or sets image source url
  6506. */
  6507. set: function (value) {
  6508. var _this = this;
  6509. if (this._source === value) {
  6510. return;
  6511. }
  6512. this._loaded = false;
  6513. this._source = value;
  6514. if (value) {
  6515. value = this._svgCheck(value);
  6516. }
  6517. this._domImage = document.createElement("img");
  6518. this._domImage.onload = function () {
  6519. _this._onImageLoaded();
  6520. };
  6521. if (value) {
  6522. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6523. this._domImage.src = value;
  6524. }
  6525. },
  6526. enumerable: true,
  6527. configurable: true
  6528. });
  6529. /**
  6530. * Checks for svg document with icon id present
  6531. */
  6532. Image.prototype._svgCheck = function (value) {
  6533. var _this = this;
  6534. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6535. var svgsrc = value.split('#')[0];
  6536. var elemid = value.split('#')[1];
  6537. // check if object alr exist in document
  6538. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6539. if (svgExist) {
  6540. // wait for object to load
  6541. svgExist.addEventListener("load", function () {
  6542. _this._getSVGAttribs(svgExist, elemid);
  6543. });
  6544. }
  6545. else {
  6546. // create document object
  6547. var svgImage = document.createElement("object");
  6548. svgImage.data = svgsrc;
  6549. svgImage.type = "image/svg+xml";
  6550. svgImage.width = "0%";
  6551. svgImage.height = "0%";
  6552. document.body.appendChild(svgImage);
  6553. // when the object has loaded, get the element attribs
  6554. svgImage.onload = function () {
  6555. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6556. if (svgobj) {
  6557. _this._getSVGAttribs(svgobj, elemid);
  6558. }
  6559. };
  6560. }
  6561. return svgsrc;
  6562. }
  6563. else {
  6564. return value;
  6565. }
  6566. };
  6567. /**
  6568. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6569. * given external svg file and icon id
  6570. */
  6571. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6572. var svgDoc = svgsrc.contentDocument;
  6573. // get viewbox width and height, get svg document width and height in px
  6574. if (svgDoc && svgDoc.documentElement) {
  6575. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6576. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6577. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6578. // get element bbox and matrix transform
  6579. var elem = svgDoc.getElementById(elemid);
  6580. if (vb && docwidth && docheight) {
  6581. var vb_width = Number(vb.split(" ")[2]);
  6582. var vb_height = Number(vb.split(" ")[3]);
  6583. var elem_bbox = elem.getBBox();
  6584. var elem_matrix_a = 1;
  6585. var elem_matrix_d = 1;
  6586. var elem_matrix_e = 0;
  6587. var elem_matrix_f = 0;
  6588. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6589. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6590. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6591. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6592. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6593. }
  6594. // compute source coordinates and dimensions
  6595. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6596. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6597. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6598. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6599. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6600. }
  6601. }
  6602. };
  6603. Object.defineProperty(Image.prototype, "cellWidth", {
  6604. /**
  6605. * Gets or sets the cell width to use when animation sheet is enabled
  6606. * @see http://doc.babylonjs.com/how_to/gui#image
  6607. */
  6608. get: function () {
  6609. return this._cellWidth;
  6610. },
  6611. set: function (value) {
  6612. if (this._cellWidth === value) {
  6613. return;
  6614. }
  6615. this._cellWidth = value;
  6616. this._markAsDirty();
  6617. },
  6618. enumerable: true,
  6619. configurable: true
  6620. });
  6621. Object.defineProperty(Image.prototype, "cellHeight", {
  6622. /**
  6623. * Gets or sets the cell height to use when animation sheet is enabled
  6624. * @see http://doc.babylonjs.com/how_to/gui#image
  6625. */
  6626. get: function () {
  6627. return this._cellHeight;
  6628. },
  6629. set: function (value) {
  6630. if (this._cellHeight === value) {
  6631. return;
  6632. }
  6633. this._cellHeight = value;
  6634. this._markAsDirty();
  6635. },
  6636. enumerable: true,
  6637. configurable: true
  6638. });
  6639. Object.defineProperty(Image.prototype, "cellId", {
  6640. /**
  6641. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6642. * @see http://doc.babylonjs.com/how_to/gui#image
  6643. */
  6644. get: function () {
  6645. return this._cellId;
  6646. },
  6647. set: function (value) {
  6648. if (this._cellId === value) {
  6649. return;
  6650. }
  6651. this._cellId = value;
  6652. this._markAsDirty();
  6653. },
  6654. enumerable: true,
  6655. configurable: true
  6656. });
  6657. /**
  6658. * Tests if a given coordinates belong to the current control
  6659. * @param x defines x coordinate to test
  6660. * @param y defines y coordinate to test
  6661. * @returns true if the coordinates are inside the control
  6662. */
  6663. Image.prototype.contains = function (x, y) {
  6664. if (!_super.prototype.contains.call(this, x, y)) {
  6665. return false;
  6666. }
  6667. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6668. return true;
  6669. }
  6670. var canvas = this._workingCanvas;
  6671. var context = canvas.getContext("2d");
  6672. var width = this._currentMeasure.width | 0;
  6673. var height = this._currentMeasure.height | 0;
  6674. var imageData = context.getImageData(0, 0, width, height).data;
  6675. x = (x - this._currentMeasure.left) | 0;
  6676. y = (y - this._currentMeasure.top) | 0;
  6677. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6678. return pickedPixel > 0;
  6679. };
  6680. Image.prototype._getTypeName = function () {
  6681. return "Image";
  6682. };
  6683. /** Force the control to synchronize with its content */
  6684. Image.prototype.synchronizeSizeWithContent = function () {
  6685. if (!this._loaded) {
  6686. return;
  6687. }
  6688. this.width = this._domImage.width + "px";
  6689. this.height = this._domImage.height + "px";
  6690. };
  6691. Image.prototype._processMeasures = function (parentMeasure, context) {
  6692. if (this._loaded) {
  6693. switch (this._stretch) {
  6694. case Image.STRETCH_NONE:
  6695. break;
  6696. case Image.STRETCH_FILL:
  6697. break;
  6698. case Image.STRETCH_UNIFORM:
  6699. break;
  6700. case Image.STRETCH_NINE_PATCH:
  6701. break;
  6702. case Image.STRETCH_EXTEND:
  6703. if (this._autoScale) {
  6704. this.synchronizeSizeWithContent();
  6705. }
  6706. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6707. this.parent.adaptWidthToChildren = true;
  6708. this.parent.adaptHeightToChildren = true;
  6709. }
  6710. break;
  6711. }
  6712. }
  6713. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6714. };
  6715. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6716. if (!this._detectPointerOnOpaqueOnly) {
  6717. return;
  6718. }
  6719. if (!this._workingCanvas) {
  6720. this._workingCanvas = document.createElement('canvas');
  6721. }
  6722. var canvas = this._workingCanvas;
  6723. var width = this._currentMeasure.width;
  6724. var height = this._currentMeasure.height;
  6725. var context = canvas.getContext("2d");
  6726. canvas.width = width;
  6727. canvas.height = height;
  6728. context.clearRect(0, 0, width, height);
  6729. };
  6730. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6731. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6732. if (!this._detectPointerOnOpaqueOnly) {
  6733. return;
  6734. }
  6735. var canvas = this._workingCanvas;
  6736. context = canvas.getContext("2d");
  6737. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6738. };
  6739. Image.prototype._draw = function (context) {
  6740. context.save();
  6741. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6742. context.shadowColor = this.shadowColor;
  6743. context.shadowBlur = this.shadowBlur;
  6744. context.shadowOffsetX = this.shadowOffsetX;
  6745. context.shadowOffsetY = this.shadowOffsetY;
  6746. }
  6747. var x, y, width, height;
  6748. if (this.cellId == -1) {
  6749. x = this._sourceLeft;
  6750. y = this._sourceTop;
  6751. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6752. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6753. }
  6754. else {
  6755. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6756. var column = (this.cellId / rowCount) >> 0;
  6757. var row = this.cellId % rowCount;
  6758. x = this.cellWidth * row;
  6759. y = this.cellHeight * column;
  6760. width = this.cellWidth;
  6761. height = this.cellHeight;
  6762. }
  6763. this._prepareWorkingCanvasForOpaqueDetection();
  6764. this._applyStates(context);
  6765. if (this._loaded) {
  6766. switch (this._stretch) {
  6767. case Image.STRETCH_NONE:
  6768. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6769. break;
  6770. case Image.STRETCH_FILL:
  6771. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6772. break;
  6773. case Image.STRETCH_UNIFORM:
  6774. var hRatio = this._currentMeasure.width / width;
  6775. var vRatio = this._currentMeasure.height / height;
  6776. var ratio = Math.min(hRatio, vRatio);
  6777. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6778. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6779. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6780. break;
  6781. case Image.STRETCH_EXTEND:
  6782. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6783. break;
  6784. case Image.STRETCH_NINE_PATCH:
  6785. this._renderNinePatch(context);
  6786. break;
  6787. }
  6788. }
  6789. context.restore();
  6790. };
  6791. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6792. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6793. };
  6794. Image.prototype._renderNinePatch = function (context) {
  6795. var height = this._imageHeight;
  6796. var leftWidth = this._sliceLeft;
  6797. var topHeight = this._sliceTop;
  6798. var bottomHeight = this._imageHeight - this._sliceBottom;
  6799. var rightWidth = this._imageWidth - this._sliceRight;
  6800. var left = 0;
  6801. var top = 0;
  6802. if (this._populateNinePatchSlicesFromImage) {
  6803. left = 1;
  6804. top = 1;
  6805. height -= 2;
  6806. leftWidth -= 1;
  6807. topHeight -= 1;
  6808. bottomHeight -= 1;
  6809. rightWidth -= 1;
  6810. }
  6811. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6812. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6813. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6814. // Corners
  6815. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6816. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6817. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6818. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6819. // Center
  6820. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6821. // Borders
  6822. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6823. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6824. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6825. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6826. };
  6827. Image.prototype.dispose = function () {
  6828. _super.prototype.dispose.call(this);
  6829. this.onImageLoadedObservable.clear();
  6830. this.onSVGAttributesComputedObservable.clear();
  6831. };
  6832. // Static
  6833. /** STRETCH_NONE */
  6834. Image.STRETCH_NONE = 0;
  6835. /** STRETCH_FILL */
  6836. Image.STRETCH_FILL = 1;
  6837. /** STRETCH_UNIFORM */
  6838. Image.STRETCH_UNIFORM = 2;
  6839. /** STRETCH_EXTEND */
  6840. Image.STRETCH_EXTEND = 3;
  6841. /** NINE_PATCH */
  6842. Image.STRETCH_NINE_PATCH = 4;
  6843. return Image;
  6844. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6845. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6846. /***/ }),
  6847. /***/ "./2D/controls/index.ts":
  6848. /*!******************************!*\
  6849. !*** ./2D/controls/index.ts ***!
  6850. \******************************/
  6851. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  6852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6853. "use strict";
  6854. __webpack_require__.r(__webpack_exports__);
  6855. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6857. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6859. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6861. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6863. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6865. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6867. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6869. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6871. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6873. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6875. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6877. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6879. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6881. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6883. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6889. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6891. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6894. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6897. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6899. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6901. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6903. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6905. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6907. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6909. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6911. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6913. /***/ }),
  6914. /***/ "./2D/controls/inputPassword.ts":
  6915. /*!**************************************!*\
  6916. !*** ./2D/controls/inputPassword.ts ***!
  6917. \**************************************/
  6918. /*! exports provided: InputPassword */
  6919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6920. "use strict";
  6921. __webpack_require__.r(__webpack_exports__);
  6922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6923. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6924. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6925. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  6926. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6927. /**
  6928. * Class used to create a password control
  6929. */
  6930. var InputPassword = /** @class */ (function (_super) {
  6931. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6932. function InputPassword() {
  6933. return _super !== null && _super.apply(this, arguments) || this;
  6934. }
  6935. InputPassword.prototype._beforeRenderText = function (text) {
  6936. var txt = "";
  6937. for (var i = 0; i < text.length; i++) {
  6938. txt += "\u2022";
  6939. }
  6940. return txt;
  6941. };
  6942. return InputPassword;
  6943. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6944. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6945. /***/ }),
  6946. /***/ "./2D/controls/inputText.ts":
  6947. /*!**********************************!*\
  6948. !*** ./2D/controls/inputText.ts ***!
  6949. \**********************************/
  6950. /*! exports provided: InputText */
  6951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6952. "use strict";
  6953. __webpack_require__.r(__webpack_exports__);
  6954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6955. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6956. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6957. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6958. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6959. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6960. /**
  6961. * Class used to create input text control
  6962. */
  6963. var InputText = /** @class */ (function (_super) {
  6964. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6965. /**
  6966. * Creates a new InputText
  6967. * @param name defines the control name
  6968. * @param text defines the text of the control
  6969. */
  6970. function InputText(name, text) {
  6971. if (text === void 0) { text = ""; }
  6972. var _this = _super.call(this, name) || this;
  6973. _this.name = name;
  6974. _this._text = "";
  6975. _this._placeholderText = "";
  6976. _this._background = "#222222";
  6977. _this._focusedBackground = "#000000";
  6978. _this._focusedColor = "white";
  6979. _this._placeholderColor = "gray";
  6980. _this._thickness = 1;
  6981. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6982. _this._autoStretchWidth = true;
  6983. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6984. _this._isFocused = false;
  6985. _this._blinkIsEven = false;
  6986. _this._cursorOffset = 0;
  6987. _this._deadKey = false;
  6988. _this._addKey = true;
  6989. _this._currentKey = "";
  6990. _this._isTextHighlightOn = false;
  6991. _this._textHighlightColor = "#d5e0ff";
  6992. _this._highligherOpacity = 0.4;
  6993. _this._highlightedText = "";
  6994. _this._startHighlightIndex = 0;
  6995. _this._endHighlightIndex = 0;
  6996. _this._cursorIndex = -1;
  6997. _this._onFocusSelectAll = false;
  6998. _this._isPointerDown = false;
  6999. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7000. _this.promptMessage = "Please enter text:";
  7001. /** Force disable prompt on mobile device */
  7002. _this.disableMobilePrompt = false;
  7003. /** Observable raised when the text changes */
  7004. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7005. /** Observable raised just before an entered character is to be added */
  7006. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7007. /** Observable raised when the control gets the focus */
  7008. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7009. /** Observable raised when the control loses the focus */
  7010. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7011. /**Observable raised when the text is highlighted */
  7012. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7013. /**Observable raised when copy event is triggered */
  7014. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7015. /** Observable raised when cut event is triggered */
  7016. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7017. /** Observable raised when paste event is triggered */
  7018. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7019. /** Observable raised when a key event was processed */
  7020. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7021. _this.text = text;
  7022. _this.isPointerBlocker = true;
  7023. return _this;
  7024. }
  7025. Object.defineProperty(InputText.prototype, "maxWidth", {
  7026. /** Gets or sets the maximum width allowed by the control */
  7027. get: function () {
  7028. return this._maxWidth.toString(this._host);
  7029. },
  7030. set: function (value) {
  7031. if (this._maxWidth.toString(this._host) === value) {
  7032. return;
  7033. }
  7034. if (this._maxWidth.fromString(value)) {
  7035. this._markAsDirty();
  7036. }
  7037. },
  7038. enumerable: true,
  7039. configurable: true
  7040. });
  7041. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7042. /** Gets the maximum width allowed by the control in pixels */
  7043. get: function () {
  7044. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7045. },
  7046. enumerable: true,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7050. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7051. get: function () {
  7052. return this._highligherOpacity;
  7053. },
  7054. set: function (value) {
  7055. if (this._highligherOpacity === value) {
  7056. return;
  7057. }
  7058. this._highligherOpacity = value;
  7059. this._markAsDirty();
  7060. },
  7061. enumerable: true,
  7062. configurable: true
  7063. });
  7064. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7065. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7066. get: function () {
  7067. return this._onFocusSelectAll;
  7068. },
  7069. set: function (value) {
  7070. if (this._onFocusSelectAll === value) {
  7071. return;
  7072. }
  7073. this._onFocusSelectAll = value;
  7074. this._markAsDirty();
  7075. },
  7076. enumerable: true,
  7077. configurable: true
  7078. });
  7079. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7080. /** Gets or sets the text hightlight color */
  7081. get: function () {
  7082. return this._textHighlightColor;
  7083. },
  7084. set: function (value) {
  7085. if (this._textHighlightColor === value) {
  7086. return;
  7087. }
  7088. this._textHighlightColor = value;
  7089. this._markAsDirty();
  7090. },
  7091. enumerable: true,
  7092. configurable: true
  7093. });
  7094. Object.defineProperty(InputText.prototype, "margin", {
  7095. /** Gets or sets control margin */
  7096. get: function () {
  7097. return this._margin.toString(this._host);
  7098. },
  7099. set: function (value) {
  7100. if (this._margin.toString(this._host) === value) {
  7101. return;
  7102. }
  7103. if (this._margin.fromString(value)) {
  7104. this._markAsDirty();
  7105. }
  7106. },
  7107. enumerable: true,
  7108. configurable: true
  7109. });
  7110. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7111. /** Gets control margin in pixels */
  7112. get: function () {
  7113. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7114. },
  7115. enumerable: true,
  7116. configurable: true
  7117. });
  7118. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7119. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7120. get: function () {
  7121. return this._autoStretchWidth;
  7122. },
  7123. set: function (value) {
  7124. if (this._autoStretchWidth === value) {
  7125. return;
  7126. }
  7127. this._autoStretchWidth = value;
  7128. this._markAsDirty();
  7129. },
  7130. enumerable: true,
  7131. configurable: true
  7132. });
  7133. Object.defineProperty(InputText.prototype, "thickness", {
  7134. /** Gets or sets border thickness */
  7135. get: function () {
  7136. return this._thickness;
  7137. },
  7138. set: function (value) {
  7139. if (this._thickness === value) {
  7140. return;
  7141. }
  7142. this._thickness = value;
  7143. this._markAsDirty();
  7144. },
  7145. enumerable: true,
  7146. configurable: true
  7147. });
  7148. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7149. /** Gets or sets the background color when focused */
  7150. get: function () {
  7151. return this._focusedBackground;
  7152. },
  7153. set: function (value) {
  7154. if (this._focusedBackground === value) {
  7155. return;
  7156. }
  7157. this._focusedBackground = value;
  7158. this._markAsDirty();
  7159. },
  7160. enumerable: true,
  7161. configurable: true
  7162. });
  7163. Object.defineProperty(InputText.prototype, "focusedColor", {
  7164. /** Gets or sets the background color when focused */
  7165. get: function () {
  7166. return this._focusedColor;
  7167. },
  7168. set: function (value) {
  7169. if (this._focusedColor === value) {
  7170. return;
  7171. }
  7172. this._focusedColor = value;
  7173. this._markAsDirty();
  7174. },
  7175. enumerable: true,
  7176. configurable: true
  7177. });
  7178. Object.defineProperty(InputText.prototype, "background", {
  7179. /** Gets or sets the background color */
  7180. get: function () {
  7181. return this._background;
  7182. },
  7183. set: function (value) {
  7184. if (this._background === value) {
  7185. return;
  7186. }
  7187. this._background = value;
  7188. this._markAsDirty();
  7189. },
  7190. enumerable: true,
  7191. configurable: true
  7192. });
  7193. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7194. /** Gets or sets the placeholder color */
  7195. get: function () {
  7196. return this._placeholderColor;
  7197. },
  7198. set: function (value) {
  7199. if (this._placeholderColor === value) {
  7200. return;
  7201. }
  7202. this._placeholderColor = value;
  7203. this._markAsDirty();
  7204. },
  7205. enumerable: true,
  7206. configurable: true
  7207. });
  7208. Object.defineProperty(InputText.prototype, "placeholderText", {
  7209. /** Gets or sets the text displayed when the control is empty */
  7210. get: function () {
  7211. return this._placeholderText;
  7212. },
  7213. set: function (value) {
  7214. if (this._placeholderText === value) {
  7215. return;
  7216. }
  7217. this._placeholderText = value;
  7218. this._markAsDirty();
  7219. },
  7220. enumerable: true,
  7221. configurable: true
  7222. });
  7223. Object.defineProperty(InputText.prototype, "deadKey", {
  7224. /** Gets or sets the dead key flag */
  7225. get: function () {
  7226. return this._deadKey;
  7227. },
  7228. set: function (flag) {
  7229. this._deadKey = flag;
  7230. },
  7231. enumerable: true,
  7232. configurable: true
  7233. });
  7234. Object.defineProperty(InputText.prototype, "highlightedText", {
  7235. /** Gets or sets the highlight text */
  7236. get: function () {
  7237. return this._highlightedText;
  7238. },
  7239. set: function (text) {
  7240. if (this._highlightedText === text) {
  7241. return;
  7242. }
  7243. this._highlightedText = text;
  7244. this._markAsDirty();
  7245. },
  7246. enumerable: true,
  7247. configurable: true
  7248. });
  7249. Object.defineProperty(InputText.prototype, "addKey", {
  7250. /** Gets or sets if the current key should be added */
  7251. get: function () {
  7252. return this._addKey;
  7253. },
  7254. set: function (flag) {
  7255. this._addKey = flag;
  7256. },
  7257. enumerable: true,
  7258. configurable: true
  7259. });
  7260. Object.defineProperty(InputText.prototype, "currentKey", {
  7261. /** Gets or sets the value of the current key being entered */
  7262. get: function () {
  7263. return this._currentKey;
  7264. },
  7265. set: function (key) {
  7266. this._currentKey = key;
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "text", {
  7272. /** Gets or sets the text displayed in the control */
  7273. get: function () {
  7274. return this._text;
  7275. },
  7276. set: function (value) {
  7277. var valueAsString = value.toString(); // Forcing convertion
  7278. if (this._text === valueAsString) {
  7279. return;
  7280. }
  7281. this._text = valueAsString;
  7282. this._markAsDirty();
  7283. this.onTextChangedObservable.notifyObservers(this);
  7284. },
  7285. enumerable: true,
  7286. configurable: true
  7287. });
  7288. Object.defineProperty(InputText.prototype, "width", {
  7289. /** Gets or sets control width */
  7290. get: function () {
  7291. return this._width.toString(this._host);
  7292. },
  7293. set: function (value) {
  7294. if (this._width.toString(this._host) === value) {
  7295. return;
  7296. }
  7297. if (this._width.fromString(value)) {
  7298. this._markAsDirty();
  7299. }
  7300. this.autoStretchWidth = false;
  7301. },
  7302. enumerable: true,
  7303. configurable: true
  7304. });
  7305. /** @hidden */
  7306. InputText.prototype.onBlur = function () {
  7307. this._isFocused = false;
  7308. this._scrollLeft = null;
  7309. this._cursorOffset = 0;
  7310. clearTimeout(this._blinkTimeout);
  7311. this._markAsDirty();
  7312. this.onBlurObservable.notifyObservers(this);
  7313. this._host.unRegisterClipboardEvents();
  7314. if (this._onClipboardObserver) {
  7315. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7316. }
  7317. var scene = this._host.getScene();
  7318. if (this._onPointerDblTapObserver && scene) {
  7319. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7320. }
  7321. };
  7322. /** @hidden */
  7323. InputText.prototype.onFocus = function () {
  7324. var _this = this;
  7325. if (!this._isEnabled) {
  7326. return;
  7327. }
  7328. this._scrollLeft = null;
  7329. this._isFocused = true;
  7330. this._blinkIsEven = false;
  7331. this._cursorOffset = 0;
  7332. this._markAsDirty();
  7333. this.onFocusObservable.notifyObservers(this);
  7334. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7335. var value = prompt(this.promptMessage);
  7336. if (value !== null) {
  7337. this.text = value;
  7338. }
  7339. this._host.focusedControl = null;
  7340. return;
  7341. }
  7342. this._host.registerClipboardEvents();
  7343. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7344. // process clipboard event, can be configured.
  7345. switch (clipboardInfo.type) {
  7346. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7347. _this._onCopyText(clipboardInfo.event);
  7348. _this.onTextCopyObservable.notifyObservers(_this);
  7349. break;
  7350. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7351. _this._onCutText(clipboardInfo.event);
  7352. _this.onTextCutObservable.notifyObservers(_this);
  7353. break;
  7354. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7355. _this._onPasteText(clipboardInfo.event);
  7356. _this.onTextPasteObservable.notifyObservers(_this);
  7357. break;
  7358. default: return;
  7359. }
  7360. });
  7361. var scene = this._host.getScene();
  7362. if (scene) {
  7363. //register the pointer double tap event
  7364. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7365. if (!_this._isFocused) {
  7366. return;
  7367. }
  7368. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7369. _this._processDblClick(pointerInfo);
  7370. }
  7371. });
  7372. }
  7373. if (this._onFocusSelectAll) {
  7374. this._selectAllText();
  7375. }
  7376. };
  7377. InputText.prototype._getTypeName = function () {
  7378. return "InputText";
  7379. };
  7380. /**
  7381. * Function called to get the list of controls that should not steal the focus from this control
  7382. * @returns an array of controls
  7383. */
  7384. InputText.prototype.keepsFocusWith = function () {
  7385. if (!this._connectedVirtualKeyboard) {
  7386. return null;
  7387. }
  7388. return [this._connectedVirtualKeyboard];
  7389. };
  7390. /** @hidden */
  7391. InputText.prototype.processKey = function (keyCode, key, evt) {
  7392. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7393. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7394. return;
  7395. }
  7396. //select all
  7397. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7398. this._selectAllText();
  7399. evt.preventDefault();
  7400. return;
  7401. }
  7402. // Specific cases
  7403. switch (keyCode) {
  7404. case 32: //SPACE
  7405. key = " "; //ie11 key for space is "Spacebar"
  7406. break;
  7407. case 191: //SLASH
  7408. if (evt) {
  7409. evt.preventDefault();
  7410. }
  7411. break;
  7412. case 8: // BACKSPACE
  7413. if (this._text && this._text.length > 0) {
  7414. //delete the highlighted text
  7415. if (this._isTextHighlightOn) {
  7416. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7417. this._isTextHighlightOn = false;
  7418. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7419. this._blinkIsEven = false;
  7420. if (evt) {
  7421. evt.preventDefault();
  7422. }
  7423. return;
  7424. }
  7425. //delete single character
  7426. if (this._cursorOffset === 0) {
  7427. this.text = this._text.substr(0, this._text.length - 1);
  7428. }
  7429. else {
  7430. var deletePosition = this._text.length - this._cursorOffset;
  7431. if (deletePosition > 0) {
  7432. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7433. }
  7434. }
  7435. }
  7436. if (evt) {
  7437. evt.preventDefault();
  7438. }
  7439. return;
  7440. case 46: // DELETE
  7441. if (this._isTextHighlightOn) {
  7442. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7443. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7444. while (decrementor > 0 && this._cursorOffset > 0) {
  7445. this._cursorOffset--;
  7446. }
  7447. this._isTextHighlightOn = false;
  7448. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7449. if (evt) {
  7450. evt.preventDefault();
  7451. }
  7452. return;
  7453. }
  7454. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7455. var deletePosition = this._text.length - this._cursorOffset;
  7456. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7457. this._cursorOffset--;
  7458. }
  7459. if (evt) {
  7460. evt.preventDefault();
  7461. }
  7462. return;
  7463. case 13: // RETURN
  7464. this._host.focusedControl = null;
  7465. this._isTextHighlightOn = false;
  7466. return;
  7467. case 35: // END
  7468. this._cursorOffset = 0;
  7469. this._blinkIsEven = false;
  7470. this._isTextHighlightOn = false;
  7471. this._markAsDirty();
  7472. return;
  7473. case 36: // HOME
  7474. this._cursorOffset = this._text.length;
  7475. this._blinkIsEven = false;
  7476. this._isTextHighlightOn = false;
  7477. this._markAsDirty();
  7478. return;
  7479. case 37: // LEFT
  7480. this._cursorOffset++;
  7481. if (this._cursorOffset > this._text.length) {
  7482. this._cursorOffset = this._text.length;
  7483. }
  7484. if (evt && evt.shiftKey) {
  7485. // update the cursor
  7486. this._blinkIsEven = false;
  7487. // shift + ctrl/cmd + <-
  7488. if (evt.ctrlKey || evt.metaKey) {
  7489. if (!this._isTextHighlightOn) {
  7490. if (this._text.length === this._cursorOffset) {
  7491. return;
  7492. }
  7493. else {
  7494. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7495. }
  7496. }
  7497. this._startHighlightIndex = 0;
  7498. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7499. this._cursorOffset = this._text.length;
  7500. this._isTextHighlightOn = true;
  7501. this._markAsDirty();
  7502. return;
  7503. }
  7504. //store the starting point
  7505. if (!this._isTextHighlightOn) {
  7506. this._isTextHighlightOn = true;
  7507. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7508. }
  7509. //if text is already highlighted
  7510. else if (this._cursorIndex === -1) {
  7511. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7512. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7513. }
  7514. //set the highlight indexes
  7515. if (this._cursorIndex < this._cursorOffset) {
  7516. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7517. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7518. }
  7519. else if (this._cursorIndex > this._cursorOffset) {
  7520. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7521. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7522. }
  7523. else {
  7524. this._isTextHighlightOn = false;
  7525. }
  7526. this._markAsDirty();
  7527. return;
  7528. }
  7529. if (this._isTextHighlightOn) {
  7530. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7531. this._isTextHighlightOn = false;
  7532. }
  7533. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7534. this._cursorOffset = this.text.length;
  7535. evt.preventDefault();
  7536. }
  7537. this._blinkIsEven = false;
  7538. this._isTextHighlightOn = false;
  7539. this._cursorIndex = -1;
  7540. this._markAsDirty();
  7541. return;
  7542. case 39: // RIGHT
  7543. this._cursorOffset--;
  7544. if (this._cursorOffset < 0) {
  7545. this._cursorOffset = 0;
  7546. }
  7547. if (evt && evt.shiftKey) {
  7548. //update the cursor
  7549. this._blinkIsEven = false;
  7550. //shift + ctrl/cmd + ->
  7551. if (evt.ctrlKey || evt.metaKey) {
  7552. if (!this._isTextHighlightOn) {
  7553. if (this._cursorOffset === 0) {
  7554. return;
  7555. }
  7556. else {
  7557. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7558. }
  7559. }
  7560. this._endHighlightIndex = this._text.length;
  7561. this._isTextHighlightOn = true;
  7562. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7563. this._cursorOffset = 0;
  7564. this._markAsDirty();
  7565. return;
  7566. }
  7567. if (!this._isTextHighlightOn) {
  7568. this._isTextHighlightOn = true;
  7569. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7570. }
  7571. //if text is already highlighted
  7572. else if (this._cursorIndex === -1) {
  7573. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7574. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7575. }
  7576. //set the highlight indexes
  7577. if (this._cursorIndex < this._cursorOffset) {
  7578. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7579. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7580. }
  7581. else if (this._cursorIndex > this._cursorOffset) {
  7582. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7583. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7584. }
  7585. else {
  7586. this._isTextHighlightOn = false;
  7587. }
  7588. this._markAsDirty();
  7589. return;
  7590. }
  7591. if (this._isTextHighlightOn) {
  7592. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7593. this._isTextHighlightOn = false;
  7594. }
  7595. //ctr + ->
  7596. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7597. this._cursorOffset = 0;
  7598. evt.preventDefault();
  7599. }
  7600. this._blinkIsEven = false;
  7601. this._isTextHighlightOn = false;
  7602. this._cursorIndex = -1;
  7603. this._markAsDirty();
  7604. return;
  7605. case 222: // Dead
  7606. if (evt) {
  7607. evt.preventDefault();
  7608. }
  7609. this._cursorIndex = -1;
  7610. this.deadKey = true;
  7611. break;
  7612. }
  7613. // Printable characters
  7614. if (key &&
  7615. ((keyCode === -1) || // Direct access
  7616. (keyCode === 32) || // Space
  7617. (keyCode > 47 && keyCode < 64) || // Numbers
  7618. (keyCode > 64 && keyCode < 91) || // Letters
  7619. (keyCode > 159 && keyCode < 193) || // Special characters
  7620. (keyCode > 218 && keyCode < 223) || // Special characters
  7621. (keyCode > 95 && keyCode < 112))) { // Numpad
  7622. this._currentKey = key;
  7623. this.onBeforeKeyAddObservable.notifyObservers(this);
  7624. key = this._currentKey;
  7625. if (this._addKey) {
  7626. if (this._isTextHighlightOn) {
  7627. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7628. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7629. this._isTextHighlightOn = false;
  7630. this._blinkIsEven = false;
  7631. this._markAsDirty();
  7632. }
  7633. else if (this._cursorOffset === 0) {
  7634. this.text += key;
  7635. }
  7636. else {
  7637. var insertPosition = this._text.length - this._cursorOffset;
  7638. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7639. }
  7640. }
  7641. }
  7642. };
  7643. /** @hidden */
  7644. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7645. //update the cursor
  7646. this._blinkIsEven = false;
  7647. if (this._cursorIndex === -1) {
  7648. this._cursorIndex = offset;
  7649. }
  7650. else {
  7651. if (this._cursorIndex < this._cursorOffset) {
  7652. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7653. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7654. }
  7655. else if (this._cursorIndex > this._cursorOffset) {
  7656. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7657. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7658. }
  7659. else {
  7660. this._isTextHighlightOn = false;
  7661. this._markAsDirty();
  7662. return;
  7663. }
  7664. }
  7665. this._isTextHighlightOn = true;
  7666. this._markAsDirty();
  7667. };
  7668. /** @hidden */
  7669. InputText.prototype._processDblClick = function (evt) {
  7670. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7671. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7672. this._endHighlightIndex = this._startHighlightIndex;
  7673. var rWord = /\w+/g, moveLeft, moveRight;
  7674. do {
  7675. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7676. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7677. } while (moveLeft || moveRight);
  7678. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7679. this.onTextHighlightObservable.notifyObservers(this);
  7680. this._isTextHighlightOn = true;
  7681. this._clickedCoordinate = null;
  7682. this._blinkIsEven = true;
  7683. this._cursorIndex = -1;
  7684. this._markAsDirty();
  7685. };
  7686. /** @hidden */
  7687. InputText.prototype._selectAllText = function () {
  7688. this._blinkIsEven = true;
  7689. this._isTextHighlightOn = true;
  7690. this._startHighlightIndex = 0;
  7691. this._endHighlightIndex = this._text.length;
  7692. this._cursorOffset = this._text.length;
  7693. this._cursorIndex = -1;
  7694. this._markAsDirty();
  7695. };
  7696. /**
  7697. * Handles the keyboard event
  7698. * @param evt Defines the KeyboardEvent
  7699. */
  7700. InputText.prototype.processKeyboard = function (evt) {
  7701. // process pressed key
  7702. this.processKey(evt.keyCode, evt.key, evt);
  7703. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7704. };
  7705. /** @hidden */
  7706. InputText.prototype._onCopyText = function (ev) {
  7707. this._isTextHighlightOn = false;
  7708. //when write permission to clipbaord data is denied
  7709. try {
  7710. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7711. }
  7712. catch (_a) { } //pass
  7713. this._host.clipboardData = this._highlightedText;
  7714. };
  7715. /** @hidden */
  7716. InputText.prototype._onCutText = function (ev) {
  7717. if (!this._highlightedText) {
  7718. return;
  7719. }
  7720. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7721. this._isTextHighlightOn = false;
  7722. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7723. //when write permission to clipbaord data is denied
  7724. try {
  7725. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7726. }
  7727. catch (_a) { } //pass
  7728. this._host.clipboardData = this._highlightedText;
  7729. this._highlightedText = "";
  7730. };
  7731. /** @hidden */
  7732. InputText.prototype._onPasteText = function (ev) {
  7733. var data = "";
  7734. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7735. data = ev.clipboardData.getData("text/plain");
  7736. }
  7737. else {
  7738. //get the cached data; returns blank string by default
  7739. data = this._host.clipboardData;
  7740. }
  7741. var insertPosition = this._text.length - this._cursorOffset;
  7742. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7743. };
  7744. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7745. var _this = this;
  7746. context.save();
  7747. this._applyStates(context);
  7748. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7749. context.shadowColor = this.shadowColor;
  7750. context.shadowBlur = this.shadowBlur;
  7751. context.shadowOffsetX = this.shadowOffsetX;
  7752. context.shadowOffsetY = this.shadowOffsetY;
  7753. }
  7754. // Background
  7755. if (this._isFocused) {
  7756. if (this._focusedBackground) {
  7757. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7758. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7759. }
  7760. }
  7761. else if (this._background) {
  7762. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7763. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7764. }
  7765. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7766. context.shadowBlur = 0;
  7767. context.shadowOffsetX = 0;
  7768. context.shadowOffsetY = 0;
  7769. }
  7770. if (!this._fontOffset) {
  7771. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7772. }
  7773. // Text
  7774. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7775. if (this.color) {
  7776. context.fillStyle = this.color;
  7777. }
  7778. var text = this._beforeRenderText(this._text);
  7779. if (!this._isFocused && !this._text && this._placeholderText) {
  7780. text = this._placeholderText;
  7781. if (this._placeholderColor) {
  7782. context.fillStyle = this._placeholderColor;
  7783. }
  7784. }
  7785. this._textWidth = context.measureText(text).width;
  7786. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7787. if (this._autoStretchWidth) {
  7788. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7789. }
  7790. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7791. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7792. context.save();
  7793. context.beginPath();
  7794. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7795. context.clip();
  7796. if (this._isFocused && this._textWidth > availableWidth) {
  7797. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7798. if (!this._scrollLeft) {
  7799. this._scrollLeft = textLeft;
  7800. }
  7801. }
  7802. else {
  7803. this._scrollLeft = clipTextLeft;
  7804. }
  7805. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7806. // Cursor
  7807. if (this._isFocused) {
  7808. // Need to move cursor
  7809. if (this._clickedCoordinate) {
  7810. var rightPosition = this._scrollLeft + this._textWidth;
  7811. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7812. var currentSize = 0;
  7813. this._cursorOffset = 0;
  7814. var previousDist = 0;
  7815. do {
  7816. if (this._cursorOffset) {
  7817. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7818. }
  7819. this._cursorOffset++;
  7820. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7821. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7822. // Find closest move
  7823. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7824. this._cursorOffset--;
  7825. }
  7826. this._blinkIsEven = false;
  7827. this._clickedCoordinate = null;
  7828. }
  7829. // Render cursor
  7830. if (!this._blinkIsEven) {
  7831. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7832. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7833. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7834. if (cursorLeft < clipTextLeft) {
  7835. this._scrollLeft += (clipTextLeft - cursorLeft);
  7836. cursorLeft = clipTextLeft;
  7837. this._markAsDirty();
  7838. }
  7839. else if (cursorLeft > clipTextLeft + availableWidth) {
  7840. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7841. cursorLeft = clipTextLeft + availableWidth;
  7842. this._markAsDirty();
  7843. }
  7844. if (!this._isTextHighlightOn) {
  7845. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7846. }
  7847. }
  7848. clearTimeout(this._blinkTimeout);
  7849. this._blinkTimeout = setTimeout(function () {
  7850. _this._blinkIsEven = !_this._blinkIsEven;
  7851. _this._markAsDirty();
  7852. }, 500);
  7853. //show the highlighted text
  7854. if (this._isTextHighlightOn) {
  7855. clearTimeout(this._blinkTimeout);
  7856. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7857. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7858. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7859. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7860. if (highlightCursorLeft < clipTextLeft) {
  7861. width = width - (clipTextLeft - highlightCursorLeft);
  7862. if (!width) {
  7863. // when using left arrow on text.length > availableWidth;
  7864. // assigns the width of the first letter after clipTextLeft
  7865. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7866. }
  7867. highlightCursorLeft = clipTextLeft;
  7868. }
  7869. //for transparancy
  7870. context.globalAlpha = this._highligherOpacity;
  7871. context.fillStyle = this._textHighlightColor;
  7872. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7873. context.globalAlpha = 1.0;
  7874. }
  7875. }
  7876. context.restore();
  7877. // Border
  7878. if (this._thickness) {
  7879. if (this._isFocused) {
  7880. if (this.focusedColor) {
  7881. context.strokeStyle = this.focusedColor;
  7882. }
  7883. }
  7884. else {
  7885. if (this.color) {
  7886. context.strokeStyle = this.color;
  7887. }
  7888. }
  7889. context.lineWidth = this._thickness;
  7890. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7891. }
  7892. context.restore();
  7893. };
  7894. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7895. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7896. return false;
  7897. }
  7898. this._clickedCoordinate = coordinates.x;
  7899. this._isTextHighlightOn = false;
  7900. this._highlightedText = "";
  7901. this._cursorIndex = -1;
  7902. this._isPointerDown = true;
  7903. this._host._capturingControl[pointerId] = this;
  7904. if (this._host.focusedControl === this) {
  7905. // Move cursor
  7906. clearTimeout(this._blinkTimeout);
  7907. this._markAsDirty();
  7908. return true;
  7909. }
  7910. if (!this._isEnabled) {
  7911. return false;
  7912. }
  7913. this._host.focusedControl = this;
  7914. return true;
  7915. };
  7916. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7917. if (this._host.focusedControl === this && this._isPointerDown) {
  7918. this._clickedCoordinate = coordinates.x;
  7919. this._markAsDirty();
  7920. this._updateValueFromCursorIndex(this._cursorOffset);
  7921. }
  7922. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7923. };
  7924. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7925. this._isPointerDown = false;
  7926. delete this._host._capturingControl[pointerId];
  7927. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7928. };
  7929. InputText.prototype._beforeRenderText = function (text) {
  7930. return text;
  7931. };
  7932. InputText.prototype.dispose = function () {
  7933. _super.prototype.dispose.call(this);
  7934. this.onBlurObservable.clear();
  7935. this.onFocusObservable.clear();
  7936. this.onTextChangedObservable.clear();
  7937. this.onTextCopyObservable.clear();
  7938. this.onTextCutObservable.clear();
  7939. this.onTextPasteObservable.clear();
  7940. this.onTextHighlightObservable.clear();
  7941. this.onKeyboardEventProcessedObservable.clear();
  7942. };
  7943. return InputText;
  7944. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7945. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7946. /***/ }),
  7947. /***/ "./2D/controls/line.ts":
  7948. /*!*****************************!*\
  7949. !*** ./2D/controls/line.ts ***!
  7950. \*****************************/
  7951. /*! exports provided: Line */
  7952. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7953. "use strict";
  7954. __webpack_require__.r(__webpack_exports__);
  7955. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7956. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7957. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7958. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7959. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7960. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7961. /** Class used to render 2D lines */
  7962. var Line = /** @class */ (function (_super) {
  7963. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7964. /**
  7965. * Creates a new Line
  7966. * @param name defines the control name
  7967. */
  7968. function Line(name) {
  7969. var _this = _super.call(this, name) || this;
  7970. _this.name = name;
  7971. _this._lineWidth = 1;
  7972. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7973. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7974. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7975. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7976. _this._dash = new Array();
  7977. _this._automaticSize = true;
  7978. _this.isHitTestVisible = false;
  7979. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7980. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7981. return _this;
  7982. }
  7983. Object.defineProperty(Line.prototype, "dash", {
  7984. /** Gets or sets the dash pattern */
  7985. get: function () {
  7986. return this._dash;
  7987. },
  7988. set: function (value) {
  7989. if (this._dash === value) {
  7990. return;
  7991. }
  7992. this._dash = value;
  7993. this._markAsDirty();
  7994. },
  7995. enumerable: true,
  7996. configurable: true
  7997. });
  7998. Object.defineProperty(Line.prototype, "connectedControl", {
  7999. /** Gets or sets the control connected with the line end */
  8000. get: function () {
  8001. return this._connectedControl;
  8002. },
  8003. set: function (value) {
  8004. var _this = this;
  8005. if (this._connectedControl === value) {
  8006. return;
  8007. }
  8008. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8009. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8010. this._connectedControlDirtyObserver = null;
  8011. }
  8012. if (value) {
  8013. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8014. }
  8015. this._connectedControl = value;
  8016. this._markAsDirty();
  8017. },
  8018. enumerable: true,
  8019. configurable: true
  8020. });
  8021. Object.defineProperty(Line.prototype, "x1", {
  8022. /** Gets or sets start coordinates on X axis */
  8023. get: function () {
  8024. return this._x1.toString(this._host);
  8025. },
  8026. set: function (value) {
  8027. if (this._x1.toString(this._host) === value) {
  8028. return;
  8029. }
  8030. if (this._x1.fromString(value)) {
  8031. this._markAsDirty();
  8032. }
  8033. },
  8034. enumerable: true,
  8035. configurable: true
  8036. });
  8037. Object.defineProperty(Line.prototype, "y1", {
  8038. /** Gets or sets start coordinates on Y axis */
  8039. get: function () {
  8040. return this._y1.toString(this._host);
  8041. },
  8042. set: function (value) {
  8043. if (this._y1.toString(this._host) === value) {
  8044. return;
  8045. }
  8046. if (this._y1.fromString(value)) {
  8047. this._markAsDirty();
  8048. }
  8049. },
  8050. enumerable: true,
  8051. configurable: true
  8052. });
  8053. Object.defineProperty(Line.prototype, "x2", {
  8054. /** Gets or sets end coordinates on X axis */
  8055. get: function () {
  8056. return this._x2.toString(this._host);
  8057. },
  8058. set: function (value) {
  8059. if (this._x2.toString(this._host) === value) {
  8060. return;
  8061. }
  8062. if (this._x2.fromString(value)) {
  8063. this._markAsDirty();
  8064. }
  8065. },
  8066. enumerable: true,
  8067. configurable: true
  8068. });
  8069. Object.defineProperty(Line.prototype, "y2", {
  8070. /** Gets or sets end coordinates on Y axis */
  8071. get: function () {
  8072. return this._y2.toString(this._host);
  8073. },
  8074. set: function (value) {
  8075. if (this._y2.toString(this._host) === value) {
  8076. return;
  8077. }
  8078. if (this._y2.fromString(value)) {
  8079. this._markAsDirty();
  8080. }
  8081. },
  8082. enumerable: true,
  8083. configurable: true
  8084. });
  8085. Object.defineProperty(Line.prototype, "lineWidth", {
  8086. /** Gets or sets line width */
  8087. get: function () {
  8088. return this._lineWidth;
  8089. },
  8090. set: function (value) {
  8091. if (this._lineWidth === value) {
  8092. return;
  8093. }
  8094. this._lineWidth = value;
  8095. this._markAsDirty();
  8096. },
  8097. enumerable: true,
  8098. configurable: true
  8099. });
  8100. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8101. /** Gets or sets horizontal alignment */
  8102. set: function (value) {
  8103. return;
  8104. },
  8105. enumerable: true,
  8106. configurable: true
  8107. });
  8108. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8109. /** Gets or sets vertical alignment */
  8110. set: function (value) {
  8111. return;
  8112. },
  8113. enumerable: true,
  8114. configurable: true
  8115. });
  8116. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8117. get: function () {
  8118. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8119. },
  8120. enumerable: true,
  8121. configurable: true
  8122. });
  8123. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8124. get: function () {
  8125. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8126. },
  8127. enumerable: true,
  8128. configurable: true
  8129. });
  8130. Line.prototype._getTypeName = function () {
  8131. return "Line";
  8132. };
  8133. Line.prototype._draw = function (context) {
  8134. context.save();
  8135. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8136. context.shadowColor = this.shadowColor;
  8137. context.shadowBlur = this.shadowBlur;
  8138. context.shadowOffsetX = this.shadowOffsetX;
  8139. context.shadowOffsetY = this.shadowOffsetY;
  8140. }
  8141. this._applyStates(context);
  8142. context.strokeStyle = this.color;
  8143. context.lineWidth = this._lineWidth;
  8144. context.setLineDash(this._dash);
  8145. context.beginPath();
  8146. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8147. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8148. context.stroke();
  8149. context.restore();
  8150. };
  8151. Line.prototype._measure = function () {
  8152. // Width / Height
  8153. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8154. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8155. };
  8156. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8157. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8158. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8159. };
  8160. /**
  8161. * Move one end of the line given 3D cartesian coordinates.
  8162. * @param position Targeted world position
  8163. * @param scene Scene
  8164. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8165. */
  8166. Line.prototype.moveToVector3 = function (position, scene, end) {
  8167. if (end === void 0) { end = false; }
  8168. if (!this._host || this.parent !== this._host._rootContainer) {
  8169. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8170. return;
  8171. }
  8172. var globalViewport = this._host._getGlobalViewport(scene);
  8173. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8174. this._moveToProjectedPosition(projectedPosition, end);
  8175. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8176. this.notRenderable = true;
  8177. return;
  8178. }
  8179. this.notRenderable = false;
  8180. };
  8181. /**
  8182. * Move one end of the line to a position in screen absolute space.
  8183. * @param projectedPosition Position in screen absolute space (X, Y)
  8184. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8185. */
  8186. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8187. if (end === void 0) { end = false; }
  8188. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8189. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8190. if (end) {
  8191. this.x2 = x;
  8192. this.y2 = y;
  8193. this._x2.ignoreAdaptiveScaling = true;
  8194. this._y2.ignoreAdaptiveScaling = true;
  8195. }
  8196. else {
  8197. this.x1 = x;
  8198. this.y1 = y;
  8199. this._x1.ignoreAdaptiveScaling = true;
  8200. this._y1.ignoreAdaptiveScaling = true;
  8201. }
  8202. };
  8203. return Line;
  8204. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8205. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8206. /***/ }),
  8207. /***/ "./2D/controls/multiLine.ts":
  8208. /*!**********************************!*\
  8209. !*** ./2D/controls/multiLine.ts ***!
  8210. \**********************************/
  8211. /*! exports provided: MultiLine */
  8212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8213. "use strict";
  8214. __webpack_require__.r(__webpack_exports__);
  8215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8216. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8217. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8218. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8219. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8220. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8221. /**
  8222. * Class used to create multi line control
  8223. */
  8224. var MultiLine = /** @class */ (function (_super) {
  8225. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8226. /**
  8227. * Creates a new MultiLine
  8228. * @param name defines the control name
  8229. */
  8230. function MultiLine(name) {
  8231. var _this = _super.call(this, name) || this;
  8232. _this.name = name;
  8233. _this._lineWidth = 1;
  8234. /** Function called when a point is updated */
  8235. _this.onPointUpdate = function () {
  8236. _this._markAsDirty();
  8237. };
  8238. _this._automaticSize = true;
  8239. _this.isHitTestVisible = false;
  8240. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8241. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8242. _this._dash = [];
  8243. _this._points = [];
  8244. return _this;
  8245. }
  8246. Object.defineProperty(MultiLine.prototype, "dash", {
  8247. /** Gets or sets dash pattern */
  8248. get: function () {
  8249. return this._dash;
  8250. },
  8251. set: function (value) {
  8252. if (this._dash === value) {
  8253. return;
  8254. }
  8255. this._dash = value;
  8256. this._markAsDirty();
  8257. },
  8258. enumerable: true,
  8259. configurable: true
  8260. });
  8261. /**
  8262. * Gets point stored at specified index
  8263. * @param index defines the index to look for
  8264. * @returns the requested point if found
  8265. */
  8266. MultiLine.prototype.getAt = function (index) {
  8267. if (!this._points[index]) {
  8268. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8269. }
  8270. return this._points[index];
  8271. };
  8272. /**
  8273. * Adds new points to the point collection
  8274. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8275. * @returns the list of created MultiLinePoint
  8276. */
  8277. MultiLine.prototype.add = function () {
  8278. var _this = this;
  8279. var items = [];
  8280. for (var _i = 0; _i < arguments.length; _i++) {
  8281. items[_i] = arguments[_i];
  8282. }
  8283. return items.map(function (item) { return _this.push(item); });
  8284. };
  8285. /**
  8286. * Adds a new point to the point collection
  8287. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8288. * @returns the created MultiLinePoint
  8289. */
  8290. MultiLine.prototype.push = function (item) {
  8291. var point = this.getAt(this._points.length);
  8292. if (item == null) {
  8293. return point;
  8294. }
  8295. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8296. point.mesh = item;
  8297. }
  8298. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8299. point.control = item;
  8300. }
  8301. else if (item.x != null && item.y != null) {
  8302. point.x = item.x;
  8303. point.y = item.y;
  8304. }
  8305. return point;
  8306. };
  8307. /**
  8308. * Remove a specific value or point from the active point collection
  8309. * @param value defines the value or point to remove
  8310. */
  8311. MultiLine.prototype.remove = function (value) {
  8312. var index;
  8313. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8314. index = this._points.indexOf(value);
  8315. if (index === -1) {
  8316. return;
  8317. }
  8318. }
  8319. else {
  8320. index = value;
  8321. }
  8322. var point = this._points[index];
  8323. if (!point) {
  8324. return;
  8325. }
  8326. point.dispose();
  8327. this._points.splice(index, 1);
  8328. };
  8329. /**
  8330. * Resets this object to initial state (no point)
  8331. */
  8332. MultiLine.prototype.reset = function () {
  8333. while (this._points.length > 0) {
  8334. this.remove(this._points.length - 1);
  8335. }
  8336. };
  8337. /**
  8338. * Resets all links
  8339. */
  8340. MultiLine.prototype.resetLinks = function () {
  8341. this._points.forEach(function (point) {
  8342. if (point != null) {
  8343. point.resetLinks();
  8344. }
  8345. });
  8346. };
  8347. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8348. /** Gets or sets line width */
  8349. get: function () {
  8350. return this._lineWidth;
  8351. },
  8352. set: function (value) {
  8353. if (this._lineWidth === value) {
  8354. return;
  8355. }
  8356. this._lineWidth = value;
  8357. this._markAsDirty();
  8358. },
  8359. enumerable: true,
  8360. configurable: true
  8361. });
  8362. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8363. set: function (value) {
  8364. return;
  8365. },
  8366. enumerable: true,
  8367. configurable: true
  8368. });
  8369. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8370. set: function (value) {
  8371. return;
  8372. },
  8373. enumerable: true,
  8374. configurable: true
  8375. });
  8376. MultiLine.prototype._getTypeName = function () {
  8377. return "MultiLine";
  8378. };
  8379. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8380. context.save();
  8381. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8382. context.shadowColor = this.shadowColor;
  8383. context.shadowBlur = this.shadowBlur;
  8384. context.shadowOffsetX = this.shadowOffsetX;
  8385. context.shadowOffsetY = this.shadowOffsetY;
  8386. }
  8387. this._applyStates(context);
  8388. context.strokeStyle = this.color;
  8389. context.lineWidth = this._lineWidth;
  8390. context.setLineDash(this._dash);
  8391. context.beginPath();
  8392. var first = true; //first index is not necessarily 0
  8393. this._points.forEach(function (point) {
  8394. if (!point) {
  8395. return;
  8396. }
  8397. if (first) {
  8398. context.moveTo(point._point.x, point._point.y);
  8399. first = false;
  8400. }
  8401. else {
  8402. context.lineTo(point._point.x, point._point.y);
  8403. }
  8404. });
  8405. context.stroke();
  8406. context.restore();
  8407. };
  8408. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8409. var _this = this;
  8410. this._minX = null;
  8411. this._minY = null;
  8412. this._maxX = null;
  8413. this._maxY = null;
  8414. this._points.forEach(function (point, index) {
  8415. if (!point) {
  8416. return;
  8417. }
  8418. point.translate();
  8419. if (_this._minX == null || point._point.x < _this._minX) {
  8420. _this._minX = point._point.x;
  8421. }
  8422. if (_this._minY == null || point._point.y < _this._minY) {
  8423. _this._minY = point._point.y;
  8424. }
  8425. if (_this._maxX == null || point._point.x > _this._maxX) {
  8426. _this._maxX = point._point.x;
  8427. }
  8428. if (_this._maxY == null || point._point.y > _this._maxY) {
  8429. _this._maxY = point._point.y;
  8430. }
  8431. });
  8432. if (this._minX == null) {
  8433. this._minX = 0;
  8434. }
  8435. if (this._minY == null) {
  8436. this._minY = 0;
  8437. }
  8438. if (this._maxX == null) {
  8439. this._maxX = 0;
  8440. }
  8441. if (this._maxY == null) {
  8442. this._maxY = 0;
  8443. }
  8444. };
  8445. MultiLine.prototype._measure = function () {
  8446. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8447. return;
  8448. }
  8449. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8450. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8451. };
  8452. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8453. if (this._minX == null || this._minY == null) {
  8454. return;
  8455. }
  8456. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8457. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8458. };
  8459. MultiLine.prototype.dispose = function () {
  8460. this.reset();
  8461. _super.prototype.dispose.call(this);
  8462. };
  8463. return MultiLine;
  8464. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8465. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8466. /***/ }),
  8467. /***/ "./2D/controls/radioButton.ts":
  8468. /*!************************************!*\
  8469. !*** ./2D/controls/radioButton.ts ***!
  8470. \************************************/
  8471. /*! exports provided: RadioButton */
  8472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8473. "use strict";
  8474. __webpack_require__.r(__webpack_exports__);
  8475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8477. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8478. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8479. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8480. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8481. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8482. /**
  8483. * Class used to create radio button controls
  8484. */
  8485. var RadioButton = /** @class */ (function (_super) {
  8486. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8487. /**
  8488. * Creates a new RadioButton
  8489. * @param name defines the control name
  8490. */
  8491. function RadioButton(name) {
  8492. var _this = _super.call(this, name) || this;
  8493. _this.name = name;
  8494. _this._isChecked = false;
  8495. _this._background = "black";
  8496. _this._checkSizeRatio = 0.8;
  8497. _this._thickness = 1;
  8498. /** Gets or sets group name */
  8499. _this.group = "";
  8500. /** Observable raised when isChecked is changed */
  8501. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8502. _this.isPointerBlocker = true;
  8503. return _this;
  8504. }
  8505. Object.defineProperty(RadioButton.prototype, "thickness", {
  8506. /** Gets or sets border thickness */
  8507. get: function () {
  8508. return this._thickness;
  8509. },
  8510. set: function (value) {
  8511. if (this._thickness === value) {
  8512. return;
  8513. }
  8514. this._thickness = value;
  8515. this._markAsDirty();
  8516. },
  8517. enumerable: true,
  8518. configurable: true
  8519. });
  8520. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8521. /** Gets or sets a value indicating the ratio between overall size and check size */
  8522. get: function () {
  8523. return this._checkSizeRatio;
  8524. },
  8525. set: function (value) {
  8526. value = Math.max(Math.min(1, value), 0);
  8527. if (this._checkSizeRatio === value) {
  8528. return;
  8529. }
  8530. this._checkSizeRatio = value;
  8531. this._markAsDirty();
  8532. },
  8533. enumerable: true,
  8534. configurable: true
  8535. });
  8536. Object.defineProperty(RadioButton.prototype, "background", {
  8537. /** Gets or sets background color */
  8538. get: function () {
  8539. return this._background;
  8540. },
  8541. set: function (value) {
  8542. if (this._background === value) {
  8543. return;
  8544. }
  8545. this._background = value;
  8546. this._markAsDirty();
  8547. },
  8548. enumerable: true,
  8549. configurable: true
  8550. });
  8551. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8552. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8553. get: function () {
  8554. return this._isChecked;
  8555. },
  8556. set: function (value) {
  8557. var _this = this;
  8558. if (this._isChecked === value) {
  8559. return;
  8560. }
  8561. this._isChecked = value;
  8562. this._markAsDirty();
  8563. this.onIsCheckedChangedObservable.notifyObservers(value);
  8564. if (this._isChecked && this._host) {
  8565. // Update all controls from same group
  8566. this._host.executeOnAllControls(function (control) {
  8567. if (control === _this) {
  8568. return;
  8569. }
  8570. if (control.group === undefined) {
  8571. return;
  8572. }
  8573. var childRadio = control;
  8574. if (childRadio.group === _this.group) {
  8575. childRadio.isChecked = false;
  8576. }
  8577. });
  8578. }
  8579. },
  8580. enumerable: true,
  8581. configurable: true
  8582. });
  8583. RadioButton.prototype._getTypeName = function () {
  8584. return "RadioButton";
  8585. };
  8586. RadioButton.prototype._draw = function (context) {
  8587. context.save();
  8588. this._applyStates(context);
  8589. var actualWidth = this._currentMeasure.width - this._thickness;
  8590. var actualHeight = this._currentMeasure.height - this._thickness;
  8591. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8592. context.shadowColor = this.shadowColor;
  8593. context.shadowBlur = this.shadowBlur;
  8594. context.shadowOffsetX = this.shadowOffsetX;
  8595. context.shadowOffsetY = this.shadowOffsetY;
  8596. }
  8597. // Outer
  8598. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8599. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8600. context.fill();
  8601. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8602. context.shadowBlur = 0;
  8603. context.shadowOffsetX = 0;
  8604. context.shadowOffsetY = 0;
  8605. }
  8606. context.strokeStyle = this.color;
  8607. context.lineWidth = this._thickness;
  8608. context.stroke();
  8609. // Inner
  8610. if (this._isChecked) {
  8611. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8612. var offsetWidth = actualWidth * this._checkSizeRatio;
  8613. var offseHeight = actualHeight * this._checkSizeRatio;
  8614. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8615. context.fill();
  8616. }
  8617. context.restore();
  8618. };
  8619. // Events
  8620. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8621. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8622. return false;
  8623. }
  8624. if (!this.isChecked) {
  8625. this.isChecked = true;
  8626. }
  8627. return true;
  8628. };
  8629. /**
  8630. * Utility function to easily create a radio button with a header
  8631. * @param title defines the label to use for the header
  8632. * @param group defines the group to use for the radio button
  8633. * @param isChecked defines the initial state of the radio button
  8634. * @param onValueChanged defines the callback to call when value changes
  8635. * @returns a StackPanel containing the radio button and a textBlock
  8636. */
  8637. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8638. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8639. panel.isVertical = false;
  8640. panel.height = "30px";
  8641. var radio = new RadioButton();
  8642. radio.width = "20px";
  8643. radio.height = "20px";
  8644. radio.isChecked = isChecked;
  8645. radio.color = "green";
  8646. radio.group = group;
  8647. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8648. panel.addControl(radio);
  8649. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8650. header.text = title;
  8651. header.width = "180px";
  8652. header.paddingLeft = "5px";
  8653. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8654. header.color = "white";
  8655. panel.addControl(header);
  8656. return panel;
  8657. };
  8658. return RadioButton;
  8659. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8660. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8661. /***/ }),
  8662. /***/ "./2D/controls/rectangle.ts":
  8663. /*!**********************************!*\
  8664. !*** ./2D/controls/rectangle.ts ***!
  8665. \**********************************/
  8666. /*! exports provided: Rectangle */
  8667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8668. "use strict";
  8669. __webpack_require__.r(__webpack_exports__);
  8670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8673. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  8674. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8675. /** Class used to create rectangle container */
  8676. var Rectangle = /** @class */ (function (_super) {
  8677. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8678. /**
  8679. * Creates a new Rectangle
  8680. * @param name defines the control name
  8681. */
  8682. function Rectangle(name) {
  8683. var _this = _super.call(this, name) || this;
  8684. _this.name = name;
  8685. _this._thickness = 1;
  8686. _this._cornerRadius = 0;
  8687. return _this;
  8688. }
  8689. Object.defineProperty(Rectangle.prototype, "thickness", {
  8690. /** Gets or sets border thickness */
  8691. get: function () {
  8692. return this._thickness;
  8693. },
  8694. set: function (value) {
  8695. if (this._thickness === value) {
  8696. return;
  8697. }
  8698. this._thickness = value;
  8699. this._markAsDirty();
  8700. },
  8701. enumerable: true,
  8702. configurable: true
  8703. });
  8704. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8705. /** Gets or sets the corner radius angle */
  8706. get: function () {
  8707. return this._cornerRadius;
  8708. },
  8709. set: function (value) {
  8710. if (value < 0) {
  8711. value = 0;
  8712. }
  8713. if (this._cornerRadius === value) {
  8714. return;
  8715. }
  8716. this._cornerRadius = value;
  8717. this._markAsDirty();
  8718. },
  8719. enumerable: true,
  8720. configurable: true
  8721. });
  8722. Rectangle.prototype._getTypeName = function () {
  8723. return "Rectangle";
  8724. };
  8725. Rectangle.prototype._localDraw = function (context) {
  8726. context.save();
  8727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8728. context.shadowColor = this.shadowColor;
  8729. context.shadowBlur = this.shadowBlur;
  8730. context.shadowOffsetX = this.shadowOffsetX;
  8731. context.shadowOffsetY = this.shadowOffsetY;
  8732. }
  8733. if (this._background) {
  8734. context.fillStyle = this._background;
  8735. if (this._cornerRadius) {
  8736. this._drawRoundedRect(context, this._thickness / 2);
  8737. context.fill();
  8738. }
  8739. else {
  8740. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8741. }
  8742. }
  8743. if (this._thickness) {
  8744. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8745. context.shadowBlur = 0;
  8746. context.shadowOffsetX = 0;
  8747. context.shadowOffsetY = 0;
  8748. }
  8749. if (this.color) {
  8750. context.strokeStyle = this.color;
  8751. }
  8752. context.lineWidth = this._thickness;
  8753. if (this._cornerRadius) {
  8754. this._drawRoundedRect(context, this._thickness / 2);
  8755. context.stroke();
  8756. }
  8757. else {
  8758. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8759. }
  8760. }
  8761. context.restore();
  8762. };
  8763. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8764. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8765. this._measureForChildren.width -= 2 * this._thickness;
  8766. this._measureForChildren.height -= 2 * this._thickness;
  8767. this._measureForChildren.left += this._thickness;
  8768. this._measureForChildren.top += this._thickness;
  8769. };
  8770. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8771. if (offset === void 0) { offset = 0; }
  8772. var x = this._currentMeasure.left + offset;
  8773. var y = this._currentMeasure.top + offset;
  8774. var width = this._currentMeasure.width - offset * 2;
  8775. var height = this._currentMeasure.height - offset * 2;
  8776. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8777. context.beginPath();
  8778. context.moveTo(x + radius, y);
  8779. context.lineTo(x + width - radius, y);
  8780. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8781. context.lineTo(x + width, y + height - radius);
  8782. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8783. context.lineTo(x + radius, y + height);
  8784. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8785. context.lineTo(x, y + radius);
  8786. context.quadraticCurveTo(x, y, x + radius, y);
  8787. context.closePath();
  8788. };
  8789. Rectangle.prototype._clipForChildren = function (context) {
  8790. if (this._cornerRadius) {
  8791. this._drawRoundedRect(context, this._thickness);
  8792. context.clip();
  8793. }
  8794. };
  8795. return Rectangle;
  8796. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8797. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8798. /***/ }),
  8799. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8800. /*!***************************************************!*\
  8801. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8802. \***************************************************/
  8803. /*! exports provided: ScrollViewer */
  8804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8805. "use strict";
  8806. __webpack_require__.r(__webpack_exports__);
  8807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8809. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8810. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8811. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8812. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8813. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8814. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8815. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8816. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8817. /**
  8818. * Class used to hold a viewer window and sliders in a grid
  8819. */
  8820. var ScrollViewer = /** @class */ (function (_super) {
  8821. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8822. /**
  8823. * Creates a new ScrollViewer
  8824. * @param name of ScrollViewer
  8825. */
  8826. function ScrollViewer(name, isImageBased) {
  8827. var _this = _super.call(this, name) || this;
  8828. _this._barSize = 20;
  8829. _this._pointerIsOver = false;
  8830. _this._wheelPrecision = 0.05;
  8831. _this._thumbLength = 0.5;
  8832. _this._thumbHeight = 1;
  8833. _this._barImageHeight = 1;
  8834. _this._useImageBar = isImageBased ? isImageBased : false;
  8835. _this.onDirtyObservable.add(function () {
  8836. _this._horizontalBarSpace.color = _this.color;
  8837. _this._verticalBarSpace.color = _this.color;
  8838. _this._dragSpace.color = _this.color;
  8839. });
  8840. _this.onPointerEnterObservable.add(function () {
  8841. _this._pointerIsOver = true;
  8842. });
  8843. _this.onPointerOutObservable.add(function () {
  8844. _this._pointerIsOver = false;
  8845. });
  8846. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8847. if (_this._useImageBar) {
  8848. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8849. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8850. }
  8851. else {
  8852. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8853. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8854. }
  8855. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8856. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8857. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8858. _this._grid.addColumnDefinition(1);
  8859. _this._grid.addColumnDefinition(0, true);
  8860. _this._grid.addRowDefinition(1);
  8861. _this._grid.addRowDefinition(0, true);
  8862. _super.prototype.addControl.call(_this, _this._grid);
  8863. _this._grid.addControl(_this._window, 0, 0);
  8864. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8865. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8866. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8867. _this._verticalBarSpace.thickness = 1;
  8868. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8869. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8870. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8871. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8872. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8873. _this._horizontalBarSpace.thickness = 1;
  8874. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8875. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8876. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8877. _this._dragSpace.thickness = 1;
  8878. _this._grid.addControl(_this._dragSpace, 1, 1);
  8879. // Colors
  8880. if (!_this._useImageBar) {
  8881. _this.barColor = "grey";
  8882. _this.barBackground = "transparent";
  8883. }
  8884. return _this;
  8885. }
  8886. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8887. /**
  8888. * Gets the horizontal scrollbar
  8889. */
  8890. get: function () {
  8891. return this._horizontalBar;
  8892. },
  8893. enumerable: true,
  8894. configurable: true
  8895. });
  8896. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8897. /**
  8898. * Gets the vertical scrollbar
  8899. */
  8900. get: function () {
  8901. return this._verticalBar;
  8902. },
  8903. enumerable: true,
  8904. configurable: true
  8905. });
  8906. /**
  8907. * Adds a new control to the current container
  8908. * @param control defines the control to add
  8909. * @returns the current container
  8910. */
  8911. ScrollViewer.prototype.addControl = function (control) {
  8912. if (!control) {
  8913. return this;
  8914. }
  8915. this._window.addControl(control);
  8916. return this;
  8917. };
  8918. /**
  8919. * Removes a control from the current container
  8920. * @param control defines the control to remove
  8921. * @returns the current container
  8922. */
  8923. ScrollViewer.prototype.removeControl = function (control) {
  8924. this._window.removeControl(control);
  8925. return this;
  8926. };
  8927. Object.defineProperty(ScrollViewer.prototype, "children", {
  8928. /** Gets the list of children */
  8929. get: function () {
  8930. return this._window.children;
  8931. },
  8932. enumerable: true,
  8933. configurable: true
  8934. });
  8935. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8936. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8937. var child = _a[_i];
  8938. child._markMatrixAsDirty();
  8939. }
  8940. };
  8941. /** Reset the scroll viewer window to initial size */
  8942. ScrollViewer.prototype.resetWindow = function () {
  8943. this._window.width = "100%";
  8944. this._window.height = "100%";
  8945. };
  8946. ScrollViewer.prototype._getTypeName = function () {
  8947. return "ScrollViewer";
  8948. };
  8949. ScrollViewer.prototype._buildClientSizes = function () {
  8950. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8951. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8952. this._clientWidth = this._window.parentClientWidth;
  8953. this._clientHeight = this._window.parentClientHeight;
  8954. };
  8955. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8956. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8957. this._buildClientSizes();
  8958. };
  8959. ScrollViewer.prototype._postMeasure = function () {
  8960. _super.prototype._postMeasure.call(this);
  8961. this._updateScroller();
  8962. };
  8963. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8964. /**
  8965. * Gets or sets the mouse wheel precision
  8966. * from 0 to 1 with a default value of 0.05
  8967. * */
  8968. get: function () {
  8969. return this._wheelPrecision;
  8970. },
  8971. set: function (value) {
  8972. if (this._wheelPrecision === value) {
  8973. return;
  8974. }
  8975. if (value < 0) {
  8976. value = 0;
  8977. }
  8978. if (value > 1) {
  8979. value = 1;
  8980. }
  8981. this._wheelPrecision = value;
  8982. },
  8983. enumerable: true,
  8984. configurable: true
  8985. });
  8986. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  8987. /** Gets or sets the scroll bar container background color */
  8988. get: function () {
  8989. return this._horizontalBarSpace.background;
  8990. },
  8991. set: function (color) {
  8992. if (this._horizontalBarSpace.background === color) {
  8993. return;
  8994. }
  8995. this._horizontalBarSpace.background = color;
  8996. this._verticalBarSpace.background = color;
  8997. },
  8998. enumerable: true,
  8999. configurable: true
  9000. });
  9001. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9002. /** Gets or sets the bar color */
  9003. get: function () {
  9004. return this._barColor;
  9005. },
  9006. set: function (color) {
  9007. if (this._barColor === color) {
  9008. return;
  9009. }
  9010. this._barColor = color;
  9011. this._horizontalBar.color = color;
  9012. this._verticalBar.color = color;
  9013. },
  9014. enumerable: true,
  9015. configurable: true
  9016. });
  9017. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9018. /** Gets or sets the bar image */
  9019. get: function () {
  9020. return this._barImage;
  9021. },
  9022. set: function (value) {
  9023. if (this._barImage === value) {
  9024. return;
  9025. }
  9026. this._barImage = value;
  9027. var hb = this._horizontalBar;
  9028. var vb = this._verticalBar;
  9029. hb.thumbImage = value;
  9030. vb.thumbImage = value;
  9031. },
  9032. enumerable: true,
  9033. configurable: true
  9034. });
  9035. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9036. /** Gets or sets the size of the bar */
  9037. get: function () {
  9038. return this._barSize;
  9039. },
  9040. set: function (value) {
  9041. if (this._barSize === value) {
  9042. return;
  9043. }
  9044. this._barSize = value;
  9045. this._markAsDirty();
  9046. if (this._horizontalBar.isVisible) {
  9047. this._grid.setRowDefinition(1, this._barSize, true);
  9048. }
  9049. if (this._verticalBar.isVisible) {
  9050. this._grid.setColumnDefinition(1, this._barSize, true);
  9051. }
  9052. },
  9053. enumerable: true,
  9054. configurable: true
  9055. });
  9056. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9057. /** Gets or sets the length of the thumb */
  9058. get: function () {
  9059. return this._thumbLength;
  9060. },
  9061. set: function (value) {
  9062. if (this._thumbLength === value) {
  9063. return;
  9064. }
  9065. if (value <= 0) {
  9066. value = 0.1;
  9067. }
  9068. if (value > 1) {
  9069. value = 1;
  9070. }
  9071. this._thumbLength = value;
  9072. var hb = this._horizontalBar;
  9073. var vb = this._verticalBar;
  9074. hb.thumbLength = value;
  9075. vb.thumbLength = value;
  9076. this._markAsDirty();
  9077. },
  9078. enumerable: true,
  9079. configurable: true
  9080. });
  9081. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9082. /** Gets or sets the height of the thumb */
  9083. get: function () {
  9084. return this._thumbHeight;
  9085. },
  9086. set: function (value) {
  9087. if (this._thumbHeight === value) {
  9088. return;
  9089. }
  9090. if (value <= 0) {
  9091. value = 0.1;
  9092. }
  9093. if (value > 1) {
  9094. value = 1;
  9095. }
  9096. this._thumbHeight = value;
  9097. var hb = this._horizontalBar;
  9098. var vb = this._verticalBar;
  9099. hb.thumbHeight = value;
  9100. vb.thumbHeight = value;
  9101. this._markAsDirty();
  9102. },
  9103. enumerable: true,
  9104. configurable: true
  9105. });
  9106. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9107. /** Gets or sets the height of the bar image */
  9108. get: function () {
  9109. return this._barImageHeight;
  9110. },
  9111. set: function (value) {
  9112. if (this._barImageHeight === value) {
  9113. return;
  9114. }
  9115. if (value <= 0) {
  9116. value = 0.1;
  9117. }
  9118. if (value > 1) {
  9119. value = 1;
  9120. }
  9121. this._barImageHeight = value;
  9122. var hb = this._horizontalBar;
  9123. var vb = this._verticalBar;
  9124. hb.barImageHeight = value;
  9125. vb.barImageHeight = value;
  9126. this._markAsDirty();
  9127. },
  9128. enumerable: true,
  9129. configurable: true
  9130. });
  9131. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9132. /** Gets or sets the bar background */
  9133. get: function () {
  9134. return this._barBackground;
  9135. },
  9136. set: function (color) {
  9137. if (this._barBackground === color) {
  9138. return;
  9139. }
  9140. this._barBackground = color;
  9141. var hb = this._horizontalBar;
  9142. var vb = this._verticalBar;
  9143. hb.background = color;
  9144. vb.background = color;
  9145. this._dragSpace.background = color;
  9146. },
  9147. enumerable: true,
  9148. configurable: true
  9149. });
  9150. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9151. /** Gets or sets the bar background image */
  9152. get: function () {
  9153. return this._barBackgroundImage;
  9154. },
  9155. set: function (value) {
  9156. if (this._barBackgroundImage === value) {
  9157. }
  9158. this._barBackgroundImage = value;
  9159. var hb = this._horizontalBar;
  9160. var vb = this._verticalBar;
  9161. hb.backgroundImage = value;
  9162. vb.backgroundImage = value;
  9163. },
  9164. enumerable: true,
  9165. configurable: true
  9166. });
  9167. /** @hidden */
  9168. ScrollViewer.prototype._updateScroller = function () {
  9169. var windowContentsWidth = this._window._currentMeasure.width;
  9170. var windowContentsHeight = this._window._currentMeasure.height;
  9171. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9172. this._grid.setRowDefinition(1, 0, true);
  9173. this._horizontalBar.isVisible = false;
  9174. this._horizontalBar.value = 0;
  9175. this._rebuildLayout = true;
  9176. }
  9177. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9178. this._grid.setRowDefinition(1, this._barSize, true);
  9179. this._horizontalBar.isVisible = true;
  9180. this._rebuildLayout = true;
  9181. }
  9182. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9183. this._grid.setColumnDefinition(1, 0, true);
  9184. this._verticalBar.isVisible = false;
  9185. this._verticalBar.value = 0;
  9186. this._rebuildLayout = true;
  9187. }
  9188. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9189. this._grid.setColumnDefinition(1, this._barSize, true);
  9190. this._verticalBar.isVisible = true;
  9191. this._rebuildLayout = true;
  9192. }
  9193. this._buildClientSizes();
  9194. this._endLeft = this._clientWidth - windowContentsWidth;
  9195. this._endTop = this._clientHeight - windowContentsHeight;
  9196. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9197. var newTop = this._verticalBar.value * this._endTop + "px";
  9198. if (newLeft !== this._window.left) {
  9199. this._window.left = newLeft;
  9200. this._rebuildLayout = true;
  9201. }
  9202. if (newTop !== this._window.top) {
  9203. this._window.top = newTop;
  9204. this._rebuildLayout = true;
  9205. }
  9206. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * this._clientWidth + "px";
  9207. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * this._clientHeight + "px";
  9208. };
  9209. ScrollViewer.prototype._link = function (host) {
  9210. _super.prototype._link.call(this, host);
  9211. this._attachWheel();
  9212. };
  9213. /** @hidden */
  9214. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9215. var _this = this;
  9216. barControl.paddingLeft = 0;
  9217. barControl.width = "100%";
  9218. barControl.height = "100%";
  9219. barControl.barOffset = 0;
  9220. barControl.value = 0;
  9221. barControl.maximum = 1;
  9222. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9223. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9224. barControl.isVertical = isVertical;
  9225. barControl.rotation = rotation;
  9226. barControl.isVisible = false;
  9227. barContainer.addControl(barControl);
  9228. barControl.onValueChangedObservable.add(function (value) {
  9229. if (rotation > 0) {
  9230. _this._window.top = value * _this._endTop + "px";
  9231. }
  9232. else {
  9233. _this._window.left = value * _this._endLeft + "px";
  9234. }
  9235. });
  9236. };
  9237. /** @hidden */
  9238. ScrollViewer.prototype._attachWheel = function () {
  9239. var _this = this;
  9240. if (!this._host || this._onPointerObserver) {
  9241. return;
  9242. }
  9243. var scene = this._host.getScene();
  9244. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9245. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9246. return;
  9247. }
  9248. if (_this._verticalBar.isVisible == true) {
  9249. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9250. _this._verticalBar.value -= _this._wheelPrecision;
  9251. }
  9252. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9253. _this._verticalBar.value += _this._wheelPrecision;
  9254. }
  9255. }
  9256. if (_this._horizontalBar.isVisible == true) {
  9257. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9258. _this._horizontalBar.value += _this._wheelPrecision;
  9259. }
  9260. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9261. _this._horizontalBar.value -= _this._wheelPrecision;
  9262. }
  9263. }
  9264. });
  9265. };
  9266. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9267. if (!this.isHighlighted) {
  9268. return;
  9269. }
  9270. _super.prototype._renderHighlightSpecific.call(this, context);
  9271. this._grid._renderHighlightSpecific(context);
  9272. context.restore();
  9273. };
  9274. /** Releases associated resources */
  9275. ScrollViewer.prototype.dispose = function () {
  9276. var scene = this._host.getScene();
  9277. if (scene && this._onPointerObserver) {
  9278. scene.onPointerObservable.remove(this._onPointerObserver);
  9279. this._onPointerObserver = null;
  9280. }
  9281. _super.prototype.dispose.call(this);
  9282. };
  9283. return ScrollViewer;
  9284. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9285. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9286. /***/ }),
  9287. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9288. /*!*********************************************************!*\
  9289. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9290. \*********************************************************/
  9291. /*! exports provided: _ScrollViewerWindow */
  9292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9293. "use strict";
  9294. __webpack_require__.r(__webpack_exports__);
  9295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9296. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9297. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9298. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9299. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9300. /**
  9301. * Class used to hold a the container for ScrollViewer
  9302. * @hidden
  9303. */
  9304. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9305. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9306. /**
  9307. * Creates a new ScrollViewerWindow
  9308. * @param name of ScrollViewerWindow
  9309. */
  9310. function _ScrollViewerWindow(name) {
  9311. return _super.call(this, name) || this;
  9312. }
  9313. _ScrollViewerWindow.prototype._getTypeName = function () {
  9314. return "ScrollViewerWindow";
  9315. };
  9316. /** @hidden */
  9317. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9318. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9319. this._measureForChildren.left = this._currentMeasure.left;
  9320. this._measureForChildren.top = this._currentMeasure.top;
  9321. this._measureForChildren.width = parentMeasure.width;
  9322. this._measureForChildren.height = parentMeasure.height;
  9323. };
  9324. _ScrollViewerWindow.prototype._postMeasure = function () {
  9325. var maxWidth = this.parentClientWidth;
  9326. var maxHeight = this.parentClientHeight;
  9327. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9328. var child = _a[_i];
  9329. if (!child.isVisible || child.notRenderable) {
  9330. continue;
  9331. }
  9332. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9333. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9334. }
  9335. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9336. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9337. }
  9338. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9339. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9340. }
  9341. if (this._currentMeasure.width !== maxWidth) {
  9342. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9343. this._currentMeasure.width = maxWidth;
  9344. this._rebuildLayout = true;
  9345. this._isDirty = true;
  9346. }
  9347. if (this._currentMeasure.height !== maxHeight) {
  9348. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9349. this._currentMeasure.height = maxHeight;
  9350. this._rebuildLayout = true;
  9351. this._isDirty = true;
  9352. }
  9353. _super.prototype._postMeasure.call(this);
  9354. };
  9355. return _ScrollViewerWindow;
  9356. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9357. /***/ }),
  9358. /***/ "./2D/controls/selector.ts":
  9359. /*!*********************************!*\
  9360. !*** ./2D/controls/selector.ts ***!
  9361. \*********************************/
  9362. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9364. "use strict";
  9365. __webpack_require__.r(__webpack_exports__);
  9366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9371. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9372. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9373. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9374. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9375. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9376. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9377. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9378. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9379. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9380. /** Class used to create a RadioGroup
  9381. * which contains groups of radio buttons
  9382. */
  9383. var SelectorGroup = /** @class */ (function () {
  9384. /**
  9385. * Creates a new SelectorGroup
  9386. * @param name of group, used as a group heading
  9387. */
  9388. function SelectorGroup(
  9389. /** name of SelectorGroup */
  9390. name) {
  9391. this.name = name;
  9392. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9393. this._selectors = new Array();
  9394. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9395. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9396. this._groupHeader = this._addGroupHeader(name);
  9397. }
  9398. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9399. /** Gets the groupPanel of the SelectorGroup */
  9400. get: function () {
  9401. return this._groupPanel;
  9402. },
  9403. enumerable: true,
  9404. configurable: true
  9405. });
  9406. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9407. /** Gets the selectors array */
  9408. get: function () {
  9409. return this._selectors;
  9410. },
  9411. enumerable: true,
  9412. configurable: true
  9413. });
  9414. Object.defineProperty(SelectorGroup.prototype, "header", {
  9415. /** Gets and sets the group header */
  9416. get: function () {
  9417. return this._groupHeader.text;
  9418. },
  9419. set: function (label) {
  9420. if (this._groupHeader.text === "label") {
  9421. return;
  9422. }
  9423. this._groupHeader.text = label;
  9424. },
  9425. enumerable: true,
  9426. configurable: true
  9427. });
  9428. /** @hidden */
  9429. SelectorGroup.prototype._addGroupHeader = function (text) {
  9430. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9431. groupHeading.width = 0.9;
  9432. groupHeading.height = "30px";
  9433. groupHeading.textWrapping = true;
  9434. groupHeading.color = "black";
  9435. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9436. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9437. groupHeading.left = "2px";
  9438. this._groupPanel.addControl(groupHeading);
  9439. return groupHeading;
  9440. };
  9441. /** @hidden*/
  9442. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9443. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9444. return;
  9445. }
  9446. return this._selectors[selectorNb];
  9447. };
  9448. /** Removes the selector at the given position
  9449. * @param selectorNb the position of the selector within the group
  9450. */
  9451. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9452. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9453. return;
  9454. }
  9455. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9456. this._selectors.splice(selectorNb, 1);
  9457. };
  9458. return SelectorGroup;
  9459. }());
  9460. /** Class used to create a CheckboxGroup
  9461. * which contains groups of checkbox buttons
  9462. */
  9463. var CheckboxGroup = /** @class */ (function (_super) {
  9464. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9465. function CheckboxGroup() {
  9466. return _super !== null && _super.apply(this, arguments) || this;
  9467. }
  9468. /** Adds a checkbox as a control
  9469. * @param text is the label for the selector
  9470. * @param func is the function called when the Selector is checked
  9471. * @param checked is true when Selector is checked
  9472. */
  9473. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9474. if (func === void 0) { func = function (s) { }; }
  9475. if (checked === void 0) { checked = false; }
  9476. var checked = checked || false;
  9477. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9478. button.width = "20px";
  9479. button.height = "20px";
  9480. button.color = "#364249";
  9481. button.background = "#CCCCCC";
  9482. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9483. button.onIsCheckedChangedObservable.add(function (state) {
  9484. func(state);
  9485. });
  9486. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9487. _selector.height = "30px";
  9488. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9489. _selector.left = "4px";
  9490. this.groupPanel.addControl(_selector);
  9491. this.selectors.push(_selector);
  9492. button.isChecked = checked;
  9493. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9494. button.color = this.groupPanel.parent.parent.buttonColor;
  9495. button.background = this.groupPanel.parent.parent.buttonBackground;
  9496. }
  9497. };
  9498. /** @hidden */
  9499. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9500. this.selectors[selectorNb].children[1].text = label;
  9501. };
  9502. /** @hidden */
  9503. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9504. this.selectors[selectorNb].children[1].color = color;
  9505. };
  9506. /** @hidden */
  9507. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9508. this.selectors[selectorNb].children[0].color = color;
  9509. };
  9510. /** @hidden */
  9511. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9512. this.selectors[selectorNb].children[0].background = color;
  9513. };
  9514. return CheckboxGroup;
  9515. }(SelectorGroup));
  9516. /** Class used to create a RadioGroup
  9517. * which contains groups of radio buttons
  9518. */
  9519. var RadioGroup = /** @class */ (function (_super) {
  9520. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9521. function RadioGroup() {
  9522. var _this = _super !== null && _super.apply(this, arguments) || this;
  9523. _this._selectNb = 0;
  9524. return _this;
  9525. }
  9526. /** Adds a radio button as a control
  9527. * @param label is the label for the selector
  9528. * @param func is the function called when the Selector is checked
  9529. * @param checked is true when Selector is checked
  9530. */
  9531. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9532. if (func === void 0) { func = function (n) { }; }
  9533. if (checked === void 0) { checked = false; }
  9534. var nb = this._selectNb++;
  9535. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9536. button.name = label;
  9537. button.width = "20px";
  9538. button.height = "20px";
  9539. button.color = "#364249";
  9540. button.background = "#CCCCCC";
  9541. button.group = this.name;
  9542. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9543. button.onIsCheckedChangedObservable.add(function (state) {
  9544. if (state) {
  9545. func(nb);
  9546. }
  9547. });
  9548. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9549. _selector.height = "30px";
  9550. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9551. _selector.left = "4px";
  9552. this.groupPanel.addControl(_selector);
  9553. this.selectors.push(_selector);
  9554. button.isChecked = checked;
  9555. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9556. button.color = this.groupPanel.parent.parent.buttonColor;
  9557. button.background = this.groupPanel.parent.parent.buttonBackground;
  9558. }
  9559. };
  9560. /** @hidden */
  9561. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9562. this.selectors[selectorNb].children[1].text = label;
  9563. };
  9564. /** @hidden */
  9565. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9566. this.selectors[selectorNb].children[1].color = color;
  9567. };
  9568. /** @hidden */
  9569. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9570. this.selectors[selectorNb].children[0].color = color;
  9571. };
  9572. /** @hidden */
  9573. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9574. this.selectors[selectorNb].children[0].background = color;
  9575. };
  9576. return RadioGroup;
  9577. }(SelectorGroup));
  9578. /** Class used to create a SliderGroup
  9579. * which contains groups of slider buttons
  9580. */
  9581. var SliderGroup = /** @class */ (function (_super) {
  9582. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9583. function SliderGroup() {
  9584. return _super !== null && _super.apply(this, arguments) || this;
  9585. }
  9586. /**
  9587. * Adds a slider to the SelectorGroup
  9588. * @param label is the label for the SliderBar
  9589. * @param func is the function called when the Slider moves
  9590. * @param unit is a string describing the units used, eg degrees or metres
  9591. * @param min is the minimum value for the Slider
  9592. * @param max is the maximum value for the Slider
  9593. * @param value is the start value for the Slider between min and max
  9594. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9595. */
  9596. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9597. if (func === void 0) { func = function (v) { }; }
  9598. if (unit === void 0) { unit = "Units"; }
  9599. if (min === void 0) { min = 0; }
  9600. if (max === void 0) { max = 0; }
  9601. if (value === void 0) { value = 0; }
  9602. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9603. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9604. button.name = unit;
  9605. button.value = value;
  9606. button.minimum = min;
  9607. button.maximum = max;
  9608. button.width = 0.9;
  9609. button.height = "20px";
  9610. button.color = "#364249";
  9611. button.background = "#CCCCCC";
  9612. button.borderColor = "black";
  9613. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9614. button.left = "4px";
  9615. button.paddingBottom = "4px";
  9616. button.onValueChangedObservable.add(function (value) {
  9617. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9618. func(value);
  9619. });
  9620. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9621. _selector.height = "60px";
  9622. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9623. _selector.left = "4px";
  9624. _selector.children[0].name = label;
  9625. this.groupPanel.addControl(_selector);
  9626. this.selectors.push(_selector);
  9627. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9628. button.color = this.groupPanel.parent.parent.buttonColor;
  9629. button.background = this.groupPanel.parent.parent.buttonBackground;
  9630. }
  9631. };
  9632. /** @hidden */
  9633. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9634. this.selectors[selectorNb].children[0].name = label;
  9635. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9636. };
  9637. /** @hidden */
  9638. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9639. this.selectors[selectorNb].children[0].color = color;
  9640. };
  9641. /** @hidden */
  9642. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9643. this.selectors[selectorNb].children[1].color = color;
  9644. };
  9645. /** @hidden */
  9646. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9647. this.selectors[selectorNb].children[1].background = color;
  9648. };
  9649. return SliderGroup;
  9650. }(SelectorGroup));
  9651. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9652. * @see http://doc.babylonjs.com/how_to/selector
  9653. */
  9654. var SelectionPanel = /** @class */ (function (_super) {
  9655. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9656. /**
  9657. * Creates a new SelectionPanel
  9658. * @param name of SelectionPanel
  9659. * @param groups is an array of SelectionGroups
  9660. */
  9661. function SelectionPanel(
  9662. /** name of SelectionPanel */
  9663. name,
  9664. /** an array of SelectionGroups */
  9665. groups) {
  9666. if (groups === void 0) { groups = []; }
  9667. var _this = _super.call(this, name) || this;
  9668. _this.name = name;
  9669. _this.groups = groups;
  9670. _this._buttonColor = "#364249";
  9671. _this._buttonBackground = "#CCCCCC";
  9672. _this._headerColor = "black";
  9673. _this._barColor = "white";
  9674. _this._barHeight = "2px";
  9675. _this._spacerHeight = "20px";
  9676. _this._bars = new Array();
  9677. _this._groups = groups;
  9678. _this.thickness = 2;
  9679. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9680. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9681. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9682. _this._panel.top = 5;
  9683. _this._panel.left = 5;
  9684. _this._panel.width = 0.95;
  9685. if (groups.length > 0) {
  9686. for (var i = 0; i < groups.length - 1; i++) {
  9687. _this._panel.addControl(groups[i].groupPanel);
  9688. _this._addSpacer();
  9689. }
  9690. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9691. }
  9692. _this.addControl(_this._panel);
  9693. return _this;
  9694. }
  9695. SelectionPanel.prototype._getTypeName = function () {
  9696. return "SelectionPanel";
  9697. };
  9698. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9699. /** Gets or sets the headerColor */
  9700. get: function () {
  9701. return this._headerColor;
  9702. },
  9703. set: function (color) {
  9704. if (this._headerColor === color) {
  9705. return;
  9706. }
  9707. this._headerColor = color;
  9708. this._setHeaderColor();
  9709. },
  9710. enumerable: true,
  9711. configurable: true
  9712. });
  9713. SelectionPanel.prototype._setHeaderColor = function () {
  9714. for (var i = 0; i < this._groups.length; i++) {
  9715. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9716. }
  9717. };
  9718. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9719. /** Gets or sets the button color */
  9720. get: function () {
  9721. return this._buttonColor;
  9722. },
  9723. set: function (color) {
  9724. if (this._buttonColor === color) {
  9725. return;
  9726. }
  9727. this._buttonColor = color;
  9728. this._setbuttonColor();
  9729. },
  9730. enumerable: true,
  9731. configurable: true
  9732. });
  9733. SelectionPanel.prototype._setbuttonColor = function () {
  9734. for (var i = 0; i < this._groups.length; i++) {
  9735. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9736. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9737. }
  9738. }
  9739. };
  9740. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9741. /** Gets or sets the label color */
  9742. get: function () {
  9743. return this._labelColor;
  9744. },
  9745. set: function (color) {
  9746. if (this._labelColor === color) {
  9747. return;
  9748. }
  9749. this._labelColor = color;
  9750. this._setLabelColor();
  9751. },
  9752. enumerable: true,
  9753. configurable: true
  9754. });
  9755. SelectionPanel.prototype._setLabelColor = function () {
  9756. for (var i = 0; i < this._groups.length; i++) {
  9757. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9758. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9759. }
  9760. }
  9761. };
  9762. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9763. /** Gets or sets the button background */
  9764. get: function () {
  9765. return this._buttonBackground;
  9766. },
  9767. set: function (color) {
  9768. if (this._buttonBackground === color) {
  9769. return;
  9770. }
  9771. this._buttonBackground = color;
  9772. this._setButtonBackground();
  9773. },
  9774. enumerable: true,
  9775. configurable: true
  9776. });
  9777. SelectionPanel.prototype._setButtonBackground = function () {
  9778. for (var i = 0; i < this._groups.length; i++) {
  9779. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9780. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9781. }
  9782. }
  9783. };
  9784. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9785. /** Gets or sets the color of separator bar */
  9786. get: function () {
  9787. return this._barColor;
  9788. },
  9789. set: function (color) {
  9790. if (this._barColor === color) {
  9791. return;
  9792. }
  9793. this._barColor = color;
  9794. this._setBarColor();
  9795. },
  9796. enumerable: true,
  9797. configurable: true
  9798. });
  9799. SelectionPanel.prototype._setBarColor = function () {
  9800. for (var i = 0; i < this._bars.length; i++) {
  9801. this._bars[i].children[0].background = this._barColor;
  9802. }
  9803. };
  9804. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9805. /** Gets or sets the height of separator bar */
  9806. get: function () {
  9807. return this._barHeight;
  9808. },
  9809. set: function (value) {
  9810. if (this._barHeight === value) {
  9811. return;
  9812. }
  9813. this._barHeight = value;
  9814. this._setBarHeight();
  9815. },
  9816. enumerable: true,
  9817. configurable: true
  9818. });
  9819. SelectionPanel.prototype._setBarHeight = function () {
  9820. for (var i = 0; i < this._bars.length; i++) {
  9821. this._bars[i].children[0].height = this._barHeight;
  9822. }
  9823. };
  9824. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9825. /** Gets or sets the height of spacers*/
  9826. get: function () {
  9827. return this._spacerHeight;
  9828. },
  9829. set: function (value) {
  9830. if (this._spacerHeight === value) {
  9831. return;
  9832. }
  9833. this._spacerHeight = value;
  9834. this._setSpacerHeight();
  9835. },
  9836. enumerable: true,
  9837. configurable: true
  9838. });
  9839. SelectionPanel.prototype._setSpacerHeight = function () {
  9840. for (var i = 0; i < this._bars.length; i++) {
  9841. this._bars[i].height = this._spacerHeight;
  9842. }
  9843. };
  9844. /** Adds a bar between groups */
  9845. SelectionPanel.prototype._addSpacer = function () {
  9846. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9847. separator.width = 1;
  9848. separator.height = this._spacerHeight;
  9849. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9850. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9851. bar.width = 1;
  9852. bar.height = this._barHeight;
  9853. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9854. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9855. bar.background = this._barColor;
  9856. bar.color = "transparent";
  9857. separator.addControl(bar);
  9858. this._panel.addControl(separator);
  9859. this._bars.push(separator);
  9860. };
  9861. /** Add a group to the selection panel
  9862. * @param group is the selector group to add
  9863. */
  9864. SelectionPanel.prototype.addGroup = function (group) {
  9865. if (this._groups.length > 0) {
  9866. this._addSpacer();
  9867. }
  9868. this._panel.addControl(group.groupPanel);
  9869. this._groups.push(group);
  9870. group.groupPanel.children[0].color = this._headerColor;
  9871. for (var j = 0; j < group.selectors.length; j++) {
  9872. group._setSelectorButtonColor(j, this._buttonColor);
  9873. group._setSelectorButtonBackground(j, this._buttonBackground);
  9874. }
  9875. };
  9876. /** Remove the group from the given position
  9877. * @param groupNb is the position of the group in the list
  9878. */
  9879. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9880. if (groupNb < 0 || groupNb >= this._groups.length) {
  9881. return;
  9882. }
  9883. var group = this._groups[groupNb];
  9884. this._panel.removeControl(group.groupPanel);
  9885. this._groups.splice(groupNb, 1);
  9886. if (groupNb < this._bars.length) {
  9887. this._panel.removeControl(this._bars[groupNb]);
  9888. this._bars.splice(groupNb, 1);
  9889. }
  9890. };
  9891. /** Change a group header label
  9892. * @param label is the new group header label
  9893. * @param groupNb is the number of the group to relabel
  9894. * */
  9895. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9896. if (groupNb < 0 || groupNb >= this._groups.length) {
  9897. return;
  9898. }
  9899. var group = this._groups[groupNb];
  9900. group.groupPanel.children[0].text = label;
  9901. };
  9902. /** Change selector label to the one given
  9903. * @param label is the new selector label
  9904. * @param groupNb is the number of the groupcontaining the selector
  9905. * @param selectorNb is the number of the selector within a group to relabel
  9906. * */
  9907. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9908. if (groupNb < 0 || groupNb >= this._groups.length) {
  9909. return;
  9910. }
  9911. var group = this._groups[groupNb];
  9912. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9913. return;
  9914. }
  9915. group._setSelectorLabel(selectorNb, label);
  9916. };
  9917. /** For a given group position remove the selector at the given position
  9918. * @param groupNb is the number of the group to remove the selector from
  9919. * @param selectorNb is the number of the selector within the group
  9920. */
  9921. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9922. if (groupNb < 0 || groupNb >= this._groups.length) {
  9923. return;
  9924. }
  9925. var group = this._groups[groupNb];
  9926. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9927. return;
  9928. }
  9929. group.removeSelector(selectorNb);
  9930. };
  9931. /** For a given group position of correct type add a checkbox button
  9932. * @param groupNb is the number of the group to remove the selector from
  9933. * @param label is the label for the selector
  9934. * @param func is the function called when the Selector is checked
  9935. * @param checked is true when Selector is checked
  9936. */
  9937. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9938. if (func === void 0) { func = function () { }; }
  9939. if (checked === void 0) { checked = false; }
  9940. if (groupNb < 0 || groupNb >= this._groups.length) {
  9941. return;
  9942. }
  9943. var group = this._groups[groupNb];
  9944. group.addCheckbox(label, func, checked);
  9945. };
  9946. /** For a given group position of correct type add a radio button
  9947. * @param groupNb is the number of the group to remove the selector from
  9948. * @param label is the label for the selector
  9949. * @param func is the function called when the Selector is checked
  9950. * @param checked is true when Selector is checked
  9951. */
  9952. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9953. if (func === void 0) { func = function () { }; }
  9954. if (checked === void 0) { checked = false; }
  9955. if (groupNb < 0 || groupNb >= this._groups.length) {
  9956. return;
  9957. }
  9958. var group = this._groups[groupNb];
  9959. group.addRadio(label, func, checked);
  9960. };
  9961. /**
  9962. * For a given slider group add a slider
  9963. * @param groupNb is the number of the group to add the slider to
  9964. * @param label is the label for the Slider
  9965. * @param func is the function called when the Slider moves
  9966. * @param unit is a string describing the units used, eg degrees or metres
  9967. * @param min is the minimum value for the Slider
  9968. * @param max is the maximum value for the Slider
  9969. * @param value is the start value for the Slider between min and max
  9970. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9971. */
  9972. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9973. if (func === void 0) { func = function () { }; }
  9974. if (unit === void 0) { unit = "Units"; }
  9975. if (min === void 0) { min = 0; }
  9976. if (max === void 0) { max = 0; }
  9977. if (value === void 0) { value = 0; }
  9978. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9979. if (groupNb < 0 || groupNb >= this._groups.length) {
  9980. return;
  9981. }
  9982. var group = this._groups[groupNb];
  9983. group.addSlider(label, func, unit, min, max, value, onVal);
  9984. };
  9985. return SelectionPanel;
  9986. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9987. /***/ }),
  9988. /***/ "./2D/controls/sliders/baseSlider.ts":
  9989. /*!*******************************************!*\
  9990. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9991. \*******************************************/
  9992. /*! exports provided: BaseSlider */
  9993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9994. "use strict";
  9995. __webpack_require__.r(__webpack_exports__);
  9996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9997. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9998. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9999. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10000. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10001. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10002. /**
  10003. * Class used to create slider controls
  10004. */
  10005. var BaseSlider = /** @class */ (function (_super) {
  10006. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10007. /**
  10008. * Creates a new BaseSlider
  10009. * @param name defines the control name
  10010. */
  10011. function BaseSlider(name) {
  10012. var _this = _super.call(this, name) || this;
  10013. _this.name = name;
  10014. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10015. _this._minimum = 0;
  10016. _this._maximum = 100;
  10017. _this._value = 50;
  10018. _this._isVertical = false;
  10019. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10020. _this._isThumbClamped = false;
  10021. _this._displayThumb = true;
  10022. _this._step = 0;
  10023. _this._lastPointerDownID = -1;
  10024. // Shared rendering info
  10025. _this._effectiveBarOffset = 0;
  10026. /** Observable raised when the sldier value changes */
  10027. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10028. // Events
  10029. _this._pointerIsDown = false;
  10030. _this.isPointerBlocker = true;
  10031. return _this;
  10032. }
  10033. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10034. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10035. get: function () {
  10036. return this._displayThumb;
  10037. },
  10038. set: function (value) {
  10039. if (this._displayThumb === value) {
  10040. return;
  10041. }
  10042. this._displayThumb = value;
  10043. this._markAsDirty();
  10044. },
  10045. enumerable: true,
  10046. configurable: true
  10047. });
  10048. Object.defineProperty(BaseSlider.prototype, "step", {
  10049. /** Gets or sets a step to apply to values (0 by default) */
  10050. get: function () {
  10051. return this._step;
  10052. },
  10053. set: function (value) {
  10054. if (this._step === value) {
  10055. return;
  10056. }
  10057. this._step = value;
  10058. this._markAsDirty();
  10059. },
  10060. enumerable: true,
  10061. configurable: true
  10062. });
  10063. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10064. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10065. get: function () {
  10066. return this._barOffset.toString(this._host);
  10067. },
  10068. set: function (value) {
  10069. if (this._barOffset.toString(this._host) === value) {
  10070. return;
  10071. }
  10072. if (this._barOffset.fromString(value)) {
  10073. this._markAsDirty();
  10074. }
  10075. },
  10076. enumerable: true,
  10077. configurable: true
  10078. });
  10079. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10080. /** Gets main bar offset in pixels*/
  10081. get: function () {
  10082. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10083. },
  10084. enumerable: true,
  10085. configurable: true
  10086. });
  10087. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10088. /** Gets or sets thumb width */
  10089. get: function () {
  10090. return this._thumbWidth.toString(this._host);
  10091. },
  10092. set: function (value) {
  10093. if (this._thumbWidth.toString(this._host) === value) {
  10094. return;
  10095. }
  10096. if (this._thumbWidth.fromString(value)) {
  10097. this._markAsDirty();
  10098. }
  10099. },
  10100. enumerable: true,
  10101. configurable: true
  10102. });
  10103. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10104. /** Gets thumb width in pixels */
  10105. get: function () {
  10106. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10107. },
  10108. enumerable: true,
  10109. configurable: true
  10110. });
  10111. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10112. /** Gets or sets minimum value */
  10113. get: function () {
  10114. return this._minimum;
  10115. },
  10116. set: function (value) {
  10117. if (this._minimum === value) {
  10118. return;
  10119. }
  10120. this._minimum = value;
  10121. this._markAsDirty();
  10122. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10123. },
  10124. enumerable: true,
  10125. configurable: true
  10126. });
  10127. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10128. /** Gets or sets maximum value */
  10129. get: function () {
  10130. return this._maximum;
  10131. },
  10132. set: function (value) {
  10133. if (this._maximum === value) {
  10134. return;
  10135. }
  10136. this._maximum = value;
  10137. this._markAsDirty();
  10138. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10139. },
  10140. enumerable: true,
  10141. configurable: true
  10142. });
  10143. Object.defineProperty(BaseSlider.prototype, "value", {
  10144. /** Gets or sets current value */
  10145. get: function () {
  10146. return this._value;
  10147. },
  10148. set: function (value) {
  10149. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10150. if (this._value === value) {
  10151. return;
  10152. }
  10153. this._value = value;
  10154. this._markAsDirty();
  10155. this.onValueChangedObservable.notifyObservers(this._value);
  10156. },
  10157. enumerable: true,
  10158. configurable: true
  10159. });
  10160. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10161. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10162. get: function () {
  10163. return this._isVertical;
  10164. },
  10165. set: function (value) {
  10166. if (this._isVertical === value) {
  10167. return;
  10168. }
  10169. this._isVertical = value;
  10170. this._markAsDirty();
  10171. },
  10172. enumerable: true,
  10173. configurable: true
  10174. });
  10175. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10176. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10177. get: function () {
  10178. return this._isThumbClamped;
  10179. },
  10180. set: function (value) {
  10181. if (this._isThumbClamped === value) {
  10182. return;
  10183. }
  10184. this._isThumbClamped = value;
  10185. this._markAsDirty();
  10186. },
  10187. enumerable: true,
  10188. configurable: true
  10189. });
  10190. BaseSlider.prototype._getTypeName = function () {
  10191. return "BaseSlider";
  10192. };
  10193. BaseSlider.prototype._getThumbPosition = function () {
  10194. if (this.isVertical) {
  10195. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10196. }
  10197. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10198. };
  10199. BaseSlider.prototype._getThumbThickness = function (type) {
  10200. var thumbThickness = 0;
  10201. switch (type) {
  10202. case "circle":
  10203. if (this._thumbWidth.isPixel) {
  10204. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10205. }
  10206. else {
  10207. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10208. }
  10209. break;
  10210. case "rectangle":
  10211. if (this._thumbWidth.isPixel) {
  10212. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10213. }
  10214. else {
  10215. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10216. }
  10217. }
  10218. return thumbThickness;
  10219. };
  10220. BaseSlider.prototype._prepareRenderingData = function (type) {
  10221. // Main bar
  10222. this._effectiveBarOffset = 0;
  10223. this._renderLeft = this._currentMeasure.left;
  10224. this._renderTop = this._currentMeasure.top;
  10225. this._renderWidth = this._currentMeasure.width;
  10226. this._renderHeight = this._currentMeasure.height;
  10227. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10228. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10229. this._effectiveThumbThickness = this._getThumbThickness(type);
  10230. if (this.displayThumb) {
  10231. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10232. }
  10233. //throw error when height is less than width for vertical slider
  10234. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10235. console.error("Height should be greater than width");
  10236. return;
  10237. }
  10238. if (this._barOffset.isPixel) {
  10239. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10240. }
  10241. else {
  10242. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10243. }
  10244. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10245. if (this.isVertical) {
  10246. this._renderLeft += this._effectiveBarOffset;
  10247. if (!this.isThumbClamped && this.displayThumb) {
  10248. this._renderTop += (this._effectiveThumbThickness / 2);
  10249. }
  10250. this._renderHeight = this._backgroundBoxLength;
  10251. this._renderWidth = this._backgroundBoxThickness;
  10252. }
  10253. else {
  10254. this._renderTop += this._effectiveBarOffset;
  10255. if (!this.isThumbClamped && this.displayThumb) {
  10256. this._renderLeft += (this._effectiveThumbThickness / 2);
  10257. }
  10258. this._renderHeight = this._backgroundBoxThickness;
  10259. this._renderWidth = this._backgroundBoxLength;
  10260. }
  10261. };
  10262. /** @hidden */
  10263. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10264. if (this.rotation != 0) {
  10265. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10266. x = this._transformedPosition.x;
  10267. y = this._transformedPosition.y;
  10268. }
  10269. var value;
  10270. if (this._isVertical) {
  10271. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10272. }
  10273. else {
  10274. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10275. }
  10276. var mult = (1 / this._step) | 0;
  10277. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10278. };
  10279. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10280. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10281. return false;
  10282. }
  10283. this._pointerIsDown = true;
  10284. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10285. this._host._capturingControl[pointerId] = this;
  10286. this._lastPointerDownID = pointerId;
  10287. return true;
  10288. };
  10289. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10290. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10291. if (pointerId != this._lastPointerDownID) {
  10292. return;
  10293. }
  10294. if (this._pointerIsDown) {
  10295. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10296. }
  10297. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10298. };
  10299. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10300. this._pointerIsDown = false;
  10301. delete this._host._capturingControl[pointerId];
  10302. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10303. };
  10304. return BaseSlider;
  10305. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10306. /***/ }),
  10307. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10308. /*!*************************************************!*\
  10309. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10310. \*************************************************/
  10311. /*! exports provided: ImageBasedSlider */
  10312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10313. "use strict";
  10314. __webpack_require__.r(__webpack_exports__);
  10315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10317. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10318. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10319. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10320. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10321. /**
  10322. * Class used to create slider controls based on images
  10323. */
  10324. var ImageBasedSlider = /** @class */ (function (_super) {
  10325. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10326. /**
  10327. * Creates a new ImageBasedSlider
  10328. * @param name defines the control name
  10329. */
  10330. function ImageBasedSlider(name) {
  10331. var _this = _super.call(this, name) || this;
  10332. _this.name = name;
  10333. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10334. return _this;
  10335. }
  10336. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10337. get: function () {
  10338. return this._displayThumb && this.thumbImage != null;
  10339. },
  10340. set: function (value) {
  10341. if (this._displayThumb === value) {
  10342. return;
  10343. }
  10344. this._displayThumb = value;
  10345. this._markAsDirty();
  10346. },
  10347. enumerable: true,
  10348. configurable: true
  10349. });
  10350. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10351. /**
  10352. * Gets or sets the image used to render the background
  10353. */
  10354. get: function () {
  10355. return this._backgroundImage;
  10356. },
  10357. set: function (value) {
  10358. var _this = this;
  10359. if (this._backgroundImage === value) {
  10360. return;
  10361. }
  10362. this._backgroundImage = value;
  10363. if (value && !value.isLoaded) {
  10364. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10365. }
  10366. this._markAsDirty();
  10367. },
  10368. enumerable: true,
  10369. configurable: true
  10370. });
  10371. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10372. /**
  10373. * Gets or sets the image used to render the value bar
  10374. */
  10375. get: function () {
  10376. return this._valueBarImage;
  10377. },
  10378. set: function (value) {
  10379. var _this = this;
  10380. if (this._valueBarImage === value) {
  10381. return;
  10382. }
  10383. this._valueBarImage = value;
  10384. if (value && !value.isLoaded) {
  10385. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10386. }
  10387. this._markAsDirty();
  10388. },
  10389. enumerable: true,
  10390. configurable: true
  10391. });
  10392. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10393. /**
  10394. * Gets or sets the image used to render the thumb
  10395. */
  10396. get: function () {
  10397. return this._thumbImage;
  10398. },
  10399. set: function (value) {
  10400. var _this = this;
  10401. if (this._thumbImage === value) {
  10402. return;
  10403. }
  10404. this._thumbImage = value;
  10405. if (value && !value.isLoaded) {
  10406. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10407. }
  10408. this._markAsDirty();
  10409. },
  10410. enumerable: true,
  10411. configurable: true
  10412. });
  10413. ImageBasedSlider.prototype._getTypeName = function () {
  10414. return "ImageBasedSlider";
  10415. };
  10416. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10417. context.save();
  10418. this._applyStates(context);
  10419. this._prepareRenderingData("rectangle");
  10420. var thumbPosition = this._getThumbPosition();
  10421. var left = this._renderLeft;
  10422. var top = this._renderTop;
  10423. var width = this._renderWidth;
  10424. var height = this._renderHeight;
  10425. // Background
  10426. if (this._backgroundImage) {
  10427. this._tempMeasure.copyFromFloats(left, top, width, height);
  10428. if (this.isThumbClamped && this.displayThumb) {
  10429. if (this.isVertical) {
  10430. this._tempMeasure.height += this._effectiveThumbThickness;
  10431. }
  10432. else {
  10433. this._tempMeasure.width += this._effectiveThumbThickness;
  10434. }
  10435. }
  10436. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10437. this._backgroundImage._draw(context);
  10438. }
  10439. // Bar
  10440. if (this._valueBarImage) {
  10441. if (this.isVertical) {
  10442. if (this.isThumbClamped && this.displayThumb) {
  10443. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10444. }
  10445. else {
  10446. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10447. }
  10448. }
  10449. else {
  10450. if (this.isThumbClamped && this.displayThumb) {
  10451. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10452. }
  10453. else {
  10454. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10455. }
  10456. }
  10457. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10458. this._valueBarImage._draw(context);
  10459. }
  10460. // Thumb
  10461. if (this.displayThumb) {
  10462. if (this.isVertical) {
  10463. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10464. }
  10465. else {
  10466. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10467. }
  10468. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10469. this._thumbImage._draw(context);
  10470. }
  10471. context.restore();
  10472. };
  10473. return ImageBasedSlider;
  10474. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10475. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10476. /***/ }),
  10477. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10478. /*!***********************************************!*\
  10479. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10480. \***********************************************/
  10481. /*! exports provided: ImageScrollBar */
  10482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10483. "use strict";
  10484. __webpack_require__.r(__webpack_exports__);
  10485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10486. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10487. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10488. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10489. /**
  10490. * Class used to create slider controls
  10491. */
  10492. var ImageScrollBar = /** @class */ (function (_super) {
  10493. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10494. /**
  10495. * Creates a new ImageScrollBar
  10496. * @param name defines the control name
  10497. */
  10498. function ImageScrollBar(name) {
  10499. var _this = _super.call(this, name) || this;
  10500. _this.name = name;
  10501. _this._thumbLength = 0.5;
  10502. _this._thumbHeight = 1;
  10503. _this._barImageHeight = 1;
  10504. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10505. return _this;
  10506. }
  10507. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10508. /**
  10509. * Gets or sets the image used to render the background for horizontal bar
  10510. */
  10511. get: function () {
  10512. return this._backgroundBaseImage;
  10513. },
  10514. set: function (value) {
  10515. var _this = this;
  10516. if (this._backgroundBaseImage === value) {
  10517. return;
  10518. }
  10519. this._backgroundBaseImage = value;
  10520. if (this.isVertical) {
  10521. if (value && !value.isLoaded) {
  10522. value.onImageLoadedObservable.addOnce(function () {
  10523. var rotatedValue = value._rotate90(1);
  10524. _this._backgroundImage = rotatedValue;
  10525. if (!rotatedValue.isLoaded) {
  10526. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10527. _this._markAsDirty();
  10528. });
  10529. }
  10530. _this._markAsDirty();
  10531. });
  10532. }
  10533. this._backgroundImage = value._rotate90(1);
  10534. this._markAsDirty();
  10535. }
  10536. else {
  10537. this._backgroundImage = value;
  10538. if (value && !value.isLoaded) {
  10539. value.onImageLoadedObservable.addOnce(function () {
  10540. _this._markAsDirty();
  10541. });
  10542. }
  10543. this._markAsDirty();
  10544. }
  10545. },
  10546. enumerable: true,
  10547. configurable: true
  10548. });
  10549. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10550. /**
  10551. * Gets or sets the image used to render the thumb
  10552. */
  10553. get: function () {
  10554. return this._thumbBaseImage;
  10555. },
  10556. set: function (value) {
  10557. var _this = this;
  10558. if (this._thumbBaseImage === value) {
  10559. return;
  10560. }
  10561. this._thumbBaseImage = value;
  10562. if (this.isVertical) {
  10563. if (value && !value.isLoaded) {
  10564. value.onImageLoadedObservable.addOnce(function () {
  10565. var rotatedValue = value._rotate90(-1);
  10566. _this._thumbImage = rotatedValue;
  10567. if (!rotatedValue.isLoaded) {
  10568. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10569. _this._markAsDirty();
  10570. });
  10571. }
  10572. _this._markAsDirty();
  10573. });
  10574. }
  10575. this._thumbImage = value._rotate90(-1);
  10576. this._markAsDirty();
  10577. }
  10578. else {
  10579. this._thumbImage = value;
  10580. if (value && !value.isLoaded) {
  10581. value.onImageLoadedObservable.addOnce(function () {
  10582. _this._markAsDirty();
  10583. });
  10584. }
  10585. this._markAsDirty();
  10586. }
  10587. },
  10588. enumerable: true,
  10589. configurable: true
  10590. });
  10591. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  10592. /**
  10593. * Gets or sets the length of the thumb
  10594. */
  10595. get: function () {
  10596. return this._thumbLength;
  10597. },
  10598. set: function (value) {
  10599. if (this._thumbLength === value) {
  10600. return;
  10601. }
  10602. this._thumbLength = value;
  10603. this._markAsDirty();
  10604. },
  10605. enumerable: true,
  10606. configurable: true
  10607. });
  10608. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  10609. /**
  10610. * Gets or sets the height of the thumb
  10611. */
  10612. get: function () {
  10613. return this._thumbHeight;
  10614. },
  10615. set: function (value) {
  10616. if (this._thumbLength === value) {
  10617. return;
  10618. }
  10619. this._thumbHeight = value;
  10620. this._markAsDirty();
  10621. },
  10622. enumerable: true,
  10623. configurable: true
  10624. });
  10625. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  10626. /**
  10627. * Gets or sets the height of the bar image
  10628. */
  10629. get: function () {
  10630. return this._barImageHeight;
  10631. },
  10632. set: function (value) {
  10633. if (this._barImageHeight === value) {
  10634. return;
  10635. }
  10636. this._barImageHeight = value;
  10637. this._markAsDirty();
  10638. },
  10639. enumerable: true,
  10640. configurable: true
  10641. });
  10642. ImageScrollBar.prototype._getTypeName = function () {
  10643. return "ImageScrollBar";
  10644. };
  10645. ImageScrollBar.prototype._getThumbThickness = function () {
  10646. var thumbThickness = 0;
  10647. if (this._thumbWidth.isPixel) {
  10648. thumbThickness = this._thumbWidth.getValue(this._host);
  10649. }
  10650. else {
  10651. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10652. }
  10653. return thumbThickness;
  10654. };
  10655. ImageScrollBar.prototype._draw = function (context) {
  10656. context.save();
  10657. this._applyStates(context);
  10658. this._prepareRenderingData("rectangle");
  10659. var thumbPosition = this._getThumbPosition();
  10660. var left = this._renderLeft;
  10661. var top = this._renderTop;
  10662. var width = this._renderWidth;
  10663. var height = this._renderHeight;
  10664. // Background
  10665. if (this._backgroundImage) {
  10666. this._tempMeasure.copyFromFloats(left, top, width, height);
  10667. if (this.isVertical) {
  10668. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  10669. this._tempMeasure.height += this._effectiveThumbThickness;
  10670. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10671. }
  10672. else {
  10673. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  10674. this._tempMeasure.width += this._effectiveThumbThickness;
  10675. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10676. }
  10677. this._backgroundImage._draw(context);
  10678. }
  10679. // Thumb
  10680. if (this.isVertical) {
  10681. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset + this._currentMeasure.width * (1 - this._thumbHeight) * 0.5, this._currentMeasure.top + thumbPosition, this._currentMeasure.width * this._thumbHeight, this._effectiveThumbThickness);
  10682. }
  10683. else {
  10684. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top + this._currentMeasure.height * (1 - this._thumbHeight) * 0.5, this._effectiveThumbThickness, this._currentMeasure.height * this._thumbHeight);
  10685. }
  10686. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10687. this._thumbImage._draw(context);
  10688. context.restore();
  10689. };
  10690. /** @hidden */
  10691. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10692. if (this.rotation != 0) {
  10693. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10694. x = this._transformedPosition.x;
  10695. y = this._transformedPosition.y;
  10696. }
  10697. if (this._first) {
  10698. this._first = false;
  10699. this._originX = x;
  10700. this._originY = y;
  10701. // Check if move is required
  10702. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10703. if (this.isVertical) {
  10704. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10705. }
  10706. else {
  10707. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10708. }
  10709. }
  10710. }
  10711. // Delta mode
  10712. var delta = 0;
  10713. if (this.isVertical) {
  10714. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10715. }
  10716. else {
  10717. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10718. }
  10719. this.value += delta * (this.maximum - this.minimum);
  10720. this._originX = x;
  10721. this._originY = y;
  10722. };
  10723. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10724. this._first = true;
  10725. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10726. };
  10727. return ImageScrollBar;
  10728. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10729. /***/ }),
  10730. /***/ "./2D/controls/sliders/scrollBar.ts":
  10731. /*!******************************************!*\
  10732. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10733. \******************************************/
  10734. /*! exports provided: ScrollBar */
  10735. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10736. "use strict";
  10737. __webpack_require__.r(__webpack_exports__);
  10738. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10739. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10740. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10741. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10742. /**
  10743. * Class used to create slider controls
  10744. */
  10745. var ScrollBar = /** @class */ (function (_super) {
  10746. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10747. /**
  10748. * Creates a new Slider
  10749. * @param name defines the control name
  10750. */
  10751. function ScrollBar(name) {
  10752. var _this = _super.call(this, name) || this;
  10753. _this.name = name;
  10754. _this._background = "black";
  10755. _this._borderColor = "white";
  10756. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10757. return _this;
  10758. }
  10759. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10760. /** Gets or sets border color */
  10761. get: function () {
  10762. return this._borderColor;
  10763. },
  10764. set: function (value) {
  10765. if (this._borderColor === value) {
  10766. return;
  10767. }
  10768. this._borderColor = value;
  10769. this._markAsDirty();
  10770. },
  10771. enumerable: true,
  10772. configurable: true
  10773. });
  10774. Object.defineProperty(ScrollBar.prototype, "background", {
  10775. /** Gets or sets background color */
  10776. get: function () {
  10777. return this._background;
  10778. },
  10779. set: function (value) {
  10780. if (this._background === value) {
  10781. return;
  10782. }
  10783. this._background = value;
  10784. this._markAsDirty();
  10785. },
  10786. enumerable: true,
  10787. configurable: true
  10788. });
  10789. ScrollBar.prototype._getTypeName = function () {
  10790. return "Scrollbar";
  10791. };
  10792. ScrollBar.prototype._getThumbThickness = function () {
  10793. var thumbThickness = 0;
  10794. if (this._thumbWidth.isPixel) {
  10795. thumbThickness = this._thumbWidth.getValue(this._host);
  10796. }
  10797. else {
  10798. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10799. }
  10800. return thumbThickness;
  10801. };
  10802. ScrollBar.prototype._draw = function (context) {
  10803. context.save();
  10804. this._applyStates(context);
  10805. this._prepareRenderingData("rectangle");
  10806. var left = this._renderLeft;
  10807. var thumbPosition = this._getThumbPosition();
  10808. context.fillStyle = this._background;
  10809. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10810. // Value bar
  10811. context.fillStyle = this.color;
  10812. // Thumb
  10813. if (this.isVertical) {
  10814. this._tempMeasure.left = left - this._effectiveBarOffset;
  10815. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  10816. this._tempMeasure.width = this._currentMeasure.width;
  10817. this._tempMeasure.height = this._effectiveThumbThickness;
  10818. }
  10819. else {
  10820. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  10821. this._tempMeasure.top = this._currentMeasure.top;
  10822. this._tempMeasure.width = this._effectiveThumbThickness;
  10823. this._tempMeasure.height = this._currentMeasure.height;
  10824. }
  10825. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  10826. context.restore();
  10827. };
  10828. /** @hidden */
  10829. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10830. if (this.rotation != 0) {
  10831. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10832. x = this._transformedPosition.x;
  10833. y = this._transformedPosition.y;
  10834. }
  10835. if (this._first) {
  10836. this._first = false;
  10837. this._originX = x;
  10838. this._originY = y;
  10839. // Check if move is required
  10840. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10841. if (this.isVertical) {
  10842. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10843. }
  10844. else {
  10845. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10846. }
  10847. }
  10848. }
  10849. // Delta mode
  10850. var delta = 0;
  10851. if (this.isVertical) {
  10852. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10853. }
  10854. else {
  10855. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10856. }
  10857. this.value += delta * (this.maximum - this.minimum);
  10858. this._originX = x;
  10859. this._originY = y;
  10860. };
  10861. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10862. this._first = true;
  10863. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10864. };
  10865. return ScrollBar;
  10866. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10867. /***/ }),
  10868. /***/ "./2D/controls/sliders/slider.ts":
  10869. /*!***************************************!*\
  10870. !*** ./2D/controls/sliders/slider.ts ***!
  10871. \***************************************/
  10872. /*! exports provided: Slider */
  10873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10874. "use strict";
  10875. __webpack_require__.r(__webpack_exports__);
  10876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10877. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10878. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10879. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10880. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10881. /**
  10882. * Class used to create slider controls
  10883. */
  10884. var Slider = /** @class */ (function (_super) {
  10885. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10886. /**
  10887. * Creates a new Slider
  10888. * @param name defines the control name
  10889. */
  10890. function Slider(name) {
  10891. var _this = _super.call(this, name) || this;
  10892. _this.name = name;
  10893. _this._background = "black";
  10894. _this._borderColor = "white";
  10895. _this._isThumbCircle = false;
  10896. _this._displayValueBar = true;
  10897. return _this;
  10898. }
  10899. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10900. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10901. get: function () {
  10902. return this._displayValueBar;
  10903. },
  10904. set: function (value) {
  10905. if (this._displayValueBar === value) {
  10906. return;
  10907. }
  10908. this._displayValueBar = value;
  10909. this._markAsDirty();
  10910. },
  10911. enumerable: true,
  10912. configurable: true
  10913. });
  10914. Object.defineProperty(Slider.prototype, "borderColor", {
  10915. /** Gets or sets border color */
  10916. get: function () {
  10917. return this._borderColor;
  10918. },
  10919. set: function (value) {
  10920. if (this._borderColor === value) {
  10921. return;
  10922. }
  10923. this._borderColor = value;
  10924. this._markAsDirty();
  10925. },
  10926. enumerable: true,
  10927. configurable: true
  10928. });
  10929. Object.defineProperty(Slider.prototype, "background", {
  10930. /** Gets or sets background color */
  10931. get: function () {
  10932. return this._background;
  10933. },
  10934. set: function (value) {
  10935. if (this._background === value) {
  10936. return;
  10937. }
  10938. this._background = value;
  10939. this._markAsDirty();
  10940. },
  10941. enumerable: true,
  10942. configurable: true
  10943. });
  10944. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10945. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10946. get: function () {
  10947. return this._isThumbCircle;
  10948. },
  10949. set: function (value) {
  10950. if (this._isThumbCircle === value) {
  10951. return;
  10952. }
  10953. this._isThumbCircle = value;
  10954. this._markAsDirty();
  10955. },
  10956. enumerable: true,
  10957. configurable: true
  10958. });
  10959. Slider.prototype._getTypeName = function () {
  10960. return "Slider";
  10961. };
  10962. Slider.prototype._draw = function (context, invalidatedRectangle) {
  10963. context.save();
  10964. this._applyStates(context);
  10965. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10966. var left = this._renderLeft;
  10967. var top = this._renderTop;
  10968. var width = this._renderWidth;
  10969. var height = this._renderHeight;
  10970. var radius = 0;
  10971. if (this.isThumbClamped && this.isThumbCircle) {
  10972. if (this.isVertical) {
  10973. top += (this._effectiveThumbThickness / 2);
  10974. }
  10975. else {
  10976. left += (this._effectiveThumbThickness / 2);
  10977. }
  10978. radius = this._backgroundBoxThickness / 2;
  10979. }
  10980. else {
  10981. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10982. }
  10983. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10984. context.shadowColor = this.shadowColor;
  10985. context.shadowBlur = this.shadowBlur;
  10986. context.shadowOffsetX = this.shadowOffsetX;
  10987. context.shadowOffsetY = this.shadowOffsetY;
  10988. }
  10989. var thumbPosition = this._getThumbPosition();
  10990. context.fillStyle = this._background;
  10991. if (this.isVertical) {
  10992. if (this.isThumbClamped) {
  10993. if (this.isThumbCircle) {
  10994. context.beginPath();
  10995. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10996. context.fill();
  10997. context.fillRect(left, top, width, height);
  10998. }
  10999. else {
  11000. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11001. }
  11002. }
  11003. else {
  11004. context.fillRect(left, top, width, height);
  11005. }
  11006. }
  11007. else {
  11008. if (this.isThumbClamped) {
  11009. if (this.isThumbCircle) {
  11010. context.beginPath();
  11011. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11012. context.fill();
  11013. context.fillRect(left, top, width, height);
  11014. }
  11015. else {
  11016. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11017. }
  11018. }
  11019. else {
  11020. context.fillRect(left, top, width, height);
  11021. }
  11022. }
  11023. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11024. context.shadowBlur = 0;
  11025. context.shadowOffsetX = 0;
  11026. context.shadowOffsetY = 0;
  11027. }
  11028. // Value bar
  11029. context.fillStyle = this.color;
  11030. if (this._displayValueBar) {
  11031. if (this.isVertical) {
  11032. if (this.isThumbClamped) {
  11033. if (this.isThumbCircle) {
  11034. context.beginPath();
  11035. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11036. context.fill();
  11037. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11038. }
  11039. else {
  11040. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11041. }
  11042. }
  11043. else {
  11044. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11045. }
  11046. }
  11047. else {
  11048. if (this.isThumbClamped) {
  11049. if (this.isThumbCircle) {
  11050. context.beginPath();
  11051. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11052. context.fill();
  11053. context.fillRect(left, top, thumbPosition, height);
  11054. }
  11055. else {
  11056. context.fillRect(left, top, thumbPosition, height);
  11057. }
  11058. }
  11059. else {
  11060. context.fillRect(left, top, thumbPosition, height);
  11061. }
  11062. }
  11063. }
  11064. // Thumb
  11065. if (this.displayThumb) {
  11066. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11067. context.shadowColor = this.shadowColor;
  11068. context.shadowBlur = this.shadowBlur;
  11069. context.shadowOffsetX = this.shadowOffsetX;
  11070. context.shadowOffsetY = this.shadowOffsetY;
  11071. }
  11072. if (this._isThumbCircle) {
  11073. context.beginPath();
  11074. if (this.isVertical) {
  11075. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11076. }
  11077. else {
  11078. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11079. }
  11080. context.fill();
  11081. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11082. context.shadowBlur = 0;
  11083. context.shadowOffsetX = 0;
  11084. context.shadowOffsetY = 0;
  11085. }
  11086. context.strokeStyle = this._borderColor;
  11087. context.stroke();
  11088. }
  11089. else {
  11090. if (this.isVertical) {
  11091. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11092. }
  11093. else {
  11094. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11095. }
  11096. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11097. context.shadowBlur = 0;
  11098. context.shadowOffsetX = 0;
  11099. context.shadowOffsetY = 0;
  11100. }
  11101. context.strokeStyle = this._borderColor;
  11102. if (this.isVertical) {
  11103. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11104. }
  11105. else {
  11106. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11107. }
  11108. }
  11109. }
  11110. context.restore();
  11111. };
  11112. return Slider;
  11113. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11114. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11115. /***/ }),
  11116. /***/ "./2D/controls/stackPanel.ts":
  11117. /*!***********************************!*\
  11118. !*** ./2D/controls/stackPanel.ts ***!
  11119. \***********************************/
  11120. /*! exports provided: StackPanel */
  11121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11122. "use strict";
  11123. __webpack_require__.r(__webpack_exports__);
  11124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11126. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  11127. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11128. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11129. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11130. /**
  11131. * Class used to create a 2D stack panel container
  11132. */
  11133. var StackPanel = /** @class */ (function (_super) {
  11134. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11135. /**
  11136. * Creates a new StackPanel
  11137. * @param name defines control name
  11138. */
  11139. function StackPanel(name) {
  11140. var _this = _super.call(this, name) || this;
  11141. _this.name = name;
  11142. _this._isVertical = true;
  11143. _this._manualWidth = false;
  11144. _this._manualHeight = false;
  11145. _this._doNotTrackManualChanges = false;
  11146. /**
  11147. * Gets or sets a boolean indicating that layou warnings should be ignored
  11148. */
  11149. _this.ignoreLayoutWarnings = false;
  11150. return _this;
  11151. }
  11152. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11153. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11154. get: function () {
  11155. return this._isVertical;
  11156. },
  11157. set: function (value) {
  11158. if (this._isVertical === value) {
  11159. return;
  11160. }
  11161. this._isVertical = value;
  11162. this._markAsDirty();
  11163. },
  11164. enumerable: true,
  11165. configurable: true
  11166. });
  11167. Object.defineProperty(StackPanel.prototype, "width", {
  11168. get: function () {
  11169. return this._width.toString(this._host);
  11170. },
  11171. /**
  11172. * Gets or sets panel width.
  11173. * This value should not be set when in horizontal mode as it will be computed automatically
  11174. */
  11175. set: function (value) {
  11176. if (!this._doNotTrackManualChanges) {
  11177. this._manualWidth = true;
  11178. }
  11179. if (this._width.toString(this._host) === value) {
  11180. return;
  11181. }
  11182. if (this._width.fromString(value)) {
  11183. this._markAsDirty();
  11184. }
  11185. },
  11186. enumerable: true,
  11187. configurable: true
  11188. });
  11189. Object.defineProperty(StackPanel.prototype, "height", {
  11190. get: function () {
  11191. return this._height.toString(this._host);
  11192. },
  11193. /**
  11194. * Gets or sets panel height.
  11195. * This value should not be set when in vertical mode as it will be computed automatically
  11196. */
  11197. set: function (value) {
  11198. if (!this._doNotTrackManualChanges) {
  11199. this._manualHeight = true;
  11200. }
  11201. if (this._height.toString(this._host) === value) {
  11202. return;
  11203. }
  11204. if (this._height.fromString(value)) {
  11205. this._markAsDirty();
  11206. }
  11207. },
  11208. enumerable: true,
  11209. configurable: true
  11210. });
  11211. StackPanel.prototype._getTypeName = function () {
  11212. return "StackPanel";
  11213. };
  11214. /** @hidden */
  11215. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11216. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11217. var child = _a[_i];
  11218. if (this._isVertical) {
  11219. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11220. }
  11221. else {
  11222. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11223. }
  11224. }
  11225. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11226. };
  11227. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11228. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11229. this._measureForChildren.copyFrom(parentMeasure);
  11230. this._measureForChildren.left = this._currentMeasure.left;
  11231. this._measureForChildren.top = this._currentMeasure.top;
  11232. if (!this.isVertical || this._manualWidth) {
  11233. this._measureForChildren.width = this._currentMeasure.width;
  11234. }
  11235. if (this.isVertical || this._manualHeight) {
  11236. this._measureForChildren.height = this._currentMeasure.height;
  11237. }
  11238. };
  11239. StackPanel.prototype._postMeasure = function () {
  11240. var stackWidth = 0;
  11241. var stackHeight = 0;
  11242. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11243. var child = _a[_i];
  11244. if (!child.isVisible || child.notRenderable) {
  11245. continue;
  11246. }
  11247. if (this._isVertical) {
  11248. if (child.top !== stackHeight + "px") {
  11249. child.top = stackHeight + "px";
  11250. this._rebuildLayout = true;
  11251. child._top.ignoreAdaptiveScaling = true;
  11252. }
  11253. if (child._height.isPercentage && !child._automaticSize) {
  11254. if (!this.ignoreLayoutWarnings) {
  11255. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using height in percentage mode inside a vertical StackPanel");
  11256. }
  11257. }
  11258. else {
  11259. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11260. }
  11261. }
  11262. else {
  11263. if (child.left !== stackWidth + "px") {
  11264. child.left = stackWidth + "px";
  11265. this._rebuildLayout = true;
  11266. child._left.ignoreAdaptiveScaling = true;
  11267. }
  11268. if (child._width.isPercentage && !child._automaticSize) {
  11269. if (!this.ignoreLayoutWarnings) {
  11270. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Control (Name:" + child.name + ", UniqueId:" + child.uniqueId + ") is using width in percentage mode inside a horizontal StackPanel");
  11271. }
  11272. }
  11273. else {
  11274. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11275. }
  11276. }
  11277. }
  11278. this._doNotTrackManualChanges = true;
  11279. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11280. // User can now define their own height and width for stack panel.
  11281. var panelWidthChanged = false;
  11282. var panelHeightChanged = false;
  11283. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11284. var previousHeight = this.height;
  11285. this.height = stackHeight + "px";
  11286. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11287. }
  11288. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11289. var previousWidth = this.width;
  11290. this.width = stackWidth + "px";
  11291. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11292. }
  11293. if (panelHeightChanged) {
  11294. this._height.ignoreAdaptiveScaling = true;
  11295. }
  11296. if (panelWidthChanged) {
  11297. this._width.ignoreAdaptiveScaling = true;
  11298. }
  11299. this._doNotTrackManualChanges = false;
  11300. if (panelWidthChanged || panelHeightChanged) {
  11301. this._rebuildLayout = true;
  11302. }
  11303. _super.prototype._postMeasure.call(this);
  11304. };
  11305. return StackPanel;
  11306. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11307. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11308. /***/ }),
  11309. /***/ "./2D/controls/statics.ts":
  11310. /*!********************************!*\
  11311. !*** ./2D/controls/statics.ts ***!
  11312. \********************************/
  11313. /*! exports provided: name */
  11314. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11315. "use strict";
  11316. __webpack_require__.r(__webpack_exports__);
  11317. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11318. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11319. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11320. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11321. /**
  11322. * Forcing an export so that this code will execute
  11323. * @hidden
  11324. */
  11325. var name = "Statics";
  11326. /**
  11327. * Creates a stack panel that can be used to render headers
  11328. * @param control defines the control to associate with the header
  11329. * @param text defines the text of the header
  11330. * @param size defines the size of the header
  11331. * @param options defines options used to configure the header
  11332. * @returns a new StackPanel
  11333. */
  11334. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11335. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11336. var isHorizontal = options ? options.isHorizontal : true;
  11337. var controlFirst = options ? options.controlFirst : true;
  11338. panel.isVertical = !isHorizontal;
  11339. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11340. header.text = text;
  11341. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11342. if (isHorizontal) {
  11343. header.width = size;
  11344. }
  11345. else {
  11346. header.height = size;
  11347. }
  11348. if (controlFirst) {
  11349. panel.addControl(control);
  11350. panel.addControl(header);
  11351. header.paddingLeft = "5px";
  11352. }
  11353. else {
  11354. panel.addControl(header);
  11355. panel.addControl(control);
  11356. header.paddingRight = "5px";
  11357. }
  11358. header.shadowBlur = control.shadowBlur;
  11359. header.shadowColor = control.shadowColor;
  11360. header.shadowOffsetX = control.shadowOffsetX;
  11361. header.shadowOffsetY = control.shadowOffsetY;
  11362. return panel;
  11363. };
  11364. /***/ }),
  11365. /***/ "./2D/controls/textBlock.ts":
  11366. /*!**********************************!*\
  11367. !*** ./2D/controls/textBlock.ts ***!
  11368. \**********************************/
  11369. /*! exports provided: TextWrapping, TextBlock */
  11370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11371. "use strict";
  11372. __webpack_require__.r(__webpack_exports__);
  11373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11375. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11376. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11377. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11378. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11379. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11380. /**
  11381. * Enum that determines the text-wrapping mode to use.
  11382. */
  11383. var TextWrapping;
  11384. (function (TextWrapping) {
  11385. /**
  11386. * Clip the text when it's larger than Control.width; this is the default mode.
  11387. */
  11388. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11389. /**
  11390. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11391. */
  11392. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11393. /**
  11394. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11395. */
  11396. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11397. })(TextWrapping || (TextWrapping = {}));
  11398. /**
  11399. * Class used to create text block control
  11400. */
  11401. var TextBlock = /** @class */ (function (_super) {
  11402. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11403. /**
  11404. * Creates a new TextBlock object
  11405. * @param name defines the name of the control
  11406. * @param text defines the text to display (emptry string by default)
  11407. */
  11408. function TextBlock(
  11409. /**
  11410. * Defines the name of the control
  11411. */
  11412. name, text) {
  11413. if (text === void 0) { text = ""; }
  11414. var _this = _super.call(this, name) || this;
  11415. _this.name = name;
  11416. _this._text = "";
  11417. _this._textWrapping = TextWrapping.Clip;
  11418. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11419. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11420. _this._resizeToFit = false;
  11421. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11422. _this._outlineWidth = 0;
  11423. _this._outlineColor = "white";
  11424. /**
  11425. * An event triggered after the text is changed
  11426. */
  11427. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11428. /**
  11429. * An event triggered after the text was broken up into lines
  11430. */
  11431. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11432. _this.text = text;
  11433. return _this;
  11434. }
  11435. Object.defineProperty(TextBlock.prototype, "lines", {
  11436. /**
  11437. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11438. */
  11439. get: function () {
  11440. return this._lines;
  11441. },
  11442. enumerable: true,
  11443. configurable: true
  11444. });
  11445. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11446. /**
  11447. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11448. */
  11449. get: function () {
  11450. return this._resizeToFit;
  11451. },
  11452. /**
  11453. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11454. */
  11455. set: function (value) {
  11456. if (this._resizeToFit === value) {
  11457. return;
  11458. }
  11459. this._resizeToFit = value;
  11460. if (this._resizeToFit) {
  11461. this._width.ignoreAdaptiveScaling = true;
  11462. this._height.ignoreAdaptiveScaling = true;
  11463. }
  11464. this._markAsDirty();
  11465. },
  11466. enumerable: true,
  11467. configurable: true
  11468. });
  11469. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11470. /**
  11471. * Gets or sets a boolean indicating if text must be wrapped
  11472. */
  11473. get: function () {
  11474. return this._textWrapping;
  11475. },
  11476. /**
  11477. * Gets or sets a boolean indicating if text must be wrapped
  11478. */
  11479. set: function (value) {
  11480. if (this._textWrapping === value) {
  11481. return;
  11482. }
  11483. this._textWrapping = +value;
  11484. this._markAsDirty();
  11485. },
  11486. enumerable: true,
  11487. configurable: true
  11488. });
  11489. Object.defineProperty(TextBlock.prototype, "text", {
  11490. /**
  11491. * Gets or sets text to display
  11492. */
  11493. get: function () {
  11494. return this._text;
  11495. },
  11496. /**
  11497. * Gets or sets text to display
  11498. */
  11499. set: function (value) {
  11500. if (this._text === value) {
  11501. return;
  11502. }
  11503. this._text = value;
  11504. this._markAsDirty();
  11505. this.onTextChangedObservable.notifyObservers(this);
  11506. },
  11507. enumerable: true,
  11508. configurable: true
  11509. });
  11510. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11511. /**
  11512. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11513. */
  11514. get: function () {
  11515. return this._textHorizontalAlignment;
  11516. },
  11517. /**
  11518. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11519. */
  11520. set: function (value) {
  11521. if (this._textHorizontalAlignment === value) {
  11522. return;
  11523. }
  11524. this._textHorizontalAlignment = value;
  11525. this._markAsDirty();
  11526. },
  11527. enumerable: true,
  11528. configurable: true
  11529. });
  11530. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11531. /**
  11532. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11533. */
  11534. get: function () {
  11535. return this._textVerticalAlignment;
  11536. },
  11537. /**
  11538. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11539. */
  11540. set: function (value) {
  11541. if (this._textVerticalAlignment === value) {
  11542. return;
  11543. }
  11544. this._textVerticalAlignment = value;
  11545. this._markAsDirty();
  11546. },
  11547. enumerable: true,
  11548. configurable: true
  11549. });
  11550. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11551. /**
  11552. * Gets or sets line spacing value
  11553. */
  11554. get: function () {
  11555. return this._lineSpacing.toString(this._host);
  11556. },
  11557. /**
  11558. * Gets or sets line spacing value
  11559. */
  11560. set: function (value) {
  11561. if (this._lineSpacing.fromString(value)) {
  11562. this._markAsDirty();
  11563. }
  11564. },
  11565. enumerable: true,
  11566. configurable: true
  11567. });
  11568. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11569. /**
  11570. * Gets or sets outlineWidth of the text to display
  11571. */
  11572. get: function () {
  11573. return this._outlineWidth;
  11574. },
  11575. /**
  11576. * Gets or sets outlineWidth of the text to display
  11577. */
  11578. set: function (value) {
  11579. if (this._outlineWidth === value) {
  11580. return;
  11581. }
  11582. this._outlineWidth = value;
  11583. this._markAsDirty();
  11584. },
  11585. enumerable: true,
  11586. configurable: true
  11587. });
  11588. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11589. /**
  11590. * Gets or sets outlineColor of the text to display
  11591. */
  11592. get: function () {
  11593. return this._outlineColor;
  11594. },
  11595. /**
  11596. * Gets or sets outlineColor of the text to display
  11597. */
  11598. set: function (value) {
  11599. if (this._outlineColor === value) {
  11600. return;
  11601. }
  11602. this._outlineColor = value;
  11603. this._markAsDirty();
  11604. },
  11605. enumerable: true,
  11606. configurable: true
  11607. });
  11608. TextBlock.prototype._getTypeName = function () {
  11609. return "TextBlock";
  11610. };
  11611. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11612. if (!this._fontOffset) {
  11613. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11614. }
  11615. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11616. // Prepare lines
  11617. this._lines = this._breakLines(this._currentMeasure.width, context);
  11618. this.onLinesReadyObservable.notifyObservers(this);
  11619. var maxLineWidth = 0;
  11620. for (var i = 0; i < this._lines.length; i++) {
  11621. var line = this._lines[i];
  11622. if (line.width > maxLineWidth) {
  11623. maxLineWidth = line.width;
  11624. }
  11625. }
  11626. if (this._resizeToFit) {
  11627. if (this._textWrapping === TextWrapping.Clip) {
  11628. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11629. if (newWidth !== this._width.internalValue) {
  11630. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11631. this._rebuildLayout = true;
  11632. }
  11633. }
  11634. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11635. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11636. var lineSpacing = 0;
  11637. if (this._lineSpacing.isPixel) {
  11638. lineSpacing = this._lineSpacing.getValue(this._host);
  11639. }
  11640. else {
  11641. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11642. }
  11643. newHeight += (this._lines.length - 1) * lineSpacing;
  11644. }
  11645. if (newHeight !== this._height.internalValue) {
  11646. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11647. this._rebuildLayout = true;
  11648. }
  11649. }
  11650. };
  11651. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11652. var width = this._currentMeasure.width;
  11653. var x = 0;
  11654. switch (this._textHorizontalAlignment) {
  11655. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11656. x = 0;
  11657. break;
  11658. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11659. x = width - textWidth;
  11660. break;
  11661. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11662. x = (width - textWidth) / 2;
  11663. break;
  11664. }
  11665. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11666. context.shadowColor = this.shadowColor;
  11667. context.shadowBlur = this.shadowBlur;
  11668. context.shadowOffsetX = this.shadowOffsetX;
  11669. context.shadowOffsetY = this.shadowOffsetY;
  11670. }
  11671. if (this.outlineWidth) {
  11672. context.strokeText(text, this._currentMeasure.left + x, y);
  11673. }
  11674. context.fillText(text, this._currentMeasure.left + x, y);
  11675. };
  11676. /** @hidden */
  11677. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11678. context.save();
  11679. this._applyStates(context);
  11680. // Render lines
  11681. this._renderLines(context);
  11682. context.restore();
  11683. };
  11684. TextBlock.prototype._applyStates = function (context) {
  11685. _super.prototype._applyStates.call(this, context);
  11686. if (this.outlineWidth) {
  11687. context.lineWidth = this.outlineWidth;
  11688. context.strokeStyle = this.outlineColor;
  11689. }
  11690. };
  11691. TextBlock.prototype._breakLines = function (refWidth, context) {
  11692. var lines = [];
  11693. var _lines = this.text.split("\n");
  11694. if (this._textWrapping === TextWrapping.Ellipsis) {
  11695. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11696. var _line = _lines_1[_i];
  11697. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11698. }
  11699. }
  11700. else if (this._textWrapping === TextWrapping.WordWrap) {
  11701. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11702. var _line = _lines_2[_a];
  11703. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11704. }
  11705. }
  11706. else {
  11707. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11708. var _line = _lines_3[_b];
  11709. lines.push(this._parseLine(_line, context));
  11710. }
  11711. }
  11712. return lines;
  11713. };
  11714. TextBlock.prototype._parseLine = function (line, context) {
  11715. if (line === void 0) { line = ''; }
  11716. return { text: line, width: context.measureText(line).width };
  11717. };
  11718. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11719. if (line === void 0) { line = ''; }
  11720. var lineWidth = context.measureText(line).width;
  11721. if (lineWidth > width) {
  11722. line += '…';
  11723. }
  11724. while (line.length > 2 && lineWidth > width) {
  11725. line = line.slice(0, -2) + '…';
  11726. lineWidth = context.measureText(line).width;
  11727. }
  11728. return { text: line, width: lineWidth };
  11729. };
  11730. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11731. if (line === void 0) { line = ''; }
  11732. var lines = [];
  11733. var words = line.split(' ');
  11734. var lineWidth = 0;
  11735. for (var n = 0; n < words.length; n++) {
  11736. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11737. var metrics = context.measureText(testLine);
  11738. var testWidth = metrics.width;
  11739. if (testWidth > width && n > 0) {
  11740. lines.push({ text: line, width: lineWidth });
  11741. line = words[n];
  11742. lineWidth = context.measureText(line).width;
  11743. }
  11744. else {
  11745. lineWidth = testWidth;
  11746. line = testLine;
  11747. }
  11748. }
  11749. lines.push({ text: line, width: lineWidth });
  11750. return lines;
  11751. };
  11752. TextBlock.prototype._renderLines = function (context) {
  11753. var height = this._currentMeasure.height;
  11754. var rootY = 0;
  11755. switch (this._textVerticalAlignment) {
  11756. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11757. rootY = this._fontOffset.ascent;
  11758. break;
  11759. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11760. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11761. break;
  11762. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11763. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11764. break;
  11765. }
  11766. rootY += this._currentMeasure.top;
  11767. for (var i = 0; i < this._lines.length; i++) {
  11768. var line = this._lines[i];
  11769. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11770. if (this._lineSpacing.isPixel) {
  11771. rootY += this._lineSpacing.getValue(this._host);
  11772. }
  11773. else {
  11774. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11775. }
  11776. }
  11777. this._drawText(line.text, line.width, rootY, context);
  11778. rootY += this._fontOffset.height;
  11779. }
  11780. };
  11781. /**
  11782. * Given a width constraint applied on the text block, find the expected height
  11783. * @returns expected height
  11784. */
  11785. TextBlock.prototype.computeExpectedHeight = function () {
  11786. if (this.text && this.widthInPixels) {
  11787. var context_1 = document.createElement('canvas').getContext('2d');
  11788. if (context_1) {
  11789. this._applyStates(context_1);
  11790. if (!this._fontOffset) {
  11791. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11792. }
  11793. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11794. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11795. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11796. var lineSpacing = 0;
  11797. if (this._lineSpacing.isPixel) {
  11798. lineSpacing = this._lineSpacing.getValue(this._host);
  11799. }
  11800. else {
  11801. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11802. }
  11803. newHeight += (lines.length - 1) * lineSpacing;
  11804. }
  11805. return newHeight;
  11806. }
  11807. }
  11808. return 0;
  11809. };
  11810. TextBlock.prototype.dispose = function () {
  11811. _super.prototype.dispose.call(this);
  11812. this.onTextChangedObservable.clear();
  11813. };
  11814. return TextBlock;
  11815. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11816. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11817. /***/ }),
  11818. /***/ "./2D/controls/virtualKeyboard.ts":
  11819. /*!****************************************!*\
  11820. !*** ./2D/controls/virtualKeyboard.ts ***!
  11821. \****************************************/
  11822. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11824. "use strict";
  11825. __webpack_require__.r(__webpack_exports__);
  11826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11827. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11828. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11829. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11830. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11831. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11832. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11833. /**
  11834. * Class used to store key control properties
  11835. */
  11836. var KeyPropertySet = /** @class */ (function () {
  11837. function KeyPropertySet() {
  11838. }
  11839. return KeyPropertySet;
  11840. }());
  11841. /**
  11842. * Class used to create virtual keyboard
  11843. */
  11844. var VirtualKeyboard = /** @class */ (function (_super) {
  11845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11846. function VirtualKeyboard() {
  11847. var _this = _super !== null && _super.apply(this, arguments) || this;
  11848. /** Observable raised when a key is pressed */
  11849. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11850. /** Gets or sets default key button width */
  11851. _this.defaultButtonWidth = "40px";
  11852. /** Gets or sets default key button height */
  11853. _this.defaultButtonHeight = "40px";
  11854. /** Gets or sets default key button left padding */
  11855. _this.defaultButtonPaddingLeft = "2px";
  11856. /** Gets or sets default key button right padding */
  11857. _this.defaultButtonPaddingRight = "2px";
  11858. /** Gets or sets default key button top padding */
  11859. _this.defaultButtonPaddingTop = "2px";
  11860. /** Gets or sets default key button bottom padding */
  11861. _this.defaultButtonPaddingBottom = "2px";
  11862. /** Gets or sets default key button foreground color */
  11863. _this.defaultButtonColor = "#DDD";
  11864. /** Gets or sets default key button background color */
  11865. _this.defaultButtonBackground = "#070707";
  11866. /** Gets or sets shift button foreground color */
  11867. _this.shiftButtonColor = "#7799FF";
  11868. /** Gets or sets shift button thickness*/
  11869. _this.selectedShiftThickness = 1;
  11870. /** Gets shift key state */
  11871. _this.shiftState = 0;
  11872. _this._currentlyConnectedInputText = null;
  11873. _this._connectedInputTexts = [];
  11874. _this._onKeyPressObserver = null;
  11875. return _this;
  11876. }
  11877. VirtualKeyboard.prototype._getTypeName = function () {
  11878. return "VirtualKeyboard";
  11879. };
  11880. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11881. var _this = this;
  11882. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11883. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11884. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11885. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11886. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11887. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11888. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11889. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11890. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11891. button.thickness = 0;
  11892. button.isFocusInvisible = true;
  11893. button.shadowColor = this.shadowColor;
  11894. button.shadowBlur = this.shadowBlur;
  11895. button.shadowOffsetX = this.shadowOffsetX;
  11896. button.shadowOffsetY = this.shadowOffsetY;
  11897. button.onPointerUpObservable.add(function () {
  11898. _this.onKeyPressObservable.notifyObservers(key);
  11899. });
  11900. return button;
  11901. };
  11902. /**
  11903. * Adds a new row of keys
  11904. * @param keys defines the list of keys to add
  11905. * @param propertySets defines the associated property sets
  11906. */
  11907. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11908. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11909. panel.isVertical = false;
  11910. panel.isFocusInvisible = true;
  11911. var maxKey = null;
  11912. for (var i = 0; i < keys.length; i++) {
  11913. var properties = null;
  11914. if (propertySets && propertySets.length === keys.length) {
  11915. properties = propertySets[i];
  11916. }
  11917. var key = this._createKey(keys[i], properties);
  11918. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11919. maxKey = key;
  11920. }
  11921. panel.addControl(key);
  11922. }
  11923. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11924. this.addControl(panel);
  11925. };
  11926. /**
  11927. * Set the shift key to a specific state
  11928. * @param shiftState defines the new shift state
  11929. */
  11930. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11931. if (!this.children) {
  11932. return;
  11933. }
  11934. for (var i = 0; i < this.children.length; i++) {
  11935. var row = this.children[i];
  11936. if (!row || !row.children) {
  11937. continue;
  11938. }
  11939. var rowContainer = row;
  11940. for (var j = 0; j < rowContainer.children.length; j++) {
  11941. var button = rowContainer.children[j];
  11942. if (!button || !button.children[0]) {
  11943. continue;
  11944. }
  11945. var button_tblock = button.children[0];
  11946. if (button_tblock.text === "\u21E7") {
  11947. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11948. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11949. }
  11950. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11951. }
  11952. }
  11953. };
  11954. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11955. /** Gets the input text control currently attached to the keyboard */
  11956. get: function () {
  11957. return this._currentlyConnectedInputText;
  11958. },
  11959. enumerable: true,
  11960. configurable: true
  11961. });
  11962. /**
  11963. * Connects the keyboard with an input text control
  11964. *
  11965. * @param input defines the target control
  11966. */
  11967. VirtualKeyboard.prototype.connect = function (input) {
  11968. var _this = this;
  11969. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11970. if (inputTextAlreadyConnected) {
  11971. return;
  11972. }
  11973. if (this._onKeyPressObserver === null) {
  11974. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11975. if (!_this._currentlyConnectedInputText) {
  11976. return;
  11977. }
  11978. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11979. switch (key) {
  11980. case "\u21E7":
  11981. _this.shiftState++;
  11982. if (_this.shiftState > 2) {
  11983. _this.shiftState = 0;
  11984. }
  11985. _this.applyShiftState(_this.shiftState);
  11986. return;
  11987. case "\u2190":
  11988. _this._currentlyConnectedInputText.processKey(8);
  11989. return;
  11990. case "\u21B5":
  11991. _this._currentlyConnectedInputText.processKey(13);
  11992. return;
  11993. }
  11994. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11995. if (_this.shiftState === 1) {
  11996. _this.shiftState = 0;
  11997. _this.applyShiftState(_this.shiftState);
  11998. }
  11999. });
  12000. }
  12001. this.isVisible = false;
  12002. this._currentlyConnectedInputText = input;
  12003. input._connectedVirtualKeyboard = this;
  12004. // Events hooking
  12005. var onFocusObserver = input.onFocusObservable.add(function () {
  12006. _this._currentlyConnectedInputText = input;
  12007. input._connectedVirtualKeyboard = _this;
  12008. _this.isVisible = true;
  12009. });
  12010. var onBlurObserver = input.onBlurObservable.add(function () {
  12011. input._connectedVirtualKeyboard = null;
  12012. _this._currentlyConnectedInputText = null;
  12013. _this.isVisible = false;
  12014. });
  12015. this._connectedInputTexts.push({
  12016. input: input,
  12017. onBlurObserver: onBlurObserver,
  12018. onFocusObserver: onFocusObserver
  12019. });
  12020. };
  12021. /**
  12022. * Disconnects the keyboard from connected InputText controls
  12023. *
  12024. * @param input optionally defines a target control, otherwise all are disconnected
  12025. */
  12026. VirtualKeyboard.prototype.disconnect = function (input) {
  12027. var _this = this;
  12028. if (input) {
  12029. // .find not available on IE
  12030. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12031. if (filtered.length === 1) {
  12032. this._removeConnectedInputObservables(filtered[0]);
  12033. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12034. if (this._currentlyConnectedInputText === input) {
  12035. this._currentlyConnectedInputText = null;
  12036. }
  12037. }
  12038. }
  12039. else {
  12040. this._connectedInputTexts.forEach(function (connectedInputText) {
  12041. _this._removeConnectedInputObservables(connectedInputText);
  12042. });
  12043. this._connectedInputTexts = [];
  12044. }
  12045. if (this._connectedInputTexts.length === 0) {
  12046. this._currentlyConnectedInputText = null;
  12047. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12048. this._onKeyPressObserver = null;
  12049. }
  12050. };
  12051. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12052. connectedInputText.input._connectedVirtualKeyboard = null;
  12053. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12054. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12055. };
  12056. /**
  12057. * Release all resources
  12058. */
  12059. VirtualKeyboard.prototype.dispose = function () {
  12060. _super.prototype.dispose.call(this);
  12061. this.disconnect();
  12062. };
  12063. // Statics
  12064. /**
  12065. * Creates a new keyboard using a default layout
  12066. *
  12067. * @param name defines control name
  12068. * @returns a new VirtualKeyboard
  12069. */
  12070. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12071. var returnValue = new VirtualKeyboard(name);
  12072. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12073. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12074. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12075. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12076. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12077. return returnValue;
  12078. };
  12079. return VirtualKeyboard;
  12080. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12081. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12082. /***/ }),
  12083. /***/ "./2D/index.ts":
  12084. /*!*********************!*\
  12085. !*** ./2D/index.ts ***!
  12086. \*********************/
  12087. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  12088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12089. "use strict";
  12090. __webpack_require__.r(__webpack_exports__);
  12091. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12124. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12126. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12128. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12131. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12133. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12135. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12137. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12139. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12141. /***/ }),
  12142. /***/ "./2D/math2D.ts":
  12143. /*!**********************!*\
  12144. !*** ./2D/math2D.ts ***!
  12145. \**********************/
  12146. /*! exports provided: Vector2WithInfo, Matrix2D */
  12147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12148. "use strict";
  12149. __webpack_require__.r(__webpack_exports__);
  12150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12153. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12154. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12155. /**
  12156. * Class used to transport Vector2 information for pointer events
  12157. */
  12158. var Vector2WithInfo = /** @class */ (function (_super) {
  12159. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12160. /**
  12161. * Creates a new Vector2WithInfo
  12162. * @param source defines the vector2 data to transport
  12163. * @param buttonIndex defines the current mouse button index
  12164. */
  12165. function Vector2WithInfo(source,
  12166. /** defines the current mouse button index */
  12167. buttonIndex) {
  12168. if (buttonIndex === void 0) { buttonIndex = 0; }
  12169. var _this = _super.call(this, source.x, source.y) || this;
  12170. _this.buttonIndex = buttonIndex;
  12171. return _this;
  12172. }
  12173. return Vector2WithInfo;
  12174. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12175. /** Class used to provide 2D matrix features */
  12176. var Matrix2D = /** @class */ (function () {
  12177. /**
  12178. * Creates a new matrix
  12179. * @param m00 defines value for (0, 0)
  12180. * @param m01 defines value for (0, 1)
  12181. * @param m10 defines value for (1, 0)
  12182. * @param m11 defines value for (1, 1)
  12183. * @param m20 defines value for (2, 0)
  12184. * @param m21 defines value for (2, 1)
  12185. */
  12186. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12187. /** Gets the internal array of 6 floats used to store matrix data */
  12188. this.m = new Float32Array(6);
  12189. this.fromValues(m00, m01, m10, m11, m20, m21);
  12190. }
  12191. /**
  12192. * Fills the matrix from direct values
  12193. * @param m00 defines value for (0, 0)
  12194. * @param m01 defines value for (0, 1)
  12195. * @param m10 defines value for (1, 0)
  12196. * @param m11 defines value for (1, 1)
  12197. * @param m20 defines value for (2, 0)
  12198. * @param m21 defines value for (2, 1)
  12199. * @returns the current modified matrix
  12200. */
  12201. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12202. this.m[0] = m00;
  12203. this.m[1] = m01;
  12204. this.m[2] = m10;
  12205. this.m[3] = m11;
  12206. this.m[4] = m20;
  12207. this.m[5] = m21;
  12208. return this;
  12209. };
  12210. /**
  12211. * Gets matrix determinant
  12212. * @returns the determinant
  12213. */
  12214. Matrix2D.prototype.determinant = function () {
  12215. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12216. };
  12217. /**
  12218. * Inverses the matrix and stores it in a target matrix
  12219. * @param result defines the target matrix
  12220. * @returns the current matrix
  12221. */
  12222. Matrix2D.prototype.invertToRef = function (result) {
  12223. var l0 = this.m[0];
  12224. var l1 = this.m[1];
  12225. var l2 = this.m[2];
  12226. var l3 = this.m[3];
  12227. var l4 = this.m[4];
  12228. var l5 = this.m[5];
  12229. var det = this.determinant();
  12230. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12231. result.m[0] = 0;
  12232. result.m[1] = 0;
  12233. result.m[2] = 0;
  12234. result.m[3] = 0;
  12235. result.m[4] = 0;
  12236. result.m[5] = 0;
  12237. return this;
  12238. }
  12239. var detDiv = 1 / det;
  12240. var det4 = l2 * l5 - l3 * l4;
  12241. var det5 = l1 * l4 - l0 * l5;
  12242. result.m[0] = l3 * detDiv;
  12243. result.m[1] = -l1 * detDiv;
  12244. result.m[2] = -l2 * detDiv;
  12245. result.m[3] = l0 * detDiv;
  12246. result.m[4] = det4 * detDiv;
  12247. result.m[5] = det5 * detDiv;
  12248. return this;
  12249. };
  12250. /**
  12251. * Multiplies the current matrix with another one
  12252. * @param other defines the second operand
  12253. * @param result defines the target matrix
  12254. * @returns the current matrix
  12255. */
  12256. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12257. var l0 = this.m[0];
  12258. var l1 = this.m[1];
  12259. var l2 = this.m[2];
  12260. var l3 = this.m[3];
  12261. var l4 = this.m[4];
  12262. var l5 = this.m[5];
  12263. var r0 = other.m[0];
  12264. var r1 = other.m[1];
  12265. var r2 = other.m[2];
  12266. var r3 = other.m[3];
  12267. var r4 = other.m[4];
  12268. var r5 = other.m[5];
  12269. result.m[0] = l0 * r0 + l1 * r2;
  12270. result.m[1] = l0 * r1 + l1 * r3;
  12271. result.m[2] = l2 * r0 + l3 * r2;
  12272. result.m[3] = l2 * r1 + l3 * r3;
  12273. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12274. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12275. return this;
  12276. };
  12277. /**
  12278. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12279. * @param x defines the x coordinate to transform
  12280. * @param y defines the x coordinate to transform
  12281. * @param result defines the target vector2
  12282. * @returns the current matrix
  12283. */
  12284. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12285. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12286. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12287. return this;
  12288. };
  12289. // Statics
  12290. /**
  12291. * Creates an identity matrix
  12292. * @returns a new matrix
  12293. */
  12294. Matrix2D.Identity = function () {
  12295. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12296. };
  12297. /**
  12298. * Creates a translation matrix and stores it in a target matrix
  12299. * @param x defines the x coordinate of the translation
  12300. * @param y defines the y coordinate of the translation
  12301. * @param result defines the target matrix
  12302. */
  12303. Matrix2D.TranslationToRef = function (x, y, result) {
  12304. result.fromValues(1, 0, 0, 1, x, y);
  12305. };
  12306. /**
  12307. * Creates a scaling matrix and stores it in a target matrix
  12308. * @param x defines the x coordinate of the scaling
  12309. * @param y defines the y coordinate of the scaling
  12310. * @param result defines the target matrix
  12311. */
  12312. Matrix2D.ScalingToRef = function (x, y, result) {
  12313. result.fromValues(x, 0, 0, y, 0, 0);
  12314. };
  12315. /**
  12316. * Creates a rotation matrix and stores it in a target matrix
  12317. * @param angle defines the rotation angle
  12318. * @param result defines the target matrix
  12319. */
  12320. Matrix2D.RotationToRef = function (angle, result) {
  12321. var s = Math.sin(angle);
  12322. var c = Math.cos(angle);
  12323. result.fromValues(c, s, -s, c, 0, 0);
  12324. };
  12325. /**
  12326. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12327. * @param tx defines the x coordinate of the translation
  12328. * @param ty defines the y coordinate of the translation
  12329. * @param angle defines the rotation angle
  12330. * @param scaleX defines the x coordinate of the scaling
  12331. * @param scaleY defines the y coordinate of the scaling
  12332. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12333. * @param result defines the target matrix
  12334. */
  12335. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12336. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12337. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12338. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12339. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12340. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12341. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12342. if (parentMatrix) {
  12343. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12344. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12345. }
  12346. else {
  12347. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12348. }
  12349. };
  12350. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12351. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12352. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12353. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12354. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12355. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12356. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12357. return Matrix2D;
  12358. }());
  12359. /***/ }),
  12360. /***/ "./2D/measure.ts":
  12361. /*!***********************!*\
  12362. !*** ./2D/measure.ts ***!
  12363. \***********************/
  12364. /*! exports provided: Measure */
  12365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12366. "use strict";
  12367. __webpack_require__.r(__webpack_exports__);
  12368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12369. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12370. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12371. /**
  12372. * Class used to store 2D control sizes
  12373. */
  12374. var Measure = /** @class */ (function () {
  12375. /**
  12376. * Creates a new measure
  12377. * @param left defines left coordinate
  12378. * @param top defines top coordinate
  12379. * @param width defines width dimension
  12380. * @param height defines height dimension
  12381. */
  12382. function Measure(
  12383. /** defines left coordinate */
  12384. left,
  12385. /** defines top coordinate */
  12386. top,
  12387. /** defines width dimension */
  12388. width,
  12389. /** defines height dimension */
  12390. height) {
  12391. this.left = left;
  12392. this.top = top;
  12393. this.width = width;
  12394. this.height = height;
  12395. }
  12396. /**
  12397. * Copy from another measure
  12398. * @param other defines the other measure to copy from
  12399. */
  12400. Measure.prototype.copyFrom = function (other) {
  12401. this.left = other.left;
  12402. this.top = other.top;
  12403. this.width = other.width;
  12404. this.height = other.height;
  12405. };
  12406. /**
  12407. * Copy from a group of 4 floats
  12408. * @param left defines left coordinate
  12409. * @param top defines top coordinate
  12410. * @param width defines width dimension
  12411. * @param height defines height dimension
  12412. */
  12413. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12414. this.left = left;
  12415. this.top = top;
  12416. this.width = width;
  12417. this.height = height;
  12418. };
  12419. /**
  12420. * Computes the axis aligned bounding box measure for two given measures
  12421. * @param a Input measure
  12422. * @param b Input measure
  12423. * @param result the resulting bounding measure
  12424. */
  12425. Measure.CombineToRef = function (a, b, result) {
  12426. var left = Math.min(a.left, b.left);
  12427. var top = Math.min(a.top, b.top);
  12428. var right = Math.max(a.left + a.width, b.left + b.width);
  12429. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12430. result.left = left;
  12431. result.top = top;
  12432. result.width = right - left;
  12433. result.height = bottom - top;
  12434. };
  12435. /**
  12436. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12437. * @param transform the matrix to transform the measure before computing the AABB
  12438. * @param result the resulting AABB
  12439. */
  12440. Measure.prototype.transformToRef = function (transform, result) {
  12441. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12442. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12443. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12444. for (var i = 0; i < 4; i++) {
  12445. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12446. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12447. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12448. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12449. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12450. }
  12451. result.left = min.x;
  12452. result.top = min.y;
  12453. result.width = max.x - min.x;
  12454. result.height = max.y - min.y;
  12455. };
  12456. /**
  12457. * Check equality between this measure and another one
  12458. * @param other defines the other measures
  12459. * @returns true if both measures are equals
  12460. */
  12461. Measure.prototype.isEqualsTo = function (other) {
  12462. if (this.left !== other.left) {
  12463. return false;
  12464. }
  12465. if (this.top !== other.top) {
  12466. return false;
  12467. }
  12468. if (this.width !== other.width) {
  12469. return false;
  12470. }
  12471. if (this.height !== other.height) {
  12472. return false;
  12473. }
  12474. return true;
  12475. };
  12476. /**
  12477. * Creates an empty measure
  12478. * @returns a new measure
  12479. */
  12480. Measure.Empty = function () {
  12481. return new Measure(0, 0, 0, 0);
  12482. };
  12483. return Measure;
  12484. }());
  12485. /***/ }),
  12486. /***/ "./2D/multiLinePoint.ts":
  12487. /*!******************************!*\
  12488. !*** ./2D/multiLinePoint.ts ***!
  12489. \******************************/
  12490. /*! exports provided: MultiLinePoint */
  12491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12492. "use strict";
  12493. __webpack_require__.r(__webpack_exports__);
  12494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12495. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12496. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12497. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12498. /**
  12499. * Class used to store a point for a MultiLine object.
  12500. * The point can be pure 2D coordinates, a mesh or a control
  12501. */
  12502. var MultiLinePoint = /** @class */ (function () {
  12503. /**
  12504. * Creates a new MultiLinePoint
  12505. * @param multiLine defines the source MultiLine object
  12506. */
  12507. function MultiLinePoint(multiLine) {
  12508. this._multiLine = multiLine;
  12509. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12510. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12511. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12512. }
  12513. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12514. /** Gets or sets x coordinate */
  12515. get: function () {
  12516. return this._x.toString(this._multiLine._host);
  12517. },
  12518. set: function (value) {
  12519. if (this._x.toString(this._multiLine._host) === value) {
  12520. return;
  12521. }
  12522. if (this._x.fromString(value)) {
  12523. this._multiLine._markAsDirty();
  12524. }
  12525. },
  12526. enumerable: true,
  12527. configurable: true
  12528. });
  12529. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12530. /** Gets or sets y coordinate */
  12531. get: function () {
  12532. return this._y.toString(this._multiLine._host);
  12533. },
  12534. set: function (value) {
  12535. if (this._y.toString(this._multiLine._host) === value) {
  12536. return;
  12537. }
  12538. if (this._y.fromString(value)) {
  12539. this._multiLine._markAsDirty();
  12540. }
  12541. },
  12542. enumerable: true,
  12543. configurable: true
  12544. });
  12545. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12546. /** Gets or sets the control associated with this point */
  12547. get: function () {
  12548. return this._control;
  12549. },
  12550. set: function (value) {
  12551. if (this._control === value) {
  12552. return;
  12553. }
  12554. if (this._control && this._controlObserver) {
  12555. this._control.onDirtyObservable.remove(this._controlObserver);
  12556. this._controlObserver = null;
  12557. }
  12558. this._control = value;
  12559. if (this._control) {
  12560. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12561. }
  12562. this._multiLine._markAsDirty();
  12563. },
  12564. enumerable: true,
  12565. configurable: true
  12566. });
  12567. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12568. /** Gets or sets the mesh associated with this point */
  12569. get: function () {
  12570. return this._mesh;
  12571. },
  12572. set: function (value) {
  12573. if (this._mesh === value) {
  12574. return;
  12575. }
  12576. if (this._mesh && this._meshObserver) {
  12577. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12578. }
  12579. this._mesh = value;
  12580. if (this._mesh) {
  12581. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12582. }
  12583. this._multiLine._markAsDirty();
  12584. },
  12585. enumerable: true,
  12586. configurable: true
  12587. });
  12588. /** Resets links */
  12589. MultiLinePoint.prototype.resetLinks = function () {
  12590. this.control = null;
  12591. this.mesh = null;
  12592. };
  12593. /**
  12594. * Gets a translation vector
  12595. * @returns the translation vector
  12596. */
  12597. MultiLinePoint.prototype.translate = function () {
  12598. this._point = this._translatePoint();
  12599. return this._point;
  12600. };
  12601. MultiLinePoint.prototype._translatePoint = function () {
  12602. if (this._mesh != null) {
  12603. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12604. }
  12605. else if (this._control != null) {
  12606. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12607. }
  12608. else {
  12609. var host = this._multiLine._host;
  12610. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12611. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12612. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12613. }
  12614. };
  12615. /** Release associated resources */
  12616. MultiLinePoint.prototype.dispose = function () {
  12617. this.resetLinks();
  12618. };
  12619. return MultiLinePoint;
  12620. }());
  12621. /***/ }),
  12622. /***/ "./2D/style.ts":
  12623. /*!*********************!*\
  12624. !*** ./2D/style.ts ***!
  12625. \*********************/
  12626. /*! exports provided: Style */
  12627. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12628. "use strict";
  12629. __webpack_require__.r(__webpack_exports__);
  12630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12632. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12633. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12634. /**
  12635. * Define a style used by control to automatically setup properties based on a template.
  12636. * Only support font related properties so far
  12637. */
  12638. var Style = /** @class */ (function () {
  12639. /**
  12640. * Creates a new style object
  12641. * @param host defines the AdvancedDynamicTexture which hosts this style
  12642. */
  12643. function Style(host) {
  12644. this._fontFamily = "Arial";
  12645. this._fontStyle = "";
  12646. this._fontWeight = "";
  12647. /** @hidden */
  12648. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12649. /**
  12650. * Observable raised when the style values are changed
  12651. */
  12652. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12653. this._host = host;
  12654. }
  12655. Object.defineProperty(Style.prototype, "fontSize", {
  12656. /**
  12657. * Gets or sets the font size
  12658. */
  12659. get: function () {
  12660. return this._fontSize.toString(this._host);
  12661. },
  12662. set: function (value) {
  12663. if (this._fontSize.toString(this._host) === value) {
  12664. return;
  12665. }
  12666. if (this._fontSize.fromString(value)) {
  12667. this.onChangedObservable.notifyObservers(this);
  12668. }
  12669. },
  12670. enumerable: true,
  12671. configurable: true
  12672. });
  12673. Object.defineProperty(Style.prototype, "fontFamily", {
  12674. /**
  12675. * Gets or sets the font family
  12676. */
  12677. get: function () {
  12678. return this._fontFamily;
  12679. },
  12680. set: function (value) {
  12681. if (this._fontFamily === value) {
  12682. return;
  12683. }
  12684. this._fontFamily = value;
  12685. this.onChangedObservable.notifyObservers(this);
  12686. },
  12687. enumerable: true,
  12688. configurable: true
  12689. });
  12690. Object.defineProperty(Style.prototype, "fontStyle", {
  12691. /**
  12692. * Gets or sets the font style
  12693. */
  12694. get: function () {
  12695. return this._fontStyle;
  12696. },
  12697. set: function (value) {
  12698. if (this._fontStyle === value) {
  12699. return;
  12700. }
  12701. this._fontStyle = value;
  12702. this.onChangedObservable.notifyObservers(this);
  12703. },
  12704. enumerable: true,
  12705. configurable: true
  12706. });
  12707. Object.defineProperty(Style.prototype, "fontWeight", {
  12708. /** Gets or sets font weight */
  12709. get: function () {
  12710. return this._fontWeight;
  12711. },
  12712. set: function (value) {
  12713. if (this._fontWeight === value) {
  12714. return;
  12715. }
  12716. this._fontWeight = value;
  12717. this.onChangedObservable.notifyObservers(this);
  12718. },
  12719. enumerable: true,
  12720. configurable: true
  12721. });
  12722. /** Dispose all associated resources */
  12723. Style.prototype.dispose = function () {
  12724. this.onChangedObservable.clear();
  12725. };
  12726. return Style;
  12727. }());
  12728. /***/ }),
  12729. /***/ "./2D/valueAndUnit.ts":
  12730. /*!****************************!*\
  12731. !*** ./2D/valueAndUnit.ts ***!
  12732. \****************************/
  12733. /*! exports provided: ValueAndUnit */
  12734. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12735. "use strict";
  12736. __webpack_require__.r(__webpack_exports__);
  12737. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12738. /**
  12739. * Class used to specific a value and its associated unit
  12740. */
  12741. var ValueAndUnit = /** @class */ (function () {
  12742. /**
  12743. * Creates a new ValueAndUnit
  12744. * @param value defines the value to store
  12745. * @param unit defines the unit to store
  12746. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12747. */
  12748. function ValueAndUnit(value,
  12749. /** defines the unit to store */
  12750. unit,
  12751. /** defines a boolean indicating if the value can be negative */
  12752. negativeValueAllowed) {
  12753. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12754. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12755. this.unit = unit;
  12756. this.negativeValueAllowed = negativeValueAllowed;
  12757. this._value = 1;
  12758. /**
  12759. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12760. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12761. */
  12762. this.ignoreAdaptiveScaling = false;
  12763. this._value = value;
  12764. this._originalUnit = unit;
  12765. }
  12766. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12767. /** Gets a boolean indicating if the value is a percentage */
  12768. get: function () {
  12769. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12770. },
  12771. enumerable: true,
  12772. configurable: true
  12773. });
  12774. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12775. /** Gets a boolean indicating if the value is store as pixel */
  12776. get: function () {
  12777. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12778. },
  12779. enumerable: true,
  12780. configurable: true
  12781. });
  12782. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12783. /** Gets direct internal value */
  12784. get: function () {
  12785. return this._value;
  12786. },
  12787. enumerable: true,
  12788. configurable: true
  12789. });
  12790. /**
  12791. * Gets value as pixel
  12792. * @param host defines the root host
  12793. * @param refValue defines the reference value for percentages
  12794. * @returns the value as pixel
  12795. */
  12796. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12797. if (this.isPixel) {
  12798. return this.getValue(host);
  12799. }
  12800. return this.getValue(host) * refValue;
  12801. };
  12802. /**
  12803. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12804. * @param value defines the value to store
  12805. * @param unit defines the unit to store
  12806. * @returns the current ValueAndUnit
  12807. */
  12808. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12809. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12810. this._value = value;
  12811. this.unit = unit;
  12812. return this;
  12813. };
  12814. /**
  12815. * Gets the value accordingly to its unit
  12816. * @param host defines the root host
  12817. * @returns the value
  12818. */
  12819. ValueAndUnit.prototype.getValue = function (host) {
  12820. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12821. var width = 0;
  12822. var height = 0;
  12823. if (host.idealWidth) {
  12824. width = (this._value * host.getSize().width) / host.idealWidth;
  12825. }
  12826. if (host.idealHeight) {
  12827. height = (this._value * host.getSize().height) / host.idealHeight;
  12828. }
  12829. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12830. return window.innerWidth < window.innerHeight ? width : height;
  12831. }
  12832. if (host.idealWidth) { // horizontal
  12833. return width;
  12834. }
  12835. if (host.idealHeight) { // vertical
  12836. return height;
  12837. }
  12838. }
  12839. return this._value;
  12840. };
  12841. /**
  12842. * Gets a string representation of the value
  12843. * @param host defines the root host
  12844. * @param decimals defines an optional number of decimals to display
  12845. * @returns a string
  12846. */
  12847. ValueAndUnit.prototype.toString = function (host, decimals) {
  12848. switch (this.unit) {
  12849. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12850. var percentage = this.getValue(host) * 100;
  12851. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12852. case ValueAndUnit.UNITMODE_PIXEL:
  12853. var pixels = this.getValue(host);
  12854. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12855. }
  12856. return this.unit.toString();
  12857. };
  12858. /**
  12859. * Store a value parsed from a string
  12860. * @param source defines the source string
  12861. * @returns true if the value was successfully parsed
  12862. */
  12863. ValueAndUnit.prototype.fromString = function (source) {
  12864. var match = ValueAndUnit._Regex.exec(source.toString());
  12865. if (!match || match.length === 0) {
  12866. return false;
  12867. }
  12868. var sourceValue = parseFloat(match[1]);
  12869. var sourceUnit = this._originalUnit;
  12870. if (!this.negativeValueAllowed) {
  12871. if (sourceValue < 0) {
  12872. sourceValue = 0;
  12873. }
  12874. }
  12875. if (match.length === 4) {
  12876. switch (match[3]) {
  12877. case "px":
  12878. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12879. break;
  12880. case "%":
  12881. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12882. sourceValue /= 100.0;
  12883. break;
  12884. }
  12885. }
  12886. if (sourceValue === this._value && sourceUnit === this.unit) {
  12887. return false;
  12888. }
  12889. this._value = sourceValue;
  12890. this.unit = sourceUnit;
  12891. return true;
  12892. };
  12893. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12894. /** UNITMODE_PERCENTAGE */
  12895. get: function () {
  12896. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12897. },
  12898. enumerable: true,
  12899. configurable: true
  12900. });
  12901. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12902. /** UNITMODE_PIXEL */
  12903. get: function () {
  12904. return ValueAndUnit._UNITMODE_PIXEL;
  12905. },
  12906. enumerable: true,
  12907. configurable: true
  12908. });
  12909. // Static
  12910. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12911. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12912. ValueAndUnit._UNITMODE_PIXEL = 1;
  12913. return ValueAndUnit;
  12914. }());
  12915. /***/ }),
  12916. /***/ "./2D/xmlLoader.ts":
  12917. /*!*************************!*\
  12918. !*** ./2D/xmlLoader.ts ***!
  12919. \*************************/
  12920. /*! exports provided: XmlLoader */
  12921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12922. "use strict";
  12923. __webpack_require__.r(__webpack_exports__);
  12924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12925. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  12926. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12927. /**
  12928. * Class used to load GUI via XML.
  12929. */
  12930. var XmlLoader = /** @class */ (function () {
  12931. /**
  12932. * Create a new xml loader
  12933. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12934. */
  12935. function XmlLoader(parentClass) {
  12936. if (parentClass === void 0) { parentClass = null; }
  12937. this._nodes = {};
  12938. this._nodeTypes = {
  12939. element: 1,
  12940. attribute: 2,
  12941. text: 3
  12942. };
  12943. this._isLoaded = false;
  12944. this._objectAttributes = {
  12945. "textHorizontalAlignment": 1,
  12946. "textVerticalAlignment": 2,
  12947. "horizontalAlignment": 3,
  12948. "verticalAlignment": 4,
  12949. "stretch": 5,
  12950. };
  12951. if (parentClass) {
  12952. this._parentClass = parentClass;
  12953. }
  12954. }
  12955. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12956. var element = window;
  12957. if (this._parentClass) {
  12958. element = this._parentClass;
  12959. }
  12960. var value = attributeValue;
  12961. value = value.split(".");
  12962. for (var i = 0; i < value.length; i++) {
  12963. element = element[value[i]];
  12964. }
  12965. return element;
  12966. };
  12967. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12968. var attribute = attributeName.split(".");
  12969. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12970. return className[attribute[1]];
  12971. };
  12972. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12973. if (linkParent === void 0) { linkParent = true; }
  12974. try {
  12975. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12976. var guiNode = new className();
  12977. if (parent && linkParent) {
  12978. parent.addControl(guiNode);
  12979. }
  12980. for (var i = 0; i < node.attributes.length; i++) {
  12981. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12982. continue;
  12983. }
  12984. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12985. var element = this._getChainElement(node.attributes[i].value);
  12986. guiNode[node.attributes[i].name].add(element);
  12987. continue;
  12988. }
  12989. else if (node.attributes[i].name == "linkWithMesh") {
  12990. if (this._parentClass) {
  12991. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12992. }
  12993. else {
  12994. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12995. }
  12996. }
  12997. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12998. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12999. guiNode[node.attributes[i].name] = element;
  13000. }
  13001. else if (!this._objectAttributes[node.attributes[i].name]) {
  13002. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13003. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13004. }
  13005. else {
  13006. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13007. }
  13008. }
  13009. else {
  13010. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13011. }
  13012. }
  13013. if (!node.attributes.getNamedItem("id")) {
  13014. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13015. return guiNode;
  13016. }
  13017. var id = node.attributes.getNamedItem("id").value;
  13018. if (id.startsWith("{{") && id.endsWith("}}")) {
  13019. id = this._getChainElement(id.substring(2, id.length - 2));
  13020. }
  13021. if (!this._nodes[id]) {
  13022. this._nodes[id] = guiNode;
  13023. }
  13024. else {
  13025. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13026. }
  13027. return guiNode;
  13028. }
  13029. catch (e) {
  13030. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13031. }
  13032. };
  13033. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13034. var width;
  13035. var height;
  13036. var columns;
  13037. var rows = node.children;
  13038. var cells;
  13039. var isPixel = false;
  13040. var cellNode;
  13041. var rowNumber = -1;
  13042. var columnNumber = -1;
  13043. var totalColumnsNumber = 0;
  13044. for (var i = 0; i < rows.length; i++) {
  13045. if (rows[i].nodeType != this._nodeTypes.element) {
  13046. continue;
  13047. }
  13048. if (rows[i].nodeName != "Row") {
  13049. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13050. }
  13051. rowNumber += 1;
  13052. columns = rows[i].children;
  13053. if (!rows[i].attributes.getNamedItem("height")) {
  13054. throw "XmlLoader Exception : Height must be defined for grid rows";
  13055. }
  13056. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13057. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13058. guiNode.addRowDefinition(height, isPixel);
  13059. for (var j = 0; j < columns.length; j++) {
  13060. if (columns[j].nodeType != this._nodeTypes.element) {
  13061. continue;
  13062. }
  13063. if (columns[j].nodeName != "Column") {
  13064. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13065. }
  13066. columnNumber += 1;
  13067. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13068. throw "XmlLoader Exception : In the Grid element, the number of columns is defined in the first row, do not add more columns in the subsequent rows.";
  13069. }
  13070. if (rowNumber == 0) {
  13071. if (!columns[j].attributes.getNamedItem("width")) {
  13072. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13073. }
  13074. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13075. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13076. guiNode.addColumnDefinition(width, isPixel);
  13077. }
  13078. cells = columns[j].children;
  13079. for (var k = 0; k < cells.length; k++) {
  13080. if (cells[k].nodeType != this._nodeTypes.element) {
  13081. continue;
  13082. }
  13083. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13084. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13085. if (cells[k].firstChild) {
  13086. this._parseXml(cells[k].firstChild, cellNode);
  13087. }
  13088. }
  13089. }
  13090. if (rowNumber == 0) {
  13091. totalColumnsNumber = columnNumber;
  13092. }
  13093. columnNumber = -1;
  13094. }
  13095. if (node.nextSibling) {
  13096. this._parseXml(node.nextSibling, parent);
  13097. }
  13098. };
  13099. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13100. if (node.firstChild) {
  13101. this._parseXml(node.firstChild, guiNode);
  13102. }
  13103. if (node.nextSibling) {
  13104. this._parseXml(node.nextSibling, parent);
  13105. }
  13106. };
  13107. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13108. if (this._parentClass) {
  13109. this._parentClass[variable] = source[iterator];
  13110. }
  13111. else {
  13112. window[variable] = source[iterator];
  13113. }
  13114. if (node.firstChild) {
  13115. this._parseXml(node.firstChild, guiNode, true);
  13116. }
  13117. };
  13118. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13119. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13120. if (!dataSource.includes(" in ")) {
  13121. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13122. }
  13123. else {
  13124. var isArray = true;
  13125. var splittedSource = dataSource.split(" in ");
  13126. if (splittedSource.length < 2) {
  13127. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13128. }
  13129. var source = splittedSource[1];
  13130. if (source.startsWith("{") && source.endsWith("}")) {
  13131. isArray = false;
  13132. }
  13133. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13134. source = source.substring(1, source.length - 1);
  13135. }
  13136. if (this._parentClass) {
  13137. source = this._parentClass[source];
  13138. }
  13139. else {
  13140. source = window[source];
  13141. }
  13142. if (isArray) {
  13143. for (var i = 0; i < source.length; i++) {
  13144. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13145. }
  13146. }
  13147. else {
  13148. for (var i in source) {
  13149. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13150. }
  13151. }
  13152. if (node.nextSibling) {
  13153. this._parseXml(node.nextSibling, parent);
  13154. }
  13155. }
  13156. };
  13157. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13158. if (generated === void 0) { generated = false; }
  13159. if (node.nodeType != this._nodeTypes.element) {
  13160. if (node.nextSibling) {
  13161. this._parseXml(node.nextSibling, parent, generated);
  13162. }
  13163. return;
  13164. }
  13165. if (generated) {
  13166. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13167. }
  13168. var guiNode = this._createGuiElement(node, parent);
  13169. if (node.nodeName == "Grid") {
  13170. this._parseGrid(node, guiNode, parent);
  13171. }
  13172. else if (!node.attributes.getNamedItem("dataSource")) {
  13173. this._parseElement(node, guiNode, parent);
  13174. }
  13175. else {
  13176. this._parseElementsFromSource(node, guiNode, parent);
  13177. }
  13178. };
  13179. /**
  13180. * Gets if the loading has finished.
  13181. * @returns whether the loading has finished or not
  13182. */
  13183. XmlLoader.prototype.isLoaded = function () {
  13184. return this._isLoaded;
  13185. };
  13186. /**
  13187. * Gets a loaded node / control by id.
  13188. * @param id the Controls id set in the xml
  13189. * @returns element of type Control
  13190. */
  13191. XmlLoader.prototype.getNodeById = function (id) {
  13192. return this._nodes[id];
  13193. };
  13194. /**
  13195. * Gets all loaded nodes / controls
  13196. * @returns Array of controls
  13197. */
  13198. XmlLoader.prototype.getNodes = function () {
  13199. return this._nodes;
  13200. };
  13201. /**
  13202. * Initiates the xml layout loading
  13203. * @param xmlFile defines the xml layout to load
  13204. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13205. * @param callback defines the callback called on layout load.
  13206. */
  13207. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13208. var xhttp = new XMLHttpRequest();
  13209. xhttp.onreadystatechange = function () {
  13210. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13211. if (!xhttp.responseXML) {
  13212. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13213. }
  13214. var xmlDoc = xhttp.responseXML.documentElement;
  13215. this._parseXml(xmlDoc.firstChild, rootNode);
  13216. this._isLoaded = true;
  13217. if (callback) {
  13218. callback();
  13219. }
  13220. }
  13221. }.bind(this);
  13222. xhttp.open("GET", xmlFile, true);
  13223. xhttp.send();
  13224. };
  13225. return XmlLoader;
  13226. }());
  13227. /***/ }),
  13228. /***/ "./3D/controls/abstractButton3D.ts":
  13229. /*!*****************************************!*\
  13230. !*** ./3D/controls/abstractButton3D.ts ***!
  13231. \*****************************************/
  13232. /*! exports provided: AbstractButton3D */
  13233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13234. "use strict";
  13235. __webpack_require__.r(__webpack_exports__);
  13236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13237. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13238. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13239. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13240. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13241. /**
  13242. * Class used as a root to all buttons
  13243. */
  13244. var AbstractButton3D = /** @class */ (function (_super) {
  13245. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13246. /**
  13247. * Creates a new button
  13248. * @param name defines the control name
  13249. */
  13250. function AbstractButton3D(name) {
  13251. return _super.call(this, name) || this;
  13252. }
  13253. AbstractButton3D.prototype._getTypeName = function () {
  13254. return "AbstractButton3D";
  13255. };
  13256. // Mesh association
  13257. AbstractButton3D.prototype._createNode = function (scene) {
  13258. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13259. };
  13260. return AbstractButton3D;
  13261. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13262. /***/ }),
  13263. /***/ "./3D/controls/button3D.ts":
  13264. /*!*********************************!*\
  13265. !*** ./3D/controls/button3D.ts ***!
  13266. \*********************************/
  13267. /*! exports provided: Button3D */
  13268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13269. "use strict";
  13270. __webpack_require__.r(__webpack_exports__);
  13271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13272. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13273. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13274. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13275. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13276. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13277. /**
  13278. * Class used to create a button in 3D
  13279. */
  13280. var Button3D = /** @class */ (function (_super) {
  13281. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13282. /**
  13283. * Creates a new button
  13284. * @param name defines the control name
  13285. */
  13286. function Button3D(name) {
  13287. var _this = _super.call(this, name) || this;
  13288. _this._contentResolution = 512;
  13289. _this._contentScaleRatio = 2;
  13290. // Default animations
  13291. _this.pointerEnterAnimation = function () {
  13292. if (!_this.mesh) {
  13293. return;
  13294. }
  13295. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13296. };
  13297. _this.pointerOutAnimation = function () {
  13298. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13299. };
  13300. _this.pointerDownAnimation = function () {
  13301. if (!_this.mesh) {
  13302. return;
  13303. }
  13304. _this.mesh.scaling.scaleInPlace(0.95);
  13305. };
  13306. _this.pointerUpAnimation = function () {
  13307. if (!_this.mesh) {
  13308. return;
  13309. }
  13310. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13311. };
  13312. return _this;
  13313. }
  13314. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13315. /**
  13316. * Gets or sets the texture resolution used to render content (512 by default)
  13317. */
  13318. get: function () {
  13319. return this._contentResolution;
  13320. },
  13321. set: function (value) {
  13322. if (this._contentResolution === value) {
  13323. return;
  13324. }
  13325. this._contentResolution = value;
  13326. this._resetContent();
  13327. },
  13328. enumerable: true,
  13329. configurable: true
  13330. });
  13331. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13332. /**
  13333. * Gets or sets the texture scale ratio used to render content (2 by default)
  13334. */
  13335. get: function () {
  13336. return this._contentScaleRatio;
  13337. },
  13338. set: function (value) {
  13339. if (this._contentScaleRatio === value) {
  13340. return;
  13341. }
  13342. this._contentScaleRatio = value;
  13343. this._resetContent();
  13344. },
  13345. enumerable: true,
  13346. configurable: true
  13347. });
  13348. Button3D.prototype._disposeFacadeTexture = function () {
  13349. if (this._facadeTexture) {
  13350. this._facadeTexture.dispose();
  13351. this._facadeTexture = null;
  13352. }
  13353. };
  13354. Button3D.prototype._resetContent = function () {
  13355. this._disposeFacadeTexture();
  13356. this.content = this._content;
  13357. };
  13358. Object.defineProperty(Button3D.prototype, "content", {
  13359. /**
  13360. * Gets or sets the GUI 2D content used to display the button's facade
  13361. */
  13362. get: function () {
  13363. return this._content;
  13364. },
  13365. set: function (value) {
  13366. this._content = value;
  13367. if (!this._host || !this._host.utilityLayer) {
  13368. return;
  13369. }
  13370. if (!this._facadeTexture) {
  13371. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13372. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13373. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13374. this._facadeTexture.premulAlpha = true;
  13375. }
  13376. else {
  13377. this._facadeTexture.rootContainer.clearControls();
  13378. }
  13379. this._facadeTexture.addControl(value);
  13380. this._applyFacade(this._facadeTexture);
  13381. },
  13382. enumerable: true,
  13383. configurable: true
  13384. });
  13385. /**
  13386. * Apply the facade texture (created from the content property).
  13387. * This function can be overloaded by child classes
  13388. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13389. */
  13390. Button3D.prototype._applyFacade = function (facadeTexture) {
  13391. this._currentMaterial.emissiveTexture = facadeTexture;
  13392. };
  13393. Button3D.prototype._getTypeName = function () {
  13394. return "Button3D";
  13395. };
  13396. // Mesh association
  13397. Button3D.prototype._createNode = function (scene) {
  13398. var faceUV = new Array(6);
  13399. for (var i = 0; i < 6; i++) {
  13400. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13401. }
  13402. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13403. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13404. width: 1.0,
  13405. height: 1.0,
  13406. depth: 0.08,
  13407. faceUV: faceUV
  13408. }, scene);
  13409. return mesh;
  13410. };
  13411. Button3D.prototype._affectMaterial = function (mesh) {
  13412. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13413. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13414. mesh.material = material;
  13415. this._currentMaterial = material;
  13416. this._resetContent();
  13417. };
  13418. /**
  13419. * Releases all associated resources
  13420. */
  13421. Button3D.prototype.dispose = function () {
  13422. _super.prototype.dispose.call(this);
  13423. this._disposeFacadeTexture();
  13424. if (this._currentMaterial) {
  13425. this._currentMaterial.dispose();
  13426. }
  13427. };
  13428. return Button3D;
  13429. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13430. /***/ }),
  13431. /***/ "./3D/controls/container3D.ts":
  13432. /*!************************************!*\
  13433. !*** ./3D/controls/container3D.ts ***!
  13434. \************************************/
  13435. /*! exports provided: Container3D */
  13436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13437. "use strict";
  13438. __webpack_require__.r(__webpack_exports__);
  13439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13441. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13442. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13443. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13444. /**
  13445. * Class used to create containers for controls
  13446. */
  13447. var Container3D = /** @class */ (function (_super) {
  13448. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13449. /**
  13450. * Creates a new container
  13451. * @param name defines the container name
  13452. */
  13453. function Container3D(name) {
  13454. var _this = _super.call(this, name) || this;
  13455. _this._blockLayout = false;
  13456. /**
  13457. * Gets the list of child controls
  13458. */
  13459. _this._children = new Array();
  13460. return _this;
  13461. }
  13462. Object.defineProperty(Container3D.prototype, "children", {
  13463. /**
  13464. * Gets the list of child controls
  13465. */
  13466. get: function () {
  13467. return this._children;
  13468. },
  13469. enumerable: true,
  13470. configurable: true
  13471. });
  13472. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13473. /**
  13474. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13475. * This is helpful to optimize layout operation when adding multiple children in a row
  13476. */
  13477. get: function () {
  13478. return this._blockLayout;
  13479. },
  13480. set: function (value) {
  13481. if (this._blockLayout === value) {
  13482. return;
  13483. }
  13484. this._blockLayout = value;
  13485. if (!this._blockLayout) {
  13486. this._arrangeChildren();
  13487. }
  13488. },
  13489. enumerable: true,
  13490. configurable: true
  13491. });
  13492. /**
  13493. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13494. * @returns the current container
  13495. */
  13496. Container3D.prototype.updateLayout = function () {
  13497. this._arrangeChildren();
  13498. return this;
  13499. };
  13500. /**
  13501. * Gets a boolean indicating if the given control is in the children of this control
  13502. * @param control defines the control to check
  13503. * @returns true if the control is in the child list
  13504. */
  13505. Container3D.prototype.containsControl = function (control) {
  13506. return this._children.indexOf(control) !== -1;
  13507. };
  13508. /**
  13509. * Adds a control to the children of this control
  13510. * @param control defines the control to add
  13511. * @returns the current container
  13512. */
  13513. Container3D.prototype.addControl = function (control) {
  13514. var index = this._children.indexOf(control);
  13515. if (index !== -1) {
  13516. return this;
  13517. }
  13518. control.parent = this;
  13519. control._host = this._host;
  13520. this._children.push(control);
  13521. if (this._host.utilityLayer) {
  13522. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13523. if (control.node) {
  13524. control.node.parent = this.node;
  13525. }
  13526. if (!this.blockLayout) {
  13527. this._arrangeChildren();
  13528. }
  13529. }
  13530. return this;
  13531. };
  13532. /**
  13533. * This function will be called everytime a new control is added
  13534. */
  13535. Container3D.prototype._arrangeChildren = function () {
  13536. };
  13537. Container3D.prototype._createNode = function (scene) {
  13538. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13539. };
  13540. /**
  13541. * Removes a control from the children of this control
  13542. * @param control defines the control to remove
  13543. * @returns the current container
  13544. */
  13545. Container3D.prototype.removeControl = function (control) {
  13546. var index = this._children.indexOf(control);
  13547. if (index !== -1) {
  13548. this._children.splice(index, 1);
  13549. control.parent = null;
  13550. control._disposeNode();
  13551. }
  13552. return this;
  13553. };
  13554. Container3D.prototype._getTypeName = function () {
  13555. return "Container3D";
  13556. };
  13557. /**
  13558. * Releases all associated resources
  13559. */
  13560. Container3D.prototype.dispose = function () {
  13561. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13562. var control = _a[_i];
  13563. control.dispose();
  13564. }
  13565. this._children = [];
  13566. _super.prototype.dispose.call(this);
  13567. };
  13568. /** Control rotation will remain unchanged */
  13569. Container3D.UNSET_ORIENTATION = 0;
  13570. /** Control will rotate to make it look at sphere central axis */
  13571. Container3D.FACEORIGIN_ORIENTATION = 1;
  13572. /** Control will rotate to make it look back at sphere central axis */
  13573. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13574. /** Control will rotate to look at z axis (0, 0, 1) */
  13575. Container3D.FACEFORWARD_ORIENTATION = 3;
  13576. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13577. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13578. return Container3D;
  13579. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13580. /***/ }),
  13581. /***/ "./3D/controls/control3D.ts":
  13582. /*!**********************************!*\
  13583. !*** ./3D/controls/control3D.ts ***!
  13584. \**********************************/
  13585. /*! exports provided: Control3D */
  13586. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13587. "use strict";
  13588. __webpack_require__.r(__webpack_exports__);
  13589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13590. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  13591. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13592. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13593. /**
  13594. * Class used as base class for controls
  13595. */
  13596. var Control3D = /** @class */ (function () {
  13597. /**
  13598. * Creates a new control
  13599. * @param name defines the control name
  13600. */
  13601. function Control3D(
  13602. /** Defines the control name */
  13603. name) {
  13604. this.name = name;
  13605. this._downCount = 0;
  13606. this._enterCount = -1;
  13607. this._downPointerIds = {};
  13608. this._isVisible = true;
  13609. /**
  13610. * An event triggered when the pointer move over the control
  13611. */
  13612. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13613. /**
  13614. * An event triggered when the pointer move out of the control
  13615. */
  13616. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13617. /**
  13618. * An event triggered when the pointer taps the control
  13619. */
  13620. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13621. /**
  13622. * An event triggered when pointer is up
  13623. */
  13624. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13625. /**
  13626. * An event triggered when a control is clicked on (with a mouse)
  13627. */
  13628. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13629. /**
  13630. * An event triggered when pointer enters the control
  13631. */
  13632. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13633. // Behaviors
  13634. this._behaviors = new Array();
  13635. }
  13636. Object.defineProperty(Control3D.prototype, "position", {
  13637. /** Gets or sets the control position in world space */
  13638. get: function () {
  13639. if (!this._node) {
  13640. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13641. }
  13642. return this._node.position;
  13643. },
  13644. set: function (value) {
  13645. if (!this._node) {
  13646. return;
  13647. }
  13648. this._node.position = value;
  13649. },
  13650. enumerable: true,
  13651. configurable: true
  13652. });
  13653. Object.defineProperty(Control3D.prototype, "scaling", {
  13654. /** Gets or sets the control scaling in world space */
  13655. get: function () {
  13656. if (!this._node) {
  13657. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13658. }
  13659. return this._node.scaling;
  13660. },
  13661. set: function (value) {
  13662. if (!this._node) {
  13663. return;
  13664. }
  13665. this._node.scaling = value;
  13666. },
  13667. enumerable: true,
  13668. configurable: true
  13669. });
  13670. Object.defineProperty(Control3D.prototype, "behaviors", {
  13671. /**
  13672. * Gets the list of attached behaviors
  13673. * @see http://doc.babylonjs.com/features/behaviour
  13674. */
  13675. get: function () {
  13676. return this._behaviors;
  13677. },
  13678. enumerable: true,
  13679. configurable: true
  13680. });
  13681. /**
  13682. * Attach a behavior to the control
  13683. * @see http://doc.babylonjs.com/features/behaviour
  13684. * @param behavior defines the behavior to attach
  13685. * @returns the current control
  13686. */
  13687. Control3D.prototype.addBehavior = function (behavior) {
  13688. var _this = this;
  13689. var index = this._behaviors.indexOf(behavior);
  13690. if (index !== -1) {
  13691. return this;
  13692. }
  13693. behavior.init();
  13694. var scene = this._host.scene;
  13695. if (scene.isLoading) {
  13696. // We defer the attach when the scene will be loaded
  13697. scene.onDataLoadedObservable.addOnce(function () {
  13698. behavior.attach(_this);
  13699. });
  13700. }
  13701. else {
  13702. behavior.attach(this);
  13703. }
  13704. this._behaviors.push(behavior);
  13705. return this;
  13706. };
  13707. /**
  13708. * Remove an attached behavior
  13709. * @see http://doc.babylonjs.com/features/behaviour
  13710. * @param behavior defines the behavior to attach
  13711. * @returns the current control
  13712. */
  13713. Control3D.prototype.removeBehavior = function (behavior) {
  13714. var index = this._behaviors.indexOf(behavior);
  13715. if (index === -1) {
  13716. return this;
  13717. }
  13718. this._behaviors[index].detach();
  13719. this._behaviors.splice(index, 1);
  13720. return this;
  13721. };
  13722. /**
  13723. * Gets an attached behavior by name
  13724. * @param name defines the name of the behavior to look for
  13725. * @see http://doc.babylonjs.com/features/behaviour
  13726. * @returns null if behavior was not found else the requested behavior
  13727. */
  13728. Control3D.prototype.getBehaviorByName = function (name) {
  13729. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13730. var behavior = _a[_i];
  13731. if (behavior.name === name) {
  13732. return behavior;
  13733. }
  13734. }
  13735. return null;
  13736. };
  13737. Object.defineProperty(Control3D.prototype, "isVisible", {
  13738. /** Gets or sets a boolean indicating if the control is visible */
  13739. get: function () {
  13740. return this._isVisible;
  13741. },
  13742. set: function (value) {
  13743. if (this._isVisible === value) {
  13744. return;
  13745. }
  13746. this._isVisible = value;
  13747. var mesh = this.mesh;
  13748. if (mesh) {
  13749. mesh.setEnabled(value);
  13750. }
  13751. },
  13752. enumerable: true,
  13753. configurable: true
  13754. });
  13755. Object.defineProperty(Control3D.prototype, "typeName", {
  13756. /**
  13757. * Gets a string representing the class name
  13758. */
  13759. get: function () {
  13760. return this._getTypeName();
  13761. },
  13762. enumerable: true,
  13763. configurable: true
  13764. });
  13765. /**
  13766. * Get the current class name of the control.
  13767. * @returns current class name
  13768. */
  13769. Control3D.prototype.getClassName = function () {
  13770. return this._getTypeName();
  13771. };
  13772. Control3D.prototype._getTypeName = function () {
  13773. return "Control3D";
  13774. };
  13775. Object.defineProperty(Control3D.prototype, "node", {
  13776. /**
  13777. * Gets the transform node used by this control
  13778. */
  13779. get: function () {
  13780. return this._node;
  13781. },
  13782. enumerable: true,
  13783. configurable: true
  13784. });
  13785. Object.defineProperty(Control3D.prototype, "mesh", {
  13786. /**
  13787. * Gets the mesh used to render this control
  13788. */
  13789. get: function () {
  13790. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13791. return this._node;
  13792. }
  13793. return null;
  13794. },
  13795. enumerable: true,
  13796. configurable: true
  13797. });
  13798. /**
  13799. * Link the control as child of the given node
  13800. * @param node defines the node to link to. Use null to unlink the control
  13801. * @returns the current control
  13802. */
  13803. Control3D.prototype.linkToTransformNode = function (node) {
  13804. if (this._node) {
  13805. this._node.parent = node;
  13806. }
  13807. return this;
  13808. };
  13809. /** @hidden **/
  13810. Control3D.prototype._prepareNode = function (scene) {
  13811. if (!this._node) {
  13812. this._node = this._createNode(scene);
  13813. if (!this.node) {
  13814. return;
  13815. }
  13816. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13817. this._node.position = this.position;
  13818. this._node.scaling = this.scaling;
  13819. var mesh = this.mesh;
  13820. if (mesh) {
  13821. mesh.isPickable = true;
  13822. this._affectMaterial(mesh);
  13823. }
  13824. }
  13825. };
  13826. /**
  13827. * Node creation.
  13828. * Can be overriden by children
  13829. * @param scene defines the scene where the node must be attached
  13830. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13831. */
  13832. Control3D.prototype._createNode = function (scene) {
  13833. // Do nothing by default
  13834. return null;
  13835. };
  13836. /**
  13837. * Affect a material to the given mesh
  13838. * @param mesh defines the mesh which will represent the control
  13839. */
  13840. Control3D.prototype._affectMaterial = function (mesh) {
  13841. mesh.material = null;
  13842. };
  13843. // Pointers
  13844. /** @hidden */
  13845. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13846. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13847. };
  13848. /** @hidden */
  13849. Control3D.prototype._onPointerEnter = function (target) {
  13850. if (this._enterCount > 0) {
  13851. return false;
  13852. }
  13853. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13854. this._enterCount = 0;
  13855. }
  13856. this._enterCount++;
  13857. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13858. if (this.pointerEnterAnimation) {
  13859. this.pointerEnterAnimation();
  13860. }
  13861. return true;
  13862. };
  13863. /** @hidden */
  13864. Control3D.prototype._onPointerOut = function (target) {
  13865. this._enterCount = 0;
  13866. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13867. if (this.pointerOutAnimation) {
  13868. this.pointerOutAnimation();
  13869. }
  13870. };
  13871. /** @hidden */
  13872. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13873. if (this._downCount !== 0) {
  13874. this._downCount++;
  13875. return false;
  13876. }
  13877. this._downCount++;
  13878. this._downPointerIds[pointerId] = true;
  13879. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13880. if (this.pointerDownAnimation) {
  13881. this.pointerDownAnimation();
  13882. }
  13883. return true;
  13884. };
  13885. /** @hidden */
  13886. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13887. this._downCount--;
  13888. delete this._downPointerIds[pointerId];
  13889. if (this._downCount < 0) {
  13890. // Handle if forcePointerUp was called prior to this
  13891. this._downCount = 0;
  13892. return;
  13893. }
  13894. if (this._downCount == 0) {
  13895. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13896. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13897. }
  13898. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13899. if (this.pointerUpAnimation) {
  13900. this.pointerUpAnimation();
  13901. }
  13902. }
  13903. };
  13904. /** @hidden */
  13905. Control3D.prototype.forcePointerUp = function (pointerId) {
  13906. if (pointerId === void 0) { pointerId = null; }
  13907. if (pointerId !== null) {
  13908. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13909. }
  13910. else {
  13911. for (var key in this._downPointerIds) {
  13912. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13913. }
  13914. if (this._downCount > 0) {
  13915. this._downCount = 1;
  13916. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13917. }
  13918. }
  13919. };
  13920. /** @hidden */
  13921. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13922. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13923. this._onPointerMove(this, pickedPoint);
  13924. var previousControlOver = this._host._lastControlOver[pointerId];
  13925. if (previousControlOver && previousControlOver !== this) {
  13926. previousControlOver._onPointerOut(this);
  13927. }
  13928. if (previousControlOver !== this) {
  13929. this._onPointerEnter(this);
  13930. }
  13931. this._host._lastControlOver[pointerId] = this;
  13932. return true;
  13933. }
  13934. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13935. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13936. this._host._lastControlDown[pointerId] = this;
  13937. this._host._lastPickedControl = this;
  13938. return true;
  13939. }
  13940. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13941. if (this._host._lastControlDown[pointerId]) {
  13942. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13943. }
  13944. delete this._host._lastControlDown[pointerId];
  13945. return true;
  13946. }
  13947. return false;
  13948. };
  13949. /** @hidden */
  13950. Control3D.prototype._disposeNode = function () {
  13951. if (this._node) {
  13952. this._node.dispose();
  13953. this._node = null;
  13954. }
  13955. };
  13956. /**
  13957. * Releases all associated resources
  13958. */
  13959. Control3D.prototype.dispose = function () {
  13960. this.onPointerDownObservable.clear();
  13961. this.onPointerEnterObservable.clear();
  13962. this.onPointerMoveObservable.clear();
  13963. this.onPointerOutObservable.clear();
  13964. this.onPointerUpObservable.clear();
  13965. this.onPointerClickObservable.clear();
  13966. this._disposeNode();
  13967. // Behaviors
  13968. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13969. var behavior = _a[_i];
  13970. behavior.detach();
  13971. }
  13972. };
  13973. return Control3D;
  13974. }());
  13975. /***/ }),
  13976. /***/ "./3D/controls/cylinderPanel.ts":
  13977. /*!**************************************!*\
  13978. !*** ./3D/controls/cylinderPanel.ts ***!
  13979. \**************************************/
  13980. /*! exports provided: CylinderPanel */
  13981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13982. "use strict";
  13983. __webpack_require__.r(__webpack_exports__);
  13984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13986. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13987. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13988. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13989. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13990. /**
  13991. * Class used to create a container panel deployed on the surface of a cylinder
  13992. */
  13993. var CylinderPanel = /** @class */ (function (_super) {
  13994. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  13995. function CylinderPanel() {
  13996. var _this = _super !== null && _super.apply(this, arguments) || this;
  13997. _this._radius = 5.0;
  13998. return _this;
  13999. }
  14000. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14001. /**
  14002. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14003. */
  14004. get: function () {
  14005. return this._radius;
  14006. },
  14007. set: function (value) {
  14008. var _this = this;
  14009. if (this._radius === value) {
  14010. return;
  14011. }
  14012. this._radius = value;
  14013. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14014. _this._arrangeChildren();
  14015. });
  14016. },
  14017. enumerable: true,
  14018. configurable: true
  14019. });
  14020. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14021. var mesh = control.mesh;
  14022. if (!mesh) {
  14023. return;
  14024. }
  14025. var newPos = this._cylindricalMapping(nodePosition);
  14026. control.position = newPos;
  14027. switch (this.orientation) {
  14028. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14029. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14030. break;
  14031. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14032. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14033. break;
  14034. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14035. break;
  14036. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14037. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14038. break;
  14039. }
  14040. };
  14041. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14042. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14043. var yAngle = (source.x / this._radius);
  14044. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14045. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14046. };
  14047. return CylinderPanel;
  14048. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14049. /***/ }),
  14050. /***/ "./3D/controls/holographicButton.ts":
  14051. /*!******************************************!*\
  14052. !*** ./3D/controls/holographicButton.ts ***!
  14053. \******************************************/
  14054. /*! exports provided: HolographicButton */
  14055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14056. "use strict";
  14057. __webpack_require__.r(__webpack_exports__);
  14058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14059. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14060. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14061. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14062. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14063. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14064. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14065. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14066. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14067. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14068. /**
  14069. * Class used to create a holographic button in 3D
  14070. */
  14071. var HolographicButton = /** @class */ (function (_super) {
  14072. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14073. /**
  14074. * Creates a new button
  14075. * @param name defines the control name
  14076. */
  14077. function HolographicButton(name, shareMaterials) {
  14078. if (shareMaterials === void 0) { shareMaterials = true; }
  14079. var _this = _super.call(this, name) || this;
  14080. _this._shareMaterials = true;
  14081. _this._shareMaterials = shareMaterials;
  14082. // Default animations
  14083. _this.pointerEnterAnimation = function () {
  14084. if (!_this.mesh) {
  14085. return;
  14086. }
  14087. _this._frontPlate.setEnabled(true);
  14088. };
  14089. _this.pointerOutAnimation = function () {
  14090. if (!_this.mesh) {
  14091. return;
  14092. }
  14093. _this._frontPlate.setEnabled(false);
  14094. };
  14095. return _this;
  14096. }
  14097. HolographicButton.prototype._disposeTooltip = function () {
  14098. this._tooltipFade = null;
  14099. if (this._tooltipTextBlock) {
  14100. this._tooltipTextBlock.dispose();
  14101. }
  14102. if (this._tooltipTexture) {
  14103. this._tooltipTexture.dispose();
  14104. }
  14105. if (this._tooltipMesh) {
  14106. this._tooltipMesh.dispose();
  14107. }
  14108. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14109. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14110. };
  14111. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14112. get: function () {
  14113. if (this._tooltipTextBlock) {
  14114. return this._tooltipTextBlock.text;
  14115. }
  14116. return null;
  14117. },
  14118. /**
  14119. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14120. */
  14121. set: function (text) {
  14122. var _this = this;
  14123. if (!text) {
  14124. this._disposeTooltip();
  14125. return;
  14126. }
  14127. if (!this._tooltipFade) {
  14128. // Create tooltip with mesh and text
  14129. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14130. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14131. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14132. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14133. tooltipBackground.material = mat;
  14134. tooltipBackground.isPickable = false;
  14135. this._tooltipMesh.addChild(tooltipBackground);
  14136. tooltipBackground.position.z = 0.05;
  14137. this._tooltipMesh.scaling.y = 1 / 3;
  14138. this._tooltipMesh.position.y = 0.7;
  14139. this._tooltipMesh.position.z = -0.15;
  14140. this._tooltipMesh.isPickable = false;
  14141. this._tooltipMesh.parent = this._backPlate;
  14142. // Create text texture for the tooltip
  14143. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14144. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14145. this._tooltipTextBlock.scaleY = 3;
  14146. this._tooltipTextBlock.color = "white";
  14147. this._tooltipTextBlock.fontSize = 130;
  14148. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14149. // Add hover action to tooltip
  14150. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14151. this._tooltipFade.delay = 500;
  14152. this._tooltipMesh.addBehavior(this._tooltipFade);
  14153. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14154. if (_this._tooltipFade) {
  14155. _this._tooltipFade.fadeIn(true);
  14156. }
  14157. });
  14158. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14159. if (_this._tooltipFade) {
  14160. _this._tooltipFade.fadeIn(false);
  14161. }
  14162. });
  14163. }
  14164. if (this._tooltipTextBlock) {
  14165. this._tooltipTextBlock.text = text;
  14166. }
  14167. },
  14168. enumerable: true,
  14169. configurable: true
  14170. });
  14171. Object.defineProperty(HolographicButton.prototype, "text", {
  14172. /**
  14173. * Gets or sets text for the button
  14174. */
  14175. get: function () {
  14176. return this._text;
  14177. },
  14178. set: function (value) {
  14179. if (this._text === value) {
  14180. return;
  14181. }
  14182. this._text = value;
  14183. this._rebuildContent();
  14184. },
  14185. enumerable: true,
  14186. configurable: true
  14187. });
  14188. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14189. /**
  14190. * Gets or sets the image url for the button
  14191. */
  14192. get: function () {
  14193. return this._imageUrl;
  14194. },
  14195. set: function (value) {
  14196. if (this._imageUrl === value) {
  14197. return;
  14198. }
  14199. this._imageUrl = value;
  14200. this._rebuildContent();
  14201. },
  14202. enumerable: true,
  14203. configurable: true
  14204. });
  14205. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14206. /**
  14207. * Gets the back material used by this button
  14208. */
  14209. get: function () {
  14210. return this._backMaterial;
  14211. },
  14212. enumerable: true,
  14213. configurable: true
  14214. });
  14215. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14216. /**
  14217. * Gets the front material used by this button
  14218. */
  14219. get: function () {
  14220. return this._frontMaterial;
  14221. },
  14222. enumerable: true,
  14223. configurable: true
  14224. });
  14225. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14226. /**
  14227. * Gets the plate material used by this button
  14228. */
  14229. get: function () {
  14230. return this._plateMaterial;
  14231. },
  14232. enumerable: true,
  14233. configurable: true
  14234. });
  14235. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14236. /**
  14237. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14238. */
  14239. get: function () {
  14240. return this._shareMaterials;
  14241. },
  14242. enumerable: true,
  14243. configurable: true
  14244. });
  14245. HolographicButton.prototype._getTypeName = function () {
  14246. return "HolographicButton";
  14247. };
  14248. HolographicButton.prototype._rebuildContent = function () {
  14249. this._disposeFacadeTexture();
  14250. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14251. panel.isVertical = true;
  14252. if (this._imageUrl) {
  14253. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14254. image.source = this._imageUrl;
  14255. image.paddingTop = "40px";
  14256. image.height = "180px";
  14257. image.width = "100px";
  14258. image.paddingBottom = "40px";
  14259. panel.addControl(image);
  14260. }
  14261. if (this._text) {
  14262. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14263. text.text = this._text;
  14264. text.color = "white";
  14265. text.height = "30px";
  14266. text.fontSize = 24;
  14267. panel.addControl(text);
  14268. }
  14269. if (this._frontPlate) {
  14270. this.content = panel;
  14271. }
  14272. };
  14273. // Mesh association
  14274. HolographicButton.prototype._createNode = function (scene) {
  14275. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14276. width: 1.0,
  14277. height: 1.0,
  14278. depth: 0.08
  14279. }, scene);
  14280. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14281. width: 1.0,
  14282. height: 1.0,
  14283. depth: 0.08
  14284. }, scene);
  14285. this._frontPlate.parent = this._backPlate;
  14286. this._frontPlate.position.z = -0.08;
  14287. this._frontPlate.isPickable = false;
  14288. this._frontPlate.setEnabled(false);
  14289. this._textPlate = _super.prototype._createNode.call(this, scene);
  14290. this._textPlate.parent = this._backPlate;
  14291. this._textPlate.position.z = -0.08;
  14292. this._textPlate.isPickable = false;
  14293. return this._backPlate;
  14294. };
  14295. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14296. this._plateMaterial.emissiveTexture = facadeTexture;
  14297. this._plateMaterial.opacityTexture = facadeTexture;
  14298. };
  14299. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14300. var _this = this;
  14301. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14302. this._backMaterial.renderHoverLight = true;
  14303. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14304. if (pickedPoint) {
  14305. _this._backMaterial.hoverPosition = pickedPoint;
  14306. _this._backMaterial.hoverColor.a = 1.0;
  14307. }
  14308. else {
  14309. _this._backMaterial.hoverColor.a = 0;
  14310. }
  14311. });
  14312. };
  14313. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14314. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14315. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14316. this._frontMaterial.alpha = 0.5; // Additive
  14317. this._frontMaterial.renderBorders = true;
  14318. };
  14319. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14320. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14321. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14322. };
  14323. HolographicButton.prototype._affectMaterial = function (mesh) {
  14324. // Back
  14325. if (this._shareMaterials) {
  14326. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14327. this._createBackMaterial(mesh);
  14328. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14329. }
  14330. else {
  14331. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14332. }
  14333. // Front
  14334. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14335. this._createFrontMaterial(mesh);
  14336. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14337. }
  14338. else {
  14339. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14340. }
  14341. }
  14342. else {
  14343. this._createBackMaterial(mesh);
  14344. this._createFrontMaterial(mesh);
  14345. }
  14346. this._createPlateMaterial(mesh);
  14347. this._backPlate.material = this._backMaterial;
  14348. this._frontPlate.material = this._frontMaterial;
  14349. this._textPlate.material = this._plateMaterial;
  14350. this._rebuildContent();
  14351. };
  14352. /**
  14353. * Releases all associated resources
  14354. */
  14355. HolographicButton.prototype.dispose = function () {
  14356. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14357. this._disposeTooltip();
  14358. if (!this.shareMaterials) {
  14359. this._backMaterial.dispose();
  14360. this._frontMaterial.dispose();
  14361. this._plateMaterial.dispose();
  14362. if (this._pickedPointObserver) {
  14363. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14364. this._pickedPointObserver = null;
  14365. }
  14366. }
  14367. };
  14368. return HolographicButton;
  14369. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14370. /***/ }),
  14371. /***/ "./3D/controls/index.ts":
  14372. /*!******************************!*\
  14373. !*** ./3D/controls/index.ts ***!
  14374. \******************************/
  14375. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14377. "use strict";
  14378. __webpack_require__.r(__webpack_exports__);
  14379. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14381. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14383. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14385. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14387. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14389. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14391. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14393. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14395. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14397. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14399. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14401. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14403. /***/ }),
  14404. /***/ "./3D/controls/meshButton3D.ts":
  14405. /*!*************************************!*\
  14406. !*** ./3D/controls/meshButton3D.ts ***!
  14407. \*************************************/
  14408. /*! exports provided: MeshButton3D */
  14409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14410. "use strict";
  14411. __webpack_require__.r(__webpack_exports__);
  14412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14413. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14414. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14415. /**
  14416. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14417. */
  14418. var MeshButton3D = /** @class */ (function (_super) {
  14419. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14420. /**
  14421. * Creates a new 3D button based on a mesh
  14422. * @param mesh mesh to become a 3D button
  14423. * @param name defines the control name
  14424. */
  14425. function MeshButton3D(mesh, name) {
  14426. var _this = _super.call(this, name) || this;
  14427. _this._currentMesh = mesh;
  14428. /**
  14429. * Provides a default behavior on hover/out & up/down
  14430. * Override those function to create your own desired behavior specific to your mesh
  14431. */
  14432. _this.pointerEnterAnimation = function () {
  14433. if (!_this.mesh) {
  14434. return;
  14435. }
  14436. _this.mesh.scaling.scaleInPlace(1.1);
  14437. };
  14438. _this.pointerOutAnimation = function () {
  14439. if (!_this.mesh) {
  14440. return;
  14441. }
  14442. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14443. };
  14444. _this.pointerDownAnimation = function () {
  14445. if (!_this.mesh) {
  14446. return;
  14447. }
  14448. _this.mesh.scaling.scaleInPlace(0.95);
  14449. };
  14450. _this.pointerUpAnimation = function () {
  14451. if (!_this.mesh) {
  14452. return;
  14453. }
  14454. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14455. };
  14456. return _this;
  14457. }
  14458. MeshButton3D.prototype._getTypeName = function () {
  14459. return "MeshButton3D";
  14460. };
  14461. // Mesh association
  14462. MeshButton3D.prototype._createNode = function (scene) {
  14463. var _this = this;
  14464. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14465. mesh.metadata = _this;
  14466. });
  14467. return this._currentMesh;
  14468. };
  14469. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14470. };
  14471. return MeshButton3D;
  14472. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14473. /***/ }),
  14474. /***/ "./3D/controls/planePanel.ts":
  14475. /*!***********************************!*\
  14476. !*** ./3D/controls/planePanel.ts ***!
  14477. \***********************************/
  14478. /*! exports provided: PlanePanel */
  14479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14480. "use strict";
  14481. __webpack_require__.r(__webpack_exports__);
  14482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14484. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14485. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14486. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14487. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14488. /**
  14489. * Class used to create a container panel deployed on the surface of a plane
  14490. */
  14491. var PlanePanel = /** @class */ (function (_super) {
  14492. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14493. function PlanePanel() {
  14494. return _super !== null && _super.apply(this, arguments) || this;
  14495. }
  14496. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14497. var mesh = control.mesh;
  14498. if (!mesh) {
  14499. return;
  14500. }
  14501. control.position = nodePosition.clone();
  14502. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14503. target.copyFrom(nodePosition);
  14504. switch (this.orientation) {
  14505. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14506. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14507. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14508. mesh.lookAt(target);
  14509. break;
  14510. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14511. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14512. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14513. mesh.lookAt(target);
  14514. break;
  14515. }
  14516. };
  14517. return PlanePanel;
  14518. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14519. /***/ }),
  14520. /***/ "./3D/controls/scatterPanel.ts":
  14521. /*!*************************************!*\
  14522. !*** ./3D/controls/scatterPanel.ts ***!
  14523. \*************************************/
  14524. /*! exports provided: ScatterPanel */
  14525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14526. "use strict";
  14527. __webpack_require__.r(__webpack_exports__);
  14528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14529. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14530. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14531. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14532. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14533. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14534. /**
  14535. * Class used to create a container panel where items get randomized planar mapping
  14536. */
  14537. var ScatterPanel = /** @class */ (function (_super) {
  14538. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14539. function ScatterPanel() {
  14540. var _this = _super !== null && _super.apply(this, arguments) || this;
  14541. _this._iteration = 100.0;
  14542. return _this;
  14543. }
  14544. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14545. /**
  14546. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14547. */
  14548. get: function () {
  14549. return this._iteration;
  14550. },
  14551. set: function (value) {
  14552. var _this = this;
  14553. if (this._iteration === value) {
  14554. return;
  14555. }
  14556. this._iteration = value;
  14557. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14558. _this._arrangeChildren();
  14559. });
  14560. },
  14561. enumerable: true,
  14562. configurable: true
  14563. });
  14564. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14565. var mesh = control.mesh;
  14566. var newPos = this._scatterMapping(nodePosition);
  14567. if (!mesh) {
  14568. return;
  14569. }
  14570. switch (this.orientation) {
  14571. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14572. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14573. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14574. break;
  14575. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14576. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14577. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14578. break;
  14579. }
  14580. control.position = newPos;
  14581. };
  14582. ScatterPanel.prototype._scatterMapping = function (source) {
  14583. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14584. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14585. return source;
  14586. };
  14587. ScatterPanel.prototype._finalProcessing = function () {
  14588. var meshes = [];
  14589. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14590. var child = _a[_i];
  14591. if (!child.mesh) {
  14592. continue;
  14593. }
  14594. meshes.push(child.mesh);
  14595. }
  14596. for (var count = 0; count < this._iteration; count++) {
  14597. meshes.sort(function (a, b) {
  14598. var distance1 = a.position.lengthSquared();
  14599. var distance2 = b.position.lengthSquared();
  14600. if (distance1 < distance2) {
  14601. return 1;
  14602. }
  14603. else if (distance1 > distance2) {
  14604. return -1;
  14605. }
  14606. return 0;
  14607. });
  14608. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14609. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14610. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14611. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14612. for (var i = 0; i < meshes.length - 1; i++) {
  14613. for (var j = i + 1; j < meshes.length; j++) {
  14614. if (i != j) {
  14615. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14616. // Ignore Z axis
  14617. difference2D.x = difference.x;
  14618. difference2D.y = difference.y;
  14619. var combinedRadius = cellSize;
  14620. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14621. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14622. distance -= minSeparation;
  14623. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14624. difference2D.normalize();
  14625. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14626. meshes[j].position.addInPlace(difference);
  14627. meshes[i].position.subtractInPlace(difference);
  14628. }
  14629. }
  14630. }
  14631. }
  14632. }
  14633. };
  14634. return ScatterPanel;
  14635. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14636. /***/ }),
  14637. /***/ "./3D/controls/spherePanel.ts":
  14638. /*!************************************!*\
  14639. !*** ./3D/controls/spherePanel.ts ***!
  14640. \************************************/
  14641. /*! exports provided: SpherePanel */
  14642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14643. "use strict";
  14644. __webpack_require__.r(__webpack_exports__);
  14645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14647. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14648. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14649. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14650. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14651. /**
  14652. * Class used to create a container panel deployed on the surface of a sphere
  14653. */
  14654. var SpherePanel = /** @class */ (function (_super) {
  14655. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14656. function SpherePanel() {
  14657. var _this = _super !== null && _super.apply(this, arguments) || this;
  14658. _this._radius = 5.0;
  14659. return _this;
  14660. }
  14661. Object.defineProperty(SpherePanel.prototype, "radius", {
  14662. /**
  14663. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14664. */
  14665. get: function () {
  14666. return this._radius;
  14667. },
  14668. set: function (value) {
  14669. var _this = this;
  14670. if (this._radius === value) {
  14671. return;
  14672. }
  14673. this._radius = value;
  14674. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14675. _this._arrangeChildren();
  14676. });
  14677. },
  14678. enumerable: true,
  14679. configurable: true
  14680. });
  14681. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14682. var mesh = control.mesh;
  14683. if (!mesh) {
  14684. return;
  14685. }
  14686. var newPos = this._sphericalMapping(nodePosition);
  14687. control.position = newPos;
  14688. switch (this.orientation) {
  14689. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14690. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14691. break;
  14692. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14693. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14694. break;
  14695. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14696. break;
  14697. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14698. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14699. break;
  14700. }
  14701. };
  14702. SpherePanel.prototype._sphericalMapping = function (source) {
  14703. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14704. var xAngle = (source.y / this._radius);
  14705. var yAngle = -(source.x / this._radius);
  14706. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14707. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14708. };
  14709. return SpherePanel;
  14710. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14711. /***/ }),
  14712. /***/ "./3D/controls/stackPanel3D.ts":
  14713. /*!*************************************!*\
  14714. !*** ./3D/controls/stackPanel3D.ts ***!
  14715. \*************************************/
  14716. /*! exports provided: StackPanel3D */
  14717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14718. "use strict";
  14719. __webpack_require__.r(__webpack_exports__);
  14720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14721. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14722. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14723. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14724. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14725. /**
  14726. * Class used to create a stack panel in 3D on XY plane
  14727. */
  14728. var StackPanel3D = /** @class */ (function (_super) {
  14729. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14730. /**
  14731. * Creates new StackPanel
  14732. * @param isVertical
  14733. */
  14734. function StackPanel3D(isVertical) {
  14735. if (isVertical === void 0) { isVertical = false; }
  14736. var _this = _super.call(this) || this;
  14737. _this._isVertical = false;
  14738. /**
  14739. * Gets or sets the distance between elements
  14740. */
  14741. _this.margin = 0.1;
  14742. _this._isVertical = isVertical;
  14743. return _this;
  14744. }
  14745. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14746. /**
  14747. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14748. */
  14749. get: function () {
  14750. return this._isVertical;
  14751. },
  14752. set: function (value) {
  14753. var _this = this;
  14754. if (this._isVertical === value) {
  14755. return;
  14756. }
  14757. this._isVertical = value;
  14758. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14759. _this._arrangeChildren();
  14760. });
  14761. },
  14762. enumerable: true,
  14763. configurable: true
  14764. });
  14765. StackPanel3D.prototype._arrangeChildren = function () {
  14766. var width = 0;
  14767. var height = 0;
  14768. var controlCount = 0;
  14769. var extendSizes = [];
  14770. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14771. // Measure
  14772. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14773. var child = _a[_i];
  14774. if (!child.mesh) {
  14775. continue;
  14776. }
  14777. controlCount++;
  14778. child.mesh.computeWorldMatrix(true);
  14779. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14780. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14781. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14782. extendSizes.push(extendSize);
  14783. if (this._isVertical) {
  14784. height += extendSize.y;
  14785. }
  14786. else {
  14787. width += extendSize.x;
  14788. }
  14789. }
  14790. if (this._isVertical) {
  14791. height += (controlCount - 1) * this.margin / 2;
  14792. }
  14793. else {
  14794. width += (controlCount - 1) * this.margin / 2;
  14795. }
  14796. // Arrange
  14797. var offset;
  14798. if (this._isVertical) {
  14799. offset = -height;
  14800. }
  14801. else {
  14802. offset = -width;
  14803. }
  14804. var index = 0;
  14805. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14806. var child = _c[_b];
  14807. if (!child.mesh) {
  14808. continue;
  14809. }
  14810. controlCount--;
  14811. var extendSize = extendSizes[index++];
  14812. if (this._isVertical) {
  14813. child.position.y = offset + extendSize.y;
  14814. child.position.x = 0;
  14815. offset += extendSize.y * 2;
  14816. }
  14817. else {
  14818. child.position.x = offset + extendSize.x;
  14819. child.position.y = 0;
  14820. offset += extendSize.x * 2;
  14821. }
  14822. offset += (controlCount > 0 ? this.margin : 0);
  14823. }
  14824. };
  14825. return StackPanel3D;
  14826. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14827. /***/ }),
  14828. /***/ "./3D/controls/volumeBasedPanel.ts":
  14829. /*!*****************************************!*\
  14830. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14831. \*****************************************/
  14832. /*! exports provided: VolumeBasedPanel */
  14833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14834. "use strict";
  14835. __webpack_require__.r(__webpack_exports__);
  14836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14837. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14838. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14839. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14840. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14841. /**
  14842. * Abstract class used to create a container panel deployed on the surface of a volume
  14843. */
  14844. var VolumeBasedPanel = /** @class */ (function (_super) {
  14845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14846. /**
  14847. * Creates new VolumeBasedPanel
  14848. */
  14849. function VolumeBasedPanel() {
  14850. var _this = _super.call(this) || this;
  14851. _this._columns = 10;
  14852. _this._rows = 0;
  14853. _this._rowThenColum = true;
  14854. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14855. /**
  14856. * Gets or sets the distance between elements
  14857. */
  14858. _this.margin = 0;
  14859. return _this;
  14860. }
  14861. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14862. /**
  14863. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14864. * | Value | Type | Description |
  14865. * | ----- | ----------------------------------- | ----------- |
  14866. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14867. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14868. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14869. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14870. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14871. */
  14872. get: function () {
  14873. return this._orientation;
  14874. },
  14875. set: function (value) {
  14876. var _this = this;
  14877. if (this._orientation === value) {
  14878. return;
  14879. }
  14880. this._orientation = value;
  14881. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14882. _this._arrangeChildren();
  14883. });
  14884. },
  14885. enumerable: true,
  14886. configurable: true
  14887. });
  14888. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14889. /**
  14890. * Gets or sets the number of columns requested (10 by default).
  14891. * The panel will automatically compute the number of rows based on number of child controls.
  14892. */
  14893. get: function () {
  14894. return this._columns;
  14895. },
  14896. set: function (value) {
  14897. var _this = this;
  14898. if (this._columns === value) {
  14899. return;
  14900. }
  14901. this._columns = value;
  14902. this._rowThenColum = true;
  14903. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14904. _this._arrangeChildren();
  14905. });
  14906. },
  14907. enumerable: true,
  14908. configurable: true
  14909. });
  14910. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14911. /**
  14912. * Gets or sets a the number of rows requested.
  14913. * The panel will automatically compute the number of columns based on number of child controls.
  14914. */
  14915. get: function () {
  14916. return this._rows;
  14917. },
  14918. set: function (value) {
  14919. var _this = this;
  14920. if (this._rows === value) {
  14921. return;
  14922. }
  14923. this._rows = value;
  14924. this._rowThenColum = false;
  14925. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14926. _this._arrangeChildren();
  14927. });
  14928. },
  14929. enumerable: true,
  14930. configurable: true
  14931. });
  14932. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14933. this._cellWidth = 0;
  14934. this._cellHeight = 0;
  14935. var rows = 0;
  14936. var columns = 0;
  14937. var controlCount = 0;
  14938. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14939. // Measure
  14940. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14941. var child = _a[_i];
  14942. if (!child.mesh) {
  14943. continue;
  14944. }
  14945. controlCount++;
  14946. child.mesh.computeWorldMatrix(true);
  14947. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14948. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14949. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14950. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14951. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14952. diff.scaleInPlace(0.5);
  14953. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14954. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14955. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14956. }
  14957. this._cellWidth += this.margin * 2;
  14958. this._cellHeight += this.margin * 2;
  14959. // Arrange
  14960. if (this._rowThenColum) {
  14961. columns = this._columns;
  14962. rows = Math.ceil(controlCount / this._columns);
  14963. }
  14964. else {
  14965. rows = this._rows;
  14966. columns = Math.ceil(controlCount / this._rows);
  14967. }
  14968. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14969. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14970. var nodeGrid = [];
  14971. var cellCounter = 0;
  14972. if (this._rowThenColum) {
  14973. for (var r = 0; r < rows; r++) {
  14974. for (var c = 0; c < columns; c++) {
  14975. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  14976. cellCounter++;
  14977. if (cellCounter > controlCount) {
  14978. break;
  14979. }
  14980. }
  14981. }
  14982. }
  14983. else {
  14984. for (var c = 0; c < columns; c++) {
  14985. for (var r = 0; r < rows; r++) {
  14986. nodeGrid.push(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"]((c * this._cellWidth) - startOffsetX + this._cellWidth / 2, (r * this._cellHeight) - startOffsetY + this._cellHeight / 2, 0));
  14987. cellCounter++;
  14988. if (cellCounter > controlCount) {
  14989. break;
  14990. }
  14991. }
  14992. }
  14993. }
  14994. cellCounter = 0;
  14995. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14996. var child = _c[_b];
  14997. if (!child.mesh) {
  14998. continue;
  14999. }
  15000. this._mapGridNode(child, nodeGrid[cellCounter]);
  15001. cellCounter++;
  15002. }
  15003. this._finalProcessing();
  15004. };
  15005. /** Child classes can implement this function to provide additional processing */
  15006. VolumeBasedPanel.prototype._finalProcessing = function () {
  15007. };
  15008. return VolumeBasedPanel;
  15009. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15010. /***/ }),
  15011. /***/ "./3D/gui3DManager.ts":
  15012. /*!****************************!*\
  15013. !*** ./3D/gui3DManager.ts ***!
  15014. \****************************/
  15015. /*! exports provided: GUI3DManager */
  15016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15017. "use strict";
  15018. __webpack_require__.r(__webpack_exports__);
  15019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15020. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  15021. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15022. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15023. /**
  15024. * Class used to manage 3D user interface
  15025. * @see http://doc.babylonjs.com/how_to/gui3d
  15026. */
  15027. var GUI3DManager = /** @class */ (function () {
  15028. /**
  15029. * Creates a new GUI3DManager
  15030. * @param scene
  15031. */
  15032. function GUI3DManager(scene) {
  15033. var _this = this;
  15034. /** @hidden */
  15035. this._lastControlOver = {};
  15036. /** @hidden */
  15037. this._lastControlDown = {};
  15038. /**
  15039. * Observable raised when the point picked by the pointer events changed
  15040. */
  15041. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15042. // Shared resources
  15043. /** @hidden */
  15044. this._sharedMaterials = {};
  15045. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15046. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15047. _this._sceneDisposeObserver = null;
  15048. _this._utilityLayer = null;
  15049. _this.dispose();
  15050. });
  15051. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15052. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15053. this._utilityLayer.pickUtilitySceneFirst = false;
  15054. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15055. return mesh && mesh.metadata && mesh.metadata._node;
  15056. };
  15057. // Root
  15058. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15059. this._rootContainer._host = this;
  15060. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15061. // Events
  15062. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15063. _this._handlePointerOut(pointerId, true);
  15064. });
  15065. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15066. _this._doPicking(pi);
  15067. });
  15068. // Scene
  15069. this._utilityLayer.utilityLayerScene.autoClear = false;
  15070. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15071. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15072. }
  15073. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15074. /** Gets the hosting scene */
  15075. get: function () {
  15076. return this._scene;
  15077. },
  15078. enumerable: true,
  15079. configurable: true
  15080. });
  15081. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15082. /** Gets associated utility layer */
  15083. get: function () {
  15084. return this._utilityLayer;
  15085. },
  15086. enumerable: true,
  15087. configurable: true
  15088. });
  15089. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15090. var previousControlOver = this._lastControlOver[pointerId];
  15091. if (previousControlOver) {
  15092. previousControlOver._onPointerOut(previousControlOver);
  15093. delete this._lastControlOver[pointerId];
  15094. }
  15095. if (isPointerUp) {
  15096. if (this._lastControlDown[pointerId]) {
  15097. this._lastControlDown[pointerId].forcePointerUp();
  15098. delete this._lastControlDown[pointerId];
  15099. }
  15100. }
  15101. this.onPickedPointChangedObservable.notifyObservers(null);
  15102. };
  15103. GUI3DManager.prototype._doPicking = function (pi) {
  15104. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15105. return false;
  15106. }
  15107. var pointerEvent = (pi.event);
  15108. var pointerId = pointerEvent.pointerId || 0;
  15109. var buttonIndex = pointerEvent.button;
  15110. var pickingInfo = pi.pickInfo;
  15111. if (!pickingInfo || !pickingInfo.hit) {
  15112. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15113. return false;
  15114. }
  15115. var control = (pickingInfo.pickedMesh.metadata);
  15116. if (pickingInfo.pickedPoint) {
  15117. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15118. }
  15119. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15120. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15121. if (this._lastControlOver[pointerId]) {
  15122. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15123. }
  15124. delete this._lastControlOver[pointerId];
  15125. }
  15126. }
  15127. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15128. if (this._lastControlDown[pointerEvent.pointerId]) {
  15129. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15130. delete this._lastControlDown[pointerEvent.pointerId];
  15131. }
  15132. if (pointerEvent.pointerType === "touch") {
  15133. this._handlePointerOut(pointerId, false);
  15134. }
  15135. }
  15136. return true;
  15137. };
  15138. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15139. /**
  15140. * Gets the root container
  15141. */
  15142. get: function () {
  15143. return this._rootContainer;
  15144. },
  15145. enumerable: true,
  15146. configurable: true
  15147. });
  15148. /**
  15149. * Gets a boolean indicating if the given control is in the root child list
  15150. * @param control defines the control to check
  15151. * @returns true if the control is in the root child list
  15152. */
  15153. GUI3DManager.prototype.containsControl = function (control) {
  15154. return this._rootContainer.containsControl(control);
  15155. };
  15156. /**
  15157. * Adds a control to the root child list
  15158. * @param control defines the control to add
  15159. * @returns the current manager
  15160. */
  15161. GUI3DManager.prototype.addControl = function (control) {
  15162. this._rootContainer.addControl(control);
  15163. return this;
  15164. };
  15165. /**
  15166. * Removes a control from the root child list
  15167. * @param control defines the control to remove
  15168. * @returns the current container
  15169. */
  15170. GUI3DManager.prototype.removeControl = function (control) {
  15171. this._rootContainer.removeControl(control);
  15172. return this;
  15173. };
  15174. /**
  15175. * Releases all associated resources
  15176. */
  15177. GUI3DManager.prototype.dispose = function () {
  15178. this._rootContainer.dispose();
  15179. for (var materialName in this._sharedMaterials) {
  15180. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15181. continue;
  15182. }
  15183. this._sharedMaterials[materialName].dispose();
  15184. }
  15185. this._sharedMaterials = {};
  15186. if (this._pointerOutObserver && this._utilityLayer) {
  15187. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15188. this._pointerOutObserver = null;
  15189. }
  15190. this.onPickedPointChangedObservable.clear();
  15191. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15192. if (utilityLayerScene) {
  15193. if (this._pointerObserver) {
  15194. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15195. this._pointerObserver = null;
  15196. }
  15197. }
  15198. if (this._scene) {
  15199. if (this._sceneDisposeObserver) {
  15200. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15201. this._sceneDisposeObserver = null;
  15202. }
  15203. }
  15204. if (this._utilityLayer) {
  15205. this._utilityLayer.dispose();
  15206. }
  15207. };
  15208. return GUI3DManager;
  15209. }());
  15210. /***/ }),
  15211. /***/ "./3D/index.ts":
  15212. /*!*********************!*\
  15213. !*** ./3D/index.ts ***!
  15214. \*********************/
  15215. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15216. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15217. "use strict";
  15218. __webpack_require__.r(__webpack_exports__);
  15219. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15232. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15235. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15237. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15239. /***/ }),
  15240. /***/ "./3D/materials/fluentMaterial.ts":
  15241. /*!****************************************!*\
  15242. !*** ./3D/materials/fluentMaterial.ts ***!
  15243. \****************************************/
  15244. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15246. "use strict";
  15247. __webpack_require__.r(__webpack_exports__);
  15248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15251. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  15252. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15253. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15254. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15255. /** @hidden */
  15256. var FluentMaterialDefines = /** @class */ (function (_super) {
  15257. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15258. function FluentMaterialDefines() {
  15259. var _this = _super.call(this) || this;
  15260. _this.INNERGLOW = false;
  15261. _this.BORDER = false;
  15262. _this.HOVERLIGHT = false;
  15263. _this.TEXTURE = false;
  15264. _this.rebuild();
  15265. return _this;
  15266. }
  15267. return FluentMaterialDefines;
  15268. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15269. /**
  15270. * Class used to render controls with fluent desgin
  15271. */
  15272. var FluentMaterial = /** @class */ (function (_super) {
  15273. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15274. /**
  15275. * Creates a new Fluent material
  15276. * @param name defines the name of the material
  15277. * @param scene defines the hosting scene
  15278. */
  15279. function FluentMaterial(name, scene) {
  15280. var _this = _super.call(this, name, scene) || this;
  15281. /**
  15282. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15283. */
  15284. _this.innerGlowColorIntensity = 0.5;
  15285. /**
  15286. * Gets or sets the inner glow color (white by default)
  15287. */
  15288. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15289. /**
  15290. * Gets or sets alpha value (default is 1.0)
  15291. */
  15292. _this.alpha = 1.0;
  15293. /**
  15294. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15295. */
  15296. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15297. /**
  15298. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15299. */
  15300. _this.renderBorders = false;
  15301. /**
  15302. * Gets or sets border width (default is 0.5)
  15303. */
  15304. _this.borderWidth = 0.5;
  15305. /**
  15306. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15307. */
  15308. _this.edgeSmoothingValue = 0.02;
  15309. /**
  15310. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15311. */
  15312. _this.borderMinValue = 0.1;
  15313. /**
  15314. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15315. */
  15316. _this.renderHoverLight = false;
  15317. /**
  15318. * Gets or sets the radius used to render the hover light (default is 1.0)
  15319. */
  15320. _this.hoverRadius = 1.0;
  15321. /**
  15322. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15323. */
  15324. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15325. /**
  15326. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15327. */
  15328. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15329. return _this;
  15330. }
  15331. FluentMaterial.prototype.needAlphaBlending = function () {
  15332. return this.alpha !== 1.0;
  15333. };
  15334. FluentMaterial.prototype.needAlphaTesting = function () {
  15335. return false;
  15336. };
  15337. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15338. return null;
  15339. };
  15340. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15341. if (this.isFrozen) {
  15342. if (this._wasPreviouslyReady && subMesh.effect) {
  15343. return true;
  15344. }
  15345. }
  15346. if (!subMesh._materialDefines) {
  15347. subMesh._materialDefines = new FluentMaterialDefines();
  15348. }
  15349. var scene = this.getScene();
  15350. var defines = subMesh._materialDefines;
  15351. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15352. if (defines._renderId === scene.getRenderId()) {
  15353. return true;
  15354. }
  15355. }
  15356. if (defines._areTexturesDirty) {
  15357. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15358. defines.BORDER = this.renderBorders;
  15359. defines.HOVERLIGHT = this.renderHoverLight;
  15360. if (this._albedoTexture) {
  15361. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15362. return false;
  15363. }
  15364. else {
  15365. defines.TEXTURE = true;
  15366. }
  15367. }
  15368. else {
  15369. defines.TEXTURE = false;
  15370. }
  15371. }
  15372. var engine = scene.getEngine();
  15373. // Get correct effect
  15374. if (defines.isDirty) {
  15375. defines.markAsProcessed();
  15376. scene.resetCachedMaterial();
  15377. //Attributes
  15378. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15379. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15380. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15381. var shaderName = "fluent";
  15382. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15383. "hoverColor", "hoverPosition", "hoverRadius"
  15384. ];
  15385. var samplers = ["albedoSampler"];
  15386. var uniformBuffers = new Array();
  15387. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15388. uniformsNames: uniforms,
  15389. uniformBuffersNames: uniformBuffers,
  15390. samplers: samplers,
  15391. defines: defines,
  15392. maxSimultaneousLights: 4
  15393. });
  15394. var join = defines.toString();
  15395. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15396. attributes: attribs,
  15397. uniformsNames: uniforms,
  15398. uniformBuffersNames: uniformBuffers,
  15399. samplers: samplers,
  15400. defines: join,
  15401. fallbacks: null,
  15402. onCompiled: this.onCompiled,
  15403. onError: this.onError,
  15404. indexParameters: { maxSimultaneousLights: 4 }
  15405. }, engine));
  15406. }
  15407. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15408. return false;
  15409. }
  15410. defines._renderId = scene.getRenderId();
  15411. this._wasPreviouslyReady = true;
  15412. return true;
  15413. };
  15414. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15415. var scene = this.getScene();
  15416. var defines = subMesh._materialDefines;
  15417. if (!defines) {
  15418. return;
  15419. }
  15420. var effect = subMesh.effect;
  15421. if (!effect) {
  15422. return;
  15423. }
  15424. this._activeEffect = effect;
  15425. // Matrices
  15426. this.bindOnlyWorldMatrix(world);
  15427. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15428. if (this._mustRebind(scene, effect)) {
  15429. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15430. if (defines.INNERGLOW) {
  15431. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15432. }
  15433. if (defines.BORDER) {
  15434. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15435. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15436. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15437. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15438. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15439. }
  15440. if (defines.HOVERLIGHT) {
  15441. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15442. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15443. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15444. }
  15445. if (defines.TEXTURE) {
  15446. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15447. }
  15448. }
  15449. this._afterBind(mesh, this._activeEffect);
  15450. };
  15451. FluentMaterial.prototype.getActiveTextures = function () {
  15452. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15453. return activeTextures;
  15454. };
  15455. FluentMaterial.prototype.hasTexture = function (texture) {
  15456. if (_super.prototype.hasTexture.call(this, texture)) {
  15457. return true;
  15458. }
  15459. return false;
  15460. };
  15461. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15462. _super.prototype.dispose.call(this, forceDisposeEffect);
  15463. };
  15464. FluentMaterial.prototype.clone = function (name) {
  15465. var _this = this;
  15466. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15467. };
  15468. FluentMaterial.prototype.serialize = function () {
  15469. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15470. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15471. return serializationObject;
  15472. };
  15473. FluentMaterial.prototype.getClassName = function () {
  15474. return "FluentMaterial";
  15475. };
  15476. // Statics
  15477. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15478. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15479. };
  15480. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15481. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15482. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15483. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15484. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15485. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15486. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15487. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15488. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15489. ], FluentMaterial.prototype, "alpha", void 0);
  15490. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15491. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15492. ], FluentMaterial.prototype, "albedoColor", void 0);
  15493. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15494. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15495. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15496. ], FluentMaterial.prototype, "renderBorders", void 0);
  15497. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15498. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15499. ], FluentMaterial.prototype, "borderWidth", void 0);
  15500. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15501. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15502. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15503. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15504. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15505. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15506. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15507. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15508. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15509. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15510. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15511. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15512. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15513. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15514. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15515. ], FluentMaterial.prototype, "hoverColor", void 0);
  15516. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15517. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15518. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15519. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15521. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15522. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15524. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15525. return FluentMaterial;
  15526. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15527. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15528. /***/ }),
  15529. /***/ "./3D/materials/index.ts":
  15530. /*!*******************************!*\
  15531. !*** ./3D/materials/index.ts ***!
  15532. \*******************************/
  15533. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15535. "use strict";
  15536. __webpack_require__.r(__webpack_exports__);
  15537. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15540. /***/ }),
  15541. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15542. /*!*************************************************!*\
  15543. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15544. \*************************************************/
  15545. /*! exports provided: fluentPixelShader */
  15546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15547. "use strict";
  15548. __webpack_require__.r(__webpack_exports__);
  15549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15550. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15551. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15552. var name = 'fluentPixelShader';
  15553. var shader = "precision highp float;\nvarying vec2 vUV;\nuniform vec4 albedoColor;\n#ifdef INNERGLOW\nuniform vec4 innerGlowColor;\n#endif\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float edgeSmoothingValue;\nuniform float borderMinValue;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\nuniform vec3 hoverPosition;\nuniform vec4 hoverColor;\nuniform float hoverRadius;\n#endif\n#ifdef TEXTURE\nuniform sampler2D albedoSampler;\n#endif\nvoid main(void) {\nvec3 albedo=albedoColor.rgb;\nfloat alpha=albedoColor.a;\n#ifdef TEXTURE\nalbedo=texture2D(albedoSampler,vUV).rgb;\n#endif\n#ifdef HOVERLIGHT\nfloat pointToHover=(1.0-clamp(length(hoverPosition-worldPosition)/hoverRadius,0.,1.))*hoverColor.a;\nalbedo=clamp(albedo+hoverColor.rgb*pointToHover,0.,1.);\n#else\nfloat pointToHover=1.0;\n#endif\n#ifdef BORDER\nfloat borderPower=10.0;\nfloat inverseBorderPower=1.0/borderPower;\nvec3 borderColor=albedo*borderPower;\nvec2 distanceToEdge;\ndistanceToEdge.x=abs(vUV.x-0.5)*2.0;\ndistanceToEdge.y=abs(vUV.y-0.5)*2.0;\nfloat borderValue=max(smoothstep(scaleInfo.x-edgeSmoothingValue,scaleInfo.x+edgeSmoothingValue,distanceToEdge.x),\nsmoothstep(scaleInfo.y-edgeSmoothingValue,scaleInfo.y+edgeSmoothingValue,distanceToEdge.y));\nborderColor=borderColor*borderValue*max(borderMinValue*inverseBorderPower,pointToHover);\nalbedo+=borderColor;\nalpha=max(alpha,borderValue);\n#endif\n#ifdef INNERGLOW\n\nvec2 uvGlow=(vUV-vec2(0.5,0.5))*(innerGlowColor.a*2.0);\nuvGlow=uvGlow*uvGlow;\nuvGlow=uvGlow*uvGlow;\nalbedo+=mix(vec3(0.0,0.0,0.0),innerGlowColor.rgb,uvGlow.x+uvGlow.y);\n#endif\ngl_FragColor=vec4(albedo,alpha);\n}";
  15554. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15555. /** @hidden */
  15556. var fluentPixelShader = { name: name, shader: shader };
  15557. /***/ }),
  15558. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15559. /*!***********************************************!*\
  15560. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15561. \***********************************************/
  15562. /*! exports provided: fluentVertexShader */
  15563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15564. "use strict";
  15565. __webpack_require__.r(__webpack_exports__);
  15566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15567. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15568. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15569. var name = 'fluentVertexShader';
  15570. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nuniform mat4 world;\nuniform mat4 viewProjection;\nvarying vec2 vUV;\n#ifdef BORDER\nvarying vec2 scaleInfo;\nuniform float borderWidth;\nuniform vec3 scaleFactor;\n#endif\n#ifdef HOVERLIGHT\nvarying vec3 worldPosition;\n#endif\nvoid main(void) {\nvUV=uv;\n#ifdef BORDER\nvec3 scale=scaleFactor;\nfloat minScale=min(min(scale.x,scale.y),scale.z);\nfloat maxScale=max(max(scale.x,scale.y),scale.z);\nfloat minOverMiddleScale=minScale/(scale.x+scale.y+scale.z-minScale-maxScale);\nfloat areaYZ=scale.y*scale.z;\nfloat areaXZ=scale.x*scale.z;\nfloat areaXY=scale.x*scale.y;\nfloat scaledBorderWidth=borderWidth;\nif (abs(normal.x) == 1.0)\n{\nscale.x=scale.y;\nscale.y=scale.z;\nif (areaYZ>areaXZ && areaYZ>areaXY)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse if (abs(normal.y) == 1.0)\n{\nscale.x=scale.z;\nif (areaXZ>areaXY && areaXZ>areaYZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nelse\n{\nif (areaXY>areaYZ && areaXY>areaXZ)\n{\nscaledBorderWidth*=minOverMiddleScale;\n}\n}\nfloat scaleRatio=min(scale.x,scale.y)/max(scale.x,scale.y);\nif (scale.x>scale.y)\n{\nscaleInfo.x=1.0-(scaledBorderWidth*scaleRatio);\nscaleInfo.y=1.0-scaledBorderWidth;\n}\nelse\n{\nscaleInfo.x=1.0-scaledBorderWidth;\nscaleInfo.y=1.0-(scaledBorderWidth*scaleRatio);\n}\n#endif\nvec4 worldPos=world*vec4(position,1.0);\n#ifdef HOVERLIGHT\nworldPosition=worldPos.xyz;\n#endif\ngl_Position=viewProjection*worldPos;\n}\n";
  15571. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15572. /** @hidden */
  15573. var fluentVertexShader = { name: name, shader: shader };
  15574. /***/ }),
  15575. /***/ "./3D/vector3WithInfo.ts":
  15576. /*!*******************************!*\
  15577. !*** ./3D/vector3WithInfo.ts ***!
  15578. \*******************************/
  15579. /*! exports provided: Vector3WithInfo */
  15580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15581. "use strict";
  15582. __webpack_require__.r(__webpack_exports__);
  15583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15585. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  15586. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15587. /**
  15588. * Class used to transport Vector3 information for pointer events
  15589. */
  15590. var Vector3WithInfo = /** @class */ (function (_super) {
  15591. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15592. /**
  15593. * Creates a new Vector3WithInfo
  15594. * @param source defines the vector3 data to transport
  15595. * @param buttonIndex defines the current mouse button index
  15596. */
  15597. function Vector3WithInfo(source,
  15598. /** defines the current mouse button index */
  15599. buttonIndex) {
  15600. if (buttonIndex === void 0) { buttonIndex = 0; }
  15601. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15602. _this.buttonIndex = buttonIndex;
  15603. return _this;
  15604. }
  15605. return Vector3WithInfo;
  15606. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15607. /***/ }),
  15608. /***/ "./index.ts":
  15609. /*!******************!*\
  15610. !*** ./index.ts ***!
  15611. \******************/
  15612. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15614. "use strict";
  15615. __webpack_require__.r(__webpack_exports__);
  15616. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15658. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15675. /***/ }),
  15676. /***/ "./legacy/legacy.ts":
  15677. /*!**************************!*\
  15678. !*** ./legacy/legacy.ts ***!
  15679. \**************************/
  15680. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15681. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15682. "use strict";
  15683. __webpack_require__.r(__webpack_exports__);
  15684. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15742. /**
  15743. * Legacy support, defining window.BABYLON.GUI (global variable).
  15744. *
  15745. * This is the entry point for the UMD module.
  15746. * The entry point for a future ESM package should be index.ts
  15747. */
  15748. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15749. if (typeof globalObject !== "undefined") {
  15750. globalObject.BABYLON = globalObject.BABYLON || {};
  15751. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15752. }
  15753. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15754. /***/ }),
  15755. /***/ "babylonjs/Maths/math":
  15756. /*!****************************************************************************************************!*\
  15757. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15758. \****************************************************************************************************/
  15759. /*! no static exports found */
  15760. /***/ (function(module, exports) {
  15761. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  15762. /***/ })
  15763. /******/ });
  15764. });
  15765. //# sourceMappingURL=babylon.gui.js.map