babylon.gui.js 705 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183
  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. !*** C:/Dev/Babylon/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._rootCanvas = scene.getEngine().getRenderingCanvas();
  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._rootCanvas = 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._rootCanvas) {
  1064. this._rootCanvas.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) {
  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. /** @hidden */
  3468. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3469. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3470. if (!this.children) {
  3471. return;
  3472. }
  3473. for (var index = 0; index < this.children.length; index++) {
  3474. var item = this.children[index];
  3475. if (!predicate || predicate(item)) {
  3476. results.push(item);
  3477. }
  3478. if (!directDescendantsOnly) {
  3479. item._getDescendants(results, false, predicate);
  3480. }
  3481. }
  3482. };
  3483. /** @hidden */
  3484. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3485. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3486. return false;
  3487. }
  3488. if (!_super.prototype.contains.call(this, x, y)) {
  3489. return false;
  3490. }
  3491. // Checking backwards to pick closest first
  3492. for (var index = this._children.length - 1; index >= 0; index--) {
  3493. var child = this._children[index];
  3494. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3495. if (child.hoverCursor) {
  3496. this._host._changeCursor(child.hoverCursor);
  3497. }
  3498. return true;
  3499. }
  3500. }
  3501. if (!this.isHitTestVisible) {
  3502. return false;
  3503. }
  3504. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3505. };
  3506. /** @hidden */
  3507. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3508. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3509. this._measureForChildren.copyFrom(this._currentMeasure);
  3510. };
  3511. /** Releases associated resources */
  3512. Container.prototype.dispose = function () {
  3513. _super.prototype.dispose.call(this);
  3514. for (var index = this.children.length - 1; index >= 0; index--) {
  3515. this.children[index].dispose();
  3516. }
  3517. };
  3518. return Container;
  3519. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3520. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3521. /***/ }),
  3522. /***/ "./2D/controls/control.ts":
  3523. /*!********************************!*\
  3524. !*** ./2D/controls/control.ts ***!
  3525. \********************************/
  3526. /*! exports provided: Control */
  3527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3528. "use strict";
  3529. __webpack_require__.r(__webpack_exports__);
  3530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3532. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3533. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3534. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3535. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3536. /**
  3537. * Root class used for all 2D controls
  3538. * @see http://doc.babylonjs.com/how_to/gui#controls
  3539. */
  3540. var Control = /** @class */ (function () {
  3541. // Functions
  3542. /**
  3543. * Creates a new control
  3544. * @param name defines the name of the control
  3545. */
  3546. function Control(
  3547. /** defines the name of the control */
  3548. name) {
  3549. this.name = name;
  3550. this._alpha = 1;
  3551. this._alphaSet = false;
  3552. this._zIndex = 0;
  3553. /** @hidden */
  3554. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3555. this._fontFamily = "Arial";
  3556. this._fontStyle = "";
  3557. this._fontWeight = "";
  3558. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3559. /** @hidden */
  3560. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3561. /** @hidden */
  3562. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3563. this._color = "";
  3564. this._style = null;
  3565. /** @hidden */
  3566. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3567. /** @hidden */
  3568. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3569. /** @hidden */
  3570. this._isDirty = true;
  3571. /** @hidden */
  3572. this._wasDirty = false;
  3573. /** @hidden */
  3574. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3575. /** @hidden */
  3576. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3577. /** @hidden */
  3578. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3579. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3583. /** @hidden */
  3584. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3585. /** @hidden */
  3586. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3587. this._scaleX = 1.0;
  3588. this._scaleY = 1.0;
  3589. this._rotation = 0;
  3590. this._transformCenterX = 0.5;
  3591. this._transformCenterY = 0.5;
  3592. /** @hidden */
  3593. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3594. /** @hidden */
  3595. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3596. /** @hidden */
  3597. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3598. this._isMatrixDirty = true;
  3599. this._isVisible = true;
  3600. this._isHighlighted = false;
  3601. this._fontSet = false;
  3602. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3603. this._downCount = 0;
  3604. this._enterCount = -1;
  3605. this._doNotRender = false;
  3606. this._downPointerIds = {};
  3607. this._isEnabled = true;
  3608. this._disabledColor = "#9a9a9a";
  3609. /** @hidden */
  3610. this._rebuildLayout = false;
  3611. /** @hidden */
  3612. this._isClipped = false;
  3613. /**
  3614. * Gets or sets an object used to store user defined information for the node
  3615. */
  3616. this.metadata = null;
  3617. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3618. this.isHitTestVisible = true;
  3619. /** Gets or sets a boolean indicating if the control can block pointer events */
  3620. this.isPointerBlocker = false;
  3621. /** Gets or sets a boolean indicating if the control can be focusable */
  3622. this.isFocusInvisible = false;
  3623. /**
  3624. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3625. * 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
  3626. */
  3627. this.clipChildren = true;
  3628. /**
  3629. * Gets or sets a boolean indicating that control content must be clipped
  3630. * 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
  3631. */
  3632. this.clipContent = true;
  3633. /**
  3634. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3635. */
  3636. this.useBitmapCache = false;
  3637. this._shadowOffsetX = 0;
  3638. this._shadowOffsetY = 0;
  3639. this._shadowBlur = 0;
  3640. this._shadowColor = 'black';
  3641. /** Gets or sets the cursor to use when the control is hovered */
  3642. this.hoverCursor = "";
  3643. /** @hidden */
  3644. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3645. /** @hidden */
  3646. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3647. /**
  3648. * An event triggered when the pointer move over the control.
  3649. */
  3650. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3651. /**
  3652. * An event triggered when the pointer move out of the control.
  3653. */
  3654. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3655. /**
  3656. * An event triggered when the pointer taps the control
  3657. */
  3658. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. /**
  3660. * An event triggered when pointer up
  3661. */
  3662. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3663. /**
  3664. * An event triggered when a control is clicked on
  3665. */
  3666. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3667. /**
  3668. * An event triggered when pointer enters the control
  3669. */
  3670. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3671. /**
  3672. * An event triggered when the control is marked as dirty
  3673. */
  3674. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3675. /**
  3676. * An event triggered before drawing the control
  3677. */
  3678. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3679. /**
  3680. * An event triggered after the control was drawn
  3681. */
  3682. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3683. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3684. }
  3685. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3686. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3687. get: function () {
  3688. return this._shadowOffsetX;
  3689. },
  3690. set: function (value) {
  3691. if (this._shadowOffsetX === value) {
  3692. return;
  3693. }
  3694. this._shadowOffsetX = value;
  3695. this._markAsDirty();
  3696. },
  3697. enumerable: true,
  3698. configurable: true
  3699. });
  3700. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3701. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3702. get: function () {
  3703. return this._shadowOffsetY;
  3704. },
  3705. set: function (value) {
  3706. if (this._shadowOffsetY === value) {
  3707. return;
  3708. }
  3709. this._shadowOffsetY = value;
  3710. this._markAsDirty();
  3711. },
  3712. enumerable: true,
  3713. configurable: true
  3714. });
  3715. Object.defineProperty(Control.prototype, "shadowBlur", {
  3716. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3717. get: function () {
  3718. return this._shadowBlur;
  3719. },
  3720. set: function (value) {
  3721. if (this._shadowBlur === value) {
  3722. return;
  3723. }
  3724. this._shadowBlur = value;
  3725. this._markAsDirty();
  3726. },
  3727. enumerable: true,
  3728. configurable: true
  3729. });
  3730. Object.defineProperty(Control.prototype, "shadowColor", {
  3731. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3732. get: function () {
  3733. return this._shadowColor;
  3734. },
  3735. set: function (value) {
  3736. if (this._shadowColor === value) {
  3737. return;
  3738. }
  3739. this._shadowColor = value;
  3740. this._markAsDirty();
  3741. },
  3742. enumerable: true,
  3743. configurable: true
  3744. });
  3745. Object.defineProperty(Control.prototype, "typeName", {
  3746. // Properties
  3747. /** Gets the control type name */
  3748. get: function () {
  3749. return this._getTypeName();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. /**
  3755. * Get the current class name of the control.
  3756. * @returns current class name
  3757. */
  3758. Control.prototype.getClassName = function () {
  3759. return this._getTypeName();
  3760. };
  3761. Object.defineProperty(Control.prototype, "host", {
  3762. /**
  3763. * Get the hosting AdvancedDynamicTexture
  3764. */
  3765. get: function () {
  3766. return this._host;
  3767. },
  3768. enumerable: true,
  3769. configurable: true
  3770. });
  3771. Object.defineProperty(Control.prototype, "fontOffset", {
  3772. /** Gets or set information about font offsets (used to render and align text) */
  3773. get: function () {
  3774. return this._fontOffset;
  3775. },
  3776. set: function (offset) {
  3777. this._fontOffset = offset;
  3778. },
  3779. enumerable: true,
  3780. configurable: true
  3781. });
  3782. Object.defineProperty(Control.prototype, "alpha", {
  3783. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3784. get: function () {
  3785. return this._alpha;
  3786. },
  3787. set: function (value) {
  3788. if (this._alpha === value) {
  3789. return;
  3790. }
  3791. this._alphaSet = true;
  3792. this._alpha = value;
  3793. this._markAsDirty();
  3794. },
  3795. enumerable: true,
  3796. configurable: true
  3797. });
  3798. Object.defineProperty(Control.prototype, "isHighlighted", {
  3799. /**
  3800. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3801. */
  3802. get: function () {
  3803. return this._isHighlighted;
  3804. },
  3805. set: function (value) {
  3806. if (this._isHighlighted === value) {
  3807. return;
  3808. }
  3809. this._isHighlighted = value;
  3810. this._markAsDirty();
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Control.prototype, "scaleX", {
  3816. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3817. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3818. */
  3819. get: function () {
  3820. return this._scaleX;
  3821. },
  3822. set: function (value) {
  3823. if (this._scaleX === value) {
  3824. return;
  3825. }
  3826. this._scaleX = value;
  3827. this._markAsDirty();
  3828. this._markMatrixAsDirty();
  3829. },
  3830. enumerable: true,
  3831. configurable: true
  3832. });
  3833. Object.defineProperty(Control.prototype, "scaleY", {
  3834. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3835. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3836. */
  3837. get: function () {
  3838. return this._scaleY;
  3839. },
  3840. set: function (value) {
  3841. if (this._scaleY === value) {
  3842. return;
  3843. }
  3844. this._scaleY = value;
  3845. this._markAsDirty();
  3846. this._markMatrixAsDirty();
  3847. },
  3848. enumerable: true,
  3849. configurable: true
  3850. });
  3851. Object.defineProperty(Control.prototype, "rotation", {
  3852. /** Gets or sets the rotation angle (0 by default)
  3853. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3854. */
  3855. get: function () {
  3856. return this._rotation;
  3857. },
  3858. set: function (value) {
  3859. if (this._rotation === value) {
  3860. return;
  3861. }
  3862. this._rotation = value;
  3863. this._markAsDirty();
  3864. this._markMatrixAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "transformCenterY", {
  3870. /** Gets or sets the transformation center on Y axis (0 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._transformCenterY;
  3875. },
  3876. set: function (value) {
  3877. if (this._transformCenterY === value) {
  3878. return;
  3879. }
  3880. this._transformCenterY = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "transformCenterX", {
  3888. /** Gets or sets the transformation center on X axis (0 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._transformCenterX;
  3893. },
  3894. set: function (value) {
  3895. if (this._transformCenterX === value) {
  3896. return;
  3897. }
  3898. this._transformCenterX = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3906. /**
  3907. * Gets or sets the horizontal alignment
  3908. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3909. */
  3910. get: function () {
  3911. return this._horizontalAlignment;
  3912. },
  3913. set: function (value) {
  3914. if (this._horizontalAlignment === value) {
  3915. return;
  3916. }
  3917. this._horizontalAlignment = value;
  3918. this._markAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3924. /**
  3925. * Gets or sets the vertical alignment
  3926. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3927. */
  3928. get: function () {
  3929. return this._verticalAlignment;
  3930. },
  3931. set: function (value) {
  3932. if (this._verticalAlignment === value) {
  3933. return;
  3934. }
  3935. this._verticalAlignment = value;
  3936. this._markAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "width", {
  3942. /**
  3943. * Gets or sets control width
  3944. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3945. */
  3946. get: function () {
  3947. return this._width.toString(this._host);
  3948. },
  3949. set: function (value) {
  3950. if (this._width.toString(this._host) === value) {
  3951. return;
  3952. }
  3953. if (this._width.fromString(value)) {
  3954. this._markAsDirty();
  3955. }
  3956. },
  3957. enumerable: true,
  3958. configurable: true
  3959. });
  3960. Object.defineProperty(Control.prototype, "widthInPixels", {
  3961. /**
  3962. * Gets or sets the control width in pixel
  3963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3964. */
  3965. get: function () {
  3966. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3967. },
  3968. set: function (value) {
  3969. if (isNaN(value)) {
  3970. return;
  3971. }
  3972. this.width = value + "px";
  3973. },
  3974. enumerable: true,
  3975. configurable: true
  3976. });
  3977. Object.defineProperty(Control.prototype, "height", {
  3978. /**
  3979. * Gets or sets control height
  3980. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3981. */
  3982. get: function () {
  3983. return this._height.toString(this._host);
  3984. },
  3985. set: function (value) {
  3986. if (this._height.toString(this._host) === value) {
  3987. return;
  3988. }
  3989. if (this._height.fromString(value)) {
  3990. this._markAsDirty();
  3991. }
  3992. },
  3993. enumerable: true,
  3994. configurable: true
  3995. });
  3996. Object.defineProperty(Control.prototype, "heightInPixels", {
  3997. /**
  3998. * Gets or sets control height in pixel
  3999. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4000. */
  4001. get: function () {
  4002. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4003. },
  4004. set: function (value) {
  4005. if (isNaN(value)) {
  4006. return;
  4007. }
  4008. this.height = value + "px";
  4009. },
  4010. enumerable: true,
  4011. configurable: true
  4012. });
  4013. Object.defineProperty(Control.prototype, "fontFamily", {
  4014. /** Gets or set font family */
  4015. get: function () {
  4016. if (!this._fontSet) {
  4017. return "";
  4018. }
  4019. return this._fontFamily;
  4020. },
  4021. set: function (value) {
  4022. if (this._fontFamily === value) {
  4023. return;
  4024. }
  4025. this._fontFamily = value;
  4026. this._resetFontCache();
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "fontStyle", {
  4032. /** Gets or sets font style */
  4033. get: function () {
  4034. return this._fontStyle;
  4035. },
  4036. set: function (value) {
  4037. if (this._fontStyle === value) {
  4038. return;
  4039. }
  4040. this._fontStyle = value;
  4041. this._resetFontCache();
  4042. },
  4043. enumerable: true,
  4044. configurable: true
  4045. });
  4046. Object.defineProperty(Control.prototype, "fontWeight", {
  4047. /** Gets or sets font weight */
  4048. get: function () {
  4049. return this._fontWeight;
  4050. },
  4051. set: function (value) {
  4052. if (this._fontWeight === value) {
  4053. return;
  4054. }
  4055. this._fontWeight = value;
  4056. this._resetFontCache();
  4057. },
  4058. enumerable: true,
  4059. configurable: true
  4060. });
  4061. Object.defineProperty(Control.prototype, "style", {
  4062. /**
  4063. * Gets or sets style
  4064. * @see http://doc.babylonjs.com/how_to/gui#styles
  4065. */
  4066. get: function () {
  4067. return this._style;
  4068. },
  4069. set: function (value) {
  4070. var _this = this;
  4071. if (this._style) {
  4072. this._style.onChangedObservable.remove(this._styleObserver);
  4073. this._styleObserver = null;
  4074. }
  4075. this._style = value;
  4076. if (this._style) {
  4077. this._styleObserver = this._style.onChangedObservable.add(function () {
  4078. _this._markAsDirty();
  4079. _this._resetFontCache();
  4080. });
  4081. }
  4082. this._markAsDirty();
  4083. this._resetFontCache();
  4084. },
  4085. enumerable: true,
  4086. configurable: true
  4087. });
  4088. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4089. /** @hidden */
  4090. get: function () {
  4091. return this._fontSize.isPercentage;
  4092. },
  4093. enumerable: true,
  4094. configurable: true
  4095. });
  4096. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4097. /** Gets or sets font size in pixels */
  4098. get: function () {
  4099. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4100. if (fontSizeToUse.isPixel) {
  4101. return fontSizeToUse.getValue(this._host);
  4102. }
  4103. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4104. },
  4105. set: function (value) {
  4106. if (isNaN(value)) {
  4107. return;
  4108. }
  4109. this.fontSize = value + "px";
  4110. },
  4111. enumerable: true,
  4112. configurable: true
  4113. });
  4114. Object.defineProperty(Control.prototype, "fontSize", {
  4115. /** Gets or sets font size */
  4116. get: function () {
  4117. return this._fontSize.toString(this._host);
  4118. },
  4119. set: function (value) {
  4120. if (this._fontSize.toString(this._host) === value) {
  4121. return;
  4122. }
  4123. if (this._fontSize.fromString(value)) {
  4124. this._markAsDirty();
  4125. this._resetFontCache();
  4126. }
  4127. },
  4128. enumerable: true,
  4129. configurable: true
  4130. });
  4131. Object.defineProperty(Control.prototype, "color", {
  4132. /** Gets or sets foreground color */
  4133. get: function () {
  4134. return this._color;
  4135. },
  4136. set: function (value) {
  4137. if (this._color === value) {
  4138. return;
  4139. }
  4140. this._color = value;
  4141. this._markAsDirty();
  4142. },
  4143. enumerable: true,
  4144. configurable: true
  4145. });
  4146. Object.defineProperty(Control.prototype, "zIndex", {
  4147. /** Gets or sets z index which is used to reorder controls on the z axis */
  4148. get: function () {
  4149. return this._zIndex;
  4150. },
  4151. set: function (value) {
  4152. if (this.zIndex === value) {
  4153. return;
  4154. }
  4155. this._zIndex = value;
  4156. if (this.parent) {
  4157. this.parent._reOrderControl(this);
  4158. }
  4159. },
  4160. enumerable: true,
  4161. configurable: true
  4162. });
  4163. Object.defineProperty(Control.prototype, "notRenderable", {
  4164. /** Gets or sets a boolean indicating if the control can be rendered */
  4165. get: function () {
  4166. return this._doNotRender;
  4167. },
  4168. set: function (value) {
  4169. if (this._doNotRender === value) {
  4170. return;
  4171. }
  4172. this._doNotRender = value;
  4173. this._markAsDirty();
  4174. },
  4175. enumerable: true,
  4176. configurable: true
  4177. });
  4178. Object.defineProperty(Control.prototype, "isVisible", {
  4179. /** Gets or sets a boolean indicating if the control is visible */
  4180. get: function () {
  4181. return this._isVisible;
  4182. },
  4183. set: function (value) {
  4184. if (this._isVisible === value) {
  4185. return;
  4186. }
  4187. this._isVisible = value;
  4188. this._markAsDirty(true);
  4189. },
  4190. enumerable: true,
  4191. configurable: true
  4192. });
  4193. Object.defineProperty(Control.prototype, "isDirty", {
  4194. /** Gets a boolean indicating that the control needs to update its rendering */
  4195. get: function () {
  4196. return this._isDirty;
  4197. },
  4198. enumerable: true,
  4199. configurable: true
  4200. });
  4201. Object.defineProperty(Control.prototype, "linkedMesh", {
  4202. /**
  4203. * Gets the current linked mesh (or null if none)
  4204. */
  4205. get: function () {
  4206. return this._linkedMesh;
  4207. },
  4208. enumerable: true,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "paddingLeft", {
  4212. /**
  4213. * Gets or sets a value indicating the padding to use on the left of the control
  4214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4215. */
  4216. get: function () {
  4217. return this._paddingLeft.toString(this._host);
  4218. },
  4219. set: function (value) {
  4220. if (this._paddingLeft.fromString(value)) {
  4221. this._markAsDirty();
  4222. }
  4223. },
  4224. enumerable: true,
  4225. configurable: true
  4226. });
  4227. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4228. /**
  4229. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4230. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4231. */
  4232. get: function () {
  4233. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4234. },
  4235. set: function (value) {
  4236. if (isNaN(value)) {
  4237. return;
  4238. }
  4239. this.paddingLeft = value + "px";
  4240. },
  4241. enumerable: true,
  4242. configurable: true
  4243. });
  4244. Object.defineProperty(Control.prototype, "paddingRight", {
  4245. /**
  4246. * Gets or sets a value indicating the padding to use on the right of the control
  4247. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4248. */
  4249. get: function () {
  4250. return this._paddingRight.toString(this._host);
  4251. },
  4252. set: function (value) {
  4253. if (this._paddingRight.fromString(value)) {
  4254. this._markAsDirty();
  4255. }
  4256. },
  4257. enumerable: true,
  4258. configurable: true
  4259. });
  4260. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4261. /**
  4262. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4263. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4264. */
  4265. get: function () {
  4266. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4267. },
  4268. set: function (value) {
  4269. if (isNaN(value)) {
  4270. return;
  4271. }
  4272. this.paddingRight = value + "px";
  4273. },
  4274. enumerable: true,
  4275. configurable: true
  4276. });
  4277. Object.defineProperty(Control.prototype, "paddingTop", {
  4278. /**
  4279. * Gets or sets a value indicating the padding to use on the top of the control
  4280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4281. */
  4282. get: function () {
  4283. return this._paddingTop.toString(this._host);
  4284. },
  4285. set: function (value) {
  4286. if (this._paddingTop.fromString(value)) {
  4287. this._markAsDirty();
  4288. }
  4289. },
  4290. enumerable: true,
  4291. configurable: true
  4292. });
  4293. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4294. /**
  4295. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4296. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4297. */
  4298. get: function () {
  4299. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4300. },
  4301. set: function (value) {
  4302. if (isNaN(value)) {
  4303. return;
  4304. }
  4305. this.paddingTop = value + "px";
  4306. },
  4307. enumerable: true,
  4308. configurable: true
  4309. });
  4310. Object.defineProperty(Control.prototype, "paddingBottom", {
  4311. /**
  4312. * Gets or sets a value indicating the padding to use on the bottom of the control
  4313. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4314. */
  4315. get: function () {
  4316. return this._paddingBottom.toString(this._host);
  4317. },
  4318. set: function (value) {
  4319. if (this._paddingBottom.fromString(value)) {
  4320. this._markAsDirty();
  4321. }
  4322. },
  4323. enumerable: true,
  4324. configurable: true
  4325. });
  4326. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4327. /**
  4328. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4329. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4330. */
  4331. get: function () {
  4332. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4333. },
  4334. set: function (value) {
  4335. if (isNaN(value)) {
  4336. return;
  4337. }
  4338. this.paddingBottom = value + "px";
  4339. },
  4340. enumerable: true,
  4341. configurable: true
  4342. });
  4343. Object.defineProperty(Control.prototype, "left", {
  4344. /**
  4345. * Gets or sets a value indicating the left coordinate of the control
  4346. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4347. */
  4348. get: function () {
  4349. return this._left.toString(this._host);
  4350. },
  4351. set: function (value) {
  4352. if (this._left.fromString(value)) {
  4353. this._markAsDirty();
  4354. }
  4355. },
  4356. enumerable: true,
  4357. configurable: true
  4358. });
  4359. Object.defineProperty(Control.prototype, "leftInPixels", {
  4360. /**
  4361. * Gets or sets a value indicating the left coordinate in pixels of the control
  4362. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4363. */
  4364. get: function () {
  4365. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4366. },
  4367. set: function (value) {
  4368. if (isNaN(value)) {
  4369. return;
  4370. }
  4371. this.left = value + "px";
  4372. },
  4373. enumerable: true,
  4374. configurable: true
  4375. });
  4376. Object.defineProperty(Control.prototype, "top", {
  4377. /**
  4378. * Gets or sets a value indicating the top coordinate of the control
  4379. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4380. */
  4381. get: function () {
  4382. return this._top.toString(this._host);
  4383. },
  4384. set: function (value) {
  4385. if (this._top.fromString(value)) {
  4386. this._markAsDirty();
  4387. }
  4388. },
  4389. enumerable: true,
  4390. configurable: true
  4391. });
  4392. Object.defineProperty(Control.prototype, "topInPixels", {
  4393. /**
  4394. * Gets or sets a value indicating the top coordinate in pixels of the control
  4395. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4396. */
  4397. get: function () {
  4398. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4399. },
  4400. set: function (value) {
  4401. if (isNaN(value)) {
  4402. return;
  4403. }
  4404. this.top = value + "px";
  4405. },
  4406. enumerable: true,
  4407. configurable: true
  4408. });
  4409. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4410. /**
  4411. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4412. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4413. */
  4414. get: function () {
  4415. return this._linkOffsetX.toString(this._host);
  4416. },
  4417. set: function (value) {
  4418. if (this._linkOffsetX.fromString(value)) {
  4419. this._markAsDirty();
  4420. }
  4421. },
  4422. enumerable: true,
  4423. configurable: true
  4424. });
  4425. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4426. /**
  4427. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4428. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4429. */
  4430. get: function () {
  4431. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4432. },
  4433. set: function (value) {
  4434. if (isNaN(value)) {
  4435. return;
  4436. }
  4437. this.linkOffsetX = value + "px";
  4438. },
  4439. enumerable: true,
  4440. configurable: true
  4441. });
  4442. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4443. /**
  4444. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4445. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4446. */
  4447. get: function () {
  4448. return this._linkOffsetY.toString(this._host);
  4449. },
  4450. set: function (value) {
  4451. if (this._linkOffsetY.fromString(value)) {
  4452. this._markAsDirty();
  4453. }
  4454. },
  4455. enumerable: true,
  4456. configurable: true
  4457. });
  4458. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4459. /**
  4460. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4461. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4462. */
  4463. get: function () {
  4464. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4465. },
  4466. set: function (value) {
  4467. if (isNaN(value)) {
  4468. return;
  4469. }
  4470. this.linkOffsetY = value + "px";
  4471. },
  4472. enumerable: true,
  4473. configurable: true
  4474. });
  4475. Object.defineProperty(Control.prototype, "centerX", {
  4476. /** Gets the center coordinate on X axis */
  4477. get: function () {
  4478. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4479. },
  4480. enumerable: true,
  4481. configurable: true
  4482. });
  4483. Object.defineProperty(Control.prototype, "centerY", {
  4484. /** Gets the center coordinate on Y axis */
  4485. get: function () {
  4486. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4487. },
  4488. enumerable: true,
  4489. configurable: true
  4490. });
  4491. Object.defineProperty(Control.prototype, "isEnabled", {
  4492. /** Gets or sets if control is Enabled*/
  4493. get: function () {
  4494. return this._isEnabled;
  4495. },
  4496. set: function (value) {
  4497. if (this._isEnabled === value) {
  4498. return;
  4499. }
  4500. this._isEnabled = value;
  4501. this._markAsDirty();
  4502. },
  4503. enumerable: true,
  4504. configurable: true
  4505. });
  4506. Object.defineProperty(Control.prototype, "disabledColor", {
  4507. /** Gets or sets background color of control if it's disabled*/
  4508. get: function () {
  4509. return this._disabledColor;
  4510. },
  4511. set: function (value) {
  4512. if (this._disabledColor === value) {
  4513. return;
  4514. }
  4515. this._disabledColor = value;
  4516. this._markAsDirty();
  4517. },
  4518. enumerable: true,
  4519. configurable: true
  4520. });
  4521. /** @hidden */
  4522. Control.prototype._getTypeName = function () {
  4523. return "Control";
  4524. };
  4525. /**
  4526. * Gets the first ascendant in the hierarchy of the given type
  4527. * @param className defines the required type
  4528. * @returns the ascendant or null if not found
  4529. */
  4530. Control.prototype.getAscendantOfClass = function (className) {
  4531. if (!this.parent) {
  4532. return null;
  4533. }
  4534. if (this.parent.getClassName() === className) {
  4535. return this.parent;
  4536. }
  4537. return this.parent.getAscendantOfClass(className);
  4538. };
  4539. /** @hidden */
  4540. Control.prototype._resetFontCache = function () {
  4541. this._fontSet = true;
  4542. this._markAsDirty();
  4543. };
  4544. /**
  4545. * Determines if a container is an ascendant of the current control
  4546. * @param container defines the container to look for
  4547. * @returns true if the container is one of the ascendant of the control
  4548. */
  4549. Control.prototype.isAscendant = function (container) {
  4550. if (!this.parent) {
  4551. return false;
  4552. }
  4553. if (this.parent === container) {
  4554. return true;
  4555. }
  4556. return this.parent.isAscendant(container);
  4557. };
  4558. /**
  4559. * Gets coordinates in local control space
  4560. * @param globalCoordinates defines the coordinates to transform
  4561. * @returns the new coordinates in local space
  4562. */
  4563. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4564. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4565. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4566. return result;
  4567. };
  4568. /**
  4569. * Gets coordinates in local control space
  4570. * @param globalCoordinates defines the coordinates to transform
  4571. * @param result defines the target vector2 where to store the result
  4572. * @returns the current control
  4573. */
  4574. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4575. result.x = globalCoordinates.x - this._currentMeasure.left;
  4576. result.y = globalCoordinates.y - this._currentMeasure.top;
  4577. return this;
  4578. };
  4579. /**
  4580. * Gets coordinates in parent local control space
  4581. * @param globalCoordinates defines the coordinates to transform
  4582. * @returns the new coordinates in parent local space
  4583. */
  4584. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4585. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4586. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4587. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4588. return result;
  4589. };
  4590. /**
  4591. * Move the current control to a vector3 position projected onto the screen.
  4592. * @param position defines the target position
  4593. * @param scene defines the hosting scene
  4594. */
  4595. Control.prototype.moveToVector3 = function (position, scene) {
  4596. if (!this._host || this.parent !== this._host._rootContainer) {
  4597. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4598. return;
  4599. }
  4600. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4601. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4602. var globalViewport = this._host._getGlobalViewport(scene);
  4603. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4604. this._moveToProjectedPosition(projectedPosition);
  4605. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4606. this.notRenderable = true;
  4607. return;
  4608. }
  4609. this.notRenderable = false;
  4610. };
  4611. /** @hidden */
  4612. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4613. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4614. // Do nothing by default
  4615. };
  4616. /**
  4617. * Will return all controls that have this control as ascendant
  4618. * @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
  4619. * @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
  4620. * @return all child controls
  4621. */
  4622. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4623. var results = new Array();
  4624. this._getDescendants(results, directDescendantsOnly, predicate);
  4625. return results;
  4626. };
  4627. /**
  4628. * Link current control with a target mesh
  4629. * @param mesh defines the mesh to link with
  4630. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4631. */
  4632. Control.prototype.linkWithMesh = function (mesh) {
  4633. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4634. if (mesh) {
  4635. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4636. }
  4637. return;
  4638. }
  4639. var index = this._host._linkedControls.indexOf(this);
  4640. if (index !== -1) {
  4641. this._linkedMesh = mesh;
  4642. if (!mesh) {
  4643. this._host._linkedControls.splice(index, 1);
  4644. }
  4645. return;
  4646. }
  4647. else if (!mesh) {
  4648. return;
  4649. }
  4650. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4651. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4652. this._linkedMesh = mesh;
  4653. this._host._linkedControls.push(this);
  4654. };
  4655. /** @hidden */
  4656. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4657. var oldLeft = this._left.getValue(this._host);
  4658. var oldTop = this._top.getValue(this._host);
  4659. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4660. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4661. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4662. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4663. newLeft = oldLeft;
  4664. }
  4665. if (Math.abs(newTop - oldTop) < 0.5) {
  4666. newTop = oldTop;
  4667. }
  4668. }
  4669. this.left = newLeft + "px";
  4670. this.top = newTop + "px";
  4671. this._left.ignoreAdaptiveScaling = true;
  4672. this._top.ignoreAdaptiveScaling = true;
  4673. this._markAsDirty();
  4674. };
  4675. /** @hidden */
  4676. Control.prototype._offsetLeft = function (offset) {
  4677. this._isDirty = true;
  4678. this._currentMeasure.left += offset;
  4679. };
  4680. /** @hidden */
  4681. Control.prototype._offsetTop = function (offset) {
  4682. this._isDirty = true;
  4683. this._currentMeasure.top += offset;
  4684. };
  4685. /** @hidden */
  4686. Control.prototype._markMatrixAsDirty = function () {
  4687. this._isMatrixDirty = true;
  4688. this._flagDescendantsAsMatrixDirty();
  4689. };
  4690. /** @hidden */
  4691. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4692. // No child
  4693. };
  4694. /** @hidden */
  4695. Control.prototype._intersectsRect = function (rect) {
  4696. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4697. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4698. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4699. return false;
  4700. }
  4701. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4702. return false;
  4703. }
  4704. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4708. return false;
  4709. }
  4710. return true;
  4711. };
  4712. /** @hidden */
  4713. Control.prototype.invalidateRect = function () {
  4714. this._transform();
  4715. if (this.host && this.host.useInvalidateRectOptimization) {
  4716. // Rotate by transform to get the measure transformed to global space
  4717. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4718. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4719. // the previous measure is used to properly clear a control that is scaled down
  4720. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4721. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4722. // Expand rect based on shadows
  4723. var shadowOffsetX = this.shadowOffsetX;
  4724. var shadowOffsetY = this.shadowOffsetY;
  4725. var shadowBlur = this.shadowBlur;
  4726. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4727. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4728. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4729. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4730. 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));
  4731. }
  4732. else {
  4733. 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));
  4734. }
  4735. }
  4736. };
  4737. /** @hidden */
  4738. Control.prototype._markAsDirty = function (force) {
  4739. if (force === void 0) { force = false; }
  4740. if (!this._isVisible && !force) {
  4741. return;
  4742. }
  4743. this._isDirty = true;
  4744. // Redraw only this rectangle
  4745. if (this._host) {
  4746. this._host.markAsDirty();
  4747. }
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._markAllAsDirty = function () {
  4751. this._markAsDirty();
  4752. if (this._font) {
  4753. this._prepareFont();
  4754. }
  4755. };
  4756. /** @hidden */
  4757. Control.prototype._link = function (host) {
  4758. this._host = host;
  4759. if (this._host) {
  4760. this.uniqueId = this._host.getScene().getUniqueId();
  4761. }
  4762. };
  4763. /** @hidden */
  4764. Control.prototype._transform = function (context) {
  4765. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4766. return;
  4767. }
  4768. // postTranslate
  4769. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4770. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4771. if (context) {
  4772. context.translate(offsetX, offsetY);
  4773. // rotate
  4774. context.rotate(this._rotation);
  4775. // scale
  4776. context.scale(this._scaleX, this._scaleY);
  4777. // preTranslate
  4778. context.translate(-offsetX, -offsetY);
  4779. }
  4780. // Need to update matrices?
  4781. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4782. this._cachedOffsetX = offsetX;
  4783. this._cachedOffsetY = offsetY;
  4784. this._isMatrixDirty = false;
  4785. this._flagDescendantsAsMatrixDirty();
  4786. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4787. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4788. }
  4789. };
  4790. /** @hidden */
  4791. Control.prototype._renderHighlight = function (context) {
  4792. if (!this.isHighlighted) {
  4793. return;
  4794. }
  4795. context.save();
  4796. context.strokeStyle = "#4affff";
  4797. context.lineWidth = 2;
  4798. this._renderHighlightSpecific(context);
  4799. context.restore();
  4800. };
  4801. /** @hidden */
  4802. Control.prototype._renderHighlightSpecific = function (context) {
  4803. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4804. };
  4805. /** @hidden */
  4806. Control.prototype._applyStates = function (context) {
  4807. if (this._isFontSizeInPercentage) {
  4808. this._fontSet = true;
  4809. }
  4810. if (this._fontSet) {
  4811. this._prepareFont();
  4812. this._fontSet = false;
  4813. }
  4814. if (this._font) {
  4815. context.font = this._font;
  4816. }
  4817. if (this._color) {
  4818. context.fillStyle = this._color;
  4819. }
  4820. if (Control.AllowAlphaInheritance) {
  4821. context.globalAlpha *= this._alpha;
  4822. }
  4823. else if (this._alphaSet) {
  4824. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4825. }
  4826. };
  4827. /** @hidden */
  4828. Control.prototype._layout = function (parentMeasure, context) {
  4829. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4830. return false;
  4831. }
  4832. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4833. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4834. context.save();
  4835. this._applyStates(context);
  4836. var rebuildCount = 0;
  4837. do {
  4838. this._rebuildLayout = false;
  4839. this._processMeasures(parentMeasure, context);
  4840. rebuildCount++;
  4841. } while (this._rebuildLayout && rebuildCount < 3);
  4842. if (rebuildCount >= 3) {
  4843. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4844. }
  4845. context.restore();
  4846. this.invalidateRect();
  4847. this._evaluateClippingState(parentMeasure);
  4848. }
  4849. this._wasDirty = this._isDirty;
  4850. this._isDirty = false;
  4851. return true;
  4852. };
  4853. /** @hidden */
  4854. Control.prototype._processMeasures = function (parentMeasure, context) {
  4855. this._currentMeasure.copyFrom(parentMeasure);
  4856. // Let children take some pre-measurement actions
  4857. this._preMeasure(parentMeasure, context);
  4858. this._measure();
  4859. this._computeAlignment(parentMeasure, context);
  4860. // Convert to int values
  4861. this._currentMeasure.left = this._currentMeasure.left | 0;
  4862. this._currentMeasure.top = this._currentMeasure.top | 0;
  4863. this._currentMeasure.width = this._currentMeasure.width | 0;
  4864. this._currentMeasure.height = this._currentMeasure.height | 0;
  4865. // Let children add more features
  4866. this._additionalProcessing(parentMeasure, context);
  4867. this._cachedParentMeasure.copyFrom(parentMeasure);
  4868. if (this.onDirtyObservable.hasObservers()) {
  4869. this.onDirtyObservable.notifyObservers(this);
  4870. }
  4871. };
  4872. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4873. if (this.parent && this.parent.clipChildren) {
  4874. // Early clip
  4875. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4876. this._isClipped = true;
  4877. return;
  4878. }
  4879. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4880. this._isClipped = true;
  4881. return;
  4882. }
  4883. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4884. this._isClipped = true;
  4885. return;
  4886. }
  4887. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4888. this._isClipped = true;
  4889. return;
  4890. }
  4891. }
  4892. this._isClipped = false;
  4893. };
  4894. /** @hidden */
  4895. Control.prototype._measure = function () {
  4896. // Width / Height
  4897. if (this._width.isPixel) {
  4898. this._currentMeasure.width = this._width.getValue(this._host);
  4899. }
  4900. else {
  4901. this._currentMeasure.width *= this._width.getValue(this._host);
  4902. }
  4903. if (this._height.isPixel) {
  4904. this._currentMeasure.height = this._height.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.height *= this._height.getValue(this._host);
  4908. }
  4909. };
  4910. /** @hidden */
  4911. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4912. var width = this._currentMeasure.width;
  4913. var height = this._currentMeasure.height;
  4914. var parentWidth = parentMeasure.width;
  4915. var parentHeight = parentMeasure.height;
  4916. // Left / top
  4917. var x = 0;
  4918. var y = 0;
  4919. switch (this.horizontalAlignment) {
  4920. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4921. x = 0;
  4922. break;
  4923. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4924. x = parentWidth - width;
  4925. break;
  4926. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4927. x = (parentWidth - width) / 2;
  4928. break;
  4929. }
  4930. switch (this.verticalAlignment) {
  4931. case Control.VERTICAL_ALIGNMENT_TOP:
  4932. y = 0;
  4933. break;
  4934. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4935. y = parentHeight - height;
  4936. break;
  4937. case Control.VERTICAL_ALIGNMENT_CENTER:
  4938. y = (parentHeight - height) / 2;
  4939. break;
  4940. }
  4941. if (this._paddingLeft.isPixel) {
  4942. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4943. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4944. }
  4945. else {
  4946. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4947. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4948. }
  4949. if (this._paddingRight.isPixel) {
  4950. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4951. }
  4952. else {
  4953. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4954. }
  4955. if (this._paddingTop.isPixel) {
  4956. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4957. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4958. }
  4959. else {
  4960. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4961. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4962. }
  4963. if (this._paddingBottom.isPixel) {
  4964. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4968. }
  4969. if (this._left.isPixel) {
  4970. this._currentMeasure.left += this._left.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4974. }
  4975. if (this._top.isPixel) {
  4976. this._currentMeasure.top += this._top.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4980. }
  4981. this._currentMeasure.left += x;
  4982. this._currentMeasure.top += y;
  4983. };
  4984. /** @hidden */
  4985. Control.prototype._preMeasure = function (parentMeasure, context) {
  4986. // Do nothing
  4987. };
  4988. /** @hidden */
  4989. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4990. // Do nothing
  4991. };
  4992. /** @hidden */
  4993. Control.prototype._clipForChildren = function (context) {
  4994. // DO nothing
  4995. };
  4996. Control.prototype._clip = function (context, invalidatedRectangle) {
  4997. context.beginPath();
  4998. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4999. if (invalidatedRectangle) {
  5000. // Rotate the invalidated rect into the control's space
  5001. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5002. // Get the intersection of the rect in context space and the current context
  5003. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5004. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5005. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5006. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5007. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5008. Control._ClipMeasure.copyFrom(intersection);
  5009. }
  5010. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5011. var shadowOffsetX = this.shadowOffsetX;
  5012. var shadowOffsetY = this.shadowOffsetY;
  5013. var shadowBlur = this.shadowBlur;
  5014. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5015. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5016. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5017. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5018. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5019. }
  5020. else {
  5021. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5022. }
  5023. context.clip();
  5024. };
  5025. /** @hidden */
  5026. Control.prototype._render = function (context, invalidatedRectangle) {
  5027. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5028. this._isDirty = false;
  5029. return false;
  5030. }
  5031. context.save();
  5032. this._applyStates(context);
  5033. // Transform
  5034. this._transform(context);
  5035. // Clip
  5036. if (this.clipContent) {
  5037. this._clip(context, invalidatedRectangle);
  5038. }
  5039. if (this.onBeforeDrawObservable.hasObservers()) {
  5040. this.onBeforeDrawObservable.notifyObservers(this);
  5041. }
  5042. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5043. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5044. }
  5045. else {
  5046. this._draw(context, invalidatedRectangle);
  5047. }
  5048. if (this.useBitmapCache && this._wasDirty) {
  5049. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5050. }
  5051. this._renderHighlight(context);
  5052. if (this.onAfterDrawObservable.hasObservers()) {
  5053. this.onAfterDrawObservable.notifyObservers(this);
  5054. }
  5055. context.restore();
  5056. return true;
  5057. };
  5058. /** @hidden */
  5059. Control.prototype._draw = function (context, invalidatedRectangle) {
  5060. // Do nothing
  5061. };
  5062. /**
  5063. * Tests if a given coordinates belong to the current control
  5064. * @param x defines x coordinate to test
  5065. * @param y defines y coordinate to test
  5066. * @returns true if the coordinates are inside the control
  5067. */
  5068. Control.prototype.contains = function (x, y) {
  5069. // Invert transform
  5070. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5071. x = this._transformedPosition.x;
  5072. y = this._transformedPosition.y;
  5073. // Check
  5074. if (x < this._currentMeasure.left) {
  5075. return false;
  5076. }
  5077. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5078. return false;
  5079. }
  5080. if (y < this._currentMeasure.top) {
  5081. return false;
  5082. }
  5083. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5084. return false;
  5085. }
  5086. if (this.isPointerBlocker) {
  5087. this._host._shouldBlockPointer = true;
  5088. }
  5089. return true;
  5090. };
  5091. /** @hidden */
  5092. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5093. if (!this._isEnabled) {
  5094. return false;
  5095. }
  5096. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5097. return false;
  5098. }
  5099. if (!this.contains(x, y)) {
  5100. return false;
  5101. }
  5102. this._processObservables(type, x, y, pointerId, buttonIndex);
  5103. return true;
  5104. };
  5105. /** @hidden */
  5106. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5107. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5108. if (canNotify && this.parent != null) {
  5109. this.parent._onPointerMove(target, coordinates, pointerId);
  5110. }
  5111. };
  5112. /** @hidden */
  5113. Control.prototype._onPointerEnter = function (target) {
  5114. if (!this._isEnabled) {
  5115. return false;
  5116. }
  5117. if (this._enterCount > 0) {
  5118. return false;
  5119. }
  5120. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5121. this._enterCount = 0;
  5122. }
  5123. this._enterCount++;
  5124. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5125. if (canNotify && this.parent != null) {
  5126. this.parent._onPointerEnter(target);
  5127. }
  5128. return true;
  5129. };
  5130. /** @hidden */
  5131. Control.prototype._onPointerOut = function (target, force) {
  5132. if (force === void 0) { force = false; }
  5133. if (!force && (!this._isEnabled || target === this)) {
  5134. return;
  5135. }
  5136. this._enterCount = 0;
  5137. var canNotify = true;
  5138. if (!target.isAscendant(this)) {
  5139. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5140. }
  5141. if (canNotify && this.parent != null) {
  5142. this.parent._onPointerOut(target, force);
  5143. }
  5144. };
  5145. /** @hidden */
  5146. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5147. // Prevent pointerout to lose control context.
  5148. // Event redundancy is checked inside the function.
  5149. this._onPointerEnter(this);
  5150. if (this._downCount !== 0) {
  5151. return false;
  5152. }
  5153. this._downCount++;
  5154. this._downPointerIds[pointerId] = true;
  5155. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5156. if (canNotify && this.parent != null) {
  5157. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5158. }
  5159. return true;
  5160. };
  5161. /** @hidden */
  5162. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5163. if (!this._isEnabled) {
  5164. return;
  5165. }
  5166. this._downCount = 0;
  5167. delete this._downPointerIds[pointerId];
  5168. var canNotifyClick = notifyClick;
  5169. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5170. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5171. }
  5172. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5173. if (canNotify && this.parent != null) {
  5174. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5175. }
  5176. };
  5177. /** @hidden */
  5178. Control.prototype._forcePointerUp = function (pointerId) {
  5179. if (pointerId === void 0) { pointerId = null; }
  5180. if (pointerId !== null) {
  5181. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5182. }
  5183. else {
  5184. for (var key in this._downPointerIds) {
  5185. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5186. }
  5187. }
  5188. };
  5189. /** @hidden */
  5190. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5191. if (!this._isEnabled) {
  5192. return false;
  5193. }
  5194. this._dummyVector2.copyFromFloats(x, y);
  5195. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5196. this._onPointerMove(this, this._dummyVector2, pointerId);
  5197. var previousControlOver = this._host._lastControlOver[pointerId];
  5198. if (previousControlOver && previousControlOver !== this) {
  5199. previousControlOver._onPointerOut(this);
  5200. }
  5201. if (previousControlOver !== this) {
  5202. this._onPointerEnter(this);
  5203. }
  5204. this._host._lastControlOver[pointerId] = this;
  5205. return true;
  5206. }
  5207. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5208. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5209. this._host._registerLastControlDown(this, pointerId);
  5210. this._host._lastPickedControl = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5214. if (this._host._lastControlDown[pointerId]) {
  5215. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5216. }
  5217. delete this._host._lastControlDown[pointerId];
  5218. return true;
  5219. }
  5220. return false;
  5221. };
  5222. Control.prototype._prepareFont = function () {
  5223. if (!this._font && !this._fontSet) {
  5224. return;
  5225. }
  5226. if (this._style) {
  5227. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5228. }
  5229. else {
  5230. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5231. }
  5232. this._fontOffset = Control._GetFontOffset(this._font);
  5233. };
  5234. /** Releases associated resources */
  5235. Control.prototype.dispose = function () {
  5236. this.onDirtyObservable.clear();
  5237. this.onBeforeDrawObservable.clear();
  5238. this.onAfterDrawObservable.clear();
  5239. this.onPointerDownObservable.clear();
  5240. this.onPointerEnterObservable.clear();
  5241. this.onPointerMoveObservable.clear();
  5242. this.onPointerOutObservable.clear();
  5243. this.onPointerUpObservable.clear();
  5244. this.onPointerClickObservable.clear();
  5245. if (this._styleObserver && this._style) {
  5246. this._style.onChangedObservable.remove(this._styleObserver);
  5247. this._styleObserver = null;
  5248. }
  5249. if (this.parent) {
  5250. this.parent.removeControl(this);
  5251. this.parent = null;
  5252. }
  5253. if (this._host) {
  5254. var index = this._host._linkedControls.indexOf(this);
  5255. if (index > -1) {
  5256. this.linkWithMesh(null);
  5257. }
  5258. }
  5259. };
  5260. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5261. /** HORIZONTAL_ALIGNMENT_LEFT */
  5262. get: function () {
  5263. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5264. },
  5265. enumerable: true,
  5266. configurable: true
  5267. });
  5268. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5269. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5270. get: function () {
  5271. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5272. },
  5273. enumerable: true,
  5274. configurable: true
  5275. });
  5276. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5277. /** HORIZONTAL_ALIGNMENT_CENTER */
  5278. get: function () {
  5279. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5280. },
  5281. enumerable: true,
  5282. configurable: true
  5283. });
  5284. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5285. /** VERTICAL_ALIGNMENT_TOP */
  5286. get: function () {
  5287. return Control._VERTICAL_ALIGNMENT_TOP;
  5288. },
  5289. enumerable: true,
  5290. configurable: true
  5291. });
  5292. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5293. /** VERTICAL_ALIGNMENT_BOTTOM */
  5294. get: function () {
  5295. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5296. },
  5297. enumerable: true,
  5298. configurable: true
  5299. });
  5300. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5301. /** VERTICAL_ALIGNMENT_CENTER */
  5302. get: function () {
  5303. return Control._VERTICAL_ALIGNMENT_CENTER;
  5304. },
  5305. enumerable: true,
  5306. configurable: true
  5307. });
  5308. /** @hidden */
  5309. Control._GetFontOffset = function (font) {
  5310. if (Control._FontHeightSizes[font]) {
  5311. return Control._FontHeightSizes[font];
  5312. }
  5313. var text = document.createElement("span");
  5314. text.innerHTML = "Hg";
  5315. text.style.font = font;
  5316. var block = document.createElement("div");
  5317. block.style.display = "inline-block";
  5318. block.style.width = "1px";
  5319. block.style.height = "0px";
  5320. block.style.verticalAlign = "bottom";
  5321. var div = document.createElement("div");
  5322. div.appendChild(text);
  5323. div.appendChild(block);
  5324. document.body.appendChild(div);
  5325. var fontAscent = 0;
  5326. var fontHeight = 0;
  5327. try {
  5328. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5329. block.style.verticalAlign = "baseline";
  5330. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5331. }
  5332. finally {
  5333. document.body.removeChild(div);
  5334. }
  5335. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5336. Control._FontHeightSizes[font] = result;
  5337. return result;
  5338. };
  5339. /** @hidden */
  5340. Control.drawEllipse = function (x, y, width, height, context) {
  5341. context.translate(x, y);
  5342. context.scale(width, height);
  5343. context.beginPath();
  5344. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5345. context.closePath();
  5346. context.scale(1 / width, 1 / height);
  5347. context.translate(-x, -y);
  5348. };
  5349. /**
  5350. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5351. */
  5352. Control.AllowAlphaInheritance = false;
  5353. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5354. // Statics
  5355. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5356. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5357. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5358. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5359. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5360. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5361. Control._FontHeightSizes = {};
  5362. /**
  5363. * Creates a stack panel that can be used to render headers
  5364. * @param control defines the control to associate with the header
  5365. * @param text defines the text of the header
  5366. * @param size defines the size of the header
  5367. * @param options defines options used to configure the header
  5368. * @returns a new StackPanel
  5369. * @ignore
  5370. * @hidden
  5371. */
  5372. Control.AddHeader = function () { };
  5373. return Control;
  5374. }());
  5375. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5376. /***/ }),
  5377. /***/ "./2D/controls/displayGrid.ts":
  5378. /*!************************************!*\
  5379. !*** ./2D/controls/displayGrid.ts ***!
  5380. \************************************/
  5381. /*! exports provided: DisplayGrid */
  5382. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5383. "use strict";
  5384. __webpack_require__.r(__webpack_exports__);
  5385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5387. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5388. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5389. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5390. /** Class used to render a grid */
  5391. var DisplayGrid = /** @class */ (function (_super) {
  5392. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5393. /**
  5394. * Creates a new GridDisplayRectangle
  5395. * @param name defines the control name
  5396. */
  5397. function DisplayGrid(name) {
  5398. var _this = _super.call(this, name) || this;
  5399. _this.name = name;
  5400. _this._cellWidth = 20;
  5401. _this._cellHeight = 20;
  5402. _this._minorLineTickness = 1;
  5403. _this._minorLineColor = "DarkGray";
  5404. _this._majorLineTickness = 2;
  5405. _this._majorLineColor = "White";
  5406. _this._majorLineFrequency = 5;
  5407. _this._background = "Black";
  5408. _this._displayMajorLines = true;
  5409. _this._displayMinorLines = true;
  5410. return _this;
  5411. }
  5412. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5413. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5414. get: function () {
  5415. return this._displayMinorLines;
  5416. },
  5417. set: function (value) {
  5418. if (this._displayMinorLines === value) {
  5419. return;
  5420. }
  5421. this._displayMinorLines = value;
  5422. this._markAsDirty();
  5423. },
  5424. enumerable: true,
  5425. configurable: true
  5426. });
  5427. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5428. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5429. get: function () {
  5430. return this._displayMajorLines;
  5431. },
  5432. set: function (value) {
  5433. if (this._displayMajorLines === value) {
  5434. return;
  5435. }
  5436. this._displayMajorLines = value;
  5437. this._markAsDirty();
  5438. },
  5439. enumerable: true,
  5440. configurable: true
  5441. });
  5442. Object.defineProperty(DisplayGrid.prototype, "background", {
  5443. /** Gets or sets background color (Black by default) */
  5444. get: function () {
  5445. return this._background;
  5446. },
  5447. set: function (value) {
  5448. if (this._background === value) {
  5449. return;
  5450. }
  5451. this._background = value;
  5452. this._markAsDirty();
  5453. },
  5454. enumerable: true,
  5455. configurable: true
  5456. });
  5457. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5458. /** Gets or sets the width of each cell (20 by default) */
  5459. get: function () {
  5460. return this._cellWidth;
  5461. },
  5462. set: function (value) {
  5463. this._cellWidth = value;
  5464. this._markAsDirty();
  5465. },
  5466. enumerable: true,
  5467. configurable: true
  5468. });
  5469. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5470. /** Gets or sets the height of each cell (20 by default) */
  5471. get: function () {
  5472. return this._cellHeight;
  5473. },
  5474. set: function (value) {
  5475. this._cellHeight = value;
  5476. this._markAsDirty();
  5477. },
  5478. enumerable: true,
  5479. configurable: true
  5480. });
  5481. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5482. /** Gets or sets the tickness of minor lines (1 by default) */
  5483. get: function () {
  5484. return this._minorLineTickness;
  5485. },
  5486. set: function (value) {
  5487. this._minorLineTickness = value;
  5488. this._markAsDirty();
  5489. },
  5490. enumerable: true,
  5491. configurable: true
  5492. });
  5493. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5494. /** Gets or sets the color of minor lines (DarkGray by default) */
  5495. get: function () {
  5496. return this._minorLineColor;
  5497. },
  5498. set: function (value) {
  5499. this._minorLineColor = value;
  5500. this._markAsDirty();
  5501. },
  5502. enumerable: true,
  5503. configurable: true
  5504. });
  5505. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5506. /** Gets or sets the tickness of major lines (2 by default) */
  5507. get: function () {
  5508. return this._majorLineTickness;
  5509. },
  5510. set: function (value) {
  5511. this._majorLineTickness = value;
  5512. this._markAsDirty();
  5513. },
  5514. enumerable: true,
  5515. configurable: true
  5516. });
  5517. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5518. /** Gets or sets the color of major lines (White by default) */
  5519. get: function () {
  5520. return this._majorLineColor;
  5521. },
  5522. set: function (value) {
  5523. this._majorLineColor = value;
  5524. this._markAsDirty();
  5525. },
  5526. enumerable: true,
  5527. configurable: true
  5528. });
  5529. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5530. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5531. get: function () {
  5532. return this._majorLineFrequency;
  5533. },
  5534. set: function (value) {
  5535. this._majorLineFrequency = value;
  5536. this._markAsDirty();
  5537. },
  5538. enumerable: true,
  5539. configurable: true
  5540. });
  5541. DisplayGrid.prototype._draw = function (context) {
  5542. context.save();
  5543. this._applyStates(context);
  5544. if (this._isEnabled) {
  5545. if (this._background) {
  5546. context.fillStyle = this._background;
  5547. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5548. }
  5549. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5550. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5551. // Minor lines
  5552. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5553. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5554. if (this._displayMinorLines) {
  5555. context.strokeStyle = this._minorLineColor;
  5556. context.lineWidth = this._minorLineTickness;
  5557. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5558. var cellX = left + x * this.cellWidth;
  5559. context.beginPath();
  5560. context.moveTo(cellX, this._currentMeasure.top);
  5561. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5562. context.stroke();
  5563. }
  5564. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5565. var cellY = top_1 + y * this.cellHeight;
  5566. context.beginPath();
  5567. context.moveTo(this._currentMeasure.left, cellY);
  5568. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5569. context.stroke();
  5570. }
  5571. }
  5572. // Major lines
  5573. if (this._displayMajorLines) {
  5574. context.strokeStyle = this._majorLineColor;
  5575. context.lineWidth = this._majorLineTickness;
  5576. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5577. var cellX = left + x * this.cellWidth;
  5578. context.beginPath();
  5579. context.moveTo(cellX, this._currentMeasure.top);
  5580. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5581. context.stroke();
  5582. }
  5583. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5584. var cellY = top_1 + y * this.cellHeight;
  5585. context.moveTo(this._currentMeasure.left, cellY);
  5586. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5587. context.closePath();
  5588. context.stroke();
  5589. }
  5590. }
  5591. }
  5592. context.restore();
  5593. };
  5594. DisplayGrid.prototype._getTypeName = function () {
  5595. return "DisplayGrid";
  5596. };
  5597. return DisplayGrid;
  5598. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5599. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5600. /***/ }),
  5601. /***/ "./2D/controls/ellipse.ts":
  5602. /*!********************************!*\
  5603. !*** ./2D/controls/ellipse.ts ***!
  5604. \********************************/
  5605. /*! exports provided: Ellipse */
  5606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5607. "use strict";
  5608. __webpack_require__.r(__webpack_exports__);
  5609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5610. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5611. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5612. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5613. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5614. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5615. /** Class used to create 2D ellipse containers */
  5616. var Ellipse = /** @class */ (function (_super) {
  5617. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5618. /**
  5619. * Creates a new Ellipse
  5620. * @param name defines the control name
  5621. */
  5622. function Ellipse(name) {
  5623. var _this = _super.call(this, name) || this;
  5624. _this.name = name;
  5625. _this._thickness = 1;
  5626. return _this;
  5627. }
  5628. Object.defineProperty(Ellipse.prototype, "thickness", {
  5629. /** Gets or sets border thickness */
  5630. get: function () {
  5631. return this._thickness;
  5632. },
  5633. set: function (value) {
  5634. if (this._thickness === value) {
  5635. return;
  5636. }
  5637. this._thickness = value;
  5638. this._markAsDirty();
  5639. },
  5640. enumerable: true,
  5641. configurable: true
  5642. });
  5643. Ellipse.prototype._getTypeName = function () {
  5644. return "Ellipse";
  5645. };
  5646. Ellipse.prototype._localDraw = function (context) {
  5647. context.save();
  5648. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5649. context.shadowColor = this.shadowColor;
  5650. context.shadowBlur = this.shadowBlur;
  5651. context.shadowOffsetX = this.shadowOffsetX;
  5652. context.shadowOffsetY = this.shadowOffsetY;
  5653. }
  5654. _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);
  5655. if (this._background) {
  5656. context.fillStyle = this._background;
  5657. context.fill();
  5658. }
  5659. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5660. context.shadowBlur = 0;
  5661. context.shadowOffsetX = 0;
  5662. context.shadowOffsetY = 0;
  5663. }
  5664. if (this._thickness) {
  5665. if (this.color) {
  5666. context.strokeStyle = this.color;
  5667. }
  5668. context.lineWidth = this._thickness;
  5669. context.stroke();
  5670. }
  5671. context.restore();
  5672. };
  5673. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5674. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5675. this._measureForChildren.width -= 2 * this._thickness;
  5676. this._measureForChildren.height -= 2 * this._thickness;
  5677. this._measureForChildren.left += this._thickness;
  5678. this._measureForChildren.top += this._thickness;
  5679. };
  5680. Ellipse.prototype._clipForChildren = function (context) {
  5681. _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);
  5682. context.clip();
  5683. };
  5684. return Ellipse;
  5685. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5686. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5687. /***/ }),
  5688. /***/ "./2D/controls/grid.ts":
  5689. /*!*****************************!*\
  5690. !*** ./2D/controls/grid.ts ***!
  5691. \*****************************/
  5692. /*! exports provided: Grid */
  5693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5694. "use strict";
  5695. __webpack_require__.r(__webpack_exports__);
  5696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5698. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5699. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5700. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5701. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5702. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5703. /**
  5704. * Class used to create a 2D grid container
  5705. */
  5706. var Grid = /** @class */ (function (_super) {
  5707. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5708. /**
  5709. * Creates a new Grid
  5710. * @param name defines control name
  5711. */
  5712. function Grid(name) {
  5713. var _this = _super.call(this, name) || this;
  5714. _this.name = name;
  5715. _this._rowDefinitions = new Array();
  5716. _this._columnDefinitions = new Array();
  5717. _this._cells = {};
  5718. _this._childControls = new Array();
  5719. return _this;
  5720. }
  5721. Object.defineProperty(Grid.prototype, "columnCount", {
  5722. /**
  5723. * Gets the number of columns
  5724. */
  5725. get: function () {
  5726. return this._columnDefinitions.length;
  5727. },
  5728. enumerable: true,
  5729. configurable: true
  5730. });
  5731. Object.defineProperty(Grid.prototype, "rowCount", {
  5732. /**
  5733. * Gets the number of rows
  5734. */
  5735. get: function () {
  5736. return this._rowDefinitions.length;
  5737. },
  5738. enumerable: true,
  5739. configurable: true
  5740. });
  5741. Object.defineProperty(Grid.prototype, "children", {
  5742. /** Gets the list of children */
  5743. get: function () {
  5744. return this._childControls;
  5745. },
  5746. enumerable: true,
  5747. configurable: true
  5748. });
  5749. Object.defineProperty(Grid.prototype, "cells", {
  5750. /** Gets the list of cells (e.g. the containers) */
  5751. get: function () {
  5752. return this._cells;
  5753. },
  5754. enumerable: true,
  5755. configurable: true
  5756. });
  5757. /**
  5758. * Gets the definition of a specific row
  5759. * @param index defines the index of the row
  5760. * @returns the row definition
  5761. */
  5762. Grid.prototype.getRowDefinition = function (index) {
  5763. if (index < 0 || index >= this._rowDefinitions.length) {
  5764. return null;
  5765. }
  5766. return this._rowDefinitions[index];
  5767. };
  5768. /**
  5769. * Gets the definition of a specific column
  5770. * @param index defines the index of the column
  5771. * @returns the column definition
  5772. */
  5773. Grid.prototype.getColumnDefinition = function (index) {
  5774. if (index < 0 || index >= this._columnDefinitions.length) {
  5775. return null;
  5776. }
  5777. return this._columnDefinitions[index];
  5778. };
  5779. /**
  5780. * Adds a new row to the grid
  5781. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5782. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5783. * @returns the current grid
  5784. */
  5785. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5786. if (isPixel === void 0) { isPixel = false; }
  5787. 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));
  5788. this._markAsDirty();
  5789. return this;
  5790. };
  5791. /**
  5792. * Adds a new column to the grid
  5793. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5794. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5795. * @returns the current grid
  5796. */
  5797. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5798. if (isPixel === void 0) { isPixel = false; }
  5799. 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));
  5800. this._markAsDirty();
  5801. return this;
  5802. };
  5803. /**
  5804. * Update a row definition
  5805. * @param index defines the index of the row to update
  5806. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5807. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5808. * @returns the current grid
  5809. */
  5810. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5811. if (isPixel === void 0) { isPixel = false; }
  5812. if (index < 0 || index >= this._rowDefinitions.length) {
  5813. return this;
  5814. }
  5815. var current = this._rowDefinitions[index];
  5816. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5817. return this;
  5818. }
  5819. 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);
  5820. this._markAsDirty();
  5821. return this;
  5822. };
  5823. /**
  5824. * Update a column definition
  5825. * @param index defines the index of the column to update
  5826. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5827. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5828. * @returns the current grid
  5829. */
  5830. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5831. if (isPixel === void 0) { isPixel = false; }
  5832. if (index < 0 || index >= this._columnDefinitions.length) {
  5833. return this;
  5834. }
  5835. var current = this._columnDefinitions[index];
  5836. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5837. return this;
  5838. }
  5839. 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);
  5840. this._markAsDirty();
  5841. return this;
  5842. };
  5843. /**
  5844. * Gets the list of children stored in a specific cell
  5845. * @param row defines the row to check
  5846. * @param column defines the column to check
  5847. * @returns the list of controls
  5848. */
  5849. Grid.prototype.getChildrenAt = function (row, column) {
  5850. var cell = this._cells[row + ":" + column];
  5851. if (!cell) {
  5852. return null;
  5853. }
  5854. return cell.children;
  5855. };
  5856. /**
  5857. * Gets a string representing the child cell info (row x column)
  5858. * @param child defines the control to get info from
  5859. * @returns a string containing the child cell info (row x column)
  5860. */
  5861. Grid.prototype.getChildCellInfo = function (child) {
  5862. return child._tag;
  5863. };
  5864. Grid.prototype._removeCell = function (cell, key) {
  5865. if (!cell) {
  5866. return;
  5867. }
  5868. _super.prototype.removeControl.call(this, cell);
  5869. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5870. var control = _a[_i];
  5871. var childIndex = this._childControls.indexOf(control);
  5872. if (childIndex !== -1) {
  5873. this._childControls.splice(childIndex, 1);
  5874. }
  5875. }
  5876. delete this._cells[key];
  5877. };
  5878. Grid.prototype._offsetCell = function (previousKey, key) {
  5879. if (!this._cells[key]) {
  5880. return;
  5881. }
  5882. this._cells[previousKey] = this._cells[key];
  5883. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5884. var control = _a[_i];
  5885. control._tag = previousKey;
  5886. }
  5887. delete this._cells[key];
  5888. };
  5889. /**
  5890. * Remove a column definition at specified index
  5891. * @param index defines the index of the column to remove
  5892. * @returns the current grid
  5893. */
  5894. Grid.prototype.removeColumnDefinition = function (index) {
  5895. if (index < 0 || index >= this._columnDefinitions.length) {
  5896. return this;
  5897. }
  5898. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5899. var key = x + ":" + index;
  5900. var cell = this._cells[key];
  5901. this._removeCell(cell, key);
  5902. }
  5903. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5904. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5905. var previousKey = x + ":" + (y - 1);
  5906. var key = x + ":" + y;
  5907. this._offsetCell(previousKey, key);
  5908. }
  5909. }
  5910. this._columnDefinitions.splice(index, 1);
  5911. this._markAsDirty();
  5912. return this;
  5913. };
  5914. /**
  5915. * Remove a row definition at specified index
  5916. * @param index defines the index of the row to remove
  5917. * @returns the current grid
  5918. */
  5919. Grid.prototype.removeRowDefinition = function (index) {
  5920. if (index < 0 || index >= this._rowDefinitions.length) {
  5921. return this;
  5922. }
  5923. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5924. var key = index + ":" + y;
  5925. var cell = this._cells[key];
  5926. this._removeCell(cell, key);
  5927. }
  5928. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5929. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5930. var previousKey = x - 1 + ":" + y;
  5931. var key = x + ":" + y;
  5932. this._offsetCell(previousKey, key);
  5933. }
  5934. }
  5935. this._rowDefinitions.splice(index, 1);
  5936. this._markAsDirty();
  5937. return this;
  5938. };
  5939. /**
  5940. * Adds a new control to the current grid
  5941. * @param control defines the control to add
  5942. * @param row defines the row where to add the control (0 by default)
  5943. * @param column defines the column where to add the control (0 by default)
  5944. * @returns the current grid
  5945. */
  5946. Grid.prototype.addControl = function (control, row, column) {
  5947. if (row === void 0) { row = 0; }
  5948. if (column === void 0) { column = 0; }
  5949. if (this._rowDefinitions.length === 0) {
  5950. // Add default row definition
  5951. this.addRowDefinition(1, false);
  5952. }
  5953. if (this._columnDefinitions.length === 0) {
  5954. // Add default column definition
  5955. this.addColumnDefinition(1, false);
  5956. }
  5957. if (this._childControls.indexOf(control) !== -1) {
  5958. 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");
  5959. return this;
  5960. }
  5961. var x = Math.min(row, this._rowDefinitions.length - 1);
  5962. var y = Math.min(column, this._columnDefinitions.length - 1);
  5963. var key = x + ":" + y;
  5964. var goodContainer = this._cells[key];
  5965. if (!goodContainer) {
  5966. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5967. this._cells[key] = goodContainer;
  5968. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5969. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5970. _super.prototype.addControl.call(this, goodContainer);
  5971. }
  5972. goodContainer.addControl(control);
  5973. this._childControls.push(control);
  5974. control._tag = key;
  5975. control.parent = this;
  5976. this._markAsDirty();
  5977. return this;
  5978. };
  5979. /**
  5980. * Removes a control from the current container
  5981. * @param control defines the control to remove
  5982. * @returns the current container
  5983. */
  5984. Grid.prototype.removeControl = function (control) {
  5985. var index = this._childControls.indexOf(control);
  5986. if (index !== -1) {
  5987. this._childControls.splice(index, 1);
  5988. }
  5989. var cell = this._cells[control._tag];
  5990. if (cell) {
  5991. cell.removeControl(control);
  5992. control._tag = null;
  5993. }
  5994. this._markAsDirty();
  5995. return this;
  5996. };
  5997. Grid.prototype._getTypeName = function () {
  5998. return "Grid";
  5999. };
  6000. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6001. var widths = [];
  6002. var heights = [];
  6003. var lefts = [];
  6004. var tops = [];
  6005. var availableWidth = this._currentMeasure.width;
  6006. var globalWidthPercentage = 0;
  6007. var availableHeight = this._currentMeasure.height;
  6008. var globalHeightPercentage = 0;
  6009. // Heights
  6010. var index = 0;
  6011. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6012. var value = _a[_i];
  6013. if (value.isPixel) {
  6014. var height = value.getValue(this._host);
  6015. availableHeight -= height;
  6016. heights[index] = height;
  6017. }
  6018. else {
  6019. globalHeightPercentage += value.internalValue;
  6020. }
  6021. index++;
  6022. }
  6023. var top = 0;
  6024. index = 0;
  6025. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6026. var value = _c[_b];
  6027. tops.push(top);
  6028. if (!value.isPixel) {
  6029. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6030. top += height;
  6031. heights[index] = height;
  6032. }
  6033. else {
  6034. top += value.getValue(this._host);
  6035. }
  6036. index++;
  6037. }
  6038. // Widths
  6039. index = 0;
  6040. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6041. var value = _e[_d];
  6042. if (value.isPixel) {
  6043. var width = value.getValue(this._host);
  6044. availableWidth -= width;
  6045. widths[index] = width;
  6046. }
  6047. else {
  6048. globalWidthPercentage += value.internalValue;
  6049. }
  6050. index++;
  6051. }
  6052. var left = 0;
  6053. index = 0;
  6054. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6055. var value = _g[_f];
  6056. lefts.push(left);
  6057. if (!value.isPixel) {
  6058. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6059. left += width;
  6060. widths[index] = width;
  6061. }
  6062. else {
  6063. left += value.getValue(this._host);
  6064. }
  6065. index++;
  6066. }
  6067. definitionCallback(lefts, tops, widths, heights);
  6068. };
  6069. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6070. var _this = this;
  6071. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6072. // Setting child sizes
  6073. for (var key in _this._cells) {
  6074. if (!_this._cells.hasOwnProperty(key)) {
  6075. continue;
  6076. }
  6077. var split = key.split(":");
  6078. var x = parseInt(split[0]);
  6079. var y = parseInt(split[1]);
  6080. var cell = _this._cells[key];
  6081. cell.left = lefts[y] + "px";
  6082. cell.top = tops[x] + "px";
  6083. cell.width = widths[y] + "px";
  6084. cell.height = heights[x] + "px";
  6085. cell._left.ignoreAdaptiveScaling = true;
  6086. cell._top.ignoreAdaptiveScaling = true;
  6087. cell._width.ignoreAdaptiveScaling = true;
  6088. cell._height.ignoreAdaptiveScaling = true;
  6089. }
  6090. });
  6091. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6092. };
  6093. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6094. for (var key in this._cells) {
  6095. if (!this._cells.hasOwnProperty(key)) {
  6096. continue;
  6097. }
  6098. var child = this._cells[key];
  6099. child._markMatrixAsDirty();
  6100. }
  6101. };
  6102. Grid.prototype._renderHighlightSpecific = function (context) {
  6103. var _this = this;
  6104. _super.prototype._renderHighlightSpecific.call(this, context);
  6105. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6106. // Columns
  6107. for (var index = 0; index < lefts.length; index++) {
  6108. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6109. context.beginPath();
  6110. context.moveTo(left, _this._currentMeasure.top);
  6111. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6112. context.stroke();
  6113. }
  6114. // Rows
  6115. for (var index = 0; index < tops.length; index++) {
  6116. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6117. context.beginPath();
  6118. context.moveTo(_this._currentMeasure.left, top_1);
  6119. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6120. context.stroke();
  6121. }
  6122. });
  6123. context.restore();
  6124. };
  6125. /** Releases associated resources */
  6126. Grid.prototype.dispose = function () {
  6127. _super.prototype.dispose.call(this);
  6128. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6129. var control = _a[_i];
  6130. control.dispose();
  6131. }
  6132. this._childControls = [];
  6133. };
  6134. return Grid;
  6135. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6136. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6137. /***/ }),
  6138. /***/ "./2D/controls/image.ts":
  6139. /*!******************************!*\
  6140. !*** ./2D/controls/image.ts ***!
  6141. \******************************/
  6142. /*! exports provided: Image */
  6143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6144. "use strict";
  6145. __webpack_require__.r(__webpack_exports__);
  6146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6148. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6149. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6150. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6151. /**
  6152. * Class used to create 2D images
  6153. */
  6154. var Image = /** @class */ (function (_super) {
  6155. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6156. /**
  6157. * Creates a new Image
  6158. * @param name defines the control name
  6159. * @param url defines the image url
  6160. */
  6161. function Image(name, url) {
  6162. if (url === void 0) { url = null; }
  6163. var _this = _super.call(this, name) || this;
  6164. _this.name = name;
  6165. _this._workingCanvas = null;
  6166. _this._loaded = false;
  6167. _this._stretch = Image.STRETCH_FILL;
  6168. _this._autoScale = false;
  6169. _this._sourceLeft = 0;
  6170. _this._sourceTop = 0;
  6171. _this._sourceWidth = 0;
  6172. _this._sourceHeight = 0;
  6173. _this._cellWidth = 0;
  6174. _this._cellHeight = 0;
  6175. _this._cellId = -1;
  6176. _this._populateNinePatchSlicesFromImage = false;
  6177. /**
  6178. * Observable notified when the content is loaded
  6179. */
  6180. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6181. /**
  6182. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6183. */
  6184. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6185. _this.source = url;
  6186. return _this;
  6187. }
  6188. Object.defineProperty(Image.prototype, "isLoaded", {
  6189. /**
  6190. * Gets a boolean indicating that the content is loaded
  6191. */
  6192. get: function () {
  6193. return this._loaded;
  6194. },
  6195. enumerable: true,
  6196. configurable: true
  6197. });
  6198. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6199. /**
  6200. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6201. */
  6202. get: function () {
  6203. return this._populateNinePatchSlicesFromImage;
  6204. },
  6205. set: function (value) {
  6206. if (this._populateNinePatchSlicesFromImage === value) {
  6207. return;
  6208. }
  6209. this._populateNinePatchSlicesFromImage = value;
  6210. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6211. this._extractNinePatchSliceDataFromImage();
  6212. }
  6213. },
  6214. enumerable: true,
  6215. configurable: true
  6216. });
  6217. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6218. /**
  6219. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6220. * Beware using this as this will comsume more memory as the image has to be stored twice
  6221. */
  6222. get: function () {
  6223. return this._detectPointerOnOpaqueOnly;
  6224. },
  6225. set: function (value) {
  6226. if (this._detectPointerOnOpaqueOnly === value) {
  6227. return;
  6228. }
  6229. this._detectPointerOnOpaqueOnly = value;
  6230. },
  6231. enumerable: true,
  6232. configurable: true
  6233. });
  6234. Object.defineProperty(Image.prototype, "sliceLeft", {
  6235. /**
  6236. * Gets or sets the left value for slicing (9-patch)
  6237. */
  6238. get: function () {
  6239. return this._sliceLeft;
  6240. },
  6241. set: function (value) {
  6242. if (this._sliceLeft === value) {
  6243. return;
  6244. }
  6245. this._sliceLeft = value;
  6246. this._markAsDirty();
  6247. },
  6248. enumerable: true,
  6249. configurable: true
  6250. });
  6251. Object.defineProperty(Image.prototype, "sliceRight", {
  6252. /**
  6253. * Gets or sets the right value for slicing (9-patch)
  6254. */
  6255. get: function () {
  6256. return this._sliceRight;
  6257. },
  6258. set: function (value) {
  6259. if (this._sliceRight === value) {
  6260. return;
  6261. }
  6262. this._sliceRight = value;
  6263. this._markAsDirty();
  6264. },
  6265. enumerable: true,
  6266. configurable: true
  6267. });
  6268. Object.defineProperty(Image.prototype, "sliceTop", {
  6269. /**
  6270. * Gets or sets the top value for slicing (9-patch)
  6271. */
  6272. get: function () {
  6273. return this._sliceTop;
  6274. },
  6275. set: function (value) {
  6276. if (this._sliceTop === value) {
  6277. return;
  6278. }
  6279. this._sliceTop = value;
  6280. this._markAsDirty();
  6281. },
  6282. enumerable: true,
  6283. configurable: true
  6284. });
  6285. Object.defineProperty(Image.prototype, "sliceBottom", {
  6286. /**
  6287. * Gets or sets the bottom value for slicing (9-patch)
  6288. */
  6289. get: function () {
  6290. return this._sliceBottom;
  6291. },
  6292. set: function (value) {
  6293. if (this._sliceBottom === value) {
  6294. return;
  6295. }
  6296. this._sliceBottom = value;
  6297. this._markAsDirty();
  6298. },
  6299. enumerable: true,
  6300. configurable: true
  6301. });
  6302. Object.defineProperty(Image.prototype, "sourceLeft", {
  6303. /**
  6304. * Gets or sets the left coordinate in the source image
  6305. */
  6306. get: function () {
  6307. return this._sourceLeft;
  6308. },
  6309. set: function (value) {
  6310. if (this._sourceLeft === value) {
  6311. return;
  6312. }
  6313. this._sourceLeft = value;
  6314. this._markAsDirty();
  6315. },
  6316. enumerable: true,
  6317. configurable: true
  6318. });
  6319. Object.defineProperty(Image.prototype, "sourceTop", {
  6320. /**
  6321. * Gets or sets the top coordinate in the source image
  6322. */
  6323. get: function () {
  6324. return this._sourceTop;
  6325. },
  6326. set: function (value) {
  6327. if (this._sourceTop === value) {
  6328. return;
  6329. }
  6330. this._sourceTop = value;
  6331. this._markAsDirty();
  6332. },
  6333. enumerable: true,
  6334. configurable: true
  6335. });
  6336. Object.defineProperty(Image.prototype, "sourceWidth", {
  6337. /**
  6338. * Gets or sets the width to capture in the source image
  6339. */
  6340. get: function () {
  6341. return this._sourceWidth;
  6342. },
  6343. set: function (value) {
  6344. if (this._sourceWidth === value) {
  6345. return;
  6346. }
  6347. this._sourceWidth = value;
  6348. this._markAsDirty();
  6349. },
  6350. enumerable: true,
  6351. configurable: true
  6352. });
  6353. Object.defineProperty(Image.prototype, "sourceHeight", {
  6354. /**
  6355. * Gets or sets the height to capture in the source image
  6356. */
  6357. get: function () {
  6358. return this._sourceHeight;
  6359. },
  6360. set: function (value) {
  6361. if (this._sourceHeight === value) {
  6362. return;
  6363. }
  6364. this._sourceHeight = value;
  6365. this._markAsDirty();
  6366. },
  6367. enumerable: true,
  6368. configurable: true
  6369. });
  6370. Object.defineProperty(Image.prototype, "autoScale", {
  6371. /**
  6372. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6373. * @see http://doc.babylonjs.com/how_to/gui#image
  6374. */
  6375. get: function () {
  6376. return this._autoScale;
  6377. },
  6378. set: function (value) {
  6379. if (this._autoScale === value) {
  6380. return;
  6381. }
  6382. this._autoScale = value;
  6383. if (value && this._loaded) {
  6384. this.synchronizeSizeWithContent();
  6385. }
  6386. },
  6387. enumerable: true,
  6388. configurable: true
  6389. });
  6390. Object.defineProperty(Image.prototype, "stretch", {
  6391. /** Gets or sets the streching mode used by the image */
  6392. get: function () {
  6393. return this._stretch;
  6394. },
  6395. set: function (value) {
  6396. if (this._stretch === value) {
  6397. return;
  6398. }
  6399. this._stretch = value;
  6400. this._markAsDirty();
  6401. },
  6402. enumerable: true,
  6403. configurable: true
  6404. });
  6405. Object.defineProperty(Image.prototype, "domImage", {
  6406. get: function () {
  6407. return this._domImage;
  6408. },
  6409. /**
  6410. * Gets or sets the internal DOM image used to render the control
  6411. */
  6412. set: function (value) {
  6413. var _this = this;
  6414. this._domImage = value;
  6415. this._loaded = false;
  6416. if (this._domImage.width) {
  6417. this._onImageLoaded();
  6418. }
  6419. else {
  6420. this._domImage.onload = function () {
  6421. _this._onImageLoaded();
  6422. };
  6423. }
  6424. },
  6425. enumerable: true,
  6426. configurable: true
  6427. });
  6428. Image.prototype._onImageLoaded = function () {
  6429. this._imageWidth = this._domImage.width;
  6430. this._imageHeight = this._domImage.height;
  6431. this._loaded = true;
  6432. if (this._populateNinePatchSlicesFromImage) {
  6433. this._extractNinePatchSliceDataFromImage();
  6434. }
  6435. if (this._autoScale) {
  6436. this.synchronizeSizeWithContent();
  6437. }
  6438. this.onImageLoadedObservable.notifyObservers(this);
  6439. this._markAsDirty();
  6440. };
  6441. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6442. if (!this._workingCanvas) {
  6443. this._workingCanvas = document.createElement('canvas');
  6444. }
  6445. var canvas = this._workingCanvas;
  6446. var context = canvas.getContext('2d');
  6447. var width = this._domImage.width;
  6448. var height = this._domImage.height;
  6449. canvas.width = width;
  6450. canvas.height = height;
  6451. context.drawImage(this._domImage, 0, 0, width, height);
  6452. var imageData = context.getImageData(0, 0, width, height);
  6453. // Left and right
  6454. this._sliceLeft = -1;
  6455. this._sliceRight = -1;
  6456. for (var x = 0; x < width; x++) {
  6457. var alpha = imageData.data[x * 4 + 3];
  6458. if (alpha > 127 && this._sliceLeft === -1) {
  6459. this._sliceLeft = x;
  6460. continue;
  6461. }
  6462. if (alpha < 127 && this._sliceLeft > -1) {
  6463. this._sliceRight = x;
  6464. break;
  6465. }
  6466. }
  6467. // top and bottom
  6468. this._sliceTop = -1;
  6469. this._sliceBottom = -1;
  6470. for (var y = 0; y < height; y++) {
  6471. var alpha = imageData.data[y * width * 4 + 3];
  6472. if (alpha > 127 && this._sliceTop === -1) {
  6473. this._sliceTop = y;
  6474. continue;
  6475. }
  6476. if (alpha < 127 && this._sliceTop > -1) {
  6477. this._sliceBottom = y;
  6478. break;
  6479. }
  6480. }
  6481. };
  6482. Object.defineProperty(Image.prototype, "source", {
  6483. /**
  6484. * Gets or sets image source url
  6485. */
  6486. set: function (value) {
  6487. var _this = this;
  6488. if (this._source === value) {
  6489. return;
  6490. }
  6491. this._loaded = false;
  6492. this._source = value;
  6493. if (value) {
  6494. value = this._svgCheck(value);
  6495. }
  6496. this._domImage = document.createElement("img");
  6497. this._domImage.onload = function () {
  6498. _this._onImageLoaded();
  6499. };
  6500. if (value) {
  6501. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6502. this._domImage.src = value;
  6503. }
  6504. },
  6505. enumerable: true,
  6506. configurable: true
  6507. });
  6508. /**
  6509. * Checks for svg document with icon id present
  6510. */
  6511. Image.prototype._svgCheck = function (value) {
  6512. var _this = this;
  6513. if ((value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6514. var svgsrc = value.split('#')[0];
  6515. var elemid = value.split('#')[1];
  6516. // check if object alr exist in document
  6517. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6518. if (svgExist) {
  6519. // wait for object to load
  6520. svgExist.addEventListener("load", function () {
  6521. _this._getSVGAttribs(svgExist, elemid);
  6522. });
  6523. }
  6524. else {
  6525. // create document object
  6526. var svgImage = document.createElement("object");
  6527. svgImage.data = svgsrc;
  6528. svgImage.type = "image/svg+xml";
  6529. svgImage.width = "0%";
  6530. svgImage.height = "0%";
  6531. document.body.appendChild(svgImage);
  6532. // when the object has loaded, get the element attribs
  6533. svgImage.onload = function () {
  6534. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6535. if (svgobj) {
  6536. _this._getSVGAttribs(svgobj, elemid);
  6537. }
  6538. };
  6539. }
  6540. return svgsrc;
  6541. }
  6542. else {
  6543. return value;
  6544. }
  6545. };
  6546. /**
  6547. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6548. * given external svg file and icon id
  6549. */
  6550. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6551. var svgDoc = svgsrc.contentDocument;
  6552. // get viewbox width and height, get svg document width and height in px
  6553. if (svgDoc && svgDoc.documentElement) {
  6554. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6555. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6556. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6557. // get element bbox and matrix transform
  6558. var elem = svgDoc.getElementById(elemid);
  6559. if (vb && docwidth && docheight) {
  6560. var vb_width = Number(vb.split(" ")[2]);
  6561. var vb_height = Number(vb.split(" ")[3]);
  6562. var elem_bbox = elem.getBBox();
  6563. var elem_matrix_a = 1;
  6564. var elem_matrix_d = 1;
  6565. var elem_matrix_e = 0;
  6566. var elem_matrix_f = 0;
  6567. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6568. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6569. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6570. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6571. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6572. }
  6573. // compute source coordinates and dimensions
  6574. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6575. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6576. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6577. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6578. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6579. }
  6580. }
  6581. };
  6582. Object.defineProperty(Image.prototype, "cellWidth", {
  6583. /**
  6584. * Gets or sets the cell width to use when animation sheet is enabled
  6585. * @see http://doc.babylonjs.com/how_to/gui#image
  6586. */
  6587. get: function () {
  6588. return this._cellWidth;
  6589. },
  6590. set: function (value) {
  6591. if (this._cellWidth === value) {
  6592. return;
  6593. }
  6594. this._cellWidth = value;
  6595. this._markAsDirty();
  6596. },
  6597. enumerable: true,
  6598. configurable: true
  6599. });
  6600. Object.defineProperty(Image.prototype, "cellHeight", {
  6601. /**
  6602. * Gets or sets the cell height to use when animation sheet is enabled
  6603. * @see http://doc.babylonjs.com/how_to/gui#image
  6604. */
  6605. get: function () {
  6606. return this._cellHeight;
  6607. },
  6608. set: function (value) {
  6609. if (this._cellHeight === value) {
  6610. return;
  6611. }
  6612. this._cellHeight = value;
  6613. this._markAsDirty();
  6614. },
  6615. enumerable: true,
  6616. configurable: true
  6617. });
  6618. Object.defineProperty(Image.prototype, "cellId", {
  6619. /**
  6620. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6621. * @see http://doc.babylonjs.com/how_to/gui#image
  6622. */
  6623. get: function () {
  6624. return this._cellId;
  6625. },
  6626. set: function (value) {
  6627. if (this._cellId === value) {
  6628. return;
  6629. }
  6630. this._cellId = value;
  6631. this._markAsDirty();
  6632. },
  6633. enumerable: true,
  6634. configurable: true
  6635. });
  6636. /**
  6637. * Tests if a given coordinates belong to the current control
  6638. * @param x defines x coordinate to test
  6639. * @param y defines y coordinate to test
  6640. * @returns true if the coordinates are inside the control
  6641. */
  6642. Image.prototype.contains = function (x, y) {
  6643. if (!_super.prototype.contains.call(this, x, y)) {
  6644. return false;
  6645. }
  6646. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6647. return true;
  6648. }
  6649. var canvas = this._workingCanvas;
  6650. var context = canvas.getContext("2d");
  6651. var width = this._currentMeasure.width | 0;
  6652. var height = this._currentMeasure.height | 0;
  6653. var imageData = context.getImageData(0, 0, width, height).data;
  6654. x = (x - this._currentMeasure.left) | 0;
  6655. y = (y - this._currentMeasure.top) | 0;
  6656. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6657. return pickedPixel > 0;
  6658. };
  6659. Image.prototype._getTypeName = function () {
  6660. return "Image";
  6661. };
  6662. /** Force the control to synchronize with its content */
  6663. Image.prototype.synchronizeSizeWithContent = function () {
  6664. if (!this._loaded) {
  6665. return;
  6666. }
  6667. this.width = this._domImage.width + "px";
  6668. this.height = this._domImage.height + "px";
  6669. };
  6670. Image.prototype._processMeasures = function (parentMeasure, context) {
  6671. if (this._loaded) {
  6672. switch (this._stretch) {
  6673. case Image.STRETCH_NONE:
  6674. break;
  6675. case Image.STRETCH_FILL:
  6676. break;
  6677. case Image.STRETCH_UNIFORM:
  6678. break;
  6679. case Image.STRETCH_NINE_PATCH:
  6680. break;
  6681. case Image.STRETCH_EXTEND:
  6682. if (this._autoScale) {
  6683. this.synchronizeSizeWithContent();
  6684. }
  6685. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6686. this.parent.adaptWidthToChildren = true;
  6687. this.parent.adaptHeightToChildren = true;
  6688. }
  6689. break;
  6690. }
  6691. }
  6692. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6693. };
  6694. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6695. if (!this._detectPointerOnOpaqueOnly) {
  6696. return;
  6697. }
  6698. if (!this._workingCanvas) {
  6699. this._workingCanvas = document.createElement('canvas');
  6700. }
  6701. var canvas = this._workingCanvas;
  6702. var width = this._currentMeasure.width;
  6703. var height = this._currentMeasure.height;
  6704. var context = canvas.getContext("2d");
  6705. canvas.width = width;
  6706. canvas.height = height;
  6707. context.clearRect(0, 0, width, height);
  6708. };
  6709. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6710. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6711. if (!this._detectPointerOnOpaqueOnly) {
  6712. return;
  6713. }
  6714. var canvas = this._workingCanvas;
  6715. context = canvas.getContext("2d");
  6716. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6717. };
  6718. Image.prototype._draw = function (context) {
  6719. context.save();
  6720. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6721. context.shadowColor = this.shadowColor;
  6722. context.shadowBlur = this.shadowBlur;
  6723. context.shadowOffsetX = this.shadowOffsetX;
  6724. context.shadowOffsetY = this.shadowOffsetY;
  6725. }
  6726. var x, y, width, height;
  6727. if (this.cellId == -1) {
  6728. x = this._sourceLeft;
  6729. y = this._sourceTop;
  6730. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6731. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6732. }
  6733. else {
  6734. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6735. var column = (this.cellId / rowCount) >> 0;
  6736. var row = this.cellId % rowCount;
  6737. x = this.cellWidth * row;
  6738. y = this.cellHeight * column;
  6739. width = this.cellWidth;
  6740. height = this.cellHeight;
  6741. }
  6742. this._prepareWorkingCanvasForOpaqueDetection();
  6743. this._applyStates(context);
  6744. if (this._loaded) {
  6745. switch (this._stretch) {
  6746. case Image.STRETCH_NONE:
  6747. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6748. break;
  6749. case Image.STRETCH_FILL:
  6750. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6751. break;
  6752. case Image.STRETCH_UNIFORM:
  6753. var hRatio = this._currentMeasure.width / width;
  6754. var vRatio = this._currentMeasure.height / height;
  6755. var ratio = Math.min(hRatio, vRatio);
  6756. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6757. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6758. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6759. break;
  6760. case Image.STRETCH_EXTEND:
  6761. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6762. break;
  6763. case Image.STRETCH_NINE_PATCH:
  6764. this._renderNinePatch(context);
  6765. break;
  6766. }
  6767. }
  6768. context.restore();
  6769. };
  6770. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6771. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6772. };
  6773. Image.prototype._renderNinePatch = function (context) {
  6774. var height = this._imageHeight;
  6775. var leftWidth = this._sliceLeft;
  6776. var topHeight = this._sliceTop;
  6777. var bottomHeight = this._imageHeight - this._sliceBottom;
  6778. var rightWidth = this._imageWidth - this._sliceRight;
  6779. var left = 0;
  6780. var top = 0;
  6781. if (this._populateNinePatchSlicesFromImage) {
  6782. left = 1;
  6783. top = 1;
  6784. height -= 2;
  6785. leftWidth -= 1;
  6786. topHeight -= 1;
  6787. bottomHeight -= 1;
  6788. rightWidth -= 1;
  6789. }
  6790. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6791. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6792. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6793. // Corners
  6794. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6795. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6796. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6797. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6798. // Center
  6799. 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);
  6800. // Borders
  6801. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6802. 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);
  6803. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6804. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6805. };
  6806. Image.prototype.dispose = function () {
  6807. _super.prototype.dispose.call(this);
  6808. this.onImageLoadedObservable.clear();
  6809. this.onSVGAttributesComputedObservable.clear();
  6810. };
  6811. // Static
  6812. /** STRETCH_NONE */
  6813. Image.STRETCH_NONE = 0;
  6814. /** STRETCH_FILL */
  6815. Image.STRETCH_FILL = 1;
  6816. /** STRETCH_UNIFORM */
  6817. Image.STRETCH_UNIFORM = 2;
  6818. /** STRETCH_EXTEND */
  6819. Image.STRETCH_EXTEND = 3;
  6820. /** NINE_PATCH */
  6821. Image.STRETCH_NINE_PATCH = 4;
  6822. return Image;
  6823. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6824. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6825. /***/ }),
  6826. /***/ "./2D/controls/index.ts":
  6827. /*!******************************!*\
  6828. !*** ./2D/controls/index.ts ***!
  6829. \******************************/
  6830. /*! 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, name */
  6831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6832. "use strict";
  6833. __webpack_require__.r(__webpack_exports__);
  6834. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6836. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6838. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6840. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6842. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6844. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6846. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6848. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6850. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6852. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6854. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6856. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6858. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6860. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6862. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6868. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6870. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6873. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6876. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6878. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6880. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6882. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6884. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6886. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6888. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6890. /***/ }),
  6891. /***/ "./2D/controls/inputPassword.ts":
  6892. /*!**************************************!*\
  6893. !*** ./2D/controls/inputPassword.ts ***!
  6894. \**************************************/
  6895. /*! exports provided: InputPassword */
  6896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6897. "use strict";
  6898. __webpack_require__.r(__webpack_exports__);
  6899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6901. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6902. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  6903. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6904. /**
  6905. * Class used to create a password control
  6906. */
  6907. var InputPassword = /** @class */ (function (_super) {
  6908. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6909. function InputPassword() {
  6910. return _super !== null && _super.apply(this, arguments) || this;
  6911. }
  6912. InputPassword.prototype._beforeRenderText = function (text) {
  6913. var txt = "";
  6914. for (var i = 0; i < text.length; i++) {
  6915. txt += "\u2022";
  6916. }
  6917. return txt;
  6918. };
  6919. return InputPassword;
  6920. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6921. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6922. /***/ }),
  6923. /***/ "./2D/controls/inputText.ts":
  6924. /*!**********************************!*\
  6925. !*** ./2D/controls/inputText.ts ***!
  6926. \**********************************/
  6927. /*! exports provided: InputText */
  6928. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6929. "use strict";
  6930. __webpack_require__.r(__webpack_exports__);
  6931. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6932. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6933. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6934. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6935. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6936. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6937. /**
  6938. * Class used to create input text control
  6939. */
  6940. var InputText = /** @class */ (function (_super) {
  6941. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6942. /**
  6943. * Creates a new InputText
  6944. * @param name defines the control name
  6945. * @param text defines the text of the control
  6946. */
  6947. function InputText(name, text) {
  6948. if (text === void 0) { text = ""; }
  6949. var _this = _super.call(this, name) || this;
  6950. _this.name = name;
  6951. _this._text = "";
  6952. _this._placeholderText = "";
  6953. _this._background = "#222222";
  6954. _this._focusedBackground = "#000000";
  6955. _this._focusedColor = "white";
  6956. _this._placeholderColor = "gray";
  6957. _this._thickness = 1;
  6958. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6959. _this._autoStretchWidth = true;
  6960. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6961. _this._isFocused = false;
  6962. _this._blinkIsEven = false;
  6963. _this._cursorOffset = 0;
  6964. _this._deadKey = false;
  6965. _this._addKey = true;
  6966. _this._currentKey = "";
  6967. _this._isTextHighlightOn = false;
  6968. _this._textHighlightColor = "#d5e0ff";
  6969. _this._highligherOpacity = 0.4;
  6970. _this._highlightedText = "";
  6971. _this._startHighlightIndex = 0;
  6972. _this._endHighlightIndex = 0;
  6973. _this._cursorIndex = -1;
  6974. _this._onFocusSelectAll = false;
  6975. _this._isPointerDown = false;
  6976. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6977. _this.promptMessage = "Please enter text:";
  6978. /** Force disable prompt on mobile device */
  6979. _this.disableMobilePrompt = false;
  6980. /** Observable raised when the text changes */
  6981. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6982. /** Observable raised just before an entered character is to be added */
  6983. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6984. /** Observable raised when the control gets the focus */
  6985. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6986. /** Observable raised when the control loses the focus */
  6987. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6988. /**Observable raised when the text is highlighted */
  6989. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6990. /**Observable raised when copy event is triggered */
  6991. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6992. /** Observable raised when cut event is triggered */
  6993. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6994. /** Observable raised when paste event is triggered */
  6995. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6996. /** Observable raised when a key event was processed */
  6997. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6998. _this.text = text;
  6999. _this.isPointerBlocker = true;
  7000. return _this;
  7001. }
  7002. Object.defineProperty(InputText.prototype, "maxWidth", {
  7003. /** Gets or sets the maximum width allowed by the control */
  7004. get: function () {
  7005. return this._maxWidth.toString(this._host);
  7006. },
  7007. set: function (value) {
  7008. if (this._maxWidth.toString(this._host) === value) {
  7009. return;
  7010. }
  7011. if (this._maxWidth.fromString(value)) {
  7012. this._markAsDirty();
  7013. }
  7014. },
  7015. enumerable: true,
  7016. configurable: true
  7017. });
  7018. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7019. /** Gets the maximum width allowed by the control in pixels */
  7020. get: function () {
  7021. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7022. },
  7023. enumerable: true,
  7024. configurable: true
  7025. });
  7026. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7027. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7028. get: function () {
  7029. return this._highligherOpacity;
  7030. },
  7031. set: function (value) {
  7032. if (this._highligherOpacity === value) {
  7033. return;
  7034. }
  7035. this._highligherOpacity = value;
  7036. this._markAsDirty();
  7037. },
  7038. enumerable: true,
  7039. configurable: true
  7040. });
  7041. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7042. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7043. get: function () {
  7044. return this._onFocusSelectAll;
  7045. },
  7046. set: function (value) {
  7047. if (this._onFocusSelectAll === value) {
  7048. return;
  7049. }
  7050. this._onFocusSelectAll = value;
  7051. this._markAsDirty();
  7052. },
  7053. enumerable: true,
  7054. configurable: true
  7055. });
  7056. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7057. /** Gets or sets the text hightlight color */
  7058. get: function () {
  7059. return this._textHighlightColor;
  7060. },
  7061. set: function (value) {
  7062. if (this._textHighlightColor === value) {
  7063. return;
  7064. }
  7065. this._textHighlightColor = value;
  7066. this._markAsDirty();
  7067. },
  7068. enumerable: true,
  7069. configurable: true
  7070. });
  7071. Object.defineProperty(InputText.prototype, "margin", {
  7072. /** Gets or sets control margin */
  7073. get: function () {
  7074. return this._margin.toString(this._host);
  7075. },
  7076. set: function (value) {
  7077. if (this._margin.toString(this._host) === value) {
  7078. return;
  7079. }
  7080. if (this._margin.fromString(value)) {
  7081. this._markAsDirty();
  7082. }
  7083. },
  7084. enumerable: true,
  7085. configurable: true
  7086. });
  7087. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7088. /** Gets control margin in pixels */
  7089. get: function () {
  7090. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7091. },
  7092. enumerable: true,
  7093. configurable: true
  7094. });
  7095. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7096. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7097. get: function () {
  7098. return this._autoStretchWidth;
  7099. },
  7100. set: function (value) {
  7101. if (this._autoStretchWidth === value) {
  7102. return;
  7103. }
  7104. this._autoStretchWidth = value;
  7105. this._markAsDirty();
  7106. },
  7107. enumerable: true,
  7108. configurable: true
  7109. });
  7110. Object.defineProperty(InputText.prototype, "thickness", {
  7111. /** Gets or sets border thickness */
  7112. get: function () {
  7113. return this._thickness;
  7114. },
  7115. set: function (value) {
  7116. if (this._thickness === value) {
  7117. return;
  7118. }
  7119. this._thickness = value;
  7120. this._markAsDirty();
  7121. },
  7122. enumerable: true,
  7123. configurable: true
  7124. });
  7125. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7126. /** Gets or sets the background color when focused */
  7127. get: function () {
  7128. return this._focusedBackground;
  7129. },
  7130. set: function (value) {
  7131. if (this._focusedBackground === value) {
  7132. return;
  7133. }
  7134. this._focusedBackground = value;
  7135. this._markAsDirty();
  7136. },
  7137. enumerable: true,
  7138. configurable: true
  7139. });
  7140. Object.defineProperty(InputText.prototype, "focusedColor", {
  7141. /** Gets or sets the background color when focused */
  7142. get: function () {
  7143. return this._focusedColor;
  7144. },
  7145. set: function (value) {
  7146. if (this._focusedColor === value) {
  7147. return;
  7148. }
  7149. this._focusedColor = value;
  7150. this._markAsDirty();
  7151. },
  7152. enumerable: true,
  7153. configurable: true
  7154. });
  7155. Object.defineProperty(InputText.prototype, "background", {
  7156. /** Gets or sets the background color */
  7157. get: function () {
  7158. return this._background;
  7159. },
  7160. set: function (value) {
  7161. if (this._background === value) {
  7162. return;
  7163. }
  7164. this._background = value;
  7165. this._markAsDirty();
  7166. },
  7167. enumerable: true,
  7168. configurable: true
  7169. });
  7170. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7171. /** Gets or sets the placeholder color */
  7172. get: function () {
  7173. return this._placeholderColor;
  7174. },
  7175. set: function (value) {
  7176. if (this._placeholderColor === value) {
  7177. return;
  7178. }
  7179. this._placeholderColor = value;
  7180. this._markAsDirty();
  7181. },
  7182. enumerable: true,
  7183. configurable: true
  7184. });
  7185. Object.defineProperty(InputText.prototype, "placeholderText", {
  7186. /** Gets or sets the text displayed when the control is empty */
  7187. get: function () {
  7188. return this._placeholderText;
  7189. },
  7190. set: function (value) {
  7191. if (this._placeholderText === value) {
  7192. return;
  7193. }
  7194. this._placeholderText = value;
  7195. this._markAsDirty();
  7196. },
  7197. enumerable: true,
  7198. configurable: true
  7199. });
  7200. Object.defineProperty(InputText.prototype, "deadKey", {
  7201. /** Gets or sets the dead key flag */
  7202. get: function () {
  7203. return this._deadKey;
  7204. },
  7205. set: function (flag) {
  7206. this._deadKey = flag;
  7207. },
  7208. enumerable: true,
  7209. configurable: true
  7210. });
  7211. Object.defineProperty(InputText.prototype, "highlightedText", {
  7212. /** Gets or sets the highlight text */
  7213. get: function () {
  7214. return this._highlightedText;
  7215. },
  7216. set: function (text) {
  7217. if (this._highlightedText === text) {
  7218. return;
  7219. }
  7220. this._highlightedText = text;
  7221. this._markAsDirty();
  7222. },
  7223. enumerable: true,
  7224. configurable: true
  7225. });
  7226. Object.defineProperty(InputText.prototype, "addKey", {
  7227. /** Gets or sets if the current key should be added */
  7228. get: function () {
  7229. return this._addKey;
  7230. },
  7231. set: function (flag) {
  7232. this._addKey = flag;
  7233. },
  7234. enumerable: true,
  7235. configurable: true
  7236. });
  7237. Object.defineProperty(InputText.prototype, "currentKey", {
  7238. /** Gets or sets the value of the current key being entered */
  7239. get: function () {
  7240. return this._currentKey;
  7241. },
  7242. set: function (key) {
  7243. this._currentKey = key;
  7244. },
  7245. enumerable: true,
  7246. configurable: true
  7247. });
  7248. Object.defineProperty(InputText.prototype, "text", {
  7249. /** Gets or sets the text displayed in the control */
  7250. get: function () {
  7251. return this._text;
  7252. },
  7253. set: function (value) {
  7254. var valueAsString = value.toString(); // Forcing convertion
  7255. if (this._text === valueAsString) {
  7256. return;
  7257. }
  7258. this._text = valueAsString;
  7259. this._markAsDirty();
  7260. this.onTextChangedObservable.notifyObservers(this);
  7261. },
  7262. enumerable: true,
  7263. configurable: true
  7264. });
  7265. Object.defineProperty(InputText.prototype, "width", {
  7266. /** Gets or sets control width */
  7267. get: function () {
  7268. return this._width.toString(this._host);
  7269. },
  7270. set: function (value) {
  7271. if (this._width.toString(this._host) === value) {
  7272. return;
  7273. }
  7274. if (this._width.fromString(value)) {
  7275. this._markAsDirty();
  7276. }
  7277. this.autoStretchWidth = false;
  7278. },
  7279. enumerable: true,
  7280. configurable: true
  7281. });
  7282. /** @hidden */
  7283. InputText.prototype.onBlur = function () {
  7284. this._isFocused = false;
  7285. this._scrollLeft = null;
  7286. this._cursorOffset = 0;
  7287. clearTimeout(this._blinkTimeout);
  7288. this._markAsDirty();
  7289. this.onBlurObservable.notifyObservers(this);
  7290. this._host.unRegisterClipboardEvents();
  7291. if (this._onClipboardObserver) {
  7292. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7293. }
  7294. var scene = this._host.getScene();
  7295. if (this._onPointerDblTapObserver && scene) {
  7296. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7297. }
  7298. };
  7299. /** @hidden */
  7300. InputText.prototype.onFocus = function () {
  7301. var _this = this;
  7302. if (!this._isEnabled) {
  7303. return;
  7304. }
  7305. this._scrollLeft = null;
  7306. this._isFocused = true;
  7307. this._blinkIsEven = false;
  7308. this._cursorOffset = 0;
  7309. this._markAsDirty();
  7310. this.onFocusObservable.notifyObservers(this);
  7311. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7312. var value = prompt(this.promptMessage);
  7313. if (value !== null) {
  7314. this.text = value;
  7315. }
  7316. this._host.focusedControl = null;
  7317. return;
  7318. }
  7319. this._host.registerClipboardEvents();
  7320. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7321. // process clipboard event, can be configured.
  7322. switch (clipboardInfo.type) {
  7323. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7324. _this._onCopyText(clipboardInfo.event);
  7325. _this.onTextCopyObservable.notifyObservers(_this);
  7326. break;
  7327. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7328. _this._onCutText(clipboardInfo.event);
  7329. _this.onTextCutObservable.notifyObservers(_this);
  7330. break;
  7331. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7332. _this._onPasteText(clipboardInfo.event);
  7333. _this.onTextPasteObservable.notifyObservers(_this);
  7334. break;
  7335. default: return;
  7336. }
  7337. });
  7338. var scene = this._host.getScene();
  7339. if (scene) {
  7340. //register the pointer double tap event
  7341. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7342. if (!_this._isFocused) {
  7343. return;
  7344. }
  7345. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7346. _this._processDblClick(pointerInfo);
  7347. }
  7348. });
  7349. }
  7350. if (this._onFocusSelectAll) {
  7351. this._selectAllText();
  7352. }
  7353. };
  7354. InputText.prototype._getTypeName = function () {
  7355. return "InputText";
  7356. };
  7357. /**
  7358. * Function called to get the list of controls that should not steal the focus from this control
  7359. * @returns an array of controls
  7360. */
  7361. InputText.prototype.keepsFocusWith = function () {
  7362. if (!this._connectedVirtualKeyboard) {
  7363. return null;
  7364. }
  7365. return [this._connectedVirtualKeyboard];
  7366. };
  7367. /** @hidden */
  7368. InputText.prototype.processKey = function (keyCode, key, evt) {
  7369. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7370. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7371. return;
  7372. }
  7373. //select all
  7374. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7375. this._selectAllText();
  7376. evt.preventDefault();
  7377. return;
  7378. }
  7379. // Specific cases
  7380. switch (keyCode) {
  7381. case 32: //SPACE
  7382. key = " "; //ie11 key for space is "Spacebar"
  7383. break;
  7384. case 191: //SLASH
  7385. if (evt) {
  7386. evt.preventDefault();
  7387. }
  7388. break;
  7389. case 8: // BACKSPACE
  7390. if (this._text && this._text.length > 0) {
  7391. //delete the highlighted text
  7392. if (this._isTextHighlightOn) {
  7393. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7394. this._isTextHighlightOn = false;
  7395. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7396. this._blinkIsEven = false;
  7397. if (evt) {
  7398. evt.preventDefault();
  7399. }
  7400. return;
  7401. }
  7402. //delete single character
  7403. if (this._cursorOffset === 0) {
  7404. this.text = this._text.substr(0, this._text.length - 1);
  7405. }
  7406. else {
  7407. var deletePosition = this._text.length - this._cursorOffset;
  7408. if (deletePosition > 0) {
  7409. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7410. }
  7411. }
  7412. }
  7413. if (evt) {
  7414. evt.preventDefault();
  7415. }
  7416. return;
  7417. case 46: // DELETE
  7418. if (this._isTextHighlightOn) {
  7419. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7420. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7421. while (decrementor > 0 && this._cursorOffset > 0) {
  7422. this._cursorOffset--;
  7423. }
  7424. this._isTextHighlightOn = false;
  7425. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7426. if (evt) {
  7427. evt.preventDefault();
  7428. }
  7429. return;
  7430. }
  7431. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7432. var deletePosition = this._text.length - this._cursorOffset;
  7433. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7434. this._cursorOffset--;
  7435. }
  7436. if (evt) {
  7437. evt.preventDefault();
  7438. }
  7439. return;
  7440. case 13: // RETURN
  7441. this._host.focusedControl = null;
  7442. this._isTextHighlightOn = false;
  7443. return;
  7444. case 35: // END
  7445. this._cursorOffset = 0;
  7446. this._blinkIsEven = false;
  7447. this._isTextHighlightOn = false;
  7448. this._markAsDirty();
  7449. return;
  7450. case 36: // HOME
  7451. this._cursorOffset = this._text.length;
  7452. this._blinkIsEven = false;
  7453. this._isTextHighlightOn = false;
  7454. this._markAsDirty();
  7455. return;
  7456. case 37: // LEFT
  7457. this._cursorOffset++;
  7458. if (this._cursorOffset > this._text.length) {
  7459. this._cursorOffset = this._text.length;
  7460. }
  7461. if (evt && evt.shiftKey) {
  7462. // update the cursor
  7463. this._blinkIsEven = false;
  7464. // shift + ctrl/cmd + <-
  7465. if (evt.ctrlKey || evt.metaKey) {
  7466. if (!this._isTextHighlightOn) {
  7467. if (this._text.length === this._cursorOffset) {
  7468. return;
  7469. }
  7470. else {
  7471. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7472. }
  7473. }
  7474. this._startHighlightIndex = 0;
  7475. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7476. this._cursorOffset = this._text.length;
  7477. this._isTextHighlightOn = true;
  7478. this._markAsDirty();
  7479. return;
  7480. }
  7481. //store the starting point
  7482. if (!this._isTextHighlightOn) {
  7483. this._isTextHighlightOn = true;
  7484. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7485. }
  7486. //if text is already highlighted
  7487. else if (this._cursorIndex === -1) {
  7488. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7489. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7490. }
  7491. //set the highlight indexes
  7492. if (this._cursorIndex < this._cursorOffset) {
  7493. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7494. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7495. }
  7496. else if (this._cursorIndex > this._cursorOffset) {
  7497. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7498. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7499. }
  7500. else {
  7501. this._isTextHighlightOn = false;
  7502. }
  7503. this._markAsDirty();
  7504. return;
  7505. }
  7506. if (this._isTextHighlightOn) {
  7507. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7508. this._isTextHighlightOn = false;
  7509. }
  7510. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7511. this._cursorOffset = this.text.length;
  7512. evt.preventDefault();
  7513. }
  7514. this._blinkIsEven = false;
  7515. this._isTextHighlightOn = false;
  7516. this._cursorIndex = -1;
  7517. this._markAsDirty();
  7518. return;
  7519. case 39: // RIGHT
  7520. this._cursorOffset--;
  7521. if (this._cursorOffset < 0) {
  7522. this._cursorOffset = 0;
  7523. }
  7524. if (evt && evt.shiftKey) {
  7525. //update the cursor
  7526. this._blinkIsEven = false;
  7527. //shift + ctrl/cmd + ->
  7528. if (evt.ctrlKey || evt.metaKey) {
  7529. if (!this._isTextHighlightOn) {
  7530. if (this._cursorOffset === 0) {
  7531. return;
  7532. }
  7533. else {
  7534. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7535. }
  7536. }
  7537. this._endHighlightIndex = this._text.length;
  7538. this._isTextHighlightOn = true;
  7539. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7540. this._cursorOffset = 0;
  7541. this._markAsDirty();
  7542. return;
  7543. }
  7544. if (!this._isTextHighlightOn) {
  7545. this._isTextHighlightOn = true;
  7546. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7547. }
  7548. //if text is already highlighted
  7549. else if (this._cursorIndex === -1) {
  7550. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7551. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7552. }
  7553. //set the highlight indexes
  7554. if (this._cursorIndex < this._cursorOffset) {
  7555. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7556. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7557. }
  7558. else if (this._cursorIndex > this._cursorOffset) {
  7559. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7560. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7561. }
  7562. else {
  7563. this._isTextHighlightOn = false;
  7564. }
  7565. this._markAsDirty();
  7566. return;
  7567. }
  7568. if (this._isTextHighlightOn) {
  7569. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7570. this._isTextHighlightOn = false;
  7571. }
  7572. //ctr + ->
  7573. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7574. this._cursorOffset = 0;
  7575. evt.preventDefault();
  7576. }
  7577. this._blinkIsEven = false;
  7578. this._isTextHighlightOn = false;
  7579. this._cursorIndex = -1;
  7580. this._markAsDirty();
  7581. return;
  7582. case 222: // Dead
  7583. if (evt) {
  7584. evt.preventDefault();
  7585. }
  7586. this._cursorIndex = -1;
  7587. this.deadKey = true;
  7588. break;
  7589. }
  7590. // Printable characters
  7591. if (key &&
  7592. ((keyCode === -1) || // Direct access
  7593. (keyCode === 32) || // Space
  7594. (keyCode > 47 && keyCode < 64) || // Numbers
  7595. (keyCode > 64 && keyCode < 91) || // Letters
  7596. (keyCode > 159 && keyCode < 193) || // Special characters
  7597. (keyCode > 218 && keyCode < 223) || // Special characters
  7598. (keyCode > 95 && keyCode < 112))) { // Numpad
  7599. this._currentKey = key;
  7600. this.onBeforeKeyAddObservable.notifyObservers(this);
  7601. key = this._currentKey;
  7602. if (this._addKey) {
  7603. if (this._isTextHighlightOn) {
  7604. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7605. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7606. this._isTextHighlightOn = false;
  7607. this._blinkIsEven = false;
  7608. this._markAsDirty();
  7609. }
  7610. else if (this._cursorOffset === 0) {
  7611. this.text += key;
  7612. }
  7613. else {
  7614. var insertPosition = this._text.length - this._cursorOffset;
  7615. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7616. }
  7617. }
  7618. }
  7619. };
  7620. /** @hidden */
  7621. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7622. //update the cursor
  7623. this._blinkIsEven = false;
  7624. if (this._cursorIndex === -1) {
  7625. this._cursorIndex = offset;
  7626. }
  7627. else {
  7628. if (this._cursorIndex < this._cursorOffset) {
  7629. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7630. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7631. }
  7632. else if (this._cursorIndex > this._cursorOffset) {
  7633. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7634. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7635. }
  7636. else {
  7637. this._isTextHighlightOn = false;
  7638. this._markAsDirty();
  7639. return;
  7640. }
  7641. }
  7642. this._isTextHighlightOn = true;
  7643. this._markAsDirty();
  7644. };
  7645. /** @hidden */
  7646. InputText.prototype._processDblClick = function (evt) {
  7647. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7648. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7649. this._endHighlightIndex = this._startHighlightIndex;
  7650. var rWord = /\w+/g, moveLeft, moveRight;
  7651. do {
  7652. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7653. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7654. } while (moveLeft || moveRight);
  7655. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7656. this.onTextHighlightObservable.notifyObservers(this);
  7657. this._isTextHighlightOn = true;
  7658. this._clickedCoordinate = null;
  7659. this._blinkIsEven = true;
  7660. this._cursorIndex = -1;
  7661. this._markAsDirty();
  7662. };
  7663. /** @hidden */
  7664. InputText.prototype._selectAllText = function () {
  7665. this._blinkIsEven = true;
  7666. this._isTextHighlightOn = true;
  7667. this._startHighlightIndex = 0;
  7668. this._endHighlightIndex = this._text.length;
  7669. this._cursorOffset = this._text.length;
  7670. this._cursorIndex = -1;
  7671. this._markAsDirty();
  7672. };
  7673. /**
  7674. * Handles the keyboard event
  7675. * @param evt Defines the KeyboardEvent
  7676. */
  7677. InputText.prototype.processKeyboard = function (evt) {
  7678. // process pressed key
  7679. this.processKey(evt.keyCode, evt.key, evt);
  7680. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7681. };
  7682. /** @hidden */
  7683. InputText.prototype._onCopyText = function (ev) {
  7684. this._isTextHighlightOn = false;
  7685. //when write permission to clipbaord data is denied
  7686. try {
  7687. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7688. }
  7689. catch (_a) { } //pass
  7690. this._host.clipboardData = this._highlightedText;
  7691. };
  7692. /** @hidden */
  7693. InputText.prototype._onCutText = function (ev) {
  7694. if (!this._highlightedText) {
  7695. return;
  7696. }
  7697. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7698. this._isTextHighlightOn = false;
  7699. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7700. //when write permission to clipbaord data is denied
  7701. try {
  7702. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7703. }
  7704. catch (_a) { } //pass
  7705. this._host.clipboardData = this._highlightedText;
  7706. this._highlightedText = "";
  7707. };
  7708. /** @hidden */
  7709. InputText.prototype._onPasteText = function (ev) {
  7710. var data = "";
  7711. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7712. data = ev.clipboardData.getData("text/plain");
  7713. }
  7714. else {
  7715. //get the cached data; returns blank string by default
  7716. data = this._host.clipboardData;
  7717. }
  7718. var insertPosition = this._text.length - this._cursorOffset;
  7719. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7720. };
  7721. InputText.prototype._draw = function (context) {
  7722. var _this = this;
  7723. context.save();
  7724. this._applyStates(context);
  7725. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7726. context.shadowColor = this.shadowColor;
  7727. context.shadowBlur = this.shadowBlur;
  7728. context.shadowOffsetX = this.shadowOffsetX;
  7729. context.shadowOffsetY = this.shadowOffsetY;
  7730. }
  7731. // Background
  7732. if (this._isFocused) {
  7733. if (this._focusedBackground) {
  7734. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7735. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7736. }
  7737. }
  7738. else if (this._background) {
  7739. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7740. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7741. }
  7742. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7743. context.shadowBlur = 0;
  7744. context.shadowOffsetX = 0;
  7745. context.shadowOffsetY = 0;
  7746. }
  7747. if (!this._fontOffset) {
  7748. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7749. }
  7750. // Text
  7751. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7752. if (this.color) {
  7753. context.fillStyle = this.color;
  7754. }
  7755. var text = this._beforeRenderText(this._text);
  7756. if (!this._isFocused && !this._text && this._placeholderText) {
  7757. text = this._placeholderText;
  7758. if (this._placeholderColor) {
  7759. context.fillStyle = this._placeholderColor;
  7760. }
  7761. }
  7762. this._textWidth = context.measureText(text).width;
  7763. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7764. if (this._autoStretchWidth) {
  7765. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7766. }
  7767. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7768. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7769. context.save();
  7770. context.beginPath();
  7771. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7772. context.clip();
  7773. if (this._isFocused && this._textWidth > availableWidth) {
  7774. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7775. if (!this._scrollLeft) {
  7776. this._scrollLeft = textLeft;
  7777. }
  7778. }
  7779. else {
  7780. this._scrollLeft = clipTextLeft;
  7781. }
  7782. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7783. // Cursor
  7784. if (this._isFocused) {
  7785. // Need to move cursor
  7786. if (this._clickedCoordinate) {
  7787. var rightPosition = this._scrollLeft + this._textWidth;
  7788. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7789. var currentSize = 0;
  7790. this._cursorOffset = 0;
  7791. var previousDist = 0;
  7792. do {
  7793. if (this._cursorOffset) {
  7794. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7795. }
  7796. this._cursorOffset++;
  7797. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7798. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7799. // Find closest move
  7800. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7801. this._cursorOffset--;
  7802. }
  7803. this._blinkIsEven = false;
  7804. this._clickedCoordinate = null;
  7805. }
  7806. // Render cursor
  7807. if (!this._blinkIsEven) {
  7808. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7809. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7810. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7811. if (cursorLeft < clipTextLeft) {
  7812. this._scrollLeft += (clipTextLeft - cursorLeft);
  7813. cursorLeft = clipTextLeft;
  7814. this._markAsDirty();
  7815. }
  7816. else if (cursorLeft > clipTextLeft + availableWidth) {
  7817. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7818. cursorLeft = clipTextLeft + availableWidth;
  7819. this._markAsDirty();
  7820. }
  7821. if (!this._isTextHighlightOn) {
  7822. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7823. }
  7824. }
  7825. clearTimeout(this._blinkTimeout);
  7826. this._blinkTimeout = setTimeout(function () {
  7827. _this._blinkIsEven = !_this._blinkIsEven;
  7828. _this._markAsDirty();
  7829. }, 500);
  7830. //show the highlighted text
  7831. if (this._isTextHighlightOn) {
  7832. clearTimeout(this._blinkTimeout);
  7833. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7834. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7835. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7836. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7837. if (highlightCursorLeft < clipTextLeft) {
  7838. width = width - (clipTextLeft - highlightCursorLeft);
  7839. if (!width) {
  7840. // when using left arrow on text.length > availableWidth;
  7841. // assigns the width of the first letter after clipTextLeft
  7842. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7843. }
  7844. highlightCursorLeft = clipTextLeft;
  7845. }
  7846. //for transparancy
  7847. context.globalAlpha = this._highligherOpacity;
  7848. context.fillStyle = this._textHighlightColor;
  7849. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7850. context.globalAlpha = 1.0;
  7851. }
  7852. }
  7853. context.restore();
  7854. // Border
  7855. if (this._thickness) {
  7856. if (this._isFocused) {
  7857. if (this.focusedColor) {
  7858. context.strokeStyle = this.focusedColor;
  7859. }
  7860. }
  7861. else {
  7862. if (this.color) {
  7863. context.strokeStyle = this.color;
  7864. }
  7865. }
  7866. context.lineWidth = this._thickness;
  7867. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7868. }
  7869. context.restore();
  7870. };
  7871. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7872. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7873. return false;
  7874. }
  7875. this._clickedCoordinate = coordinates.x;
  7876. this._isTextHighlightOn = false;
  7877. this._highlightedText = "";
  7878. this._cursorIndex = -1;
  7879. this._isPointerDown = true;
  7880. this._host._capturingControl[pointerId] = this;
  7881. if (this._host.focusedControl === this) {
  7882. // Move cursor
  7883. clearTimeout(this._blinkTimeout);
  7884. this._markAsDirty();
  7885. return true;
  7886. }
  7887. if (!this._isEnabled) {
  7888. return false;
  7889. }
  7890. this._host.focusedControl = this;
  7891. return true;
  7892. };
  7893. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7894. if (this._host.focusedControl === this && this._isPointerDown) {
  7895. this._clickedCoordinate = coordinates.x;
  7896. this._markAsDirty();
  7897. this._updateValueFromCursorIndex(this._cursorOffset);
  7898. }
  7899. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7900. };
  7901. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7902. this._isPointerDown = false;
  7903. delete this._host._capturingControl[pointerId];
  7904. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7905. };
  7906. InputText.prototype._beforeRenderText = function (text) {
  7907. return text;
  7908. };
  7909. InputText.prototype.dispose = function () {
  7910. _super.prototype.dispose.call(this);
  7911. this.onBlurObservable.clear();
  7912. this.onFocusObservable.clear();
  7913. this.onTextChangedObservable.clear();
  7914. this.onTextCopyObservable.clear();
  7915. this.onTextCutObservable.clear();
  7916. this.onTextPasteObservable.clear();
  7917. this.onTextHighlightObservable.clear();
  7918. this.onKeyboardEventProcessedObservable.clear();
  7919. };
  7920. return InputText;
  7921. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7922. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7923. /***/ }),
  7924. /***/ "./2D/controls/line.ts":
  7925. /*!*****************************!*\
  7926. !*** ./2D/controls/line.ts ***!
  7927. \*****************************/
  7928. /*! exports provided: Line */
  7929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7930. "use strict";
  7931. __webpack_require__.r(__webpack_exports__);
  7932. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7933. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7934. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7935. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7936. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7937. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7938. /** Class used to render 2D lines */
  7939. var Line = /** @class */ (function (_super) {
  7940. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7941. /**
  7942. * Creates a new Line
  7943. * @param name defines the control name
  7944. */
  7945. function Line(name) {
  7946. var _this = _super.call(this, name) || this;
  7947. _this.name = name;
  7948. _this._lineWidth = 1;
  7949. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7950. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7951. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7952. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7953. _this._dash = new Array();
  7954. _this.isHitTestVisible = false;
  7955. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7956. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7957. return _this;
  7958. }
  7959. Object.defineProperty(Line.prototype, "dash", {
  7960. /** Gets or sets the dash pattern */
  7961. get: function () {
  7962. return this._dash;
  7963. },
  7964. set: function (value) {
  7965. if (this._dash === value) {
  7966. return;
  7967. }
  7968. this._dash = value;
  7969. this._markAsDirty();
  7970. },
  7971. enumerable: true,
  7972. configurable: true
  7973. });
  7974. Object.defineProperty(Line.prototype, "connectedControl", {
  7975. /** Gets or sets the control connected with the line end */
  7976. get: function () {
  7977. return this._connectedControl;
  7978. },
  7979. set: function (value) {
  7980. var _this = this;
  7981. if (this._connectedControl === value) {
  7982. return;
  7983. }
  7984. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7985. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7986. this._connectedControlDirtyObserver = null;
  7987. }
  7988. if (value) {
  7989. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7990. }
  7991. this._connectedControl = value;
  7992. this._markAsDirty();
  7993. },
  7994. enumerable: true,
  7995. configurable: true
  7996. });
  7997. Object.defineProperty(Line.prototype, "x1", {
  7998. /** Gets or sets start coordinates on X axis */
  7999. get: function () {
  8000. return this._x1.toString(this._host);
  8001. },
  8002. set: function (value) {
  8003. if (this._x1.toString(this._host) === value) {
  8004. return;
  8005. }
  8006. if (this._x1.fromString(value)) {
  8007. this._markAsDirty();
  8008. }
  8009. },
  8010. enumerable: true,
  8011. configurable: true
  8012. });
  8013. Object.defineProperty(Line.prototype, "y1", {
  8014. /** Gets or sets start coordinates on Y axis */
  8015. get: function () {
  8016. return this._y1.toString(this._host);
  8017. },
  8018. set: function (value) {
  8019. if (this._y1.toString(this._host) === value) {
  8020. return;
  8021. }
  8022. if (this._y1.fromString(value)) {
  8023. this._markAsDirty();
  8024. }
  8025. },
  8026. enumerable: true,
  8027. configurable: true
  8028. });
  8029. Object.defineProperty(Line.prototype, "x2", {
  8030. /** Gets or sets end coordinates on X axis */
  8031. get: function () {
  8032. return this._x2.toString(this._host);
  8033. },
  8034. set: function (value) {
  8035. if (this._x2.toString(this._host) === value) {
  8036. return;
  8037. }
  8038. if (this._x2.fromString(value)) {
  8039. this._markAsDirty();
  8040. }
  8041. },
  8042. enumerable: true,
  8043. configurable: true
  8044. });
  8045. Object.defineProperty(Line.prototype, "y2", {
  8046. /** Gets or sets end coordinates on Y axis */
  8047. get: function () {
  8048. return this._y2.toString(this._host);
  8049. },
  8050. set: function (value) {
  8051. if (this._y2.toString(this._host) === value) {
  8052. return;
  8053. }
  8054. if (this._y2.fromString(value)) {
  8055. this._markAsDirty();
  8056. }
  8057. },
  8058. enumerable: true,
  8059. configurable: true
  8060. });
  8061. Object.defineProperty(Line.prototype, "lineWidth", {
  8062. /** Gets or sets line width */
  8063. get: function () {
  8064. return this._lineWidth;
  8065. },
  8066. set: function (value) {
  8067. if (this._lineWidth === value) {
  8068. return;
  8069. }
  8070. this._lineWidth = value;
  8071. this._markAsDirty();
  8072. },
  8073. enumerable: true,
  8074. configurable: true
  8075. });
  8076. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8077. /** Gets or sets horizontal alignment */
  8078. set: function (value) {
  8079. return;
  8080. },
  8081. enumerable: true,
  8082. configurable: true
  8083. });
  8084. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8085. /** Gets or sets vertical alignment */
  8086. set: function (value) {
  8087. return;
  8088. },
  8089. enumerable: true,
  8090. configurable: true
  8091. });
  8092. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8093. get: function () {
  8094. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8095. },
  8096. enumerable: true,
  8097. configurable: true
  8098. });
  8099. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8100. get: function () {
  8101. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8102. },
  8103. enumerable: true,
  8104. configurable: true
  8105. });
  8106. Line.prototype._getTypeName = function () {
  8107. return "Line";
  8108. };
  8109. Line.prototype._draw = function (context) {
  8110. context.save();
  8111. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8112. context.shadowColor = this.shadowColor;
  8113. context.shadowBlur = this.shadowBlur;
  8114. context.shadowOffsetX = this.shadowOffsetX;
  8115. context.shadowOffsetY = this.shadowOffsetY;
  8116. }
  8117. this._applyStates(context);
  8118. context.strokeStyle = this.color;
  8119. context.lineWidth = this._lineWidth;
  8120. context.setLineDash(this._dash);
  8121. context.beginPath();
  8122. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8123. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8124. context.stroke();
  8125. context.restore();
  8126. };
  8127. Line.prototype._measure = function () {
  8128. // Width / Height
  8129. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8130. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8131. };
  8132. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8133. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8134. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8135. };
  8136. /**
  8137. * Move one end of the line given 3D cartesian coordinates.
  8138. * @param position Targeted world position
  8139. * @param scene Scene
  8140. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8141. */
  8142. Line.prototype.moveToVector3 = function (position, scene, end) {
  8143. if (end === void 0) { end = false; }
  8144. if (!this._host || this.parent !== this._host._rootContainer) {
  8145. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8146. return;
  8147. }
  8148. var globalViewport = this._host._getGlobalViewport(scene);
  8149. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8150. this._moveToProjectedPosition(projectedPosition, end);
  8151. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8152. this.notRenderable = true;
  8153. return;
  8154. }
  8155. this.notRenderable = false;
  8156. };
  8157. /**
  8158. * Move one end of the line to a position in screen absolute space.
  8159. * @param projectedPosition Position in screen absolute space (X, Y)
  8160. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8161. */
  8162. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8163. if (end === void 0) { end = false; }
  8164. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8165. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8166. if (end) {
  8167. this.x2 = x;
  8168. this.y2 = y;
  8169. this._x2.ignoreAdaptiveScaling = true;
  8170. this._y2.ignoreAdaptiveScaling = true;
  8171. }
  8172. else {
  8173. this.x1 = x;
  8174. this.y1 = y;
  8175. this._x1.ignoreAdaptiveScaling = true;
  8176. this._y1.ignoreAdaptiveScaling = true;
  8177. }
  8178. };
  8179. return Line;
  8180. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8181. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8182. /***/ }),
  8183. /***/ "./2D/controls/multiLine.ts":
  8184. /*!**********************************!*\
  8185. !*** ./2D/controls/multiLine.ts ***!
  8186. \**********************************/
  8187. /*! exports provided: MultiLine */
  8188. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8189. "use strict";
  8190. __webpack_require__.r(__webpack_exports__);
  8191. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8192. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8193. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8194. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8195. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8196. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8197. /**
  8198. * Class used to create multi line control
  8199. */
  8200. var MultiLine = /** @class */ (function (_super) {
  8201. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8202. /**
  8203. * Creates a new MultiLine
  8204. * @param name defines the control name
  8205. */
  8206. function MultiLine(name) {
  8207. var _this = _super.call(this, name) || this;
  8208. _this.name = name;
  8209. _this._lineWidth = 1;
  8210. /** Function called when a point is updated */
  8211. _this.onPointUpdate = function () {
  8212. _this._markAsDirty();
  8213. };
  8214. _this.isHitTestVisible = false;
  8215. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8216. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8217. _this._dash = [];
  8218. _this._points = [];
  8219. return _this;
  8220. }
  8221. Object.defineProperty(MultiLine.prototype, "dash", {
  8222. /** Gets or sets dash pattern */
  8223. get: function () {
  8224. return this._dash;
  8225. },
  8226. set: function (value) {
  8227. if (this._dash === value) {
  8228. return;
  8229. }
  8230. this._dash = value;
  8231. this._markAsDirty();
  8232. },
  8233. enumerable: true,
  8234. configurable: true
  8235. });
  8236. /**
  8237. * Gets point stored at specified index
  8238. * @param index defines the index to look for
  8239. * @returns the requested point if found
  8240. */
  8241. MultiLine.prototype.getAt = function (index) {
  8242. if (!this._points[index]) {
  8243. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8244. }
  8245. return this._points[index];
  8246. };
  8247. /**
  8248. * Adds new points to the point collection
  8249. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8250. * @returns the list of created MultiLinePoint
  8251. */
  8252. MultiLine.prototype.add = function () {
  8253. var _this = this;
  8254. var items = [];
  8255. for (var _i = 0; _i < arguments.length; _i++) {
  8256. items[_i] = arguments[_i];
  8257. }
  8258. return items.map(function (item) { return _this.push(item); });
  8259. };
  8260. /**
  8261. * Adds a new point to the point collection
  8262. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8263. * @returns the created MultiLinePoint
  8264. */
  8265. MultiLine.prototype.push = function (item) {
  8266. var point = this.getAt(this._points.length);
  8267. if (item == null) {
  8268. return point;
  8269. }
  8270. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8271. point.mesh = item;
  8272. }
  8273. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8274. point.control = item;
  8275. }
  8276. else if (item.x != null && item.y != null) {
  8277. point.x = item.x;
  8278. point.y = item.y;
  8279. }
  8280. return point;
  8281. };
  8282. /**
  8283. * Remove a specific value or point from the active point collection
  8284. * @param value defines the value or point to remove
  8285. */
  8286. MultiLine.prototype.remove = function (value) {
  8287. var index;
  8288. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8289. index = this._points.indexOf(value);
  8290. if (index === -1) {
  8291. return;
  8292. }
  8293. }
  8294. else {
  8295. index = value;
  8296. }
  8297. var point = this._points[index];
  8298. if (!point) {
  8299. return;
  8300. }
  8301. point.dispose();
  8302. this._points.splice(index, 1);
  8303. };
  8304. /**
  8305. * Resets this object to initial state (no point)
  8306. */
  8307. MultiLine.prototype.reset = function () {
  8308. while (this._points.length > 0) {
  8309. this.remove(this._points.length - 1);
  8310. }
  8311. };
  8312. /**
  8313. * Resets all links
  8314. */
  8315. MultiLine.prototype.resetLinks = function () {
  8316. this._points.forEach(function (point) {
  8317. if (point != null) {
  8318. point.resetLinks();
  8319. }
  8320. });
  8321. };
  8322. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8323. /** Gets or sets line width */
  8324. get: function () {
  8325. return this._lineWidth;
  8326. },
  8327. set: function (value) {
  8328. if (this._lineWidth === value) {
  8329. return;
  8330. }
  8331. this._lineWidth = value;
  8332. this._markAsDirty();
  8333. },
  8334. enumerable: true,
  8335. configurable: true
  8336. });
  8337. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8338. set: function (value) {
  8339. return;
  8340. },
  8341. enumerable: true,
  8342. configurable: true
  8343. });
  8344. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8345. set: function (value) {
  8346. return;
  8347. },
  8348. enumerable: true,
  8349. configurable: true
  8350. });
  8351. MultiLine.prototype._getTypeName = function () {
  8352. return "MultiLine";
  8353. };
  8354. MultiLine.prototype._draw = function (context) {
  8355. context.save();
  8356. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8357. context.shadowColor = this.shadowColor;
  8358. context.shadowBlur = this.shadowBlur;
  8359. context.shadowOffsetX = this.shadowOffsetX;
  8360. context.shadowOffsetY = this.shadowOffsetY;
  8361. }
  8362. this._applyStates(context);
  8363. context.strokeStyle = this.color;
  8364. context.lineWidth = this._lineWidth;
  8365. context.setLineDash(this._dash);
  8366. context.beginPath();
  8367. var first = true; //first index is not necessarily 0
  8368. this._points.forEach(function (point) {
  8369. if (!point) {
  8370. return;
  8371. }
  8372. if (first) {
  8373. context.moveTo(point._point.x, point._point.y);
  8374. first = false;
  8375. }
  8376. else {
  8377. context.lineTo(point._point.x, point._point.y);
  8378. }
  8379. });
  8380. context.stroke();
  8381. context.restore();
  8382. };
  8383. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8384. var _this = this;
  8385. this._minX = null;
  8386. this._minY = null;
  8387. this._maxX = null;
  8388. this._maxY = null;
  8389. this._points.forEach(function (point, index) {
  8390. if (!point) {
  8391. return;
  8392. }
  8393. point.translate();
  8394. if (_this._minX == null || point._point.x < _this._minX) {
  8395. _this._minX = point._point.x;
  8396. }
  8397. if (_this._minY == null || point._point.y < _this._minY) {
  8398. _this._minY = point._point.y;
  8399. }
  8400. if (_this._maxX == null || point._point.x > _this._maxX) {
  8401. _this._maxX = point._point.x;
  8402. }
  8403. if (_this._maxY == null || point._point.y > _this._maxY) {
  8404. _this._maxY = point._point.y;
  8405. }
  8406. });
  8407. if (this._minX == null) {
  8408. this._minX = 0;
  8409. }
  8410. if (this._minY == null) {
  8411. this._minY = 0;
  8412. }
  8413. if (this._maxX == null) {
  8414. this._maxX = 0;
  8415. }
  8416. if (this._maxY == null) {
  8417. this._maxY = 0;
  8418. }
  8419. };
  8420. MultiLine.prototype._measure = function () {
  8421. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8422. return;
  8423. }
  8424. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8425. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8426. };
  8427. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8428. if (this._minX == null || this._minY == null) {
  8429. return;
  8430. }
  8431. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8432. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8433. };
  8434. MultiLine.prototype.dispose = function () {
  8435. this.reset();
  8436. _super.prototype.dispose.call(this);
  8437. };
  8438. return MultiLine;
  8439. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8440. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8441. /***/ }),
  8442. /***/ "./2D/controls/radioButton.ts":
  8443. /*!************************************!*\
  8444. !*** ./2D/controls/radioButton.ts ***!
  8445. \************************************/
  8446. /*! exports provided: RadioButton */
  8447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8448. "use strict";
  8449. __webpack_require__.r(__webpack_exports__);
  8450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8451. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8452. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8453. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8454. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8455. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8456. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8457. /**
  8458. * Class used to create radio button controls
  8459. */
  8460. var RadioButton = /** @class */ (function (_super) {
  8461. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8462. /**
  8463. * Creates a new RadioButton
  8464. * @param name defines the control name
  8465. */
  8466. function RadioButton(name) {
  8467. var _this = _super.call(this, name) || this;
  8468. _this.name = name;
  8469. _this._isChecked = false;
  8470. _this._background = "black";
  8471. _this._checkSizeRatio = 0.8;
  8472. _this._thickness = 1;
  8473. /** Gets or sets group name */
  8474. _this.group = "";
  8475. /** Observable raised when isChecked is changed */
  8476. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8477. _this.isPointerBlocker = true;
  8478. return _this;
  8479. }
  8480. Object.defineProperty(RadioButton.prototype, "thickness", {
  8481. /** Gets or sets border thickness */
  8482. get: function () {
  8483. return this._thickness;
  8484. },
  8485. set: function (value) {
  8486. if (this._thickness === value) {
  8487. return;
  8488. }
  8489. this._thickness = value;
  8490. this._markAsDirty();
  8491. },
  8492. enumerable: true,
  8493. configurable: true
  8494. });
  8495. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8496. /** Gets or sets a value indicating the ratio between overall size and check size */
  8497. get: function () {
  8498. return this._checkSizeRatio;
  8499. },
  8500. set: function (value) {
  8501. value = Math.max(Math.min(1, value), 0);
  8502. if (this._checkSizeRatio === value) {
  8503. return;
  8504. }
  8505. this._checkSizeRatio = value;
  8506. this._markAsDirty();
  8507. },
  8508. enumerable: true,
  8509. configurable: true
  8510. });
  8511. Object.defineProperty(RadioButton.prototype, "background", {
  8512. /** Gets or sets background color */
  8513. get: function () {
  8514. return this._background;
  8515. },
  8516. set: function (value) {
  8517. if (this._background === value) {
  8518. return;
  8519. }
  8520. this._background = value;
  8521. this._markAsDirty();
  8522. },
  8523. enumerable: true,
  8524. configurable: true
  8525. });
  8526. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8527. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8528. get: function () {
  8529. return this._isChecked;
  8530. },
  8531. set: function (value) {
  8532. var _this = this;
  8533. if (this._isChecked === value) {
  8534. return;
  8535. }
  8536. this._isChecked = value;
  8537. this._markAsDirty();
  8538. this.onIsCheckedChangedObservable.notifyObservers(value);
  8539. if (this._isChecked && this._host) {
  8540. // Update all controls from same group
  8541. this._host.executeOnAllControls(function (control) {
  8542. if (control === _this) {
  8543. return;
  8544. }
  8545. if (control.group === undefined) {
  8546. return;
  8547. }
  8548. var childRadio = control;
  8549. if (childRadio.group === _this.group) {
  8550. childRadio.isChecked = false;
  8551. }
  8552. });
  8553. }
  8554. },
  8555. enumerable: true,
  8556. configurable: true
  8557. });
  8558. RadioButton.prototype._getTypeName = function () {
  8559. return "RadioButton";
  8560. };
  8561. RadioButton.prototype._draw = function (context) {
  8562. context.save();
  8563. this._applyStates(context);
  8564. var actualWidth = this._currentMeasure.width - this._thickness;
  8565. var actualHeight = this._currentMeasure.height - this._thickness;
  8566. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8567. context.shadowColor = this.shadowColor;
  8568. context.shadowBlur = this.shadowBlur;
  8569. context.shadowOffsetX = this.shadowOffsetX;
  8570. context.shadowOffsetY = this.shadowOffsetY;
  8571. }
  8572. // Outer
  8573. _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);
  8574. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8575. context.fill();
  8576. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8577. context.shadowBlur = 0;
  8578. context.shadowOffsetX = 0;
  8579. context.shadowOffsetY = 0;
  8580. }
  8581. context.strokeStyle = this.color;
  8582. context.lineWidth = this._thickness;
  8583. context.stroke();
  8584. // Inner
  8585. if (this._isChecked) {
  8586. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8587. var offsetWidth = actualWidth * this._checkSizeRatio;
  8588. var offseHeight = actualHeight * this._checkSizeRatio;
  8589. _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);
  8590. context.fill();
  8591. }
  8592. context.restore();
  8593. };
  8594. // Events
  8595. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8596. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8597. return false;
  8598. }
  8599. if (!this.isChecked) {
  8600. this.isChecked = true;
  8601. }
  8602. return true;
  8603. };
  8604. /**
  8605. * Utility function to easily create a radio button with a header
  8606. * @param title defines the label to use for the header
  8607. * @param group defines the group to use for the radio button
  8608. * @param isChecked defines the initial state of the radio button
  8609. * @param onValueChanged defines the callback to call when value changes
  8610. * @returns a StackPanel containing the radio button and a textBlock
  8611. */
  8612. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8613. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8614. panel.isVertical = false;
  8615. panel.height = "30px";
  8616. var radio = new RadioButton();
  8617. radio.width = "20px";
  8618. radio.height = "20px";
  8619. radio.isChecked = isChecked;
  8620. radio.color = "green";
  8621. radio.group = group;
  8622. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8623. panel.addControl(radio);
  8624. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8625. header.text = title;
  8626. header.width = "180px";
  8627. header.paddingLeft = "5px";
  8628. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8629. header.color = "white";
  8630. panel.addControl(header);
  8631. return panel;
  8632. };
  8633. return RadioButton;
  8634. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8635. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8636. /***/ }),
  8637. /***/ "./2D/controls/rectangle.ts":
  8638. /*!**********************************!*\
  8639. !*** ./2D/controls/rectangle.ts ***!
  8640. \**********************************/
  8641. /*! exports provided: Rectangle */
  8642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8643. "use strict";
  8644. __webpack_require__.r(__webpack_exports__);
  8645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8647. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8648. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  8649. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8650. /** Class used to create rectangle container */
  8651. var Rectangle = /** @class */ (function (_super) {
  8652. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8653. /**
  8654. * Creates a new Rectangle
  8655. * @param name defines the control name
  8656. */
  8657. function Rectangle(name) {
  8658. var _this = _super.call(this, name) || this;
  8659. _this.name = name;
  8660. _this._thickness = 1;
  8661. _this._cornerRadius = 0;
  8662. return _this;
  8663. }
  8664. Object.defineProperty(Rectangle.prototype, "thickness", {
  8665. /** Gets or sets border thickness */
  8666. get: function () {
  8667. return this._thickness;
  8668. },
  8669. set: function (value) {
  8670. if (this._thickness === value) {
  8671. return;
  8672. }
  8673. this._thickness = value;
  8674. this._markAsDirty();
  8675. },
  8676. enumerable: true,
  8677. configurable: true
  8678. });
  8679. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8680. /** Gets or sets the corner radius angle */
  8681. get: function () {
  8682. return this._cornerRadius;
  8683. },
  8684. set: function (value) {
  8685. if (value < 0) {
  8686. value = 0;
  8687. }
  8688. if (this._cornerRadius === value) {
  8689. return;
  8690. }
  8691. this._cornerRadius = value;
  8692. this._markAsDirty();
  8693. },
  8694. enumerable: true,
  8695. configurable: true
  8696. });
  8697. Rectangle.prototype._getTypeName = function () {
  8698. return "Rectangle";
  8699. };
  8700. Rectangle.prototype._localDraw = function (context) {
  8701. context.save();
  8702. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8703. context.shadowColor = this.shadowColor;
  8704. context.shadowBlur = this.shadowBlur;
  8705. context.shadowOffsetX = this.shadowOffsetX;
  8706. context.shadowOffsetY = this.shadowOffsetY;
  8707. }
  8708. if (this._background) {
  8709. context.fillStyle = this._background;
  8710. if (this._cornerRadius) {
  8711. this._drawRoundedRect(context, this._thickness / 2);
  8712. context.fill();
  8713. }
  8714. else {
  8715. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8716. }
  8717. }
  8718. if (this._thickness) {
  8719. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8720. context.shadowBlur = 0;
  8721. context.shadowOffsetX = 0;
  8722. context.shadowOffsetY = 0;
  8723. }
  8724. if (this.color) {
  8725. context.strokeStyle = this.color;
  8726. }
  8727. context.lineWidth = this._thickness;
  8728. if (this._cornerRadius) {
  8729. this._drawRoundedRect(context, this._thickness / 2);
  8730. context.stroke();
  8731. }
  8732. else {
  8733. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8734. }
  8735. }
  8736. context.restore();
  8737. };
  8738. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8739. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8740. this._measureForChildren.width -= 2 * this._thickness;
  8741. this._measureForChildren.height -= 2 * this._thickness;
  8742. this._measureForChildren.left += this._thickness;
  8743. this._measureForChildren.top += this._thickness;
  8744. };
  8745. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8746. if (offset === void 0) { offset = 0; }
  8747. var x = this._currentMeasure.left + offset;
  8748. var y = this._currentMeasure.top + offset;
  8749. var width = this._currentMeasure.width - offset * 2;
  8750. var height = this._currentMeasure.height - offset * 2;
  8751. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8752. context.beginPath();
  8753. context.moveTo(x + radius, y);
  8754. context.lineTo(x + width - radius, y);
  8755. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8756. context.lineTo(x + width, y + height - radius);
  8757. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8758. context.lineTo(x + radius, y + height);
  8759. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8760. context.lineTo(x, y + radius);
  8761. context.quadraticCurveTo(x, y, x + radius, y);
  8762. context.closePath();
  8763. };
  8764. Rectangle.prototype._clipForChildren = function (context) {
  8765. if (this._cornerRadius) {
  8766. this._drawRoundedRect(context, this._thickness);
  8767. context.clip();
  8768. }
  8769. };
  8770. return Rectangle;
  8771. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8772. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8773. /***/ }),
  8774. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8775. /*!***************************************************!*\
  8776. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8777. \***************************************************/
  8778. /*! exports provided: ScrollViewer */
  8779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8780. "use strict";
  8781. __webpack_require__.r(__webpack_exports__);
  8782. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8783. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8784. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8785. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8786. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8787. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8788. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8789. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8790. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8791. /**
  8792. * Class used to hold a viewer window and sliders in a grid
  8793. */
  8794. var ScrollViewer = /** @class */ (function (_super) {
  8795. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8796. /**
  8797. * Creates a new ScrollViewer
  8798. * @param name of ScrollViewer
  8799. */
  8800. function ScrollViewer(name) {
  8801. var _this = _super.call(this, name) || this;
  8802. _this._barSize = 20;
  8803. _this._pointerIsOver = false;
  8804. _this._wheelPrecision = 0.05;
  8805. _this.onDirtyObservable.add(function () {
  8806. _this._horizontalBarSpace.color = _this.color;
  8807. _this._verticalBarSpace.color = _this.color;
  8808. _this._dragSpace.color = _this.color;
  8809. });
  8810. _this.onPointerEnterObservable.add(function () {
  8811. _this._pointerIsOver = true;
  8812. });
  8813. _this.onPointerOutObservable.add(function () {
  8814. _this._pointerIsOver = false;
  8815. });
  8816. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8817. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8818. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8819. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8820. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8821. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8822. _this._grid.addColumnDefinition(1);
  8823. _this._grid.addColumnDefinition(0, true);
  8824. _this._grid.addRowDefinition(1);
  8825. _this._grid.addRowDefinition(0, true);
  8826. _super.prototype.addControl.call(_this, _this._grid);
  8827. _this._grid.addControl(_this._window, 0, 0);
  8828. _this._verticalBar.paddingLeft = 0;
  8829. _this._verticalBar.width = "100%";
  8830. _this._verticalBar.height = "100%";
  8831. _this._verticalBar.barOffset = 0;
  8832. _this._verticalBar.value = 0;
  8833. _this._verticalBar.maximum = 1;
  8834. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8835. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8836. _this._verticalBar.isVertical = true;
  8837. _this._verticalBar.rotation = Math.PI;
  8838. _this._verticalBar.isVisible = false;
  8839. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8840. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8841. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8842. _this._verticalBarSpace.thickness = 1;
  8843. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8844. _this._verticalBarSpace.addControl(_this._verticalBar);
  8845. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8846. _this._window.top = value * _this._endTop + "px";
  8847. });
  8848. _this._horizontalBar.paddingLeft = 0;
  8849. _this._horizontalBar.width = "100%";
  8850. _this._horizontalBar.height = "100%";
  8851. _this._horizontalBar.barOffset = 0;
  8852. _this._horizontalBar.value = 0;
  8853. _this._horizontalBar.maximum = 1;
  8854. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8855. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8856. _this._horizontalBar.isVisible = false;
  8857. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8858. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8859. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8860. _this._horizontalBarSpace.thickness = 1;
  8861. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8862. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8863. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8864. _this._window.left = value * _this._endLeft + "px";
  8865. });
  8866. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8867. _this._dragSpace.thickness = 1;
  8868. _this._grid.addControl(_this._dragSpace, 1, 1);
  8869. // Colors
  8870. _this.barColor = "grey";
  8871. _this.barBackground = "transparent";
  8872. return _this;
  8873. }
  8874. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8875. /**
  8876. * Gets the horizontal scrollbar
  8877. */
  8878. get: function () {
  8879. return this._horizontalBar;
  8880. },
  8881. enumerable: true,
  8882. configurable: true
  8883. });
  8884. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8885. /**
  8886. * Gets the vertical scrollbar
  8887. */
  8888. get: function () {
  8889. return this._verticalBar;
  8890. },
  8891. enumerable: true,
  8892. configurable: true
  8893. });
  8894. /**
  8895. * Adds a new control to the current container
  8896. * @param control defines the control to add
  8897. * @returns the current container
  8898. */
  8899. ScrollViewer.prototype.addControl = function (control) {
  8900. if (!control) {
  8901. return this;
  8902. }
  8903. this._window.addControl(control);
  8904. return this;
  8905. };
  8906. /**
  8907. * Removes a control from the current container
  8908. * @param control defines the control to remove
  8909. * @returns the current container
  8910. */
  8911. ScrollViewer.prototype.removeControl = function (control) {
  8912. this._window.removeControl(control);
  8913. return this;
  8914. };
  8915. Object.defineProperty(ScrollViewer.prototype, "children", {
  8916. /** Gets the list of children */
  8917. get: function () {
  8918. return this._window.children;
  8919. },
  8920. enumerable: true,
  8921. configurable: true
  8922. });
  8923. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8924. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8925. var child = _a[_i];
  8926. child._markMatrixAsDirty();
  8927. }
  8928. };
  8929. /** Reset the scroll viewer window to initial size */
  8930. ScrollViewer.prototype.resetWindow = function () {
  8931. this._window.width = "100%";
  8932. this._window.height = "100%";
  8933. };
  8934. ScrollViewer.prototype._getTypeName = function () {
  8935. return "ScrollViewer";
  8936. };
  8937. ScrollViewer.prototype._buildClientSizes = function () {
  8938. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8939. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8940. this._clientWidth = this._window.parentClientWidth;
  8941. this._clientHeight = this._window.parentClientHeight;
  8942. };
  8943. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8944. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8945. this._buildClientSizes();
  8946. };
  8947. ScrollViewer.prototype._postMeasure = function () {
  8948. _super.prototype._postMeasure.call(this);
  8949. this._updateScroller();
  8950. };
  8951. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8952. /**
  8953. * Gets or sets the mouse wheel precision
  8954. * from 0 to 1 with a default value of 0.05
  8955. * */
  8956. get: function () {
  8957. return this._wheelPrecision;
  8958. },
  8959. set: function (value) {
  8960. if (this._wheelPrecision === value) {
  8961. return;
  8962. }
  8963. if (value < 0) {
  8964. value = 0;
  8965. }
  8966. if (value > 1) {
  8967. value = 1;
  8968. }
  8969. this._wheelPrecision = value;
  8970. },
  8971. enumerable: true,
  8972. configurable: true
  8973. });
  8974. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8975. /** Gets or sets the bar color */
  8976. get: function () {
  8977. return this._barColor;
  8978. },
  8979. set: function (color) {
  8980. if (this._barColor === color) {
  8981. return;
  8982. }
  8983. this._barColor = color;
  8984. this._horizontalBar.color = color;
  8985. this._verticalBar.color = color;
  8986. },
  8987. enumerable: true,
  8988. configurable: true
  8989. });
  8990. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8991. /** Gets or sets the size of the bar */
  8992. get: function () {
  8993. return this._barSize;
  8994. },
  8995. set: function (value) {
  8996. if (this._barSize === value) {
  8997. return;
  8998. }
  8999. this._barSize = value;
  9000. this._markAsDirty();
  9001. if (this._horizontalBar.isVisible) {
  9002. this._grid.setRowDefinition(1, this._barSize, true);
  9003. }
  9004. if (this._verticalBar.isVisible) {
  9005. this._grid.setColumnDefinition(1, this._barSize, true);
  9006. }
  9007. },
  9008. enumerable: true,
  9009. configurable: true
  9010. });
  9011. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9012. /** Gets or sets the bar background */
  9013. get: function () {
  9014. return this._barBackground;
  9015. },
  9016. set: function (color) {
  9017. if (this._barBackground === color) {
  9018. return;
  9019. }
  9020. this._barBackground = color;
  9021. this._horizontalBar.background = color;
  9022. this._verticalBar.background = color;
  9023. this._dragSpace.background = color;
  9024. },
  9025. enumerable: true,
  9026. configurable: true
  9027. });
  9028. /** @hidden */
  9029. ScrollViewer.prototype._updateScroller = function () {
  9030. var windowContentsWidth = this._window._currentMeasure.width;
  9031. var windowContentsHeight = this._window._currentMeasure.height;
  9032. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9033. this._grid.setRowDefinition(1, 0, true);
  9034. this._horizontalBar.isVisible = false;
  9035. this._horizontalBar.value = 0;
  9036. this._rebuildLayout = true;
  9037. }
  9038. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9039. this._grid.setRowDefinition(1, this._barSize, true);
  9040. this._horizontalBar.isVisible = true;
  9041. this._rebuildLayout = true;
  9042. }
  9043. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9044. this._grid.setColumnDefinition(1, 0, true);
  9045. this._verticalBar.isVisible = false;
  9046. this._verticalBar.value = 0;
  9047. this._rebuildLayout = true;
  9048. }
  9049. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9050. this._grid.setColumnDefinition(1, this._barSize, true);
  9051. this._verticalBar.isVisible = true;
  9052. this._rebuildLayout = true;
  9053. }
  9054. this._buildClientSizes();
  9055. this._endLeft = this._clientWidth - windowContentsWidth;
  9056. this._endTop = this._clientHeight - windowContentsHeight;
  9057. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9058. var newTop = this._verticalBar.value * this._endTop + "px";
  9059. if (newLeft !== this._window.left) {
  9060. this._window.left = newLeft;
  9061. this._rebuildLayout = true;
  9062. }
  9063. if (newTop !== this._window.top) {
  9064. this._window.top = newTop;
  9065. this._rebuildLayout = true;
  9066. }
  9067. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  9068. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  9069. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  9070. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  9071. };
  9072. ScrollViewer.prototype._link = function (host) {
  9073. _super.prototype._link.call(this, host);
  9074. this._attachWheel();
  9075. };
  9076. /** @hidden */
  9077. ScrollViewer.prototype._attachWheel = function () {
  9078. var _this = this;
  9079. if (!this._host || this._onPointerObserver) {
  9080. return;
  9081. }
  9082. var scene = this._host.getScene();
  9083. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9084. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9085. return;
  9086. }
  9087. if (_this._verticalBar.isVisible == true) {
  9088. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9089. _this._verticalBar.value -= _this._wheelPrecision;
  9090. }
  9091. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9092. _this._verticalBar.value += _this._wheelPrecision;
  9093. }
  9094. }
  9095. if (_this._horizontalBar.isVisible == true) {
  9096. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9097. _this._horizontalBar.value += _this._wheelPrecision;
  9098. }
  9099. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9100. _this._horizontalBar.value -= _this._wheelPrecision;
  9101. }
  9102. }
  9103. });
  9104. };
  9105. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9106. if (!this.isHighlighted) {
  9107. return;
  9108. }
  9109. _super.prototype._renderHighlightSpecific.call(this, context);
  9110. this._grid._renderHighlightSpecific(context);
  9111. context.restore();
  9112. };
  9113. /** Releases associated resources */
  9114. ScrollViewer.prototype.dispose = function () {
  9115. var scene = this._host.getScene();
  9116. if (scene && this._onPointerObserver) {
  9117. scene.onPointerObservable.remove(this._onPointerObserver);
  9118. this._onPointerObserver = null;
  9119. }
  9120. _super.prototype.dispose.call(this);
  9121. };
  9122. return ScrollViewer;
  9123. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9124. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9125. /***/ }),
  9126. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9127. /*!*********************************************************!*\
  9128. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9129. \*********************************************************/
  9130. /*! exports provided: _ScrollViewerWindow */
  9131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9132. "use strict";
  9133. __webpack_require__.r(__webpack_exports__);
  9134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9135. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9136. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9137. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9138. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9139. /**
  9140. * Class used to hold a the container for ScrollViewer
  9141. * @hidden
  9142. */
  9143. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9144. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9145. /**
  9146. * Creates a new ScrollViewerWindow
  9147. * @param name of ScrollViewerWindow
  9148. */
  9149. function _ScrollViewerWindow(name) {
  9150. return _super.call(this, name) || this;
  9151. }
  9152. _ScrollViewerWindow.prototype._getTypeName = function () {
  9153. return "ScrollViewerWindow";
  9154. };
  9155. /** @hidden */
  9156. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9157. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9158. this._measureForChildren.left = this._currentMeasure.left;
  9159. this._measureForChildren.top = this._currentMeasure.top;
  9160. this._measureForChildren.width = parentMeasure.width;
  9161. this._measureForChildren.height = parentMeasure.height;
  9162. };
  9163. _ScrollViewerWindow.prototype._postMeasure = function () {
  9164. var maxWidth = this.parentClientWidth;
  9165. var maxHeight = this.parentClientHeight;
  9166. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9167. var child = _a[_i];
  9168. if (!child.isVisible || child.notRenderable) {
  9169. continue;
  9170. }
  9171. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9172. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9173. }
  9174. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9175. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9176. }
  9177. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9178. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9179. }
  9180. if (this._currentMeasure.width !== maxWidth) {
  9181. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9182. this._currentMeasure.width = maxWidth;
  9183. this._rebuildLayout = true;
  9184. this._isDirty = true;
  9185. }
  9186. if (this._currentMeasure.height !== maxHeight) {
  9187. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9188. this._currentMeasure.height = maxHeight;
  9189. this._rebuildLayout = true;
  9190. this._isDirty = true;
  9191. }
  9192. _super.prototype._postMeasure.call(this);
  9193. };
  9194. return _ScrollViewerWindow;
  9195. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9196. /***/ }),
  9197. /***/ "./2D/controls/selector.ts":
  9198. /*!*********************************!*\
  9199. !*** ./2D/controls/selector.ts ***!
  9200. \*********************************/
  9201. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9203. "use strict";
  9204. __webpack_require__.r(__webpack_exports__);
  9205. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9206. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9209. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9210. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9211. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9212. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9213. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9214. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9215. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9216. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9217. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9218. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9219. /** Class used to create a RadioGroup
  9220. * which contains groups of radio buttons
  9221. */
  9222. var SelectorGroup = /** @class */ (function () {
  9223. /**
  9224. * Creates a new SelectorGroup
  9225. * @param name of group, used as a group heading
  9226. */
  9227. function SelectorGroup(
  9228. /** name of SelectorGroup */
  9229. name) {
  9230. this.name = name;
  9231. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9232. this._selectors = new Array();
  9233. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9234. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9235. this._groupHeader = this._addGroupHeader(name);
  9236. }
  9237. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9238. /** Gets the groupPanel of the SelectorGroup */
  9239. get: function () {
  9240. return this._groupPanel;
  9241. },
  9242. enumerable: true,
  9243. configurable: true
  9244. });
  9245. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9246. /** Gets the selectors array */
  9247. get: function () {
  9248. return this._selectors;
  9249. },
  9250. enumerable: true,
  9251. configurable: true
  9252. });
  9253. Object.defineProperty(SelectorGroup.prototype, "header", {
  9254. /** Gets and sets the group header */
  9255. get: function () {
  9256. return this._groupHeader.text;
  9257. },
  9258. set: function (label) {
  9259. if (this._groupHeader.text === "label") {
  9260. return;
  9261. }
  9262. this._groupHeader.text = label;
  9263. },
  9264. enumerable: true,
  9265. configurable: true
  9266. });
  9267. /** @hidden */
  9268. SelectorGroup.prototype._addGroupHeader = function (text) {
  9269. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9270. groupHeading.width = 0.9;
  9271. groupHeading.height = "30px";
  9272. groupHeading.textWrapping = true;
  9273. groupHeading.color = "black";
  9274. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9275. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9276. groupHeading.left = "2px";
  9277. this._groupPanel.addControl(groupHeading);
  9278. return groupHeading;
  9279. };
  9280. /** @hidden*/
  9281. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9282. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9283. return;
  9284. }
  9285. return this._selectors[selectorNb];
  9286. };
  9287. /** Removes the selector at the given position
  9288. * @param selectorNb the position of the selector within the group
  9289. */
  9290. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9291. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9292. return;
  9293. }
  9294. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9295. this._selectors.splice(selectorNb, 1);
  9296. };
  9297. return SelectorGroup;
  9298. }());
  9299. /** Class used to create a CheckboxGroup
  9300. * which contains groups of checkbox buttons
  9301. */
  9302. var CheckboxGroup = /** @class */ (function (_super) {
  9303. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9304. function CheckboxGroup() {
  9305. return _super !== null && _super.apply(this, arguments) || this;
  9306. }
  9307. /** Adds a checkbox as a control
  9308. * @param text is the label for the selector
  9309. * @param func is the function called when the Selector is checked
  9310. * @param checked is true when Selector is checked
  9311. */
  9312. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9313. if (func === void 0) { func = function (s) { }; }
  9314. if (checked === void 0) { checked = false; }
  9315. var checked = checked || false;
  9316. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9317. button.width = "20px";
  9318. button.height = "20px";
  9319. button.color = "#364249";
  9320. button.background = "#CCCCCC";
  9321. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9322. button.onIsCheckedChangedObservable.add(function (state) {
  9323. func(state);
  9324. });
  9325. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9326. _selector.height = "30px";
  9327. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9328. _selector.left = "4px";
  9329. this.groupPanel.addControl(_selector);
  9330. this.selectors.push(_selector);
  9331. button.isChecked = checked;
  9332. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9333. button.color = this.groupPanel.parent.parent.buttonColor;
  9334. button.background = this.groupPanel.parent.parent.buttonBackground;
  9335. }
  9336. };
  9337. /** @hidden */
  9338. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9339. this.selectors[selectorNb].children[1].text = label;
  9340. };
  9341. /** @hidden */
  9342. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9343. this.selectors[selectorNb].children[1].color = color;
  9344. };
  9345. /** @hidden */
  9346. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9347. this.selectors[selectorNb].children[0].color = color;
  9348. };
  9349. /** @hidden */
  9350. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9351. this.selectors[selectorNb].children[0].background = color;
  9352. };
  9353. return CheckboxGroup;
  9354. }(SelectorGroup));
  9355. /** Class used to create a RadioGroup
  9356. * which contains groups of radio buttons
  9357. */
  9358. var RadioGroup = /** @class */ (function (_super) {
  9359. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9360. function RadioGroup() {
  9361. var _this = _super !== null && _super.apply(this, arguments) || this;
  9362. _this._selectNb = 0;
  9363. return _this;
  9364. }
  9365. /** Adds a radio button as a control
  9366. * @param label is the label for the selector
  9367. * @param func is the function called when the Selector is checked
  9368. * @param checked is true when Selector is checked
  9369. */
  9370. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9371. if (func === void 0) { func = function (n) { }; }
  9372. if (checked === void 0) { checked = false; }
  9373. var nb = this._selectNb++;
  9374. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9375. button.name = label;
  9376. button.width = "20px";
  9377. button.height = "20px";
  9378. button.color = "#364249";
  9379. button.background = "#CCCCCC";
  9380. button.group = this.name;
  9381. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9382. button.onIsCheckedChangedObservable.add(function (state) {
  9383. if (state) {
  9384. func(nb);
  9385. }
  9386. });
  9387. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9388. _selector.height = "30px";
  9389. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9390. _selector.left = "4px";
  9391. this.groupPanel.addControl(_selector);
  9392. this.selectors.push(_selector);
  9393. button.isChecked = checked;
  9394. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9395. button.color = this.groupPanel.parent.parent.buttonColor;
  9396. button.background = this.groupPanel.parent.parent.buttonBackground;
  9397. }
  9398. };
  9399. /** @hidden */
  9400. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9401. this.selectors[selectorNb].children[1].text = label;
  9402. };
  9403. /** @hidden */
  9404. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9405. this.selectors[selectorNb].children[1].color = color;
  9406. };
  9407. /** @hidden */
  9408. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9409. this.selectors[selectorNb].children[0].color = color;
  9410. };
  9411. /** @hidden */
  9412. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9413. this.selectors[selectorNb].children[0].background = color;
  9414. };
  9415. return RadioGroup;
  9416. }(SelectorGroup));
  9417. /** Class used to create a SliderGroup
  9418. * which contains groups of slider buttons
  9419. */
  9420. var SliderGroup = /** @class */ (function (_super) {
  9421. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9422. function SliderGroup() {
  9423. return _super !== null && _super.apply(this, arguments) || this;
  9424. }
  9425. /**
  9426. * Adds a slider to the SelectorGroup
  9427. * @param label is the label for the SliderBar
  9428. * @param func is the function called when the Slider moves
  9429. * @param unit is a string describing the units used, eg degrees or metres
  9430. * @param min is the minimum value for the Slider
  9431. * @param max is the maximum value for the Slider
  9432. * @param value is the start value for the Slider between min and max
  9433. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9434. */
  9435. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9436. if (func === void 0) { func = function (v) { }; }
  9437. if (unit === void 0) { unit = "Units"; }
  9438. if (min === void 0) { min = 0; }
  9439. if (max === void 0) { max = 0; }
  9440. if (value === void 0) { value = 0; }
  9441. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9442. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9443. button.name = unit;
  9444. button.value = value;
  9445. button.minimum = min;
  9446. button.maximum = max;
  9447. button.width = 0.9;
  9448. button.height = "20px";
  9449. button.color = "#364249";
  9450. button.background = "#CCCCCC";
  9451. button.borderColor = "black";
  9452. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9453. button.left = "4px";
  9454. button.paddingBottom = "4px";
  9455. button.onValueChangedObservable.add(function (value) {
  9456. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9457. func(value);
  9458. });
  9459. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9460. _selector.height = "60px";
  9461. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9462. _selector.left = "4px";
  9463. _selector.children[0].name = label;
  9464. this.groupPanel.addControl(_selector);
  9465. this.selectors.push(_selector);
  9466. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9467. button.color = this.groupPanel.parent.parent.buttonColor;
  9468. button.background = this.groupPanel.parent.parent.buttonBackground;
  9469. }
  9470. };
  9471. /** @hidden */
  9472. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9473. this.selectors[selectorNb].children[0].name = label;
  9474. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9475. };
  9476. /** @hidden */
  9477. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9478. this.selectors[selectorNb].children[0].color = color;
  9479. };
  9480. /** @hidden */
  9481. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9482. this.selectors[selectorNb].children[1].color = color;
  9483. };
  9484. /** @hidden */
  9485. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9486. this.selectors[selectorNb].children[1].background = color;
  9487. };
  9488. return SliderGroup;
  9489. }(SelectorGroup));
  9490. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9491. * @see http://doc.babylonjs.com/how_to/selector
  9492. */
  9493. var SelectionPanel = /** @class */ (function (_super) {
  9494. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9495. /**
  9496. * Creates a new SelectionPanel
  9497. * @param name of SelectionPanel
  9498. * @param groups is an array of SelectionGroups
  9499. */
  9500. function SelectionPanel(
  9501. /** name of SelectionPanel */
  9502. name,
  9503. /** an array of SelectionGroups */
  9504. groups) {
  9505. if (groups === void 0) { groups = []; }
  9506. var _this = _super.call(this, name) || this;
  9507. _this.name = name;
  9508. _this.groups = groups;
  9509. _this._buttonColor = "#364249";
  9510. _this._buttonBackground = "#CCCCCC";
  9511. _this._headerColor = "black";
  9512. _this._barColor = "white";
  9513. _this._barHeight = "2px";
  9514. _this._spacerHeight = "20px";
  9515. _this._bars = new Array();
  9516. _this._groups = groups;
  9517. _this.thickness = 2;
  9518. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9519. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9520. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9521. _this._panel.top = 5;
  9522. _this._panel.left = 5;
  9523. _this._panel.width = 0.95;
  9524. if (groups.length > 0) {
  9525. for (var i = 0; i < groups.length - 1; i++) {
  9526. _this._panel.addControl(groups[i].groupPanel);
  9527. _this._addSpacer();
  9528. }
  9529. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9530. }
  9531. _this.addControl(_this._panel);
  9532. return _this;
  9533. }
  9534. SelectionPanel.prototype._getTypeName = function () {
  9535. return "SelectionPanel";
  9536. };
  9537. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9538. /** Gets or sets the headerColor */
  9539. get: function () {
  9540. return this._headerColor;
  9541. },
  9542. set: function (color) {
  9543. if (this._headerColor === color) {
  9544. return;
  9545. }
  9546. this._headerColor = color;
  9547. this._setHeaderColor();
  9548. },
  9549. enumerable: true,
  9550. configurable: true
  9551. });
  9552. SelectionPanel.prototype._setHeaderColor = function () {
  9553. for (var i = 0; i < this._groups.length; i++) {
  9554. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9555. }
  9556. };
  9557. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9558. /** Gets or sets the button color */
  9559. get: function () {
  9560. return this._buttonColor;
  9561. },
  9562. set: function (color) {
  9563. if (this._buttonColor === color) {
  9564. return;
  9565. }
  9566. this._buttonColor = color;
  9567. this._setbuttonColor();
  9568. },
  9569. enumerable: true,
  9570. configurable: true
  9571. });
  9572. SelectionPanel.prototype._setbuttonColor = function () {
  9573. for (var i = 0; i < this._groups.length; i++) {
  9574. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9575. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9576. }
  9577. }
  9578. };
  9579. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9580. /** Gets or sets the label color */
  9581. get: function () {
  9582. return this._labelColor;
  9583. },
  9584. set: function (color) {
  9585. if (this._labelColor === color) {
  9586. return;
  9587. }
  9588. this._labelColor = color;
  9589. this._setLabelColor();
  9590. },
  9591. enumerable: true,
  9592. configurable: true
  9593. });
  9594. SelectionPanel.prototype._setLabelColor = function () {
  9595. for (var i = 0; i < this._groups.length; i++) {
  9596. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9597. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9598. }
  9599. }
  9600. };
  9601. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9602. /** Gets or sets the button background */
  9603. get: function () {
  9604. return this._buttonBackground;
  9605. },
  9606. set: function (color) {
  9607. if (this._buttonBackground === color) {
  9608. return;
  9609. }
  9610. this._buttonBackground = color;
  9611. this._setButtonBackground();
  9612. },
  9613. enumerable: true,
  9614. configurable: true
  9615. });
  9616. SelectionPanel.prototype._setButtonBackground = function () {
  9617. for (var i = 0; i < this._groups.length; i++) {
  9618. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9619. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9620. }
  9621. }
  9622. };
  9623. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9624. /** Gets or sets the color of separator bar */
  9625. get: function () {
  9626. return this._barColor;
  9627. },
  9628. set: function (color) {
  9629. if (this._barColor === color) {
  9630. return;
  9631. }
  9632. this._barColor = color;
  9633. this._setBarColor();
  9634. },
  9635. enumerable: true,
  9636. configurable: true
  9637. });
  9638. SelectionPanel.prototype._setBarColor = function () {
  9639. for (var i = 0; i < this._bars.length; i++) {
  9640. this._bars[i].children[0].background = this._barColor;
  9641. }
  9642. };
  9643. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9644. /** Gets or sets the height of separator bar */
  9645. get: function () {
  9646. return this._barHeight;
  9647. },
  9648. set: function (value) {
  9649. if (this._barHeight === value) {
  9650. return;
  9651. }
  9652. this._barHeight = value;
  9653. this._setBarHeight();
  9654. },
  9655. enumerable: true,
  9656. configurable: true
  9657. });
  9658. SelectionPanel.prototype._setBarHeight = function () {
  9659. for (var i = 0; i < this._bars.length; i++) {
  9660. this._bars[i].children[0].height = this._barHeight;
  9661. }
  9662. };
  9663. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9664. /** Gets or sets the height of spacers*/
  9665. get: function () {
  9666. return this._spacerHeight;
  9667. },
  9668. set: function (value) {
  9669. if (this._spacerHeight === value) {
  9670. return;
  9671. }
  9672. this._spacerHeight = value;
  9673. this._setSpacerHeight();
  9674. },
  9675. enumerable: true,
  9676. configurable: true
  9677. });
  9678. SelectionPanel.prototype._setSpacerHeight = function () {
  9679. for (var i = 0; i < this._bars.length; i++) {
  9680. this._bars[i].height = this._spacerHeight;
  9681. }
  9682. };
  9683. /** Adds a bar between groups */
  9684. SelectionPanel.prototype._addSpacer = function () {
  9685. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9686. separator.width = 1;
  9687. separator.height = this._spacerHeight;
  9688. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9689. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9690. bar.width = 1;
  9691. bar.height = this._barHeight;
  9692. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9693. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9694. bar.background = this._barColor;
  9695. bar.color = "transparent";
  9696. separator.addControl(bar);
  9697. this._panel.addControl(separator);
  9698. this._bars.push(separator);
  9699. };
  9700. /** Add a group to the selection panel
  9701. * @param group is the selector group to add
  9702. */
  9703. SelectionPanel.prototype.addGroup = function (group) {
  9704. if (this._groups.length > 0) {
  9705. this._addSpacer();
  9706. }
  9707. this._panel.addControl(group.groupPanel);
  9708. this._groups.push(group);
  9709. group.groupPanel.children[0].color = this._headerColor;
  9710. for (var j = 0; j < group.selectors.length; j++) {
  9711. group._setSelectorButtonColor(j, this._buttonColor);
  9712. group._setSelectorButtonBackground(j, this._buttonBackground);
  9713. }
  9714. };
  9715. /** Remove the group from the given position
  9716. * @param groupNb is the position of the group in the list
  9717. */
  9718. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9719. if (groupNb < 0 || groupNb >= this._groups.length) {
  9720. return;
  9721. }
  9722. var group = this._groups[groupNb];
  9723. this._panel.removeControl(group.groupPanel);
  9724. this._groups.splice(groupNb, 1);
  9725. if (groupNb < this._bars.length) {
  9726. this._panel.removeControl(this._bars[groupNb]);
  9727. this._bars.splice(groupNb, 1);
  9728. }
  9729. };
  9730. /** Change a group header label
  9731. * @param label is the new group header label
  9732. * @param groupNb is the number of the group to relabel
  9733. * */
  9734. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9735. if (groupNb < 0 || groupNb >= this._groups.length) {
  9736. return;
  9737. }
  9738. var group = this._groups[groupNb];
  9739. group.groupPanel.children[0].text = label;
  9740. };
  9741. /** Change selector label to the one given
  9742. * @param label is the new selector label
  9743. * @param groupNb is the number of the groupcontaining the selector
  9744. * @param selectorNb is the number of the selector within a group to relabel
  9745. * */
  9746. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9747. if (groupNb < 0 || groupNb >= this._groups.length) {
  9748. return;
  9749. }
  9750. var group = this._groups[groupNb];
  9751. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9752. return;
  9753. }
  9754. group._setSelectorLabel(selectorNb, label);
  9755. };
  9756. /** For a given group position remove the selector at the given position
  9757. * @param groupNb is the number of the group to remove the selector from
  9758. * @param selectorNb is the number of the selector within the group
  9759. */
  9760. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9761. if (groupNb < 0 || groupNb >= this._groups.length) {
  9762. return;
  9763. }
  9764. var group = this._groups[groupNb];
  9765. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9766. return;
  9767. }
  9768. group.removeSelector(selectorNb);
  9769. };
  9770. /** For a given group position of correct type add a checkbox button
  9771. * @param groupNb is the number of the group to remove the selector from
  9772. * @param label is the label for the selector
  9773. * @param func is the function called when the Selector is checked
  9774. * @param checked is true when Selector is checked
  9775. */
  9776. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9777. if (func === void 0) { func = function () { }; }
  9778. if (checked === void 0) { checked = false; }
  9779. if (groupNb < 0 || groupNb >= this._groups.length) {
  9780. return;
  9781. }
  9782. var group = this._groups[groupNb];
  9783. group.addCheckbox(label, func, checked);
  9784. };
  9785. /** For a given group position of correct type add a radio button
  9786. * @param groupNb is the number of the group to remove the selector from
  9787. * @param label is the label for the selector
  9788. * @param func is the function called when the Selector is checked
  9789. * @param checked is true when Selector is checked
  9790. */
  9791. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9792. if (func === void 0) { func = function () { }; }
  9793. if (checked === void 0) { checked = false; }
  9794. if (groupNb < 0 || groupNb >= this._groups.length) {
  9795. return;
  9796. }
  9797. var group = this._groups[groupNb];
  9798. group.addRadio(label, func, checked);
  9799. };
  9800. /**
  9801. * For a given slider group add a slider
  9802. * @param groupNb is the number of the group to add the slider to
  9803. * @param label is the label for the Slider
  9804. * @param func is the function called when the Slider moves
  9805. * @param unit is a string describing the units used, eg degrees or metres
  9806. * @param min is the minimum value for the Slider
  9807. * @param max is the maximum value for the Slider
  9808. * @param value is the start value for the Slider between min and max
  9809. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9810. */
  9811. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9812. if (func === void 0) { func = function () { }; }
  9813. if (unit === void 0) { unit = "Units"; }
  9814. if (min === void 0) { min = 0; }
  9815. if (max === void 0) { max = 0; }
  9816. if (value === void 0) { value = 0; }
  9817. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9818. if (groupNb < 0 || groupNb >= this._groups.length) {
  9819. return;
  9820. }
  9821. var group = this._groups[groupNb];
  9822. group.addSlider(label, func, unit, min, max, value, onVal);
  9823. };
  9824. return SelectionPanel;
  9825. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9826. /***/ }),
  9827. /***/ "./2D/controls/sliders/baseSlider.ts":
  9828. /*!*******************************************!*\
  9829. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9830. \*******************************************/
  9831. /*! exports provided: BaseSlider */
  9832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9833. "use strict";
  9834. __webpack_require__.r(__webpack_exports__);
  9835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9836. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9837. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  9838. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9839. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9840. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9841. /**
  9842. * Class used to create slider controls
  9843. */
  9844. var BaseSlider = /** @class */ (function (_super) {
  9845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  9846. /**
  9847. * Creates a new BaseSlider
  9848. * @param name defines the control name
  9849. */
  9850. function BaseSlider(name) {
  9851. var _this = _super.call(this, name) || this;
  9852. _this.name = name;
  9853. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9854. _this._minimum = 0;
  9855. _this._maximum = 100;
  9856. _this._value = 50;
  9857. _this._isVertical = false;
  9858. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9859. _this._isThumbClamped = false;
  9860. _this._displayThumb = true;
  9861. _this._step = 0;
  9862. _this._lastPointerDownID = -1;
  9863. // Shared rendering info
  9864. _this._effectiveBarOffset = 0;
  9865. /** Observable raised when the sldier value changes */
  9866. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9867. // Events
  9868. _this._pointerIsDown = false;
  9869. _this.isPointerBlocker = true;
  9870. return _this;
  9871. }
  9872. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9873. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9874. get: function () {
  9875. return this._displayThumb;
  9876. },
  9877. set: function (value) {
  9878. if (this._displayThumb === value) {
  9879. return;
  9880. }
  9881. this._displayThumb = value;
  9882. this._markAsDirty();
  9883. },
  9884. enumerable: true,
  9885. configurable: true
  9886. });
  9887. Object.defineProperty(BaseSlider.prototype, "step", {
  9888. /** Gets or sets a step to apply to values (0 by default) */
  9889. get: function () {
  9890. return this._step;
  9891. },
  9892. set: function (value) {
  9893. if (this._step === value) {
  9894. return;
  9895. }
  9896. this._step = value;
  9897. this._markAsDirty();
  9898. },
  9899. enumerable: true,
  9900. configurable: true
  9901. });
  9902. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9903. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9904. get: function () {
  9905. return this._barOffset.toString(this._host);
  9906. },
  9907. set: function (value) {
  9908. if (this._barOffset.toString(this._host) === value) {
  9909. return;
  9910. }
  9911. if (this._barOffset.fromString(value)) {
  9912. this._markAsDirty();
  9913. }
  9914. },
  9915. enumerable: true,
  9916. configurable: true
  9917. });
  9918. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9919. /** Gets main bar offset in pixels*/
  9920. get: function () {
  9921. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9922. },
  9923. enumerable: true,
  9924. configurable: true
  9925. });
  9926. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9927. /** Gets or sets thumb width */
  9928. get: function () {
  9929. return this._thumbWidth.toString(this._host);
  9930. },
  9931. set: function (value) {
  9932. if (this._thumbWidth.toString(this._host) === value) {
  9933. return;
  9934. }
  9935. if (this._thumbWidth.fromString(value)) {
  9936. this._markAsDirty();
  9937. }
  9938. },
  9939. enumerable: true,
  9940. configurable: true
  9941. });
  9942. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9943. /** Gets thumb width in pixels */
  9944. get: function () {
  9945. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9946. },
  9947. enumerable: true,
  9948. configurable: true
  9949. });
  9950. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9951. /** Gets or sets minimum value */
  9952. get: function () {
  9953. return this._minimum;
  9954. },
  9955. set: function (value) {
  9956. if (this._minimum === value) {
  9957. return;
  9958. }
  9959. this._minimum = value;
  9960. this._markAsDirty();
  9961. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9962. },
  9963. enumerable: true,
  9964. configurable: true
  9965. });
  9966. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9967. /** Gets or sets maximum value */
  9968. get: function () {
  9969. return this._maximum;
  9970. },
  9971. set: function (value) {
  9972. if (this._maximum === value) {
  9973. return;
  9974. }
  9975. this._maximum = value;
  9976. this._markAsDirty();
  9977. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9978. },
  9979. enumerable: true,
  9980. configurable: true
  9981. });
  9982. Object.defineProperty(BaseSlider.prototype, "value", {
  9983. /** Gets or sets current value */
  9984. get: function () {
  9985. return this._value;
  9986. },
  9987. set: function (value) {
  9988. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9989. if (this._value === value) {
  9990. return;
  9991. }
  9992. this._value = value;
  9993. this._markAsDirty();
  9994. this.onValueChangedObservable.notifyObservers(this._value);
  9995. },
  9996. enumerable: true,
  9997. configurable: true
  9998. });
  9999. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10000. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10001. get: function () {
  10002. return this._isVertical;
  10003. },
  10004. set: function (value) {
  10005. if (this._isVertical === value) {
  10006. return;
  10007. }
  10008. this._isVertical = value;
  10009. this._markAsDirty();
  10010. },
  10011. enumerable: true,
  10012. configurable: true
  10013. });
  10014. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10015. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10016. get: function () {
  10017. return this._isThumbClamped;
  10018. },
  10019. set: function (value) {
  10020. if (this._isThumbClamped === value) {
  10021. return;
  10022. }
  10023. this._isThumbClamped = value;
  10024. this._markAsDirty();
  10025. },
  10026. enumerable: true,
  10027. configurable: true
  10028. });
  10029. BaseSlider.prototype._getTypeName = function () {
  10030. return "BaseSlider";
  10031. };
  10032. BaseSlider.prototype._getThumbPosition = function () {
  10033. if (this.isVertical) {
  10034. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10035. }
  10036. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10037. };
  10038. BaseSlider.prototype._getThumbThickness = function (type) {
  10039. var thumbThickness = 0;
  10040. switch (type) {
  10041. case "circle":
  10042. if (this._thumbWidth.isPixel) {
  10043. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10044. }
  10045. else {
  10046. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10047. }
  10048. break;
  10049. case "rectangle":
  10050. if (this._thumbWidth.isPixel) {
  10051. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10052. }
  10053. else {
  10054. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10055. }
  10056. }
  10057. return thumbThickness;
  10058. };
  10059. BaseSlider.prototype._prepareRenderingData = function (type) {
  10060. // Main bar
  10061. this._effectiveBarOffset = 0;
  10062. this._renderLeft = this._currentMeasure.left;
  10063. this._renderTop = this._currentMeasure.top;
  10064. this._renderWidth = this._currentMeasure.width;
  10065. this._renderHeight = this._currentMeasure.height;
  10066. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10067. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10068. this._effectiveThumbThickness = this._getThumbThickness(type);
  10069. if (this.displayThumb) {
  10070. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10071. }
  10072. //throw error when height is less than width for vertical slider
  10073. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10074. console.error("Height should be greater than width");
  10075. return;
  10076. }
  10077. if (this._barOffset.isPixel) {
  10078. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10079. }
  10080. else {
  10081. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10082. }
  10083. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10084. if (this.isVertical) {
  10085. this._renderLeft += this._effectiveBarOffset;
  10086. if (!this.isThumbClamped && this.displayThumb) {
  10087. this._renderTop += (this._effectiveThumbThickness / 2);
  10088. }
  10089. this._renderHeight = this._backgroundBoxLength;
  10090. this._renderWidth = this._backgroundBoxThickness;
  10091. }
  10092. else {
  10093. this._renderTop += this._effectiveBarOffset;
  10094. if (!this.isThumbClamped && this.displayThumb) {
  10095. this._renderLeft += (this._effectiveThumbThickness / 2);
  10096. }
  10097. this._renderHeight = this._backgroundBoxThickness;
  10098. this._renderWidth = this._backgroundBoxLength;
  10099. }
  10100. };
  10101. /** @hidden */
  10102. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10103. if (this.rotation != 0) {
  10104. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10105. x = this._transformedPosition.x;
  10106. y = this._transformedPosition.y;
  10107. }
  10108. var value;
  10109. if (this._isVertical) {
  10110. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10111. }
  10112. else {
  10113. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10114. }
  10115. var mult = (1 / this._step) | 0;
  10116. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10117. };
  10118. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10119. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10120. return false;
  10121. }
  10122. this._pointerIsDown = true;
  10123. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10124. this._host._capturingControl[pointerId] = this;
  10125. this._lastPointerDownID = pointerId;
  10126. return true;
  10127. };
  10128. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10129. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10130. if (pointerId != this._lastPointerDownID) {
  10131. return;
  10132. }
  10133. if (this._pointerIsDown) {
  10134. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10135. }
  10136. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10137. };
  10138. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10139. this._pointerIsDown = false;
  10140. delete this._host._capturingControl[pointerId];
  10141. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10142. };
  10143. return BaseSlider;
  10144. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10145. /***/ }),
  10146. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10147. /*!*************************************************!*\
  10148. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10149. \*************************************************/
  10150. /*! exports provided: ImageBasedSlider */
  10151. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10152. "use strict";
  10153. __webpack_require__.r(__webpack_exports__);
  10154. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10155. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10156. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10157. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10158. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10159. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10160. /**
  10161. * Class used to create slider controls based on images
  10162. */
  10163. var ImageBasedSlider = /** @class */ (function (_super) {
  10164. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10165. /**
  10166. * Creates a new ImageBasedSlider
  10167. * @param name defines the control name
  10168. */
  10169. function ImageBasedSlider(name) {
  10170. var _this = _super.call(this, name) || this;
  10171. _this.name = name;
  10172. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10173. return _this;
  10174. }
  10175. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10176. get: function () {
  10177. return this._displayThumb && this.thumbImage != null;
  10178. },
  10179. set: function (value) {
  10180. if (this._displayThumb === value) {
  10181. return;
  10182. }
  10183. this._displayThumb = value;
  10184. this._markAsDirty();
  10185. },
  10186. enumerable: true,
  10187. configurable: true
  10188. });
  10189. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10190. /**
  10191. * Gets or sets the image used to render the background
  10192. */
  10193. get: function () {
  10194. return this._backgroundImage;
  10195. },
  10196. set: function (value) {
  10197. var _this = this;
  10198. if (this._backgroundImage === value) {
  10199. return;
  10200. }
  10201. this._backgroundImage = value;
  10202. if (value && !value.isLoaded) {
  10203. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10204. }
  10205. this._markAsDirty();
  10206. },
  10207. enumerable: true,
  10208. configurable: true
  10209. });
  10210. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10211. /**
  10212. * Gets or sets the image used to render the value bar
  10213. */
  10214. get: function () {
  10215. return this._valueBarImage;
  10216. },
  10217. set: function (value) {
  10218. var _this = this;
  10219. if (this._valueBarImage === value) {
  10220. return;
  10221. }
  10222. this._valueBarImage = value;
  10223. if (value && !value.isLoaded) {
  10224. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10225. }
  10226. this._markAsDirty();
  10227. },
  10228. enumerable: true,
  10229. configurable: true
  10230. });
  10231. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10232. /**
  10233. * Gets or sets the image used to render the thumb
  10234. */
  10235. get: function () {
  10236. return this._thumbImage;
  10237. },
  10238. set: function (value) {
  10239. var _this = this;
  10240. if (this._thumbImage === value) {
  10241. return;
  10242. }
  10243. this._thumbImage = value;
  10244. if (value && !value.isLoaded) {
  10245. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10246. }
  10247. this._markAsDirty();
  10248. },
  10249. enumerable: true,
  10250. configurable: true
  10251. });
  10252. ImageBasedSlider.prototype._getTypeName = function () {
  10253. return "ImageBasedSlider";
  10254. };
  10255. ImageBasedSlider.prototype._draw = function (context) {
  10256. context.save();
  10257. this._applyStates(context);
  10258. this._prepareRenderingData("rectangle");
  10259. var thumbPosition = this._getThumbPosition();
  10260. var left = this._renderLeft;
  10261. var top = this._renderTop;
  10262. var width = this._renderWidth;
  10263. var height = this._renderHeight;
  10264. // Background
  10265. if (this._backgroundImage) {
  10266. this._tempMeasure.copyFromFloats(left, top, width, height);
  10267. if (this.isThumbClamped && this.displayThumb) {
  10268. if (this.isVertical) {
  10269. this._tempMeasure.height += this._effectiveThumbThickness;
  10270. }
  10271. else {
  10272. this._tempMeasure.width += this._effectiveThumbThickness;
  10273. }
  10274. }
  10275. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10276. this._backgroundImage._draw(context);
  10277. }
  10278. // Bar
  10279. if (this._valueBarImage) {
  10280. if (this.isVertical) {
  10281. if (this.isThumbClamped && this.displayThumb) {
  10282. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10283. }
  10284. else {
  10285. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10286. }
  10287. }
  10288. else {
  10289. if (this.isThumbClamped && this.displayThumb) {
  10290. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10291. }
  10292. else {
  10293. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10294. }
  10295. }
  10296. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10297. this._valueBarImage._draw(context);
  10298. }
  10299. // Thumb
  10300. if (this.displayThumb) {
  10301. if (this.isVertical) {
  10302. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10303. }
  10304. else {
  10305. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10306. }
  10307. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10308. this._thumbImage._draw(context);
  10309. }
  10310. context.restore();
  10311. };
  10312. return ImageBasedSlider;
  10313. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10314. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10315. /***/ }),
  10316. /***/ "./2D/controls/sliders/scrollBar.ts":
  10317. /*!******************************************!*\
  10318. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10319. \******************************************/
  10320. /*! exports provided: ScrollBar */
  10321. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10322. "use strict";
  10323. __webpack_require__.r(__webpack_exports__);
  10324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10325. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10326. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10327. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10328. /**
  10329. * Class used to create slider controls
  10330. */
  10331. var ScrollBar = /** @class */ (function (_super) {
  10332. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10333. /**
  10334. * Creates a new Slider
  10335. * @param name defines the control name
  10336. */
  10337. function ScrollBar(name) {
  10338. var _this = _super.call(this, name) || this;
  10339. _this.name = name;
  10340. _this._background = "black";
  10341. _this._borderColor = "white";
  10342. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10343. return _this;
  10344. }
  10345. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10346. /** Gets or sets border color */
  10347. get: function () {
  10348. return this._borderColor;
  10349. },
  10350. set: function (value) {
  10351. if (this._borderColor === value) {
  10352. return;
  10353. }
  10354. this._borderColor = value;
  10355. this._markAsDirty();
  10356. },
  10357. enumerable: true,
  10358. configurable: true
  10359. });
  10360. Object.defineProperty(ScrollBar.prototype, "background", {
  10361. /** Gets or sets background color */
  10362. get: function () {
  10363. return this._background;
  10364. },
  10365. set: function (value) {
  10366. if (this._background === value) {
  10367. return;
  10368. }
  10369. this._background = value;
  10370. this._markAsDirty();
  10371. },
  10372. enumerable: true,
  10373. configurable: true
  10374. });
  10375. ScrollBar.prototype._getTypeName = function () {
  10376. return "Scrollbar";
  10377. };
  10378. ScrollBar.prototype._getThumbThickness = function () {
  10379. var thumbThickness = 0;
  10380. if (this._thumbWidth.isPixel) {
  10381. thumbThickness = this._thumbWidth.getValue(this._host);
  10382. }
  10383. else {
  10384. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10385. }
  10386. return thumbThickness;
  10387. };
  10388. ScrollBar.prototype._draw = function (context) {
  10389. context.save();
  10390. this._applyStates(context);
  10391. this._prepareRenderingData("rectangle");
  10392. var left = this._renderLeft;
  10393. var thumbPosition = this._getThumbPosition();
  10394. context.fillStyle = this._background;
  10395. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10396. // Value bar
  10397. context.fillStyle = this.color;
  10398. // Thumb
  10399. if (this.isVertical) {
  10400. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10401. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10402. this._thumbMeasure.width = this._currentMeasure.width;
  10403. this._thumbMeasure.height = this._effectiveThumbThickness;
  10404. }
  10405. else {
  10406. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10407. this._thumbMeasure.top = this._currentMeasure.top;
  10408. this._thumbMeasure.width = this._effectiveThumbThickness;
  10409. this._thumbMeasure.height = this._currentMeasure.height;
  10410. }
  10411. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10412. context.restore();
  10413. };
  10414. /** @hidden */
  10415. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10416. if (this.rotation != 0) {
  10417. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10418. x = this._transformedPosition.x;
  10419. y = this._transformedPosition.y;
  10420. }
  10421. if (this._first) {
  10422. this._first = false;
  10423. this._originX = x;
  10424. this._originY = y;
  10425. // Check if move is required
  10426. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10427. if (this.isVertical) {
  10428. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10429. }
  10430. else {
  10431. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10432. }
  10433. }
  10434. }
  10435. // Delta mode
  10436. var delta = 0;
  10437. if (this.isVertical) {
  10438. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10439. }
  10440. else {
  10441. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10442. }
  10443. this.value += delta * (this.maximum - this.minimum);
  10444. this._originX = x;
  10445. this._originY = y;
  10446. };
  10447. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10448. this._first = true;
  10449. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10450. };
  10451. return ScrollBar;
  10452. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10453. /***/ }),
  10454. /***/ "./2D/controls/sliders/slider.ts":
  10455. /*!***************************************!*\
  10456. !*** ./2D/controls/sliders/slider.ts ***!
  10457. \***************************************/
  10458. /*! exports provided: Slider */
  10459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10460. "use strict";
  10461. __webpack_require__.r(__webpack_exports__);
  10462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10463. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10464. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10465. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10466. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10467. /**
  10468. * Class used to create slider controls
  10469. */
  10470. var Slider = /** @class */ (function (_super) {
  10471. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10472. /**
  10473. * Creates a new Slider
  10474. * @param name defines the control name
  10475. */
  10476. function Slider(name) {
  10477. var _this = _super.call(this, name) || this;
  10478. _this.name = name;
  10479. _this._background = "black";
  10480. _this._borderColor = "white";
  10481. _this._isThumbCircle = false;
  10482. _this._displayValueBar = true;
  10483. return _this;
  10484. }
  10485. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10486. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10487. get: function () {
  10488. return this._displayValueBar;
  10489. },
  10490. set: function (value) {
  10491. if (this._displayValueBar === value) {
  10492. return;
  10493. }
  10494. this._displayValueBar = value;
  10495. this._markAsDirty();
  10496. },
  10497. enumerable: true,
  10498. configurable: true
  10499. });
  10500. Object.defineProperty(Slider.prototype, "borderColor", {
  10501. /** Gets or sets border color */
  10502. get: function () {
  10503. return this._borderColor;
  10504. },
  10505. set: function (value) {
  10506. if (this._borderColor === value) {
  10507. return;
  10508. }
  10509. this._borderColor = value;
  10510. this._markAsDirty();
  10511. },
  10512. enumerable: true,
  10513. configurable: true
  10514. });
  10515. Object.defineProperty(Slider.prototype, "background", {
  10516. /** Gets or sets background color */
  10517. get: function () {
  10518. return this._background;
  10519. },
  10520. set: function (value) {
  10521. if (this._background === value) {
  10522. return;
  10523. }
  10524. this._background = value;
  10525. this._markAsDirty();
  10526. },
  10527. enumerable: true,
  10528. configurable: true
  10529. });
  10530. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10531. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10532. get: function () {
  10533. return this._isThumbCircle;
  10534. },
  10535. set: function (value) {
  10536. if (this._isThumbCircle === value) {
  10537. return;
  10538. }
  10539. this._isThumbCircle = value;
  10540. this._markAsDirty();
  10541. },
  10542. enumerable: true,
  10543. configurable: true
  10544. });
  10545. Slider.prototype._getTypeName = function () {
  10546. return "Slider";
  10547. };
  10548. Slider.prototype._draw = function (context) {
  10549. context.save();
  10550. this._applyStates(context);
  10551. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10552. var left = this._renderLeft;
  10553. var top = this._renderTop;
  10554. var width = this._renderWidth;
  10555. var height = this._renderHeight;
  10556. var radius = 0;
  10557. if (this.isThumbClamped && this.isThumbCircle) {
  10558. if (this.isVertical) {
  10559. top += (this._effectiveThumbThickness / 2);
  10560. }
  10561. else {
  10562. left += (this._effectiveThumbThickness / 2);
  10563. }
  10564. radius = this._backgroundBoxThickness / 2;
  10565. }
  10566. else {
  10567. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10568. }
  10569. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10570. context.shadowColor = this.shadowColor;
  10571. context.shadowBlur = this.shadowBlur;
  10572. context.shadowOffsetX = this.shadowOffsetX;
  10573. context.shadowOffsetY = this.shadowOffsetY;
  10574. }
  10575. var thumbPosition = this._getThumbPosition();
  10576. context.fillStyle = this._background;
  10577. if (this.isVertical) {
  10578. if (this.isThumbClamped) {
  10579. if (this.isThumbCircle) {
  10580. context.beginPath();
  10581. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10582. context.fill();
  10583. context.fillRect(left, top, width, height);
  10584. }
  10585. else {
  10586. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10587. }
  10588. }
  10589. else {
  10590. context.fillRect(left, top, width, height);
  10591. }
  10592. }
  10593. else {
  10594. if (this.isThumbClamped) {
  10595. if (this.isThumbCircle) {
  10596. context.beginPath();
  10597. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10598. context.fill();
  10599. context.fillRect(left, top, width, height);
  10600. }
  10601. else {
  10602. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10603. }
  10604. }
  10605. else {
  10606. context.fillRect(left, top, width, height);
  10607. }
  10608. }
  10609. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10610. context.shadowBlur = 0;
  10611. context.shadowOffsetX = 0;
  10612. context.shadowOffsetY = 0;
  10613. }
  10614. // Value bar
  10615. context.fillStyle = this.color;
  10616. if (this._displayValueBar) {
  10617. if (this.isVertical) {
  10618. if (this.isThumbClamped) {
  10619. if (this.isThumbCircle) {
  10620. context.beginPath();
  10621. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10622. context.fill();
  10623. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10624. }
  10625. else {
  10626. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10627. }
  10628. }
  10629. else {
  10630. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10631. }
  10632. }
  10633. else {
  10634. if (this.isThumbClamped) {
  10635. if (this.isThumbCircle) {
  10636. context.beginPath();
  10637. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10638. context.fill();
  10639. context.fillRect(left, top, thumbPosition, height);
  10640. }
  10641. else {
  10642. context.fillRect(left, top, thumbPosition, height);
  10643. }
  10644. }
  10645. else {
  10646. context.fillRect(left, top, thumbPosition, height);
  10647. }
  10648. }
  10649. }
  10650. // Thumb
  10651. if (this.displayThumb) {
  10652. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10653. context.shadowColor = this.shadowColor;
  10654. context.shadowBlur = this.shadowBlur;
  10655. context.shadowOffsetX = this.shadowOffsetX;
  10656. context.shadowOffsetY = this.shadowOffsetY;
  10657. }
  10658. if (this._isThumbCircle) {
  10659. context.beginPath();
  10660. if (this.isVertical) {
  10661. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10662. }
  10663. else {
  10664. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10665. }
  10666. context.fill();
  10667. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10668. context.shadowBlur = 0;
  10669. context.shadowOffsetX = 0;
  10670. context.shadowOffsetY = 0;
  10671. }
  10672. context.strokeStyle = this._borderColor;
  10673. context.stroke();
  10674. }
  10675. else {
  10676. if (this.isVertical) {
  10677. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10678. }
  10679. else {
  10680. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10681. }
  10682. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10683. context.shadowBlur = 0;
  10684. context.shadowOffsetX = 0;
  10685. context.shadowOffsetY = 0;
  10686. }
  10687. context.strokeStyle = this._borderColor;
  10688. if (this.isVertical) {
  10689. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10690. }
  10691. else {
  10692. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10693. }
  10694. }
  10695. }
  10696. context.restore();
  10697. };
  10698. return Slider;
  10699. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10700. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  10701. /***/ }),
  10702. /***/ "./2D/controls/stackPanel.ts":
  10703. /*!***********************************!*\
  10704. !*** ./2D/controls/stackPanel.ts ***!
  10705. \***********************************/
  10706. /*! exports provided: StackPanel */
  10707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10708. "use strict";
  10709. __webpack_require__.r(__webpack_exports__);
  10710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10712. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  10713. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10714. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10715. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10716. /**
  10717. * Class used to create a 2D stack panel container
  10718. */
  10719. var StackPanel = /** @class */ (function (_super) {
  10720. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  10721. /**
  10722. * Creates a new StackPanel
  10723. * @param name defines control name
  10724. */
  10725. function StackPanel(name) {
  10726. var _this = _super.call(this, name) || this;
  10727. _this.name = name;
  10728. _this._isVertical = true;
  10729. _this._manualWidth = false;
  10730. _this._manualHeight = false;
  10731. _this._doNotTrackManualChanges = false;
  10732. /**
  10733. * Gets or sets a boolean indicating that layou warnings should be ignored
  10734. */
  10735. _this.ignoreLayoutWarnings = false;
  10736. return _this;
  10737. }
  10738. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10739. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10740. get: function () {
  10741. return this._isVertical;
  10742. },
  10743. set: function (value) {
  10744. if (this._isVertical === value) {
  10745. return;
  10746. }
  10747. this._isVertical = value;
  10748. this._markAsDirty();
  10749. },
  10750. enumerable: true,
  10751. configurable: true
  10752. });
  10753. Object.defineProperty(StackPanel.prototype, "width", {
  10754. get: function () {
  10755. return this._width.toString(this._host);
  10756. },
  10757. /**
  10758. * Gets or sets panel width.
  10759. * This value should not be set when in horizontal mode as it will be computed automatically
  10760. */
  10761. set: function (value) {
  10762. if (!this._doNotTrackManualChanges) {
  10763. this._manualWidth = true;
  10764. }
  10765. if (this._width.toString(this._host) === value) {
  10766. return;
  10767. }
  10768. if (this._width.fromString(value)) {
  10769. this._markAsDirty();
  10770. }
  10771. },
  10772. enumerable: true,
  10773. configurable: true
  10774. });
  10775. Object.defineProperty(StackPanel.prototype, "height", {
  10776. get: function () {
  10777. return this._height.toString(this._host);
  10778. },
  10779. /**
  10780. * Gets or sets panel height.
  10781. * This value should not be set when in vertical mode as it will be computed automatically
  10782. */
  10783. set: function (value) {
  10784. if (!this._doNotTrackManualChanges) {
  10785. this._manualHeight = true;
  10786. }
  10787. if (this._height.toString(this._host) === value) {
  10788. return;
  10789. }
  10790. if (this._height.fromString(value)) {
  10791. this._markAsDirty();
  10792. }
  10793. },
  10794. enumerable: true,
  10795. configurable: true
  10796. });
  10797. StackPanel.prototype._getTypeName = function () {
  10798. return "StackPanel";
  10799. };
  10800. /** @hidden */
  10801. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10802. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10803. var child = _a[_i];
  10804. if (this._isVertical) {
  10805. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10806. }
  10807. else {
  10808. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10809. }
  10810. }
  10811. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10812. };
  10813. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10814. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10815. this._measureForChildren.copyFrom(parentMeasure);
  10816. this._measureForChildren.left = this._currentMeasure.left;
  10817. this._measureForChildren.top = this._currentMeasure.top;
  10818. if (!this.isVertical || this._manualWidth) {
  10819. this._measureForChildren.width = this._currentMeasure.width;
  10820. }
  10821. if (this.isVertical || this._manualHeight) {
  10822. this._measureForChildren.height = this._currentMeasure.height;
  10823. }
  10824. };
  10825. StackPanel.prototype._postMeasure = function () {
  10826. var stackWidth = 0;
  10827. var stackHeight = 0;
  10828. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10829. var child = _a[_i];
  10830. if (!child.isVisible || child.notRenderable) {
  10831. continue;
  10832. }
  10833. if (this._isVertical) {
  10834. if (child.top !== stackHeight + "px") {
  10835. child.top = stackHeight + "px";
  10836. this._rebuildLayout = true;
  10837. child._top.ignoreAdaptiveScaling = true;
  10838. }
  10839. if (child._height.isPercentage) {
  10840. if (!this.ignoreLayoutWarnings) {
  10841. 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");
  10842. }
  10843. }
  10844. else {
  10845. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10846. }
  10847. }
  10848. else {
  10849. if (child.left !== stackWidth + "px") {
  10850. child.left = stackWidth + "px";
  10851. this._rebuildLayout = true;
  10852. child._left.ignoreAdaptiveScaling = true;
  10853. }
  10854. if (child._width.isPercentage) {
  10855. if (!this.ignoreLayoutWarnings) {
  10856. 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");
  10857. }
  10858. }
  10859. else {
  10860. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10861. }
  10862. }
  10863. }
  10864. this._doNotTrackManualChanges = true;
  10865. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10866. // User can now define their own height and width for stack panel.
  10867. var panelWidthChanged = false;
  10868. var panelHeightChanged = false;
  10869. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10870. var previousHeight = this.height;
  10871. this.height = stackHeight + "px";
  10872. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10873. }
  10874. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10875. var previousWidth = this.width;
  10876. this.width = stackWidth + "px";
  10877. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10878. }
  10879. if (panelHeightChanged) {
  10880. this._height.ignoreAdaptiveScaling = true;
  10881. }
  10882. if (panelWidthChanged) {
  10883. this._width.ignoreAdaptiveScaling = true;
  10884. }
  10885. this._doNotTrackManualChanges = false;
  10886. if (panelWidthChanged || panelHeightChanged) {
  10887. this._rebuildLayout = true;
  10888. }
  10889. _super.prototype._postMeasure.call(this);
  10890. };
  10891. return StackPanel;
  10892. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10893. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  10894. /***/ }),
  10895. /***/ "./2D/controls/statics.ts":
  10896. /*!********************************!*\
  10897. !*** ./2D/controls/statics.ts ***!
  10898. \********************************/
  10899. /*! exports provided: name */
  10900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10901. "use strict";
  10902. __webpack_require__.r(__webpack_exports__);
  10903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10904. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10905. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10906. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10907. /**
  10908. * Forcing an export so that this code will execute
  10909. * @hidden
  10910. */
  10911. var name = "Statics";
  10912. /**
  10913. * Creates a stack panel that can be used to render headers
  10914. * @param control defines the control to associate with the header
  10915. * @param text defines the text of the header
  10916. * @param size defines the size of the header
  10917. * @param options defines options used to configure the header
  10918. * @returns a new StackPanel
  10919. */
  10920. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10921. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10922. var isHorizontal = options ? options.isHorizontal : true;
  10923. var controlFirst = options ? options.controlFirst : true;
  10924. panel.isVertical = !isHorizontal;
  10925. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10926. header.text = text;
  10927. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10928. if (isHorizontal) {
  10929. header.width = size;
  10930. }
  10931. else {
  10932. header.height = size;
  10933. }
  10934. if (controlFirst) {
  10935. panel.addControl(control);
  10936. panel.addControl(header);
  10937. header.paddingLeft = "5px";
  10938. }
  10939. else {
  10940. panel.addControl(header);
  10941. panel.addControl(control);
  10942. header.paddingRight = "5px";
  10943. }
  10944. header.shadowBlur = control.shadowBlur;
  10945. header.shadowColor = control.shadowColor;
  10946. header.shadowOffsetX = control.shadowOffsetX;
  10947. header.shadowOffsetY = control.shadowOffsetY;
  10948. return panel;
  10949. };
  10950. /***/ }),
  10951. /***/ "./2D/controls/textBlock.ts":
  10952. /*!**********************************!*\
  10953. !*** ./2D/controls/textBlock.ts ***!
  10954. \**********************************/
  10955. /*! exports provided: TextWrapping, TextBlock */
  10956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10957. "use strict";
  10958. __webpack_require__.r(__webpack_exports__);
  10959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10962. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10963. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10964. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10965. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10966. /**
  10967. * Enum that determines the text-wrapping mode to use.
  10968. */
  10969. var TextWrapping;
  10970. (function (TextWrapping) {
  10971. /**
  10972. * Clip the text when it's larger than Control.width; this is the default mode.
  10973. */
  10974. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10975. /**
  10976. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10977. */
  10978. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10979. /**
  10980. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10981. */
  10982. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10983. })(TextWrapping || (TextWrapping = {}));
  10984. /**
  10985. * Class used to create text block control
  10986. */
  10987. var TextBlock = /** @class */ (function (_super) {
  10988. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  10989. /**
  10990. * Creates a new TextBlock object
  10991. * @param name defines the name of the control
  10992. * @param text defines the text to display (emptry string by default)
  10993. */
  10994. function TextBlock(
  10995. /**
  10996. * Defines the name of the control
  10997. */
  10998. name, text) {
  10999. if (text === void 0) { text = ""; }
  11000. var _this = _super.call(this, name) || this;
  11001. _this.name = name;
  11002. _this._text = "";
  11003. _this._textWrapping = TextWrapping.Clip;
  11004. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11005. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11006. _this._resizeToFit = false;
  11007. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11008. _this._outlineWidth = 0;
  11009. _this._outlineColor = "white";
  11010. /**
  11011. * An event triggered after the text is changed
  11012. */
  11013. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11014. /**
  11015. * An event triggered after the text was broken up into lines
  11016. */
  11017. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11018. _this.text = text;
  11019. return _this;
  11020. }
  11021. Object.defineProperty(TextBlock.prototype, "lines", {
  11022. /**
  11023. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11024. */
  11025. get: function () {
  11026. return this._lines;
  11027. },
  11028. enumerable: true,
  11029. configurable: true
  11030. });
  11031. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11032. /**
  11033. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11034. */
  11035. get: function () {
  11036. return this._resizeToFit;
  11037. },
  11038. /**
  11039. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11040. */
  11041. set: function (value) {
  11042. if (this._resizeToFit === value) {
  11043. return;
  11044. }
  11045. this._resizeToFit = value;
  11046. if (this._resizeToFit) {
  11047. this._width.ignoreAdaptiveScaling = true;
  11048. this._height.ignoreAdaptiveScaling = true;
  11049. }
  11050. this._markAsDirty();
  11051. },
  11052. enumerable: true,
  11053. configurable: true
  11054. });
  11055. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11056. /**
  11057. * Gets or sets a boolean indicating if text must be wrapped
  11058. */
  11059. get: function () {
  11060. return this._textWrapping;
  11061. },
  11062. /**
  11063. * Gets or sets a boolean indicating if text must be wrapped
  11064. */
  11065. set: function (value) {
  11066. if (this._textWrapping === value) {
  11067. return;
  11068. }
  11069. this._textWrapping = +value;
  11070. this._markAsDirty();
  11071. },
  11072. enumerable: true,
  11073. configurable: true
  11074. });
  11075. Object.defineProperty(TextBlock.prototype, "text", {
  11076. /**
  11077. * Gets or sets text to display
  11078. */
  11079. get: function () {
  11080. return this._text;
  11081. },
  11082. /**
  11083. * Gets or sets text to display
  11084. */
  11085. set: function (value) {
  11086. if (this._text === value) {
  11087. return;
  11088. }
  11089. this._text = value;
  11090. this._markAsDirty();
  11091. this.onTextChangedObservable.notifyObservers(this);
  11092. },
  11093. enumerable: true,
  11094. configurable: true
  11095. });
  11096. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11097. /**
  11098. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11099. */
  11100. get: function () {
  11101. return this._textHorizontalAlignment;
  11102. },
  11103. /**
  11104. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11105. */
  11106. set: function (value) {
  11107. if (this._textHorizontalAlignment === value) {
  11108. return;
  11109. }
  11110. this._textHorizontalAlignment = value;
  11111. this._markAsDirty();
  11112. },
  11113. enumerable: true,
  11114. configurable: true
  11115. });
  11116. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11117. /**
  11118. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11119. */
  11120. get: function () {
  11121. return this._textVerticalAlignment;
  11122. },
  11123. /**
  11124. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11125. */
  11126. set: function (value) {
  11127. if (this._textVerticalAlignment === value) {
  11128. return;
  11129. }
  11130. this._textVerticalAlignment = value;
  11131. this._markAsDirty();
  11132. },
  11133. enumerable: true,
  11134. configurable: true
  11135. });
  11136. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11137. /**
  11138. * Gets or sets line spacing value
  11139. */
  11140. get: function () {
  11141. return this._lineSpacing.toString(this._host);
  11142. },
  11143. /**
  11144. * Gets or sets line spacing value
  11145. */
  11146. set: function (value) {
  11147. if (this._lineSpacing.fromString(value)) {
  11148. this._markAsDirty();
  11149. }
  11150. },
  11151. enumerable: true,
  11152. configurable: true
  11153. });
  11154. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11155. /**
  11156. * Gets or sets outlineWidth of the text to display
  11157. */
  11158. get: function () {
  11159. return this._outlineWidth;
  11160. },
  11161. /**
  11162. * Gets or sets outlineWidth of the text to display
  11163. */
  11164. set: function (value) {
  11165. if (this._outlineWidth === value) {
  11166. return;
  11167. }
  11168. this._outlineWidth = value;
  11169. this._markAsDirty();
  11170. },
  11171. enumerable: true,
  11172. configurable: true
  11173. });
  11174. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11175. /**
  11176. * Gets or sets outlineColor of the text to display
  11177. */
  11178. get: function () {
  11179. return this._outlineColor;
  11180. },
  11181. /**
  11182. * Gets or sets outlineColor of the text to display
  11183. */
  11184. set: function (value) {
  11185. if (this._outlineColor === value) {
  11186. return;
  11187. }
  11188. this._outlineColor = value;
  11189. this._markAsDirty();
  11190. },
  11191. enumerable: true,
  11192. configurable: true
  11193. });
  11194. TextBlock.prototype._getTypeName = function () {
  11195. return "TextBlock";
  11196. };
  11197. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11198. if (!this._fontOffset) {
  11199. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11200. }
  11201. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11202. // Prepare lines
  11203. this._lines = this._breakLines(this._currentMeasure.width, context);
  11204. this.onLinesReadyObservable.notifyObservers(this);
  11205. var maxLineWidth = 0;
  11206. for (var i = 0; i < this._lines.length; i++) {
  11207. var line = this._lines[i];
  11208. if (line.width > maxLineWidth) {
  11209. maxLineWidth = line.width;
  11210. }
  11211. }
  11212. if (this._resizeToFit) {
  11213. if (this._textWrapping === TextWrapping.Clip) {
  11214. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11215. if (newWidth !== this._width.internalValue) {
  11216. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11217. this._rebuildLayout = true;
  11218. }
  11219. }
  11220. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11221. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11222. var lineSpacing = 0;
  11223. if (this._lineSpacing.isPixel) {
  11224. lineSpacing = this._lineSpacing.getValue(this._host);
  11225. }
  11226. else {
  11227. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11228. }
  11229. newHeight += (this._lines.length - 1) * lineSpacing;
  11230. }
  11231. if (newHeight !== this._height.internalValue) {
  11232. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11233. this._rebuildLayout = true;
  11234. }
  11235. }
  11236. };
  11237. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11238. var width = this._currentMeasure.width;
  11239. var x = 0;
  11240. switch (this._textHorizontalAlignment) {
  11241. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11242. x = 0;
  11243. break;
  11244. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11245. x = width - textWidth;
  11246. break;
  11247. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11248. x = (width - textWidth) / 2;
  11249. break;
  11250. }
  11251. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11252. context.shadowColor = this.shadowColor;
  11253. context.shadowBlur = this.shadowBlur;
  11254. context.shadowOffsetX = this.shadowOffsetX;
  11255. context.shadowOffsetY = this.shadowOffsetY;
  11256. }
  11257. if (this.outlineWidth) {
  11258. context.strokeText(text, this._currentMeasure.left + x, y);
  11259. }
  11260. context.fillText(text, this._currentMeasure.left + x, y);
  11261. };
  11262. /** @hidden */
  11263. TextBlock.prototype._draw = function (context) {
  11264. context.save();
  11265. this._applyStates(context);
  11266. // Render lines
  11267. this._renderLines(context);
  11268. context.restore();
  11269. };
  11270. TextBlock.prototype._applyStates = function (context) {
  11271. _super.prototype._applyStates.call(this, context);
  11272. if (this.outlineWidth) {
  11273. context.lineWidth = this.outlineWidth;
  11274. context.strokeStyle = this.outlineColor;
  11275. }
  11276. };
  11277. TextBlock.prototype._breakLines = function (refWidth, context) {
  11278. var lines = [];
  11279. var _lines = this.text.split("\n");
  11280. if (this._textWrapping === TextWrapping.Ellipsis) {
  11281. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11282. var _line = _lines_1[_i];
  11283. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11284. }
  11285. }
  11286. else if (this._textWrapping === TextWrapping.WordWrap) {
  11287. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11288. var _line = _lines_2[_a];
  11289. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11290. }
  11291. }
  11292. else {
  11293. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11294. var _line = _lines_3[_b];
  11295. lines.push(this._parseLine(_line, context));
  11296. }
  11297. }
  11298. return lines;
  11299. };
  11300. TextBlock.prototype._parseLine = function (line, context) {
  11301. if (line === void 0) { line = ''; }
  11302. return { text: line, width: context.measureText(line).width };
  11303. };
  11304. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11305. if (line === void 0) { line = ''; }
  11306. var lineWidth = context.measureText(line).width;
  11307. if (lineWidth > width) {
  11308. line += '…';
  11309. }
  11310. while (line.length > 2 && lineWidth > width) {
  11311. line = line.slice(0, -2) + '…';
  11312. lineWidth = context.measureText(line).width;
  11313. }
  11314. return { text: line, width: lineWidth };
  11315. };
  11316. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11317. if (line === void 0) { line = ''; }
  11318. var lines = [];
  11319. var words = line.split(' ');
  11320. var lineWidth = 0;
  11321. for (var n = 0; n < words.length; n++) {
  11322. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11323. var metrics = context.measureText(testLine);
  11324. var testWidth = metrics.width;
  11325. if (testWidth > width && n > 0) {
  11326. lines.push({ text: line, width: lineWidth });
  11327. line = words[n];
  11328. lineWidth = context.measureText(line).width;
  11329. }
  11330. else {
  11331. lineWidth = testWidth;
  11332. line = testLine;
  11333. }
  11334. }
  11335. lines.push({ text: line, width: lineWidth });
  11336. return lines;
  11337. };
  11338. TextBlock.prototype._renderLines = function (context) {
  11339. var height = this._currentMeasure.height;
  11340. var rootY = 0;
  11341. switch (this._textVerticalAlignment) {
  11342. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11343. rootY = this._fontOffset.ascent;
  11344. break;
  11345. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11346. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11347. break;
  11348. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11349. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11350. break;
  11351. }
  11352. rootY += this._currentMeasure.top;
  11353. for (var i = 0; i < this._lines.length; i++) {
  11354. var line = this._lines[i];
  11355. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11356. if (this._lineSpacing.isPixel) {
  11357. rootY += this._lineSpacing.getValue(this._host);
  11358. }
  11359. else {
  11360. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11361. }
  11362. }
  11363. this._drawText(line.text, line.width, rootY, context);
  11364. rootY += this._fontOffset.height;
  11365. }
  11366. };
  11367. /**
  11368. * Given a width constraint applied on the text block, find the expected height
  11369. * @returns expected height
  11370. */
  11371. TextBlock.prototype.computeExpectedHeight = function () {
  11372. if (this.text && this.widthInPixels) {
  11373. var context_1 = document.createElement('canvas').getContext('2d');
  11374. if (context_1) {
  11375. this._applyStates(context_1);
  11376. if (!this._fontOffset) {
  11377. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11378. }
  11379. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11380. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11381. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11382. var lineSpacing = 0;
  11383. if (this._lineSpacing.isPixel) {
  11384. lineSpacing = this._lineSpacing.getValue(this._host);
  11385. }
  11386. else {
  11387. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11388. }
  11389. newHeight += (lines.length - 1) * lineSpacing;
  11390. }
  11391. return newHeight;
  11392. }
  11393. }
  11394. return 0;
  11395. };
  11396. TextBlock.prototype.dispose = function () {
  11397. _super.prototype.dispose.call(this);
  11398. this.onTextChangedObservable.clear();
  11399. };
  11400. return TextBlock;
  11401. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11402. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11403. /***/ }),
  11404. /***/ "./2D/controls/virtualKeyboard.ts":
  11405. /*!****************************************!*\
  11406. !*** ./2D/controls/virtualKeyboard.ts ***!
  11407. \****************************************/
  11408. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11410. "use strict";
  11411. __webpack_require__.r(__webpack_exports__);
  11412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11415. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11416. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11417. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11418. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11419. /**
  11420. * Class used to store key control properties
  11421. */
  11422. var KeyPropertySet = /** @class */ (function () {
  11423. function KeyPropertySet() {
  11424. }
  11425. return KeyPropertySet;
  11426. }());
  11427. /**
  11428. * Class used to create virtual keyboard
  11429. */
  11430. var VirtualKeyboard = /** @class */ (function (_super) {
  11431. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11432. function VirtualKeyboard() {
  11433. var _this = _super !== null && _super.apply(this, arguments) || this;
  11434. /** Observable raised when a key is pressed */
  11435. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11436. /** Gets or sets default key button width */
  11437. _this.defaultButtonWidth = "40px";
  11438. /** Gets or sets default key button height */
  11439. _this.defaultButtonHeight = "40px";
  11440. /** Gets or sets default key button left padding */
  11441. _this.defaultButtonPaddingLeft = "2px";
  11442. /** Gets or sets default key button right padding */
  11443. _this.defaultButtonPaddingRight = "2px";
  11444. /** Gets or sets default key button top padding */
  11445. _this.defaultButtonPaddingTop = "2px";
  11446. /** Gets or sets default key button bottom padding */
  11447. _this.defaultButtonPaddingBottom = "2px";
  11448. /** Gets or sets default key button foreground color */
  11449. _this.defaultButtonColor = "#DDD";
  11450. /** Gets or sets default key button background color */
  11451. _this.defaultButtonBackground = "#070707";
  11452. /** Gets or sets shift button foreground color */
  11453. _this.shiftButtonColor = "#7799FF";
  11454. /** Gets or sets shift button thickness*/
  11455. _this.selectedShiftThickness = 1;
  11456. /** Gets shift key state */
  11457. _this.shiftState = 0;
  11458. _this._currentlyConnectedInputText = null;
  11459. _this._connectedInputTexts = [];
  11460. _this._onKeyPressObserver = null;
  11461. return _this;
  11462. }
  11463. VirtualKeyboard.prototype._getTypeName = function () {
  11464. return "VirtualKeyboard";
  11465. };
  11466. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11467. var _this = this;
  11468. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11469. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11470. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11471. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11472. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11473. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11474. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11475. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11476. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11477. button.thickness = 0;
  11478. button.isFocusInvisible = true;
  11479. button.shadowColor = this.shadowColor;
  11480. button.shadowBlur = this.shadowBlur;
  11481. button.shadowOffsetX = this.shadowOffsetX;
  11482. button.shadowOffsetY = this.shadowOffsetY;
  11483. button.onPointerUpObservable.add(function () {
  11484. _this.onKeyPressObservable.notifyObservers(key);
  11485. });
  11486. return button;
  11487. };
  11488. /**
  11489. * Adds a new row of keys
  11490. * @param keys defines the list of keys to add
  11491. * @param propertySets defines the associated property sets
  11492. */
  11493. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11494. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11495. panel.isVertical = false;
  11496. panel.isFocusInvisible = true;
  11497. var maxKey = null;
  11498. for (var i = 0; i < keys.length; i++) {
  11499. var properties = null;
  11500. if (propertySets && propertySets.length === keys.length) {
  11501. properties = propertySets[i];
  11502. }
  11503. var key = this._createKey(keys[i], properties);
  11504. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11505. maxKey = key;
  11506. }
  11507. panel.addControl(key);
  11508. }
  11509. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11510. this.addControl(panel);
  11511. };
  11512. /**
  11513. * Set the shift key to a specific state
  11514. * @param shiftState defines the new shift state
  11515. */
  11516. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11517. if (!this.children) {
  11518. return;
  11519. }
  11520. for (var i = 0; i < this.children.length; i++) {
  11521. var row = this.children[i];
  11522. if (!row || !row.children) {
  11523. continue;
  11524. }
  11525. var rowContainer = row;
  11526. for (var j = 0; j < rowContainer.children.length; j++) {
  11527. var button = rowContainer.children[j];
  11528. if (!button || !button.children[0]) {
  11529. continue;
  11530. }
  11531. var button_tblock = button.children[0];
  11532. if (button_tblock.text === "\u21E7") {
  11533. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11534. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11535. }
  11536. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11537. }
  11538. }
  11539. };
  11540. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11541. /** Gets the input text control currently attached to the keyboard */
  11542. get: function () {
  11543. return this._currentlyConnectedInputText;
  11544. },
  11545. enumerable: true,
  11546. configurable: true
  11547. });
  11548. /**
  11549. * Connects the keyboard with an input text control
  11550. *
  11551. * @param input defines the target control
  11552. */
  11553. VirtualKeyboard.prototype.connect = function (input) {
  11554. var _this = this;
  11555. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11556. if (inputTextAlreadyConnected) {
  11557. return;
  11558. }
  11559. if (this._onKeyPressObserver === null) {
  11560. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11561. if (!_this._currentlyConnectedInputText) {
  11562. return;
  11563. }
  11564. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11565. switch (key) {
  11566. case "\u21E7":
  11567. _this.shiftState++;
  11568. if (_this.shiftState > 2) {
  11569. _this.shiftState = 0;
  11570. }
  11571. _this.applyShiftState(_this.shiftState);
  11572. return;
  11573. case "\u2190":
  11574. _this._currentlyConnectedInputText.processKey(8);
  11575. return;
  11576. case "\u21B5":
  11577. _this._currentlyConnectedInputText.processKey(13);
  11578. return;
  11579. }
  11580. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11581. if (_this.shiftState === 1) {
  11582. _this.shiftState = 0;
  11583. _this.applyShiftState(_this.shiftState);
  11584. }
  11585. });
  11586. }
  11587. this.isVisible = false;
  11588. this._currentlyConnectedInputText = input;
  11589. input._connectedVirtualKeyboard = this;
  11590. // Events hooking
  11591. var onFocusObserver = input.onFocusObservable.add(function () {
  11592. _this._currentlyConnectedInputText = input;
  11593. input._connectedVirtualKeyboard = _this;
  11594. _this.isVisible = true;
  11595. });
  11596. var onBlurObserver = input.onBlurObservable.add(function () {
  11597. input._connectedVirtualKeyboard = null;
  11598. _this._currentlyConnectedInputText = null;
  11599. _this.isVisible = false;
  11600. });
  11601. this._connectedInputTexts.push({
  11602. input: input,
  11603. onBlurObserver: onBlurObserver,
  11604. onFocusObserver: onFocusObserver
  11605. });
  11606. };
  11607. /**
  11608. * Disconnects the keyboard from connected InputText controls
  11609. *
  11610. * @param input optionally defines a target control, otherwise all are disconnected
  11611. */
  11612. VirtualKeyboard.prototype.disconnect = function (input) {
  11613. var _this = this;
  11614. if (input) {
  11615. // .find not available on IE
  11616. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11617. if (filtered.length === 1) {
  11618. this._removeConnectedInputObservables(filtered[0]);
  11619. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11620. if (this._currentlyConnectedInputText === input) {
  11621. this._currentlyConnectedInputText = null;
  11622. }
  11623. }
  11624. }
  11625. else {
  11626. this._connectedInputTexts.forEach(function (connectedInputText) {
  11627. _this._removeConnectedInputObservables(connectedInputText);
  11628. });
  11629. this._connectedInputTexts = [];
  11630. }
  11631. if (this._connectedInputTexts.length === 0) {
  11632. this._currentlyConnectedInputText = null;
  11633. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11634. this._onKeyPressObserver = null;
  11635. }
  11636. };
  11637. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11638. connectedInputText.input._connectedVirtualKeyboard = null;
  11639. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11640. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11641. };
  11642. /**
  11643. * Release all resources
  11644. */
  11645. VirtualKeyboard.prototype.dispose = function () {
  11646. _super.prototype.dispose.call(this);
  11647. this.disconnect();
  11648. };
  11649. // Statics
  11650. /**
  11651. * Creates a new keyboard using a default layout
  11652. *
  11653. * @param name defines control name
  11654. * @returns a new VirtualKeyboard
  11655. */
  11656. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11657. var returnValue = new VirtualKeyboard(name);
  11658. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11659. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11660. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11661. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11662. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11663. return returnValue;
  11664. };
  11665. return VirtualKeyboard;
  11666. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11667. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  11668. /***/ }),
  11669. /***/ "./2D/index.ts":
  11670. /*!*********************!*\
  11671. !*** ./2D/index.ts ***!
  11672. \*********************/
  11673. /*! 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, name */
  11674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11675. "use strict";
  11676. __webpack_require__.r(__webpack_exports__);
  11677. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11709. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11711. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11713. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11716. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11718. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11720. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11722. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11724. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  11725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  11726. /***/ }),
  11727. /***/ "./2D/math2D.ts":
  11728. /*!**********************!*\
  11729. !*** ./2D/math2D.ts ***!
  11730. \**********************/
  11731. /*! exports provided: Vector2WithInfo, Matrix2D */
  11732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11733. "use strict";
  11734. __webpack_require__.r(__webpack_exports__);
  11735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11738. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11739. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11740. /**
  11741. * Class used to transport Vector2 information for pointer events
  11742. */
  11743. var Vector2WithInfo = /** @class */ (function (_super) {
  11744. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  11745. /**
  11746. * Creates a new Vector2WithInfo
  11747. * @param source defines the vector2 data to transport
  11748. * @param buttonIndex defines the current mouse button index
  11749. */
  11750. function Vector2WithInfo(source,
  11751. /** defines the current mouse button index */
  11752. buttonIndex) {
  11753. if (buttonIndex === void 0) { buttonIndex = 0; }
  11754. var _this = _super.call(this, source.x, source.y) || this;
  11755. _this.buttonIndex = buttonIndex;
  11756. return _this;
  11757. }
  11758. return Vector2WithInfo;
  11759. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11760. /** Class used to provide 2D matrix features */
  11761. var Matrix2D = /** @class */ (function () {
  11762. /**
  11763. * Creates a new matrix
  11764. * @param m00 defines value for (0, 0)
  11765. * @param m01 defines value for (0, 1)
  11766. * @param m10 defines value for (1, 0)
  11767. * @param m11 defines value for (1, 1)
  11768. * @param m20 defines value for (2, 0)
  11769. * @param m21 defines value for (2, 1)
  11770. */
  11771. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11772. /** Gets the internal array of 6 floats used to store matrix data */
  11773. this.m = new Float32Array(6);
  11774. this.fromValues(m00, m01, m10, m11, m20, m21);
  11775. }
  11776. /**
  11777. * Fills the matrix from direct values
  11778. * @param m00 defines value for (0, 0)
  11779. * @param m01 defines value for (0, 1)
  11780. * @param m10 defines value for (1, 0)
  11781. * @param m11 defines value for (1, 1)
  11782. * @param m20 defines value for (2, 0)
  11783. * @param m21 defines value for (2, 1)
  11784. * @returns the current modified matrix
  11785. */
  11786. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11787. this.m[0] = m00;
  11788. this.m[1] = m01;
  11789. this.m[2] = m10;
  11790. this.m[3] = m11;
  11791. this.m[4] = m20;
  11792. this.m[5] = m21;
  11793. return this;
  11794. };
  11795. /**
  11796. * Gets matrix determinant
  11797. * @returns the determinant
  11798. */
  11799. Matrix2D.prototype.determinant = function () {
  11800. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11801. };
  11802. /**
  11803. * Inverses the matrix and stores it in a target matrix
  11804. * @param result defines the target matrix
  11805. * @returns the current matrix
  11806. */
  11807. Matrix2D.prototype.invertToRef = function (result) {
  11808. var l0 = this.m[0];
  11809. var l1 = this.m[1];
  11810. var l2 = this.m[2];
  11811. var l3 = this.m[3];
  11812. var l4 = this.m[4];
  11813. var l5 = this.m[5];
  11814. var det = this.determinant();
  11815. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11816. result.m[0] = 0;
  11817. result.m[1] = 0;
  11818. result.m[2] = 0;
  11819. result.m[3] = 0;
  11820. result.m[4] = 0;
  11821. result.m[5] = 0;
  11822. return this;
  11823. }
  11824. var detDiv = 1 / det;
  11825. var det4 = l2 * l5 - l3 * l4;
  11826. var det5 = l1 * l4 - l0 * l5;
  11827. result.m[0] = l3 * detDiv;
  11828. result.m[1] = -l1 * detDiv;
  11829. result.m[2] = -l2 * detDiv;
  11830. result.m[3] = l0 * detDiv;
  11831. result.m[4] = det4 * detDiv;
  11832. result.m[5] = det5 * detDiv;
  11833. return this;
  11834. };
  11835. /**
  11836. * Multiplies the current matrix with another one
  11837. * @param other defines the second operand
  11838. * @param result defines the target matrix
  11839. * @returns the current matrix
  11840. */
  11841. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11842. var l0 = this.m[0];
  11843. var l1 = this.m[1];
  11844. var l2 = this.m[2];
  11845. var l3 = this.m[3];
  11846. var l4 = this.m[4];
  11847. var l5 = this.m[5];
  11848. var r0 = other.m[0];
  11849. var r1 = other.m[1];
  11850. var r2 = other.m[2];
  11851. var r3 = other.m[3];
  11852. var r4 = other.m[4];
  11853. var r5 = other.m[5];
  11854. result.m[0] = l0 * r0 + l1 * r2;
  11855. result.m[1] = l0 * r1 + l1 * r3;
  11856. result.m[2] = l2 * r0 + l3 * r2;
  11857. result.m[3] = l2 * r1 + l3 * r3;
  11858. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11859. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11860. return this;
  11861. };
  11862. /**
  11863. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11864. * @param x defines the x coordinate to transform
  11865. * @param y defines the x coordinate to transform
  11866. * @param result defines the target vector2
  11867. * @returns the current matrix
  11868. */
  11869. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11870. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11871. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11872. return this;
  11873. };
  11874. // Statics
  11875. /**
  11876. * Creates an identity matrix
  11877. * @returns a new matrix
  11878. */
  11879. Matrix2D.Identity = function () {
  11880. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11881. };
  11882. /**
  11883. * Creates a translation matrix and stores it in a target matrix
  11884. * @param x defines the x coordinate of the translation
  11885. * @param y defines the y coordinate of the translation
  11886. * @param result defines the target matrix
  11887. */
  11888. Matrix2D.TranslationToRef = function (x, y, result) {
  11889. result.fromValues(1, 0, 0, 1, x, y);
  11890. };
  11891. /**
  11892. * Creates a scaling matrix and stores it in a target matrix
  11893. * @param x defines the x coordinate of the scaling
  11894. * @param y defines the y coordinate of the scaling
  11895. * @param result defines the target matrix
  11896. */
  11897. Matrix2D.ScalingToRef = function (x, y, result) {
  11898. result.fromValues(x, 0, 0, y, 0, 0);
  11899. };
  11900. /**
  11901. * Creates a rotation matrix and stores it in a target matrix
  11902. * @param angle defines the rotation angle
  11903. * @param result defines the target matrix
  11904. */
  11905. Matrix2D.RotationToRef = function (angle, result) {
  11906. var s = Math.sin(angle);
  11907. var c = Math.cos(angle);
  11908. result.fromValues(c, s, -s, c, 0, 0);
  11909. };
  11910. /**
  11911. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11912. * @param tx defines the x coordinate of the translation
  11913. * @param ty defines the y coordinate of the translation
  11914. * @param angle defines the rotation angle
  11915. * @param scaleX defines the x coordinate of the scaling
  11916. * @param scaleY defines the y coordinate of the scaling
  11917. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11918. * @param result defines the target matrix
  11919. */
  11920. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11921. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11922. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11923. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11924. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11925. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11926. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11927. if (parentMatrix) {
  11928. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11929. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11930. }
  11931. else {
  11932. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11933. }
  11934. };
  11935. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11936. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11937. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11938. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11939. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11940. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11941. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11942. return Matrix2D;
  11943. }());
  11944. /***/ }),
  11945. /***/ "./2D/measure.ts":
  11946. /*!***********************!*\
  11947. !*** ./2D/measure.ts ***!
  11948. \***********************/
  11949. /*! exports provided: Measure */
  11950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11951. "use strict";
  11952. __webpack_require__.r(__webpack_exports__);
  11953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11954. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  11955. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11956. /**
  11957. * Class used to store 2D control sizes
  11958. */
  11959. var Measure = /** @class */ (function () {
  11960. /**
  11961. * Creates a new measure
  11962. * @param left defines left coordinate
  11963. * @param top defines top coordinate
  11964. * @param width defines width dimension
  11965. * @param height defines height dimension
  11966. */
  11967. function Measure(
  11968. /** defines left coordinate */
  11969. left,
  11970. /** defines top coordinate */
  11971. top,
  11972. /** defines width dimension */
  11973. width,
  11974. /** defines height dimension */
  11975. height) {
  11976. this.left = left;
  11977. this.top = top;
  11978. this.width = width;
  11979. this.height = height;
  11980. }
  11981. /**
  11982. * Copy from another measure
  11983. * @param other defines the other measure to copy from
  11984. */
  11985. Measure.prototype.copyFrom = function (other) {
  11986. this.left = other.left;
  11987. this.top = other.top;
  11988. this.width = other.width;
  11989. this.height = other.height;
  11990. };
  11991. /**
  11992. * Copy from a group of 4 floats
  11993. * @param left defines left coordinate
  11994. * @param top defines top coordinate
  11995. * @param width defines width dimension
  11996. * @param height defines height dimension
  11997. */
  11998. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11999. this.left = left;
  12000. this.top = top;
  12001. this.width = width;
  12002. this.height = height;
  12003. };
  12004. /**
  12005. * Computes the axis aligned bounding box measure for two given measures
  12006. * @param a Input measure
  12007. * @param b Input measure
  12008. * @param result the resulting bounding measure
  12009. */
  12010. Measure.CombineToRef = function (a, b, result) {
  12011. var left = Math.min(a.left, b.left);
  12012. var top = Math.min(a.top, b.top);
  12013. var right = Math.max(a.left + a.width, b.left + b.width);
  12014. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12015. result.left = left;
  12016. result.top = top;
  12017. result.width = right - left;
  12018. result.height = bottom - top;
  12019. };
  12020. /**
  12021. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12022. * @param transform the matrix to transform the measure before computing the AABB
  12023. * @param result the resulting AABB
  12024. */
  12025. Measure.prototype.transformToRef = function (transform, result) {
  12026. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12027. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12028. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12029. for (var i = 0; i < 4; i++) {
  12030. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12031. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12032. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12033. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12034. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12035. }
  12036. result.left = min.x;
  12037. result.top = min.y;
  12038. result.width = max.x - min.x;
  12039. result.height = max.y - min.y;
  12040. };
  12041. /**
  12042. * Check equality between this measure and another one
  12043. * @param other defines the other measures
  12044. * @returns true if both measures are equals
  12045. */
  12046. Measure.prototype.isEqualsTo = function (other) {
  12047. if (this.left !== other.left) {
  12048. return false;
  12049. }
  12050. if (this.top !== other.top) {
  12051. return false;
  12052. }
  12053. if (this.width !== other.width) {
  12054. return false;
  12055. }
  12056. if (this.height !== other.height) {
  12057. return false;
  12058. }
  12059. return true;
  12060. };
  12061. /**
  12062. * Creates an empty measure
  12063. * @returns a new measure
  12064. */
  12065. Measure.Empty = function () {
  12066. return new Measure(0, 0, 0, 0);
  12067. };
  12068. return Measure;
  12069. }());
  12070. /***/ }),
  12071. /***/ "./2D/multiLinePoint.ts":
  12072. /*!******************************!*\
  12073. !*** ./2D/multiLinePoint.ts ***!
  12074. \******************************/
  12075. /*! exports provided: MultiLinePoint */
  12076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12077. "use strict";
  12078. __webpack_require__.r(__webpack_exports__);
  12079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12080. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12081. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12082. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12083. /**
  12084. * Class used to store a point for a MultiLine object.
  12085. * The point can be pure 2D coordinates, a mesh or a control
  12086. */
  12087. var MultiLinePoint = /** @class */ (function () {
  12088. /**
  12089. * Creates a new MultiLinePoint
  12090. * @param multiLine defines the source MultiLine object
  12091. */
  12092. function MultiLinePoint(multiLine) {
  12093. this._multiLine = multiLine;
  12094. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12095. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12096. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12097. }
  12098. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12099. /** Gets or sets x coordinate */
  12100. get: function () {
  12101. return this._x.toString(this._multiLine._host);
  12102. },
  12103. set: function (value) {
  12104. if (this._x.toString(this._multiLine._host) === value) {
  12105. return;
  12106. }
  12107. if (this._x.fromString(value)) {
  12108. this._multiLine._markAsDirty();
  12109. }
  12110. },
  12111. enumerable: true,
  12112. configurable: true
  12113. });
  12114. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12115. /** Gets or sets y coordinate */
  12116. get: function () {
  12117. return this._y.toString(this._multiLine._host);
  12118. },
  12119. set: function (value) {
  12120. if (this._y.toString(this._multiLine._host) === value) {
  12121. return;
  12122. }
  12123. if (this._y.fromString(value)) {
  12124. this._multiLine._markAsDirty();
  12125. }
  12126. },
  12127. enumerable: true,
  12128. configurable: true
  12129. });
  12130. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12131. /** Gets or sets the control associated with this point */
  12132. get: function () {
  12133. return this._control;
  12134. },
  12135. set: function (value) {
  12136. if (this._control === value) {
  12137. return;
  12138. }
  12139. if (this._control && this._controlObserver) {
  12140. this._control.onDirtyObservable.remove(this._controlObserver);
  12141. this._controlObserver = null;
  12142. }
  12143. this._control = value;
  12144. if (this._control) {
  12145. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12146. }
  12147. this._multiLine._markAsDirty();
  12148. },
  12149. enumerable: true,
  12150. configurable: true
  12151. });
  12152. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12153. /** Gets or sets the mesh associated with this point */
  12154. get: function () {
  12155. return this._mesh;
  12156. },
  12157. set: function (value) {
  12158. if (this._mesh === value) {
  12159. return;
  12160. }
  12161. if (this._mesh && this._meshObserver) {
  12162. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12163. }
  12164. this._mesh = value;
  12165. if (this._mesh) {
  12166. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12167. }
  12168. this._multiLine._markAsDirty();
  12169. },
  12170. enumerable: true,
  12171. configurable: true
  12172. });
  12173. /** Resets links */
  12174. MultiLinePoint.prototype.resetLinks = function () {
  12175. this.control = null;
  12176. this.mesh = null;
  12177. };
  12178. /**
  12179. * Gets a translation vector
  12180. * @returns the translation vector
  12181. */
  12182. MultiLinePoint.prototype.translate = function () {
  12183. this._point = this._translatePoint();
  12184. return this._point;
  12185. };
  12186. MultiLinePoint.prototype._translatePoint = function () {
  12187. if (this._mesh != null) {
  12188. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12189. }
  12190. else if (this._control != null) {
  12191. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12192. }
  12193. else {
  12194. var host = this._multiLine._host;
  12195. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12196. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12197. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12198. }
  12199. };
  12200. /** Release associated resources */
  12201. MultiLinePoint.prototype.dispose = function () {
  12202. this.resetLinks();
  12203. };
  12204. return MultiLinePoint;
  12205. }());
  12206. /***/ }),
  12207. /***/ "./2D/style.ts":
  12208. /*!*********************!*\
  12209. !*** ./2D/style.ts ***!
  12210. \*********************/
  12211. /*! exports provided: Style */
  12212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12213. "use strict";
  12214. __webpack_require__.r(__webpack_exports__);
  12215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12216. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12217. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12218. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12219. /**
  12220. * Define a style used by control to automatically setup properties based on a template.
  12221. * Only support font related properties so far
  12222. */
  12223. var Style = /** @class */ (function () {
  12224. /**
  12225. * Creates a new style object
  12226. * @param host defines the AdvancedDynamicTexture which hosts this style
  12227. */
  12228. function Style(host) {
  12229. this._fontFamily = "Arial";
  12230. this._fontStyle = "";
  12231. this._fontWeight = "";
  12232. /** @hidden */
  12233. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12234. /**
  12235. * Observable raised when the style values are changed
  12236. */
  12237. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12238. this._host = host;
  12239. }
  12240. Object.defineProperty(Style.prototype, "fontSize", {
  12241. /**
  12242. * Gets or sets the font size
  12243. */
  12244. get: function () {
  12245. return this._fontSize.toString(this._host);
  12246. },
  12247. set: function (value) {
  12248. if (this._fontSize.toString(this._host) === value) {
  12249. return;
  12250. }
  12251. if (this._fontSize.fromString(value)) {
  12252. this.onChangedObservable.notifyObservers(this);
  12253. }
  12254. },
  12255. enumerable: true,
  12256. configurable: true
  12257. });
  12258. Object.defineProperty(Style.prototype, "fontFamily", {
  12259. /**
  12260. * Gets or sets the font family
  12261. */
  12262. get: function () {
  12263. return this._fontFamily;
  12264. },
  12265. set: function (value) {
  12266. if (this._fontFamily === value) {
  12267. return;
  12268. }
  12269. this._fontFamily = value;
  12270. this.onChangedObservable.notifyObservers(this);
  12271. },
  12272. enumerable: true,
  12273. configurable: true
  12274. });
  12275. Object.defineProperty(Style.prototype, "fontStyle", {
  12276. /**
  12277. * Gets or sets the font style
  12278. */
  12279. get: function () {
  12280. return this._fontStyle;
  12281. },
  12282. set: function (value) {
  12283. if (this._fontStyle === value) {
  12284. return;
  12285. }
  12286. this._fontStyle = value;
  12287. this.onChangedObservable.notifyObservers(this);
  12288. },
  12289. enumerable: true,
  12290. configurable: true
  12291. });
  12292. Object.defineProperty(Style.prototype, "fontWeight", {
  12293. /** Gets or sets font weight */
  12294. get: function () {
  12295. return this._fontWeight;
  12296. },
  12297. set: function (value) {
  12298. if (this._fontWeight === value) {
  12299. return;
  12300. }
  12301. this._fontWeight = value;
  12302. this.onChangedObservable.notifyObservers(this);
  12303. },
  12304. enumerable: true,
  12305. configurable: true
  12306. });
  12307. /** Dispose all associated resources */
  12308. Style.prototype.dispose = function () {
  12309. this.onChangedObservable.clear();
  12310. };
  12311. return Style;
  12312. }());
  12313. /***/ }),
  12314. /***/ "./2D/valueAndUnit.ts":
  12315. /*!****************************!*\
  12316. !*** ./2D/valueAndUnit.ts ***!
  12317. \****************************/
  12318. /*! exports provided: ValueAndUnit */
  12319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12320. "use strict";
  12321. __webpack_require__.r(__webpack_exports__);
  12322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12323. /**
  12324. * Class used to specific a value and its associated unit
  12325. */
  12326. var ValueAndUnit = /** @class */ (function () {
  12327. /**
  12328. * Creates a new ValueAndUnit
  12329. * @param value defines the value to store
  12330. * @param unit defines the unit to store
  12331. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12332. */
  12333. function ValueAndUnit(value,
  12334. /** defines the unit to store */
  12335. unit,
  12336. /** defines a boolean indicating if the value can be negative */
  12337. negativeValueAllowed) {
  12338. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12339. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12340. this.unit = unit;
  12341. this.negativeValueAllowed = negativeValueAllowed;
  12342. this._value = 1;
  12343. /**
  12344. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12345. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12346. */
  12347. this.ignoreAdaptiveScaling = false;
  12348. this._value = value;
  12349. this._originalUnit = unit;
  12350. }
  12351. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12352. /** Gets a boolean indicating if the value is a percentage */
  12353. get: function () {
  12354. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12355. },
  12356. enumerable: true,
  12357. configurable: true
  12358. });
  12359. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12360. /** Gets a boolean indicating if the value is store as pixel */
  12361. get: function () {
  12362. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12363. },
  12364. enumerable: true,
  12365. configurable: true
  12366. });
  12367. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12368. /** Gets direct internal value */
  12369. get: function () {
  12370. return this._value;
  12371. },
  12372. enumerable: true,
  12373. configurable: true
  12374. });
  12375. /**
  12376. * Gets value as pixel
  12377. * @param host defines the root host
  12378. * @param refValue defines the reference value for percentages
  12379. * @returns the value as pixel
  12380. */
  12381. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12382. if (this.isPixel) {
  12383. return this.getValue(host);
  12384. }
  12385. return this.getValue(host) * refValue;
  12386. };
  12387. /**
  12388. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12389. * @param value defines the value to store
  12390. * @param unit defines the unit to store
  12391. * @returns the current ValueAndUnit
  12392. */
  12393. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12394. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12395. this._value = value;
  12396. this.unit = unit;
  12397. return this;
  12398. };
  12399. /**
  12400. * Gets the value accordingly to its unit
  12401. * @param host defines the root host
  12402. * @returns the value
  12403. */
  12404. ValueAndUnit.prototype.getValue = function (host) {
  12405. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12406. var width = 0;
  12407. var height = 0;
  12408. if (host.idealWidth) {
  12409. width = (this._value * host.getSize().width) / host.idealWidth;
  12410. }
  12411. if (host.idealHeight) {
  12412. height = (this._value * host.getSize().height) / host.idealHeight;
  12413. }
  12414. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12415. return window.innerWidth < window.innerHeight ? width : height;
  12416. }
  12417. if (host.idealWidth) { // horizontal
  12418. return width;
  12419. }
  12420. if (host.idealHeight) { // vertical
  12421. return height;
  12422. }
  12423. }
  12424. return this._value;
  12425. };
  12426. /**
  12427. * Gets a string representation of the value
  12428. * @param host defines the root host
  12429. * @param decimals defines an optional number of decimals to display
  12430. * @returns a string
  12431. */
  12432. ValueAndUnit.prototype.toString = function (host, decimals) {
  12433. switch (this.unit) {
  12434. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12435. var percentage = this.getValue(host) * 100;
  12436. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12437. case ValueAndUnit.UNITMODE_PIXEL:
  12438. var pixels = this.getValue(host);
  12439. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12440. }
  12441. return this.unit.toString();
  12442. };
  12443. /**
  12444. * Store a value parsed from a string
  12445. * @param source defines the source string
  12446. * @returns true if the value was successfully parsed
  12447. */
  12448. ValueAndUnit.prototype.fromString = function (source) {
  12449. var match = ValueAndUnit._Regex.exec(source.toString());
  12450. if (!match || match.length === 0) {
  12451. return false;
  12452. }
  12453. var sourceValue = parseFloat(match[1]);
  12454. var sourceUnit = this._originalUnit;
  12455. if (!this.negativeValueAllowed) {
  12456. if (sourceValue < 0) {
  12457. sourceValue = 0;
  12458. }
  12459. }
  12460. if (match.length === 4) {
  12461. switch (match[3]) {
  12462. case "px":
  12463. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12464. break;
  12465. case "%":
  12466. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12467. sourceValue /= 100.0;
  12468. break;
  12469. }
  12470. }
  12471. if (sourceValue === this._value && sourceUnit === this.unit) {
  12472. return false;
  12473. }
  12474. this._value = sourceValue;
  12475. this.unit = sourceUnit;
  12476. return true;
  12477. };
  12478. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12479. /** UNITMODE_PERCENTAGE */
  12480. get: function () {
  12481. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12482. },
  12483. enumerable: true,
  12484. configurable: true
  12485. });
  12486. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12487. /** UNITMODE_PIXEL */
  12488. get: function () {
  12489. return ValueAndUnit._UNITMODE_PIXEL;
  12490. },
  12491. enumerable: true,
  12492. configurable: true
  12493. });
  12494. // Static
  12495. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12496. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12497. ValueAndUnit._UNITMODE_PIXEL = 1;
  12498. return ValueAndUnit;
  12499. }());
  12500. /***/ }),
  12501. /***/ "./2D/xmlLoader.ts":
  12502. /*!*************************!*\
  12503. !*** ./2D/xmlLoader.ts ***!
  12504. \*************************/
  12505. /*! exports provided: XmlLoader */
  12506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12507. "use strict";
  12508. __webpack_require__.r(__webpack_exports__);
  12509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12510. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  12511. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12512. /**
  12513. * Class used to load GUI via XML.
  12514. */
  12515. var XmlLoader = /** @class */ (function () {
  12516. /**
  12517. * Create a new xml loader
  12518. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12519. */
  12520. function XmlLoader(parentClass) {
  12521. if (parentClass === void 0) { parentClass = null; }
  12522. this._nodes = {};
  12523. this._nodeTypes = {
  12524. element: 1,
  12525. attribute: 2,
  12526. text: 3
  12527. };
  12528. this._isLoaded = false;
  12529. this._objectAttributes = {
  12530. "textHorizontalAlignment": 1,
  12531. "textVerticalAlignment": 2,
  12532. "horizontalAlignment": 3,
  12533. "verticalAlignment": 4,
  12534. "stretch": 5,
  12535. };
  12536. if (parentClass) {
  12537. this._parentClass = parentClass;
  12538. }
  12539. }
  12540. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12541. var element = window;
  12542. if (this._parentClass) {
  12543. element = this._parentClass;
  12544. }
  12545. var value = attributeValue;
  12546. value = value.split(".");
  12547. for (var i = 0; i < value.length; i++) {
  12548. element = element[value[i]];
  12549. }
  12550. return element;
  12551. };
  12552. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12553. var attribute = attributeName.split(".");
  12554. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12555. return className[attribute[1]];
  12556. };
  12557. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12558. if (linkParent === void 0) { linkParent = true; }
  12559. try {
  12560. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12561. var guiNode = new className();
  12562. if (parent && linkParent) {
  12563. parent.addControl(guiNode);
  12564. }
  12565. for (var i = 0; i < node.attributes.length; i++) {
  12566. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12567. continue;
  12568. }
  12569. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12570. var element = this._getChainElement(node.attributes[i].value);
  12571. guiNode[node.attributes[i].name].add(element);
  12572. continue;
  12573. }
  12574. else if (node.attributes[i].name == "linkWithMesh") {
  12575. if (this._parentClass) {
  12576. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  12577. }
  12578. else {
  12579. guiNode.linkWithMesh(window[node.attributes[i].value]);
  12580. }
  12581. }
  12582. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  12583. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  12584. guiNode[node.attributes[i].name] = element;
  12585. }
  12586. else if (!this._objectAttributes[node.attributes[i].name]) {
  12587. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  12588. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  12589. }
  12590. else {
  12591. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  12592. }
  12593. }
  12594. else {
  12595. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  12596. }
  12597. }
  12598. if (!node.attributes.getNamedItem("id")) {
  12599. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  12600. return guiNode;
  12601. }
  12602. if (!this._nodes[node.attributes.getNamedItem("id").nodeValue]) {
  12603. this._nodes[node.attributes.getNamedItem("id").nodeValue] = guiNode;
  12604. }
  12605. else {
  12606. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  12607. }
  12608. return guiNode;
  12609. }
  12610. catch (e) {
  12611. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  12612. }
  12613. };
  12614. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  12615. var width;
  12616. var height;
  12617. var columns;
  12618. var rows = node.children;
  12619. var cells;
  12620. var isPixel = false;
  12621. var cellNode;
  12622. var rowNumber = -1;
  12623. var columnNumber = -1;
  12624. var totalColumnsNumber = 0;
  12625. for (var i = 0; i < rows.length; i++) {
  12626. if (rows[i].nodeType != this._nodeTypes.element) {
  12627. continue;
  12628. }
  12629. if (rows[i].nodeName != "Row") {
  12630. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  12631. }
  12632. rowNumber += 1;
  12633. columns = rows[i].children;
  12634. if (!rows[i].attributes.getNamedItem("height")) {
  12635. throw "XmlLoader Exception : Height must be defined for grid rows";
  12636. }
  12637. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  12638. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  12639. guiNode.addRowDefinition(height, isPixel);
  12640. for (var j = 0; j < columns.length; j++) {
  12641. if (columns[j].nodeType != this._nodeTypes.element) {
  12642. continue;
  12643. }
  12644. if (columns[j].nodeName != "Column") {
  12645. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  12646. }
  12647. columnNumber += 1;
  12648. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  12649. 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.";
  12650. }
  12651. if (rowNumber == 0) {
  12652. if (!columns[j].attributes.getNamedItem("width")) {
  12653. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  12654. }
  12655. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  12656. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  12657. guiNode.addColumnDefinition(width, isPixel);
  12658. }
  12659. cells = columns[j].children;
  12660. for (var k = 0; k < cells.length; k++) {
  12661. if (cells[k].nodeType != this._nodeTypes.element) {
  12662. continue;
  12663. }
  12664. cellNode = this._createGuiElement(cells[k], guiNode, false);
  12665. guiNode.addControl(cellNode, rowNumber, columnNumber);
  12666. if (cells[k].firstChild) {
  12667. this._parseXml(cells[k].firstChild, cellNode);
  12668. }
  12669. }
  12670. }
  12671. if (rowNumber == 0) {
  12672. totalColumnsNumber = columnNumber;
  12673. }
  12674. columnNumber = -1;
  12675. }
  12676. if (node.nextSibling) {
  12677. this._parseXml(node.nextSibling, parent);
  12678. }
  12679. };
  12680. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  12681. if (node.firstChild) {
  12682. this._parseXml(node.firstChild, guiNode);
  12683. }
  12684. if (node.nextSibling) {
  12685. this._parseXml(node.nextSibling, parent);
  12686. }
  12687. };
  12688. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  12689. if (this._parentClass) {
  12690. this._parentClass[variable] = source[iterator];
  12691. }
  12692. else {
  12693. window[variable] = source[iterator];
  12694. }
  12695. if (node.firstChild) {
  12696. this._parseXml(node.firstChild, guiNode, true);
  12697. }
  12698. };
  12699. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  12700. var dataSource = node.attributes.getNamedItem("dataSource").value;
  12701. if (!dataSource.includes(" in ")) {
  12702. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  12703. }
  12704. else {
  12705. var isArray = true;
  12706. var splittedSource = dataSource.split(" in ");
  12707. if (splittedSource.length < 2) {
  12708. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  12709. }
  12710. var source = splittedSource[1];
  12711. if (source.startsWith("{") && source.endsWith("}")) {
  12712. isArray = false;
  12713. }
  12714. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  12715. source = source.substring(1, source.length - 1);
  12716. }
  12717. if (this._parentClass) {
  12718. source = this._parentClass[source];
  12719. }
  12720. else {
  12721. source = window[source];
  12722. }
  12723. if (isArray) {
  12724. for (var i = 0; i < source.length; i++) {
  12725. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12726. }
  12727. }
  12728. else {
  12729. for (var i in source) {
  12730. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  12731. }
  12732. }
  12733. if (node.nextSibling) {
  12734. this._parseXml(node.nextSibling, parent);
  12735. }
  12736. }
  12737. };
  12738. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  12739. if (generated === void 0) { generated = false; }
  12740. if (node.nodeType != this._nodeTypes.element) {
  12741. if (node.nextSibling) {
  12742. this._parseXml(node.nextSibling, parent, generated);
  12743. }
  12744. return;
  12745. }
  12746. if (generated) {
  12747. node.setAttribute("id", parent.id + parent._children.length + 1);
  12748. }
  12749. var guiNode = this._createGuiElement(node, parent);
  12750. if (node.nodeName == "Grid") {
  12751. this._parseGrid(node, guiNode, parent);
  12752. }
  12753. else if (!node.attributes.getNamedItem("dataSource")) {
  12754. this._parseElement(node, guiNode, parent);
  12755. }
  12756. else {
  12757. this._parseElementsFromSource(node, guiNode, parent);
  12758. }
  12759. };
  12760. /**
  12761. * Gets if the loading has finished.
  12762. * @returns whether the loading has finished or not
  12763. */
  12764. XmlLoader.prototype.isLoaded = function () {
  12765. return this._isLoaded;
  12766. };
  12767. /**
  12768. * Gets a loaded node / control by id.
  12769. * @param id the Controls id set in the xml
  12770. * @returns element of type Control
  12771. */
  12772. XmlLoader.prototype.getNodeById = function (id) {
  12773. return this._nodes[id];
  12774. };
  12775. /**
  12776. * Gets all loaded nodes / controls
  12777. * @returns Array of controls
  12778. */
  12779. XmlLoader.prototype.getNodes = function () {
  12780. return this._nodes;
  12781. };
  12782. /**
  12783. * Initiates the xml layout loading
  12784. * @param xmlFile defines the xml layout to load
  12785. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  12786. * @param callback defines the callback called on layout load.
  12787. */
  12788. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  12789. var xhttp = new XMLHttpRequest();
  12790. xhttp.onreadystatechange = function () {
  12791. if (xhttp.readyState == 4 && xhttp.status == 200) {
  12792. if (!xhttp.responseXML) {
  12793. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  12794. }
  12795. var xmlDoc = xhttp.responseXML.documentElement;
  12796. this._parseXml(xmlDoc.firstChild, rootNode);
  12797. this._isLoaded = true;
  12798. if (callback) {
  12799. callback();
  12800. }
  12801. }
  12802. }.bind(this);
  12803. xhttp.open("GET", xmlFile, true);
  12804. xhttp.send();
  12805. };
  12806. return XmlLoader;
  12807. }());
  12808. /***/ }),
  12809. /***/ "./3D/controls/abstractButton3D.ts":
  12810. /*!*****************************************!*\
  12811. !*** ./3D/controls/abstractButton3D.ts ***!
  12812. \*****************************************/
  12813. /*! exports provided: AbstractButton3D */
  12814. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12815. "use strict";
  12816. __webpack_require__.r(__webpack_exports__);
  12817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12818. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12819. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  12820. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12821. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12822. /**
  12823. * Class used as a root to all buttons
  12824. */
  12825. var AbstractButton3D = /** @class */ (function (_super) {
  12826. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  12827. /**
  12828. * Creates a new button
  12829. * @param name defines the control name
  12830. */
  12831. function AbstractButton3D(name) {
  12832. return _super.call(this, name) || this;
  12833. }
  12834. AbstractButton3D.prototype._getTypeName = function () {
  12835. return "AbstractButton3D";
  12836. };
  12837. // Mesh association
  12838. AbstractButton3D.prototype._createNode = function (scene) {
  12839. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12840. };
  12841. return AbstractButton3D;
  12842. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12843. /***/ }),
  12844. /***/ "./3D/controls/button3D.ts":
  12845. /*!*********************************!*\
  12846. !*** ./3D/controls/button3D.ts ***!
  12847. \*********************************/
  12848. /*! exports provided: Button3D */
  12849. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12850. "use strict";
  12851. __webpack_require__.r(__webpack_exports__);
  12852. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12853. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12854. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12855. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12856. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12857. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12858. /**
  12859. * Class used to create a button in 3D
  12860. */
  12861. var Button3D = /** @class */ (function (_super) {
  12862. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  12863. /**
  12864. * Creates a new button
  12865. * @param name defines the control name
  12866. */
  12867. function Button3D(name) {
  12868. var _this = _super.call(this, name) || this;
  12869. _this._contentResolution = 512;
  12870. _this._contentScaleRatio = 2;
  12871. // Default animations
  12872. _this.pointerEnterAnimation = function () {
  12873. if (!_this.mesh) {
  12874. return;
  12875. }
  12876. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12877. };
  12878. _this.pointerOutAnimation = function () {
  12879. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12880. };
  12881. _this.pointerDownAnimation = function () {
  12882. if (!_this.mesh) {
  12883. return;
  12884. }
  12885. _this.mesh.scaling.scaleInPlace(0.95);
  12886. };
  12887. _this.pointerUpAnimation = function () {
  12888. if (!_this.mesh) {
  12889. return;
  12890. }
  12891. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12892. };
  12893. return _this;
  12894. }
  12895. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12896. /**
  12897. * Gets or sets the texture resolution used to render content (512 by default)
  12898. */
  12899. get: function () {
  12900. return this._contentResolution;
  12901. },
  12902. set: function (value) {
  12903. if (this._contentResolution === value) {
  12904. return;
  12905. }
  12906. this._contentResolution = value;
  12907. this._resetContent();
  12908. },
  12909. enumerable: true,
  12910. configurable: true
  12911. });
  12912. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12913. /**
  12914. * Gets or sets the texture scale ratio used to render content (2 by default)
  12915. */
  12916. get: function () {
  12917. return this._contentScaleRatio;
  12918. },
  12919. set: function (value) {
  12920. if (this._contentScaleRatio === value) {
  12921. return;
  12922. }
  12923. this._contentScaleRatio = value;
  12924. this._resetContent();
  12925. },
  12926. enumerable: true,
  12927. configurable: true
  12928. });
  12929. Button3D.prototype._disposeFacadeTexture = function () {
  12930. if (this._facadeTexture) {
  12931. this._facadeTexture.dispose();
  12932. this._facadeTexture = null;
  12933. }
  12934. };
  12935. Button3D.prototype._resetContent = function () {
  12936. this._disposeFacadeTexture();
  12937. this.content = this._content;
  12938. };
  12939. Object.defineProperty(Button3D.prototype, "content", {
  12940. /**
  12941. * Gets or sets the GUI 2D content used to display the button's facade
  12942. */
  12943. get: function () {
  12944. return this._content;
  12945. },
  12946. set: function (value) {
  12947. this._content = value;
  12948. if (!this._host || !this._host.utilityLayer) {
  12949. return;
  12950. }
  12951. if (!this._facadeTexture) {
  12952. 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);
  12953. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12954. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12955. this._facadeTexture.premulAlpha = true;
  12956. }
  12957. else {
  12958. this._facadeTexture.rootContainer.clearControls();
  12959. }
  12960. this._facadeTexture.addControl(value);
  12961. this._applyFacade(this._facadeTexture);
  12962. },
  12963. enumerable: true,
  12964. configurable: true
  12965. });
  12966. /**
  12967. * Apply the facade texture (created from the content property).
  12968. * This function can be overloaded by child classes
  12969. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12970. */
  12971. Button3D.prototype._applyFacade = function (facadeTexture) {
  12972. this._currentMaterial.emissiveTexture = facadeTexture;
  12973. };
  12974. Button3D.prototype._getTypeName = function () {
  12975. return "Button3D";
  12976. };
  12977. // Mesh association
  12978. Button3D.prototype._createNode = function (scene) {
  12979. var faceUV = new Array(6);
  12980. for (var i = 0; i < 6; i++) {
  12981. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12982. }
  12983. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12984. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12985. width: 1.0,
  12986. height: 1.0,
  12987. depth: 0.08,
  12988. faceUV: faceUV
  12989. }, scene);
  12990. return mesh;
  12991. };
  12992. Button3D.prototype._affectMaterial = function (mesh) {
  12993. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12994. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12995. mesh.material = material;
  12996. this._currentMaterial = material;
  12997. this._resetContent();
  12998. };
  12999. /**
  13000. * Releases all associated resources
  13001. */
  13002. Button3D.prototype.dispose = function () {
  13003. _super.prototype.dispose.call(this);
  13004. this._disposeFacadeTexture();
  13005. if (this._currentMaterial) {
  13006. this._currentMaterial.dispose();
  13007. }
  13008. };
  13009. return Button3D;
  13010. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13011. /***/ }),
  13012. /***/ "./3D/controls/container3D.ts":
  13013. /*!************************************!*\
  13014. !*** ./3D/controls/container3D.ts ***!
  13015. \************************************/
  13016. /*! exports provided: Container3D */
  13017. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13018. "use strict";
  13019. __webpack_require__.r(__webpack_exports__);
  13020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13021. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13022. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13023. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13024. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13025. /**
  13026. * Class used to create containers for controls
  13027. */
  13028. var Container3D = /** @class */ (function (_super) {
  13029. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13030. /**
  13031. * Creates a new container
  13032. * @param name defines the container name
  13033. */
  13034. function Container3D(name) {
  13035. var _this = _super.call(this, name) || this;
  13036. _this._blockLayout = false;
  13037. /**
  13038. * Gets the list of child controls
  13039. */
  13040. _this._children = new Array();
  13041. return _this;
  13042. }
  13043. Object.defineProperty(Container3D.prototype, "children", {
  13044. /**
  13045. * Gets the list of child controls
  13046. */
  13047. get: function () {
  13048. return this._children;
  13049. },
  13050. enumerable: true,
  13051. configurable: true
  13052. });
  13053. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13054. /**
  13055. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13056. * This is helpful to optimize layout operation when adding multiple children in a row
  13057. */
  13058. get: function () {
  13059. return this._blockLayout;
  13060. },
  13061. set: function (value) {
  13062. if (this._blockLayout === value) {
  13063. return;
  13064. }
  13065. this._blockLayout = value;
  13066. if (!this._blockLayout) {
  13067. this._arrangeChildren();
  13068. }
  13069. },
  13070. enumerable: true,
  13071. configurable: true
  13072. });
  13073. /**
  13074. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13075. * @returns the current container
  13076. */
  13077. Container3D.prototype.updateLayout = function () {
  13078. this._arrangeChildren();
  13079. return this;
  13080. };
  13081. /**
  13082. * Gets a boolean indicating if the given control is in the children of this control
  13083. * @param control defines the control to check
  13084. * @returns true if the control is in the child list
  13085. */
  13086. Container3D.prototype.containsControl = function (control) {
  13087. return this._children.indexOf(control) !== -1;
  13088. };
  13089. /**
  13090. * Adds a control to the children of this control
  13091. * @param control defines the control to add
  13092. * @returns the current container
  13093. */
  13094. Container3D.prototype.addControl = function (control) {
  13095. var index = this._children.indexOf(control);
  13096. if (index !== -1) {
  13097. return this;
  13098. }
  13099. control.parent = this;
  13100. control._host = this._host;
  13101. this._children.push(control);
  13102. if (this._host.utilityLayer) {
  13103. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13104. if (control.node) {
  13105. control.node.parent = this.node;
  13106. }
  13107. if (!this.blockLayout) {
  13108. this._arrangeChildren();
  13109. }
  13110. }
  13111. return this;
  13112. };
  13113. /**
  13114. * This function will be called everytime a new control is added
  13115. */
  13116. Container3D.prototype._arrangeChildren = function () {
  13117. };
  13118. Container3D.prototype._createNode = function (scene) {
  13119. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13120. };
  13121. /**
  13122. * Removes a control from the children of this control
  13123. * @param control defines the control to remove
  13124. * @returns the current container
  13125. */
  13126. Container3D.prototype.removeControl = function (control) {
  13127. var index = this._children.indexOf(control);
  13128. if (index !== -1) {
  13129. this._children.splice(index, 1);
  13130. control.parent = null;
  13131. control._disposeNode();
  13132. }
  13133. return this;
  13134. };
  13135. Container3D.prototype._getTypeName = function () {
  13136. return "Container3D";
  13137. };
  13138. /**
  13139. * Releases all associated resources
  13140. */
  13141. Container3D.prototype.dispose = function () {
  13142. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13143. var control = _a[_i];
  13144. control.dispose();
  13145. }
  13146. this._children = [];
  13147. _super.prototype.dispose.call(this);
  13148. };
  13149. /** Control rotation will remain unchanged */
  13150. Container3D.UNSET_ORIENTATION = 0;
  13151. /** Control will rotate to make it look at sphere central axis */
  13152. Container3D.FACEORIGIN_ORIENTATION = 1;
  13153. /** Control will rotate to make it look back at sphere central axis */
  13154. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13155. /** Control will rotate to look at z axis (0, 0, 1) */
  13156. Container3D.FACEFORWARD_ORIENTATION = 3;
  13157. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13158. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13159. return Container3D;
  13160. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13161. /***/ }),
  13162. /***/ "./3D/controls/control3D.ts":
  13163. /*!**********************************!*\
  13164. !*** ./3D/controls/control3D.ts ***!
  13165. \**********************************/
  13166. /*! exports provided: Control3D */
  13167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13168. "use strict";
  13169. __webpack_require__.r(__webpack_exports__);
  13170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13171. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  13172. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13173. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13174. /**
  13175. * Class used as base class for controls
  13176. */
  13177. var Control3D = /** @class */ (function () {
  13178. /**
  13179. * Creates a new control
  13180. * @param name defines the control name
  13181. */
  13182. function Control3D(
  13183. /** Defines the control name */
  13184. name) {
  13185. this.name = name;
  13186. this._downCount = 0;
  13187. this._enterCount = -1;
  13188. this._downPointerIds = {};
  13189. this._isVisible = true;
  13190. /**
  13191. * An event triggered when the pointer move over the control
  13192. */
  13193. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13194. /**
  13195. * An event triggered when the pointer move out of the control
  13196. */
  13197. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13198. /**
  13199. * An event triggered when the pointer taps the control
  13200. */
  13201. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13202. /**
  13203. * An event triggered when pointer is up
  13204. */
  13205. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13206. /**
  13207. * An event triggered when a control is clicked on (with a mouse)
  13208. */
  13209. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13210. /**
  13211. * An event triggered when pointer enters the control
  13212. */
  13213. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13214. // Behaviors
  13215. this._behaviors = new Array();
  13216. }
  13217. Object.defineProperty(Control3D.prototype, "position", {
  13218. /** Gets or sets the control position in world space */
  13219. get: function () {
  13220. if (!this._node) {
  13221. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13222. }
  13223. return this._node.position;
  13224. },
  13225. set: function (value) {
  13226. if (!this._node) {
  13227. return;
  13228. }
  13229. this._node.position = value;
  13230. },
  13231. enumerable: true,
  13232. configurable: true
  13233. });
  13234. Object.defineProperty(Control3D.prototype, "scaling", {
  13235. /** Gets or sets the control scaling in world space */
  13236. get: function () {
  13237. if (!this._node) {
  13238. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13239. }
  13240. return this._node.scaling;
  13241. },
  13242. set: function (value) {
  13243. if (!this._node) {
  13244. return;
  13245. }
  13246. this._node.scaling = value;
  13247. },
  13248. enumerable: true,
  13249. configurable: true
  13250. });
  13251. Object.defineProperty(Control3D.prototype, "behaviors", {
  13252. /**
  13253. * Gets the list of attached behaviors
  13254. * @see http://doc.babylonjs.com/features/behaviour
  13255. */
  13256. get: function () {
  13257. return this._behaviors;
  13258. },
  13259. enumerable: true,
  13260. configurable: true
  13261. });
  13262. /**
  13263. * Attach a behavior to the control
  13264. * @see http://doc.babylonjs.com/features/behaviour
  13265. * @param behavior defines the behavior to attach
  13266. * @returns the current control
  13267. */
  13268. Control3D.prototype.addBehavior = function (behavior) {
  13269. var _this = this;
  13270. var index = this._behaviors.indexOf(behavior);
  13271. if (index !== -1) {
  13272. return this;
  13273. }
  13274. behavior.init();
  13275. var scene = this._host.scene;
  13276. if (scene.isLoading) {
  13277. // We defer the attach when the scene will be loaded
  13278. scene.onDataLoadedObservable.addOnce(function () {
  13279. behavior.attach(_this);
  13280. });
  13281. }
  13282. else {
  13283. behavior.attach(this);
  13284. }
  13285. this._behaviors.push(behavior);
  13286. return this;
  13287. };
  13288. /**
  13289. * Remove an attached behavior
  13290. * @see http://doc.babylonjs.com/features/behaviour
  13291. * @param behavior defines the behavior to attach
  13292. * @returns the current control
  13293. */
  13294. Control3D.prototype.removeBehavior = function (behavior) {
  13295. var index = this._behaviors.indexOf(behavior);
  13296. if (index === -1) {
  13297. return this;
  13298. }
  13299. this._behaviors[index].detach();
  13300. this._behaviors.splice(index, 1);
  13301. return this;
  13302. };
  13303. /**
  13304. * Gets an attached behavior by name
  13305. * @param name defines the name of the behavior to look for
  13306. * @see http://doc.babylonjs.com/features/behaviour
  13307. * @returns null if behavior was not found else the requested behavior
  13308. */
  13309. Control3D.prototype.getBehaviorByName = function (name) {
  13310. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13311. var behavior = _a[_i];
  13312. if (behavior.name === name) {
  13313. return behavior;
  13314. }
  13315. }
  13316. return null;
  13317. };
  13318. Object.defineProperty(Control3D.prototype, "isVisible", {
  13319. /** Gets or sets a boolean indicating if the control is visible */
  13320. get: function () {
  13321. return this._isVisible;
  13322. },
  13323. set: function (value) {
  13324. if (this._isVisible === value) {
  13325. return;
  13326. }
  13327. this._isVisible = value;
  13328. var mesh = this.mesh;
  13329. if (mesh) {
  13330. mesh.setEnabled(value);
  13331. }
  13332. },
  13333. enumerable: true,
  13334. configurable: true
  13335. });
  13336. Object.defineProperty(Control3D.prototype, "typeName", {
  13337. /**
  13338. * Gets a string representing the class name
  13339. */
  13340. get: function () {
  13341. return this._getTypeName();
  13342. },
  13343. enumerable: true,
  13344. configurable: true
  13345. });
  13346. /**
  13347. * Get the current class name of the control.
  13348. * @returns current class name
  13349. */
  13350. Control3D.prototype.getClassName = function () {
  13351. return this._getTypeName();
  13352. };
  13353. Control3D.prototype._getTypeName = function () {
  13354. return "Control3D";
  13355. };
  13356. Object.defineProperty(Control3D.prototype, "node", {
  13357. /**
  13358. * Gets the transform node used by this control
  13359. */
  13360. get: function () {
  13361. return this._node;
  13362. },
  13363. enumerable: true,
  13364. configurable: true
  13365. });
  13366. Object.defineProperty(Control3D.prototype, "mesh", {
  13367. /**
  13368. * Gets the mesh used to render this control
  13369. */
  13370. get: function () {
  13371. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13372. return this._node;
  13373. }
  13374. return null;
  13375. },
  13376. enumerable: true,
  13377. configurable: true
  13378. });
  13379. /**
  13380. * Link the control as child of the given node
  13381. * @param node defines the node to link to. Use null to unlink the control
  13382. * @returns the current control
  13383. */
  13384. Control3D.prototype.linkToTransformNode = function (node) {
  13385. if (this._node) {
  13386. this._node.parent = node;
  13387. }
  13388. return this;
  13389. };
  13390. /** @hidden **/
  13391. Control3D.prototype._prepareNode = function (scene) {
  13392. if (!this._node) {
  13393. this._node = this._createNode(scene);
  13394. if (!this.node) {
  13395. return;
  13396. }
  13397. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13398. this._node.position = this.position;
  13399. this._node.scaling = this.scaling;
  13400. var mesh = this.mesh;
  13401. if (mesh) {
  13402. mesh.isPickable = true;
  13403. this._affectMaterial(mesh);
  13404. }
  13405. }
  13406. };
  13407. /**
  13408. * Node creation.
  13409. * Can be overriden by children
  13410. * @param scene defines the scene where the node must be attached
  13411. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13412. */
  13413. Control3D.prototype._createNode = function (scene) {
  13414. // Do nothing by default
  13415. return null;
  13416. };
  13417. /**
  13418. * Affect a material to the given mesh
  13419. * @param mesh defines the mesh which will represent the control
  13420. */
  13421. Control3D.prototype._affectMaterial = function (mesh) {
  13422. mesh.material = null;
  13423. };
  13424. // Pointers
  13425. /** @hidden */
  13426. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13427. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13428. };
  13429. /** @hidden */
  13430. Control3D.prototype._onPointerEnter = function (target) {
  13431. if (this._enterCount > 0) {
  13432. return false;
  13433. }
  13434. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13435. this._enterCount = 0;
  13436. }
  13437. this._enterCount++;
  13438. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13439. if (this.pointerEnterAnimation) {
  13440. this.pointerEnterAnimation();
  13441. }
  13442. return true;
  13443. };
  13444. /** @hidden */
  13445. Control3D.prototype._onPointerOut = function (target) {
  13446. this._enterCount = 0;
  13447. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13448. if (this.pointerOutAnimation) {
  13449. this.pointerOutAnimation();
  13450. }
  13451. };
  13452. /** @hidden */
  13453. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13454. if (this._downCount !== 0) {
  13455. this._downCount++;
  13456. return false;
  13457. }
  13458. this._downCount++;
  13459. this._downPointerIds[pointerId] = true;
  13460. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13461. if (this.pointerDownAnimation) {
  13462. this.pointerDownAnimation();
  13463. }
  13464. return true;
  13465. };
  13466. /** @hidden */
  13467. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13468. this._downCount--;
  13469. delete this._downPointerIds[pointerId];
  13470. if (this._downCount < 0) {
  13471. // Handle if forcePointerUp was called prior to this
  13472. this._downCount = 0;
  13473. return;
  13474. }
  13475. if (this._downCount == 0) {
  13476. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13477. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13478. }
  13479. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13480. if (this.pointerUpAnimation) {
  13481. this.pointerUpAnimation();
  13482. }
  13483. }
  13484. };
  13485. /** @hidden */
  13486. Control3D.prototype.forcePointerUp = function (pointerId) {
  13487. if (pointerId === void 0) { pointerId = null; }
  13488. if (pointerId !== null) {
  13489. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13490. }
  13491. else {
  13492. for (var key in this._downPointerIds) {
  13493. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13494. }
  13495. if (this._downCount > 0) {
  13496. this._downCount = 1;
  13497. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13498. }
  13499. }
  13500. };
  13501. /** @hidden */
  13502. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13503. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13504. this._onPointerMove(this, pickedPoint);
  13505. var previousControlOver = this._host._lastControlOver[pointerId];
  13506. if (previousControlOver && previousControlOver !== this) {
  13507. previousControlOver._onPointerOut(this);
  13508. }
  13509. if (previousControlOver !== this) {
  13510. this._onPointerEnter(this);
  13511. }
  13512. this._host._lastControlOver[pointerId] = this;
  13513. return true;
  13514. }
  13515. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13516. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13517. this._host._lastControlDown[pointerId] = this;
  13518. this._host._lastPickedControl = this;
  13519. return true;
  13520. }
  13521. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13522. if (this._host._lastControlDown[pointerId]) {
  13523. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13524. }
  13525. delete this._host._lastControlDown[pointerId];
  13526. return true;
  13527. }
  13528. return false;
  13529. };
  13530. /** @hidden */
  13531. Control3D.prototype._disposeNode = function () {
  13532. if (this._node) {
  13533. this._node.dispose();
  13534. this._node = null;
  13535. }
  13536. };
  13537. /**
  13538. * Releases all associated resources
  13539. */
  13540. Control3D.prototype.dispose = function () {
  13541. this.onPointerDownObservable.clear();
  13542. this.onPointerEnterObservable.clear();
  13543. this.onPointerMoveObservable.clear();
  13544. this.onPointerOutObservable.clear();
  13545. this.onPointerUpObservable.clear();
  13546. this.onPointerClickObservable.clear();
  13547. this._disposeNode();
  13548. // Behaviors
  13549. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13550. var behavior = _a[_i];
  13551. behavior.detach();
  13552. }
  13553. };
  13554. return Control3D;
  13555. }());
  13556. /***/ }),
  13557. /***/ "./3D/controls/cylinderPanel.ts":
  13558. /*!**************************************!*\
  13559. !*** ./3D/controls/cylinderPanel.ts ***!
  13560. \**************************************/
  13561. /*! exports provided: CylinderPanel */
  13562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13563. "use strict";
  13564. __webpack_require__.r(__webpack_exports__);
  13565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13566. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13567. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13568. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13569. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13570. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13571. /**
  13572. * Class used to create a container panel deployed on the surface of a cylinder
  13573. */
  13574. var CylinderPanel = /** @class */ (function (_super) {
  13575. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  13576. function CylinderPanel() {
  13577. var _this = _super !== null && _super.apply(this, arguments) || this;
  13578. _this._radius = 5.0;
  13579. return _this;
  13580. }
  13581. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13582. /**
  13583. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13584. */
  13585. get: function () {
  13586. return this._radius;
  13587. },
  13588. set: function (value) {
  13589. var _this = this;
  13590. if (this._radius === value) {
  13591. return;
  13592. }
  13593. this._radius = value;
  13594. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13595. _this._arrangeChildren();
  13596. });
  13597. },
  13598. enumerable: true,
  13599. configurable: true
  13600. });
  13601. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13602. var mesh = control.mesh;
  13603. if (!mesh) {
  13604. return;
  13605. }
  13606. var newPos = this._cylindricalMapping(nodePosition);
  13607. control.position = newPos;
  13608. switch (this.orientation) {
  13609. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13610. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13611. break;
  13612. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13613. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13614. break;
  13615. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13616. break;
  13617. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13618. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13619. break;
  13620. }
  13621. };
  13622. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13623. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13624. var yAngle = (source.x / this._radius);
  13625. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13626. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13627. };
  13628. return CylinderPanel;
  13629. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13630. /***/ }),
  13631. /***/ "./3D/controls/holographicButton.ts":
  13632. /*!******************************************!*\
  13633. !*** ./3D/controls/holographicButton.ts ***!
  13634. \******************************************/
  13635. /*! exports provided: HolographicButton */
  13636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13637. "use strict";
  13638. __webpack_require__.r(__webpack_exports__);
  13639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13640. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13641. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13642. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13643. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13644. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13645. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13646. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13647. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13648. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13649. /**
  13650. * Class used to create a holographic button in 3D
  13651. */
  13652. var HolographicButton = /** @class */ (function (_super) {
  13653. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  13654. /**
  13655. * Creates a new button
  13656. * @param name defines the control name
  13657. */
  13658. function HolographicButton(name, shareMaterials) {
  13659. if (shareMaterials === void 0) { shareMaterials = true; }
  13660. var _this = _super.call(this, name) || this;
  13661. _this._shareMaterials = true;
  13662. _this._shareMaterials = shareMaterials;
  13663. // Default animations
  13664. _this.pointerEnterAnimation = function () {
  13665. if (!_this.mesh) {
  13666. return;
  13667. }
  13668. _this._frontPlate.setEnabled(true);
  13669. };
  13670. _this.pointerOutAnimation = function () {
  13671. if (!_this.mesh) {
  13672. return;
  13673. }
  13674. _this._frontPlate.setEnabled(false);
  13675. };
  13676. return _this;
  13677. }
  13678. HolographicButton.prototype._disposeTooltip = function () {
  13679. this._tooltipFade = null;
  13680. if (this._tooltipTextBlock) {
  13681. this._tooltipTextBlock.dispose();
  13682. }
  13683. if (this._tooltipTexture) {
  13684. this._tooltipTexture.dispose();
  13685. }
  13686. if (this._tooltipMesh) {
  13687. this._tooltipMesh.dispose();
  13688. }
  13689. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13690. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13691. };
  13692. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13693. get: function () {
  13694. if (this._tooltipTextBlock) {
  13695. return this._tooltipTextBlock.text;
  13696. }
  13697. return null;
  13698. },
  13699. /**
  13700. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13701. */
  13702. set: function (text) {
  13703. var _this = this;
  13704. if (!text) {
  13705. this._disposeTooltip();
  13706. return;
  13707. }
  13708. if (!this._tooltipFade) {
  13709. // Create tooltip with mesh and text
  13710. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13711. 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);
  13712. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13713. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13714. tooltipBackground.material = mat;
  13715. tooltipBackground.isPickable = false;
  13716. this._tooltipMesh.addChild(tooltipBackground);
  13717. tooltipBackground.position.z = 0.05;
  13718. this._tooltipMesh.scaling.y = 1 / 3;
  13719. this._tooltipMesh.position.y = 0.7;
  13720. this._tooltipMesh.position.z = -0.15;
  13721. this._tooltipMesh.isPickable = false;
  13722. this._tooltipMesh.parent = this._backPlate;
  13723. // Create text texture for the tooltip
  13724. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13725. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13726. this._tooltipTextBlock.scaleY = 3;
  13727. this._tooltipTextBlock.color = "white";
  13728. this._tooltipTextBlock.fontSize = 130;
  13729. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13730. // Add hover action to tooltip
  13731. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13732. this._tooltipFade.delay = 500;
  13733. this._tooltipMesh.addBehavior(this._tooltipFade);
  13734. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13735. if (_this._tooltipFade) {
  13736. _this._tooltipFade.fadeIn(true);
  13737. }
  13738. });
  13739. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13740. if (_this._tooltipFade) {
  13741. _this._tooltipFade.fadeIn(false);
  13742. }
  13743. });
  13744. }
  13745. if (this._tooltipTextBlock) {
  13746. this._tooltipTextBlock.text = text;
  13747. }
  13748. },
  13749. enumerable: true,
  13750. configurable: true
  13751. });
  13752. Object.defineProperty(HolographicButton.prototype, "text", {
  13753. /**
  13754. * Gets or sets text for the button
  13755. */
  13756. get: function () {
  13757. return this._text;
  13758. },
  13759. set: function (value) {
  13760. if (this._text === value) {
  13761. return;
  13762. }
  13763. this._text = value;
  13764. this._rebuildContent();
  13765. },
  13766. enumerable: true,
  13767. configurable: true
  13768. });
  13769. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13770. /**
  13771. * Gets or sets the image url for the button
  13772. */
  13773. get: function () {
  13774. return this._imageUrl;
  13775. },
  13776. set: function (value) {
  13777. if (this._imageUrl === value) {
  13778. return;
  13779. }
  13780. this._imageUrl = value;
  13781. this._rebuildContent();
  13782. },
  13783. enumerable: true,
  13784. configurable: true
  13785. });
  13786. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13787. /**
  13788. * Gets the back material used by this button
  13789. */
  13790. get: function () {
  13791. return this._backMaterial;
  13792. },
  13793. enumerable: true,
  13794. configurable: true
  13795. });
  13796. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13797. /**
  13798. * Gets the front material used by this button
  13799. */
  13800. get: function () {
  13801. return this._frontMaterial;
  13802. },
  13803. enumerable: true,
  13804. configurable: true
  13805. });
  13806. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13807. /**
  13808. * Gets the plate material used by this button
  13809. */
  13810. get: function () {
  13811. return this._plateMaterial;
  13812. },
  13813. enumerable: true,
  13814. configurable: true
  13815. });
  13816. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13817. /**
  13818. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13819. */
  13820. get: function () {
  13821. return this._shareMaterials;
  13822. },
  13823. enumerable: true,
  13824. configurable: true
  13825. });
  13826. HolographicButton.prototype._getTypeName = function () {
  13827. return "HolographicButton";
  13828. };
  13829. HolographicButton.prototype._rebuildContent = function () {
  13830. this._disposeFacadeTexture();
  13831. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13832. panel.isVertical = true;
  13833. if (this._imageUrl) {
  13834. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13835. image.source = this._imageUrl;
  13836. image.paddingTop = "40px";
  13837. image.height = "180px";
  13838. image.width = "100px";
  13839. image.paddingBottom = "40px";
  13840. panel.addControl(image);
  13841. }
  13842. if (this._text) {
  13843. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13844. text.text = this._text;
  13845. text.color = "white";
  13846. text.height = "30px";
  13847. text.fontSize = 24;
  13848. panel.addControl(text);
  13849. }
  13850. if (this._frontPlate) {
  13851. this.content = panel;
  13852. }
  13853. };
  13854. // Mesh association
  13855. HolographicButton.prototype._createNode = function (scene) {
  13856. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13857. width: 1.0,
  13858. height: 1.0,
  13859. depth: 0.08
  13860. }, scene);
  13861. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13862. width: 1.0,
  13863. height: 1.0,
  13864. depth: 0.08
  13865. }, scene);
  13866. this._frontPlate.parent = this._backPlate;
  13867. this._frontPlate.position.z = -0.08;
  13868. this._frontPlate.isPickable = false;
  13869. this._frontPlate.setEnabled(false);
  13870. this._textPlate = _super.prototype._createNode.call(this, scene);
  13871. this._textPlate.parent = this._backPlate;
  13872. this._textPlate.position.z = -0.08;
  13873. this._textPlate.isPickable = false;
  13874. return this._backPlate;
  13875. };
  13876. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13877. this._plateMaterial.emissiveTexture = facadeTexture;
  13878. this._plateMaterial.opacityTexture = facadeTexture;
  13879. };
  13880. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13881. var _this = this;
  13882. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13883. this._backMaterial.renderHoverLight = true;
  13884. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13885. if (pickedPoint) {
  13886. _this._backMaterial.hoverPosition = pickedPoint;
  13887. _this._backMaterial.hoverColor.a = 1.0;
  13888. }
  13889. else {
  13890. _this._backMaterial.hoverColor.a = 0;
  13891. }
  13892. });
  13893. };
  13894. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13895. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13896. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13897. this._frontMaterial.alpha = 0.5; // Additive
  13898. this._frontMaterial.renderBorders = true;
  13899. };
  13900. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13901. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13902. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13903. };
  13904. HolographicButton.prototype._affectMaterial = function (mesh) {
  13905. // Back
  13906. if (this._shareMaterials) {
  13907. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13908. this._createBackMaterial(mesh);
  13909. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13910. }
  13911. else {
  13912. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13913. }
  13914. // Front
  13915. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13916. this._createFrontMaterial(mesh);
  13917. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13918. }
  13919. else {
  13920. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13921. }
  13922. }
  13923. else {
  13924. this._createBackMaterial(mesh);
  13925. this._createFrontMaterial(mesh);
  13926. }
  13927. this._createPlateMaterial(mesh);
  13928. this._backPlate.material = this._backMaterial;
  13929. this._frontPlate.material = this._frontMaterial;
  13930. this._textPlate.material = this._plateMaterial;
  13931. this._rebuildContent();
  13932. };
  13933. /**
  13934. * Releases all associated resources
  13935. */
  13936. HolographicButton.prototype.dispose = function () {
  13937. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13938. this._disposeTooltip();
  13939. if (!this.shareMaterials) {
  13940. this._backMaterial.dispose();
  13941. this._frontMaterial.dispose();
  13942. this._plateMaterial.dispose();
  13943. if (this._pickedPointObserver) {
  13944. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13945. this._pickedPointObserver = null;
  13946. }
  13947. }
  13948. };
  13949. return HolographicButton;
  13950. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13951. /***/ }),
  13952. /***/ "./3D/controls/index.ts":
  13953. /*!******************************!*\
  13954. !*** ./3D/controls/index.ts ***!
  13955. \******************************/
  13956. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13958. "use strict";
  13959. __webpack_require__.r(__webpack_exports__);
  13960. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13962. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13964. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13966. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13968. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13970. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13972. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13974. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13976. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13978. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13980. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13982. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13984. /***/ }),
  13985. /***/ "./3D/controls/meshButton3D.ts":
  13986. /*!*************************************!*\
  13987. !*** ./3D/controls/meshButton3D.ts ***!
  13988. \*************************************/
  13989. /*! exports provided: MeshButton3D */
  13990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13991. "use strict";
  13992. __webpack_require__.r(__webpack_exports__);
  13993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13994. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13995. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13996. /**
  13997. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13998. */
  13999. var MeshButton3D = /** @class */ (function (_super) {
  14000. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14001. /**
  14002. * Creates a new 3D button based on a mesh
  14003. * @param mesh mesh to become a 3D button
  14004. * @param name defines the control name
  14005. */
  14006. function MeshButton3D(mesh, name) {
  14007. var _this = _super.call(this, name) || this;
  14008. _this._currentMesh = mesh;
  14009. /**
  14010. * Provides a default behavior on hover/out & up/down
  14011. * Override those function to create your own desired behavior specific to your mesh
  14012. */
  14013. _this.pointerEnterAnimation = function () {
  14014. if (!_this.mesh) {
  14015. return;
  14016. }
  14017. _this.mesh.scaling.scaleInPlace(1.1);
  14018. };
  14019. _this.pointerOutAnimation = function () {
  14020. if (!_this.mesh) {
  14021. return;
  14022. }
  14023. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14024. };
  14025. _this.pointerDownAnimation = function () {
  14026. if (!_this.mesh) {
  14027. return;
  14028. }
  14029. _this.mesh.scaling.scaleInPlace(0.95);
  14030. };
  14031. _this.pointerUpAnimation = function () {
  14032. if (!_this.mesh) {
  14033. return;
  14034. }
  14035. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14036. };
  14037. return _this;
  14038. }
  14039. MeshButton3D.prototype._getTypeName = function () {
  14040. return "MeshButton3D";
  14041. };
  14042. // Mesh association
  14043. MeshButton3D.prototype._createNode = function (scene) {
  14044. var _this = this;
  14045. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14046. mesh.metadata = _this;
  14047. });
  14048. return this._currentMesh;
  14049. };
  14050. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14051. };
  14052. return MeshButton3D;
  14053. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14054. /***/ }),
  14055. /***/ "./3D/controls/planePanel.ts":
  14056. /*!***********************************!*\
  14057. !*** ./3D/controls/planePanel.ts ***!
  14058. \***********************************/
  14059. /*! exports provided: PlanePanel */
  14060. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14061. "use strict";
  14062. __webpack_require__.r(__webpack_exports__);
  14063. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14064. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14065. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14066. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14067. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14068. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14069. /**
  14070. * Class used to create a container panel deployed on the surface of a plane
  14071. */
  14072. var PlanePanel = /** @class */ (function (_super) {
  14073. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14074. function PlanePanel() {
  14075. return _super !== null && _super.apply(this, arguments) || this;
  14076. }
  14077. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14078. var mesh = control.mesh;
  14079. if (!mesh) {
  14080. return;
  14081. }
  14082. control.position = nodePosition.clone();
  14083. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14084. target.copyFrom(nodePosition);
  14085. switch (this.orientation) {
  14086. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14087. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14088. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14089. mesh.lookAt(target);
  14090. break;
  14091. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14092. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14093. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14094. mesh.lookAt(target);
  14095. break;
  14096. }
  14097. };
  14098. return PlanePanel;
  14099. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14100. /***/ }),
  14101. /***/ "./3D/controls/scatterPanel.ts":
  14102. /*!*************************************!*\
  14103. !*** ./3D/controls/scatterPanel.ts ***!
  14104. \*************************************/
  14105. /*! exports provided: ScatterPanel */
  14106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14107. "use strict";
  14108. __webpack_require__.r(__webpack_exports__);
  14109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14111. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14112. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14113. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14114. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14115. /**
  14116. * Class used to create a container panel where items get randomized planar mapping
  14117. */
  14118. var ScatterPanel = /** @class */ (function (_super) {
  14119. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14120. function ScatterPanel() {
  14121. var _this = _super !== null && _super.apply(this, arguments) || this;
  14122. _this._iteration = 100.0;
  14123. return _this;
  14124. }
  14125. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14126. /**
  14127. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14128. */
  14129. get: function () {
  14130. return this._iteration;
  14131. },
  14132. set: function (value) {
  14133. var _this = this;
  14134. if (this._iteration === value) {
  14135. return;
  14136. }
  14137. this._iteration = value;
  14138. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14139. _this._arrangeChildren();
  14140. });
  14141. },
  14142. enumerable: true,
  14143. configurable: true
  14144. });
  14145. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14146. var mesh = control.mesh;
  14147. var newPos = this._scatterMapping(nodePosition);
  14148. if (!mesh) {
  14149. return;
  14150. }
  14151. switch (this.orientation) {
  14152. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14153. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14154. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14155. break;
  14156. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14157. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14158. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14159. break;
  14160. }
  14161. control.position = newPos;
  14162. };
  14163. ScatterPanel.prototype._scatterMapping = function (source) {
  14164. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14165. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14166. return source;
  14167. };
  14168. ScatterPanel.prototype._finalProcessing = function () {
  14169. var meshes = [];
  14170. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14171. var child = _a[_i];
  14172. if (!child.mesh) {
  14173. continue;
  14174. }
  14175. meshes.push(child.mesh);
  14176. }
  14177. for (var count = 0; count < this._iteration; count++) {
  14178. meshes.sort(function (a, b) {
  14179. var distance1 = a.position.lengthSquared();
  14180. var distance2 = b.position.lengthSquared();
  14181. if (distance1 < distance2) {
  14182. return 1;
  14183. }
  14184. else if (distance1 > distance2) {
  14185. return -1;
  14186. }
  14187. return 0;
  14188. });
  14189. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14190. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14191. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14192. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14193. for (var i = 0; i < meshes.length - 1; i++) {
  14194. for (var j = i + 1; j < meshes.length; j++) {
  14195. if (i != j) {
  14196. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14197. // Ignore Z axis
  14198. difference2D.x = difference.x;
  14199. difference2D.y = difference.y;
  14200. var combinedRadius = cellSize;
  14201. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14202. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14203. distance -= minSeparation;
  14204. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14205. difference2D.normalize();
  14206. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14207. meshes[j].position.addInPlace(difference);
  14208. meshes[i].position.subtractInPlace(difference);
  14209. }
  14210. }
  14211. }
  14212. }
  14213. }
  14214. };
  14215. return ScatterPanel;
  14216. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14217. /***/ }),
  14218. /***/ "./3D/controls/spherePanel.ts":
  14219. /*!************************************!*\
  14220. !*** ./3D/controls/spherePanel.ts ***!
  14221. \************************************/
  14222. /*! exports provided: SpherePanel */
  14223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14224. "use strict";
  14225. __webpack_require__.r(__webpack_exports__);
  14226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14228. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14229. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14230. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14231. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14232. /**
  14233. * Class used to create a container panel deployed on the surface of a sphere
  14234. */
  14235. var SpherePanel = /** @class */ (function (_super) {
  14236. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14237. function SpherePanel() {
  14238. var _this = _super !== null && _super.apply(this, arguments) || this;
  14239. _this._radius = 5.0;
  14240. return _this;
  14241. }
  14242. Object.defineProperty(SpherePanel.prototype, "radius", {
  14243. /**
  14244. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14245. */
  14246. get: function () {
  14247. return this._radius;
  14248. },
  14249. set: function (value) {
  14250. var _this = this;
  14251. if (this._radius === value) {
  14252. return;
  14253. }
  14254. this._radius = value;
  14255. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14256. _this._arrangeChildren();
  14257. });
  14258. },
  14259. enumerable: true,
  14260. configurable: true
  14261. });
  14262. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14263. var mesh = control.mesh;
  14264. if (!mesh) {
  14265. return;
  14266. }
  14267. var newPos = this._sphericalMapping(nodePosition);
  14268. control.position = newPos;
  14269. switch (this.orientation) {
  14270. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14271. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14272. break;
  14273. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14274. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14275. break;
  14276. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14277. break;
  14278. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14279. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14280. break;
  14281. }
  14282. };
  14283. SpherePanel.prototype._sphericalMapping = function (source) {
  14284. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14285. var xAngle = (source.y / this._radius);
  14286. var yAngle = -(source.x / this._radius);
  14287. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14288. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14289. };
  14290. return SpherePanel;
  14291. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14292. /***/ }),
  14293. /***/ "./3D/controls/stackPanel3D.ts":
  14294. /*!*************************************!*\
  14295. !*** ./3D/controls/stackPanel3D.ts ***!
  14296. \*************************************/
  14297. /*! exports provided: StackPanel3D */
  14298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14299. "use strict";
  14300. __webpack_require__.r(__webpack_exports__);
  14301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14302. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14303. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14304. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14305. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14306. /**
  14307. * Class used to create a stack panel in 3D on XY plane
  14308. */
  14309. var StackPanel3D = /** @class */ (function (_super) {
  14310. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14311. /**
  14312. * Creates new StackPanel
  14313. * @param isVertical
  14314. */
  14315. function StackPanel3D(isVertical) {
  14316. if (isVertical === void 0) { isVertical = false; }
  14317. var _this = _super.call(this) || this;
  14318. _this._isVertical = false;
  14319. /**
  14320. * Gets or sets the distance between elements
  14321. */
  14322. _this.margin = 0.1;
  14323. _this._isVertical = isVertical;
  14324. return _this;
  14325. }
  14326. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14327. /**
  14328. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14329. */
  14330. get: function () {
  14331. return this._isVertical;
  14332. },
  14333. set: function (value) {
  14334. var _this = this;
  14335. if (this._isVertical === value) {
  14336. return;
  14337. }
  14338. this._isVertical = value;
  14339. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14340. _this._arrangeChildren();
  14341. });
  14342. },
  14343. enumerable: true,
  14344. configurable: true
  14345. });
  14346. StackPanel3D.prototype._arrangeChildren = function () {
  14347. var width = 0;
  14348. var height = 0;
  14349. var controlCount = 0;
  14350. var extendSizes = [];
  14351. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14352. // Measure
  14353. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14354. var child = _a[_i];
  14355. if (!child.mesh) {
  14356. continue;
  14357. }
  14358. controlCount++;
  14359. child.mesh.computeWorldMatrix(true);
  14360. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14361. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14362. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14363. extendSizes.push(extendSize);
  14364. if (this._isVertical) {
  14365. height += extendSize.y;
  14366. }
  14367. else {
  14368. width += extendSize.x;
  14369. }
  14370. }
  14371. if (this._isVertical) {
  14372. height += (controlCount - 1) * this.margin / 2;
  14373. }
  14374. else {
  14375. width += (controlCount - 1) * this.margin / 2;
  14376. }
  14377. // Arrange
  14378. var offset;
  14379. if (this._isVertical) {
  14380. offset = -height;
  14381. }
  14382. else {
  14383. offset = -width;
  14384. }
  14385. var index = 0;
  14386. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14387. var child = _c[_b];
  14388. if (!child.mesh) {
  14389. continue;
  14390. }
  14391. controlCount--;
  14392. var extendSize = extendSizes[index++];
  14393. if (this._isVertical) {
  14394. child.position.y = offset + extendSize.y;
  14395. child.position.x = 0;
  14396. offset += extendSize.y * 2;
  14397. }
  14398. else {
  14399. child.position.x = offset + extendSize.x;
  14400. child.position.y = 0;
  14401. offset += extendSize.x * 2;
  14402. }
  14403. offset += (controlCount > 0 ? this.margin : 0);
  14404. }
  14405. };
  14406. return StackPanel3D;
  14407. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14408. /***/ }),
  14409. /***/ "./3D/controls/volumeBasedPanel.ts":
  14410. /*!*****************************************!*\
  14411. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14412. \*****************************************/
  14413. /*! exports provided: VolumeBasedPanel */
  14414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14415. "use strict";
  14416. __webpack_require__.r(__webpack_exports__);
  14417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14419. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14420. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14421. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14422. /**
  14423. * Abstract class used to create a container panel deployed on the surface of a volume
  14424. */
  14425. var VolumeBasedPanel = /** @class */ (function (_super) {
  14426. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14427. /**
  14428. * Creates new VolumeBasedPanel
  14429. */
  14430. function VolumeBasedPanel() {
  14431. var _this = _super.call(this) || this;
  14432. _this._columns = 10;
  14433. _this._rows = 0;
  14434. _this._rowThenColum = true;
  14435. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14436. /**
  14437. * Gets or sets the distance between elements
  14438. */
  14439. _this.margin = 0;
  14440. return _this;
  14441. }
  14442. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14443. /**
  14444. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14445. * | Value | Type | Description |
  14446. * | ----- | ----------------------------------- | ----------- |
  14447. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14448. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14449. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14450. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14451. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14452. */
  14453. get: function () {
  14454. return this._orientation;
  14455. },
  14456. set: function (value) {
  14457. var _this = this;
  14458. if (this._orientation === value) {
  14459. return;
  14460. }
  14461. this._orientation = value;
  14462. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14463. _this._arrangeChildren();
  14464. });
  14465. },
  14466. enumerable: true,
  14467. configurable: true
  14468. });
  14469. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14470. /**
  14471. * Gets or sets the number of columns requested (10 by default).
  14472. * The panel will automatically compute the number of rows based on number of child controls.
  14473. */
  14474. get: function () {
  14475. return this._columns;
  14476. },
  14477. set: function (value) {
  14478. var _this = this;
  14479. if (this._columns === value) {
  14480. return;
  14481. }
  14482. this._columns = value;
  14483. this._rowThenColum = true;
  14484. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14485. _this._arrangeChildren();
  14486. });
  14487. },
  14488. enumerable: true,
  14489. configurable: true
  14490. });
  14491. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14492. /**
  14493. * Gets or sets a the number of rows requested.
  14494. * The panel will automatically compute the number of columns based on number of child controls.
  14495. */
  14496. get: function () {
  14497. return this._rows;
  14498. },
  14499. set: function (value) {
  14500. var _this = this;
  14501. if (this._rows === value) {
  14502. return;
  14503. }
  14504. this._rows = value;
  14505. this._rowThenColum = false;
  14506. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14507. _this._arrangeChildren();
  14508. });
  14509. },
  14510. enumerable: true,
  14511. configurable: true
  14512. });
  14513. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14514. this._cellWidth = 0;
  14515. this._cellHeight = 0;
  14516. var rows = 0;
  14517. var columns = 0;
  14518. var controlCount = 0;
  14519. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14520. // Measure
  14521. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14522. var child = _a[_i];
  14523. if (!child.mesh) {
  14524. continue;
  14525. }
  14526. controlCount++;
  14527. child.mesh.computeWorldMatrix(true);
  14528. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14529. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14530. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14531. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14532. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14533. diff.scaleInPlace(0.5);
  14534. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14535. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14536. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14537. }
  14538. this._cellWidth += this.margin * 2;
  14539. this._cellHeight += this.margin * 2;
  14540. // Arrange
  14541. if (this._rowThenColum) {
  14542. columns = this._columns;
  14543. rows = Math.ceil(controlCount / this._columns);
  14544. }
  14545. else {
  14546. rows = this._rows;
  14547. columns = Math.ceil(controlCount / this._rows);
  14548. }
  14549. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14550. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14551. var nodeGrid = [];
  14552. var cellCounter = 0;
  14553. if (this._rowThenColum) {
  14554. for (var r = 0; r < rows; r++) {
  14555. for (var c = 0; c < columns; c++) {
  14556. 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));
  14557. cellCounter++;
  14558. if (cellCounter > controlCount) {
  14559. break;
  14560. }
  14561. }
  14562. }
  14563. }
  14564. else {
  14565. for (var c = 0; c < columns; c++) {
  14566. for (var r = 0; r < rows; r++) {
  14567. 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));
  14568. cellCounter++;
  14569. if (cellCounter > controlCount) {
  14570. break;
  14571. }
  14572. }
  14573. }
  14574. }
  14575. cellCounter = 0;
  14576. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14577. var child = _c[_b];
  14578. if (!child.mesh) {
  14579. continue;
  14580. }
  14581. this._mapGridNode(child, nodeGrid[cellCounter]);
  14582. cellCounter++;
  14583. }
  14584. this._finalProcessing();
  14585. };
  14586. /** Child classes can implement this function to provide additional processing */
  14587. VolumeBasedPanel.prototype._finalProcessing = function () {
  14588. };
  14589. return VolumeBasedPanel;
  14590. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14591. /***/ }),
  14592. /***/ "./3D/gui3DManager.ts":
  14593. /*!****************************!*\
  14594. !*** ./3D/gui3DManager.ts ***!
  14595. \****************************/
  14596. /*! exports provided: GUI3DManager */
  14597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14598. "use strict";
  14599. __webpack_require__.r(__webpack_exports__);
  14600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14601. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  14602. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14603. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14604. /**
  14605. * Class used to manage 3D user interface
  14606. * @see http://doc.babylonjs.com/how_to/gui3d
  14607. */
  14608. var GUI3DManager = /** @class */ (function () {
  14609. /**
  14610. * Creates a new GUI3DManager
  14611. * @param scene
  14612. */
  14613. function GUI3DManager(scene) {
  14614. var _this = this;
  14615. /** @hidden */
  14616. this._lastControlOver = {};
  14617. /** @hidden */
  14618. this._lastControlDown = {};
  14619. /**
  14620. * Observable raised when the point picked by the pointer events changed
  14621. */
  14622. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14623. // Shared resources
  14624. /** @hidden */
  14625. this._sharedMaterials = {};
  14626. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14627. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14628. _this._sceneDisposeObserver = null;
  14629. _this._utilityLayer = null;
  14630. _this.dispose();
  14631. });
  14632. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14633. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14634. this._utilityLayer.pickUtilitySceneFirst = false;
  14635. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14636. return mesh && mesh.metadata && mesh.metadata._node;
  14637. };
  14638. // Root
  14639. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14640. this._rootContainer._host = this;
  14641. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14642. // Events
  14643. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14644. _this._handlePointerOut(pointerId, true);
  14645. });
  14646. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14647. _this._doPicking(pi);
  14648. });
  14649. // Scene
  14650. this._utilityLayer.utilityLayerScene.autoClear = false;
  14651. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14652. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14653. }
  14654. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14655. /** Gets the hosting scene */
  14656. get: function () {
  14657. return this._scene;
  14658. },
  14659. enumerable: true,
  14660. configurable: true
  14661. });
  14662. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14663. /** Gets associated utility layer */
  14664. get: function () {
  14665. return this._utilityLayer;
  14666. },
  14667. enumerable: true,
  14668. configurable: true
  14669. });
  14670. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14671. var previousControlOver = this._lastControlOver[pointerId];
  14672. if (previousControlOver) {
  14673. previousControlOver._onPointerOut(previousControlOver);
  14674. delete this._lastControlOver[pointerId];
  14675. }
  14676. if (isPointerUp) {
  14677. if (this._lastControlDown[pointerId]) {
  14678. this._lastControlDown[pointerId].forcePointerUp();
  14679. delete this._lastControlDown[pointerId];
  14680. }
  14681. }
  14682. this.onPickedPointChangedObservable.notifyObservers(null);
  14683. };
  14684. GUI3DManager.prototype._doPicking = function (pi) {
  14685. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14686. return false;
  14687. }
  14688. var pointerEvent = (pi.event);
  14689. var pointerId = pointerEvent.pointerId || 0;
  14690. var buttonIndex = pointerEvent.button;
  14691. var pickingInfo = pi.pickInfo;
  14692. if (!pickingInfo || !pickingInfo.hit) {
  14693. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14694. return false;
  14695. }
  14696. var control = (pickingInfo.pickedMesh.metadata);
  14697. if (pickingInfo.pickedPoint) {
  14698. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14699. }
  14700. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14701. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14702. if (this._lastControlOver[pointerId]) {
  14703. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14704. }
  14705. delete this._lastControlOver[pointerId];
  14706. }
  14707. }
  14708. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14709. if (this._lastControlDown[pointerEvent.pointerId]) {
  14710. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14711. delete this._lastControlDown[pointerEvent.pointerId];
  14712. }
  14713. if (pointerEvent.pointerType === "touch") {
  14714. this._handlePointerOut(pointerId, false);
  14715. }
  14716. }
  14717. return true;
  14718. };
  14719. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14720. /**
  14721. * Gets the root container
  14722. */
  14723. get: function () {
  14724. return this._rootContainer;
  14725. },
  14726. enumerable: true,
  14727. configurable: true
  14728. });
  14729. /**
  14730. * Gets a boolean indicating if the given control is in the root child list
  14731. * @param control defines the control to check
  14732. * @returns true if the control is in the root child list
  14733. */
  14734. GUI3DManager.prototype.containsControl = function (control) {
  14735. return this._rootContainer.containsControl(control);
  14736. };
  14737. /**
  14738. * Adds a control to the root child list
  14739. * @param control defines the control to add
  14740. * @returns the current manager
  14741. */
  14742. GUI3DManager.prototype.addControl = function (control) {
  14743. this._rootContainer.addControl(control);
  14744. return this;
  14745. };
  14746. /**
  14747. * Removes a control from the root child list
  14748. * @param control defines the control to remove
  14749. * @returns the current container
  14750. */
  14751. GUI3DManager.prototype.removeControl = function (control) {
  14752. this._rootContainer.removeControl(control);
  14753. return this;
  14754. };
  14755. /**
  14756. * Releases all associated resources
  14757. */
  14758. GUI3DManager.prototype.dispose = function () {
  14759. this._rootContainer.dispose();
  14760. for (var materialName in this._sharedMaterials) {
  14761. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14762. continue;
  14763. }
  14764. this._sharedMaterials[materialName].dispose();
  14765. }
  14766. this._sharedMaterials = {};
  14767. if (this._pointerOutObserver && this._utilityLayer) {
  14768. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14769. this._pointerOutObserver = null;
  14770. }
  14771. this.onPickedPointChangedObservable.clear();
  14772. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14773. if (utilityLayerScene) {
  14774. if (this._pointerObserver) {
  14775. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14776. this._pointerObserver = null;
  14777. }
  14778. }
  14779. if (this._scene) {
  14780. if (this._sceneDisposeObserver) {
  14781. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14782. this._sceneDisposeObserver = null;
  14783. }
  14784. }
  14785. if (this._utilityLayer) {
  14786. this._utilityLayer.dispose();
  14787. }
  14788. };
  14789. return GUI3DManager;
  14790. }());
  14791. /***/ }),
  14792. /***/ "./3D/index.ts":
  14793. /*!*********************!*\
  14794. !*** ./3D/index.ts ***!
  14795. \*********************/
  14796. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14798. "use strict";
  14799. __webpack_require__.r(__webpack_exports__);
  14800. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14813. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14816. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14818. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14820. /***/ }),
  14821. /***/ "./3D/materials/fluentMaterial.ts":
  14822. /*!****************************************!*\
  14823. !*** ./3D/materials/fluentMaterial.ts ***!
  14824. \****************************************/
  14825. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14827. "use strict";
  14828. __webpack_require__.r(__webpack_exports__);
  14829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14832. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  14833. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14834. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14835. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14836. /** @hidden */
  14837. var FluentMaterialDefines = /** @class */ (function (_super) {
  14838. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  14839. function FluentMaterialDefines() {
  14840. var _this = _super.call(this) || this;
  14841. _this.INNERGLOW = false;
  14842. _this.BORDER = false;
  14843. _this.HOVERLIGHT = false;
  14844. _this.TEXTURE = false;
  14845. _this.rebuild();
  14846. return _this;
  14847. }
  14848. return FluentMaterialDefines;
  14849. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14850. /**
  14851. * Class used to render controls with fluent desgin
  14852. */
  14853. var FluentMaterial = /** @class */ (function (_super) {
  14854. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  14855. /**
  14856. * Creates a new Fluent material
  14857. * @param name defines the name of the material
  14858. * @param scene defines the hosting scene
  14859. */
  14860. function FluentMaterial(name, scene) {
  14861. var _this = _super.call(this, name, scene) || this;
  14862. /**
  14863. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14864. */
  14865. _this.innerGlowColorIntensity = 0.5;
  14866. /**
  14867. * Gets or sets the inner glow color (white by default)
  14868. */
  14869. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14870. /**
  14871. * Gets or sets alpha value (default is 1.0)
  14872. */
  14873. _this.alpha = 1.0;
  14874. /**
  14875. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14876. */
  14877. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14878. /**
  14879. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14880. */
  14881. _this.renderBorders = false;
  14882. /**
  14883. * Gets or sets border width (default is 0.5)
  14884. */
  14885. _this.borderWidth = 0.5;
  14886. /**
  14887. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14888. */
  14889. _this.edgeSmoothingValue = 0.02;
  14890. /**
  14891. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14892. */
  14893. _this.borderMinValue = 0.1;
  14894. /**
  14895. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14896. */
  14897. _this.renderHoverLight = false;
  14898. /**
  14899. * Gets or sets the radius used to render the hover light (default is 1.0)
  14900. */
  14901. _this.hoverRadius = 1.0;
  14902. /**
  14903. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14904. */
  14905. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14906. /**
  14907. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14908. */
  14909. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14910. return _this;
  14911. }
  14912. FluentMaterial.prototype.needAlphaBlending = function () {
  14913. return this.alpha !== 1.0;
  14914. };
  14915. FluentMaterial.prototype.needAlphaTesting = function () {
  14916. return false;
  14917. };
  14918. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14919. return null;
  14920. };
  14921. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14922. if (this.isFrozen) {
  14923. if (this._wasPreviouslyReady && subMesh.effect) {
  14924. return true;
  14925. }
  14926. }
  14927. if (!subMesh._materialDefines) {
  14928. subMesh._materialDefines = new FluentMaterialDefines();
  14929. }
  14930. var scene = this.getScene();
  14931. var defines = subMesh._materialDefines;
  14932. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14933. if (defines._renderId === scene.getRenderId()) {
  14934. return true;
  14935. }
  14936. }
  14937. if (defines._areTexturesDirty) {
  14938. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14939. defines.BORDER = this.renderBorders;
  14940. defines.HOVERLIGHT = this.renderHoverLight;
  14941. if (this._albedoTexture) {
  14942. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14943. return false;
  14944. }
  14945. else {
  14946. defines.TEXTURE = true;
  14947. }
  14948. }
  14949. else {
  14950. defines.TEXTURE = false;
  14951. }
  14952. }
  14953. var engine = scene.getEngine();
  14954. // Get correct effect
  14955. if (defines.isDirty) {
  14956. defines.markAsProcessed();
  14957. scene.resetCachedMaterial();
  14958. //Attributes
  14959. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14960. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14961. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14962. var shaderName = "fluent";
  14963. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14964. "hoverColor", "hoverPosition", "hoverRadius"
  14965. ];
  14966. var samplers = ["albedoSampler"];
  14967. var uniformBuffers = new Array();
  14968. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14969. uniformsNames: uniforms,
  14970. uniformBuffersNames: uniformBuffers,
  14971. samplers: samplers,
  14972. defines: defines,
  14973. maxSimultaneousLights: 4
  14974. });
  14975. var join = defines.toString();
  14976. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14977. attributes: attribs,
  14978. uniformsNames: uniforms,
  14979. uniformBuffersNames: uniformBuffers,
  14980. samplers: samplers,
  14981. defines: join,
  14982. fallbacks: null,
  14983. onCompiled: this.onCompiled,
  14984. onError: this.onError,
  14985. indexParameters: { maxSimultaneousLights: 4 }
  14986. }, engine));
  14987. }
  14988. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14989. return false;
  14990. }
  14991. defines._renderId = scene.getRenderId();
  14992. this._wasPreviouslyReady = true;
  14993. return true;
  14994. };
  14995. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14996. var scene = this.getScene();
  14997. var defines = subMesh._materialDefines;
  14998. if (!defines) {
  14999. return;
  15000. }
  15001. var effect = subMesh.effect;
  15002. if (!effect) {
  15003. return;
  15004. }
  15005. this._activeEffect = effect;
  15006. // Matrices
  15007. this.bindOnlyWorldMatrix(world);
  15008. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15009. if (this._mustRebind(scene, effect)) {
  15010. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15011. if (defines.INNERGLOW) {
  15012. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15013. }
  15014. if (defines.BORDER) {
  15015. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15016. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15017. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15018. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15019. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15020. }
  15021. if (defines.HOVERLIGHT) {
  15022. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15023. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15024. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15025. }
  15026. if (defines.TEXTURE) {
  15027. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15028. }
  15029. }
  15030. this._afterBind(mesh, this._activeEffect);
  15031. };
  15032. FluentMaterial.prototype.getActiveTextures = function () {
  15033. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15034. return activeTextures;
  15035. };
  15036. FluentMaterial.prototype.hasTexture = function (texture) {
  15037. if (_super.prototype.hasTexture.call(this, texture)) {
  15038. return true;
  15039. }
  15040. return false;
  15041. };
  15042. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15043. _super.prototype.dispose.call(this, forceDisposeEffect);
  15044. };
  15045. FluentMaterial.prototype.clone = function (name) {
  15046. var _this = this;
  15047. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15048. };
  15049. FluentMaterial.prototype.serialize = function () {
  15050. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15051. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15052. return serializationObject;
  15053. };
  15054. FluentMaterial.prototype.getClassName = function () {
  15055. return "FluentMaterial";
  15056. };
  15057. // Statics
  15058. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15059. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15060. };
  15061. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15062. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15063. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15064. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15065. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15066. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15067. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15068. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15069. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15070. ], FluentMaterial.prototype, "alpha", void 0);
  15071. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15072. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15073. ], FluentMaterial.prototype, "albedoColor", void 0);
  15074. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15075. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15076. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15077. ], FluentMaterial.prototype, "renderBorders", void 0);
  15078. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15079. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15080. ], FluentMaterial.prototype, "borderWidth", void 0);
  15081. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15082. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15083. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15084. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15085. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15086. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15087. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15088. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15089. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15090. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15091. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15092. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15093. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15094. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15095. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15096. ], FluentMaterial.prototype, "hoverColor", void 0);
  15097. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15098. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15099. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15100. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15101. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15102. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15103. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15104. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15105. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15106. return FluentMaterial;
  15107. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15108. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15109. /***/ }),
  15110. /***/ "./3D/materials/index.ts":
  15111. /*!*******************************!*\
  15112. !*** ./3D/materials/index.ts ***!
  15113. \*******************************/
  15114. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15116. "use strict";
  15117. __webpack_require__.r(__webpack_exports__);
  15118. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15121. /***/ }),
  15122. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15123. /*!*************************************************!*\
  15124. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15125. \*************************************************/
  15126. /*! exports provided: fluentPixelShader */
  15127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15128. "use strict";
  15129. __webpack_require__.r(__webpack_exports__);
  15130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15131. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15132. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15133. var name = 'fluentPixelShader';
  15134. 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}";
  15135. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15136. /** @hidden */
  15137. var fluentPixelShader = { name: name, shader: shader };
  15138. /***/ }),
  15139. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15140. /*!***********************************************!*\
  15141. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15142. \***********************************************/
  15143. /*! exports provided: fluentVertexShader */
  15144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15145. "use strict";
  15146. __webpack_require__.r(__webpack_exports__);
  15147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15148. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15149. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15150. var name = 'fluentVertexShader';
  15151. 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";
  15152. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15153. /** @hidden */
  15154. var fluentVertexShader = { name: name, shader: shader };
  15155. /***/ }),
  15156. /***/ "./3D/vector3WithInfo.ts":
  15157. /*!*******************************!*\
  15158. !*** ./3D/vector3WithInfo.ts ***!
  15159. \*******************************/
  15160. /*! exports provided: Vector3WithInfo */
  15161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15162. "use strict";
  15163. __webpack_require__.r(__webpack_exports__);
  15164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15165. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15166. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  15167. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15168. /**
  15169. * Class used to transport Vector3 information for pointer events
  15170. */
  15171. var Vector3WithInfo = /** @class */ (function (_super) {
  15172. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15173. /**
  15174. * Creates a new Vector3WithInfo
  15175. * @param source defines the vector3 data to transport
  15176. * @param buttonIndex defines the current mouse button index
  15177. */
  15178. function Vector3WithInfo(source,
  15179. /** defines the current mouse button index */
  15180. buttonIndex) {
  15181. if (buttonIndex === void 0) { buttonIndex = 0; }
  15182. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15183. _this.buttonIndex = buttonIndex;
  15184. return _this;
  15185. }
  15186. return Vector3WithInfo;
  15187. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15188. /***/ }),
  15189. /***/ "./index.ts":
  15190. /*!******************!*\
  15191. !*** ./index.ts ***!
  15192. \******************/
  15193. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15195. "use strict";
  15196. __webpack_require__.r(__webpack_exports__);
  15197. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15238. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15255. /***/ }),
  15256. /***/ "./legacy/legacy.ts":
  15257. /*!**************************!*\
  15258. !*** ./legacy/legacy.ts ***!
  15259. \**************************/
  15260. /*! 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, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15262. "use strict";
  15263. __webpack_require__.r(__webpack_exports__);
  15264. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15321. /**
  15322. * Legacy support, defining window.BABYLON.GUI (global variable).
  15323. *
  15324. * This is the entry point for the UMD module.
  15325. * The entry point for a future ESM package should be index.ts
  15326. */
  15327. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15328. if (typeof globalObject !== "undefined") {
  15329. globalObject.BABYLON = globalObject.BABYLON || {};
  15330. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15331. }
  15332. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15333. /***/ }),
  15334. /***/ "babylonjs/Maths/math":
  15335. /*!****************************************************************************************************!*\
  15336. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15337. \****************************************************************************************************/
  15338. /*! no static exports found */
  15339. /***/ (function(module, exports) {
  15340. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  15341. /***/ })
  15342. /******/ });
  15343. });
  15344. //# sourceMappingURL=babylon.gui.js.map