babylon.gui.js 680 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672
  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_Misc_perfCounter__) {
  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, __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__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. 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;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. 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;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. 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); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. 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; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. 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);
  272. 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); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../../node_modules/webpack/buildin/global.js":
  291. /*!***********************************!*\
  292. !*** (webpack)/buildin/global.js ***!
  293. \***********************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./2D/adtInstrumentation.ts":
  314. /*!**********************************!*\
  315. !*** ./2D/adtInstrumentation.ts ***!
  316. \**********************************/
  317. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  322. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  323. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  324. /**
  325. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  326. */
  327. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  328. /**
  329. * Instantiates a new advanced dynamic texture instrumentation.
  330. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  331. * @param texture Defines the AdvancedDynamicTexture to instrument
  332. */
  333. function AdvancedDynamicTextureInstrumentation(
  334. /**
  335. * Define the instrumented AdvancedDynamicTexture.
  336. */
  337. texture) {
  338. this.texture = texture;
  339. this._captureRenderTime = false;
  340. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  341. this._captureLayoutTime = false;
  342. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  343. // Observers
  344. this._onBeginRenderObserver = null;
  345. this._onEndRenderObserver = null;
  346. this._onBeginLayoutObserver = null;
  347. this._onEndLayoutObserver = null;
  348. }
  349. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  350. // Properties
  351. /**
  352. * Gets the perf counter used to capture render time
  353. */
  354. get: function () {
  355. return this._renderTime;
  356. },
  357. enumerable: true,
  358. configurable: true
  359. });
  360. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  361. /**
  362. * Gets the perf counter used to capture layout time
  363. */
  364. get: function () {
  365. return this._layoutTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  371. /**
  372. * Enable or disable the render time capture
  373. */
  374. get: function () {
  375. return this._captureRenderTime;
  376. },
  377. set: function (value) {
  378. var _this = this;
  379. if (value === this._captureRenderTime) {
  380. return;
  381. }
  382. this._captureRenderTime = value;
  383. if (value) {
  384. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  385. _this._renderTime.beginMonitoring();
  386. });
  387. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  388. _this._renderTime.endMonitoring(true);
  389. });
  390. }
  391. else {
  392. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  393. this._onBeginRenderObserver = null;
  394. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  395. this._onEndRenderObserver = null;
  396. }
  397. },
  398. enumerable: true,
  399. configurable: true
  400. });
  401. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  402. /**
  403. * Enable or disable the layout time capture
  404. */
  405. get: function () {
  406. return this._captureLayoutTime;
  407. },
  408. set: function (value) {
  409. var _this = this;
  410. if (value === this._captureLayoutTime) {
  411. return;
  412. }
  413. this._captureLayoutTime = value;
  414. if (value) {
  415. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  416. _this._layoutTime.beginMonitoring();
  417. });
  418. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  419. _this._layoutTime.endMonitoring(true);
  420. });
  421. }
  422. else {
  423. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  424. this._onBeginLayoutObserver = null;
  425. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  426. this._onEndLayoutObserver = null;
  427. }
  428. },
  429. enumerable: true,
  430. configurable: true
  431. });
  432. /**
  433. * Dispose and release associated resources.
  434. */
  435. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  436. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  437. this._onBeginRenderObserver = null;
  438. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  439. this._onEndRenderObserver = null;
  440. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  441. this._onBeginLayoutObserver = null;
  442. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  443. this._onEndLayoutObserver = null;
  444. this.texture = null;
  445. };
  446. return AdvancedDynamicTextureInstrumentation;
  447. }());
  448. /***/ }),
  449. /***/ "./2D/advancedDynamicTexture.ts":
  450. /*!**************************************!*\
  451. !*** ./2D/advancedDynamicTexture.ts ***!
  452. \**************************************/
  453. /*! exports provided: AdvancedDynamicTexture */
  454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  455. "use strict";
  456. __webpack_require__.r(__webpack_exports__);
  457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  459. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  460. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  461. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  462. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  463. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  464. /**
  465. * Class used to create texture to support 2D GUI elements
  466. * @see http://doc.babylonjs.com/how_to/gui
  467. */
  468. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  469. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AdvancedDynamicTexture, _super);
  470. /**
  471. * Creates a new AdvancedDynamicTexture
  472. * @param name defines the name of the texture
  473. * @param width defines the width of the texture
  474. * @param height defines the height of the texture
  475. * @param scene defines the hosting scene
  476. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  477. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  478. */
  479. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  480. if (width === void 0) { width = 0; }
  481. if (height === void 0) { height = 0; }
  482. if (generateMipMaps === void 0) { generateMipMaps = false; }
  483. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  484. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Engine"].TEXTUREFORMAT_RGBA) || this;
  485. _this._isDirty = false;
  486. /** @hidden */
  487. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  488. /** @hidden */
  489. _this._lastControlOver = {};
  490. /** @hidden */
  491. _this._lastControlDown = {};
  492. /** @hidden */
  493. _this._capturingControl = {};
  494. /** @hidden */
  495. _this._linkedControls = new Array();
  496. _this._isFullscreen = false;
  497. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  498. _this._idealWidth = 0;
  499. _this._idealHeight = 0;
  500. _this._useSmallestIdeal = false;
  501. _this._renderAtIdealSize = false;
  502. _this._blockNextFocusCheck = false;
  503. _this._renderScale = 1;
  504. _this._cursorChanged = false;
  505. /**
  506. * Define type to string to ensure compatibility across browsers
  507. * Safari doesn't support DataTransfer constructor
  508. */
  509. _this._clipboardData = "";
  510. /**
  511. * Observable event triggered each time an clipboard event is received from the rendering canvas
  512. */
  513. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  514. /**
  515. * Observable event triggered each time a pointer down is intercepted by a control
  516. */
  517. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  518. /**
  519. * Observable event triggered before layout is evaluated
  520. */
  521. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  522. /**
  523. * Observable event triggered after the layout was evaluated
  524. */
  525. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  526. /**
  527. * Observable event triggered before the texture is rendered
  528. */
  529. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  530. /**
  531. * Observable event triggered after the texture was rendered
  532. */
  533. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  534. /**
  535. * Gets or sets a boolean defining if alpha is stored as premultiplied
  536. */
  537. _this.premulAlpha = false;
  538. _this._useInvalidateRectOptimization = true;
  539. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  540. _this._invalidatedRectangle = null;
  541. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  542. /** @hidden */
  543. _this.onClipboardCopy = function (rawEvt) {
  544. var evt = rawEvt;
  545. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  546. _this.onClipboardObservable.notifyObservers(ev);
  547. evt.preventDefault();
  548. };
  549. /** @hidden */
  550. _this.onClipboardCut = function (rawEvt) {
  551. var evt = rawEvt;
  552. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  553. _this.onClipboardObservable.notifyObservers(ev);
  554. evt.preventDefault();
  555. };
  556. /** @hidden */
  557. _this.onClipboardPaste = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. scene = _this.getScene();
  564. if (!scene || !_this._texture) {
  565. return _this;
  566. }
  567. _this._rootCanvas = scene.getEngine().getRenderingCanvas();
  568. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  569. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  570. if (!_this._focusedControl) {
  571. return;
  572. }
  573. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  574. _this._focusedControl.processKeyboard(info.event);
  575. }
  576. info.skipOnPointerObservable = true;
  577. });
  578. _this._rootContainer._link(_this);
  579. _this.hasAlpha = true;
  580. if (!width || !height) {
  581. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  582. _this._onResize();
  583. }
  584. _this._texture.isReady = true;
  585. return _this;
  586. }
  587. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  588. /**
  589. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  590. * Useful when you want more antialiasing
  591. */
  592. get: function () {
  593. return this._renderScale;
  594. },
  595. set: function (value) {
  596. if (value === this._renderScale) {
  597. return;
  598. }
  599. this._renderScale = value;
  600. this._onResize();
  601. },
  602. enumerable: true,
  603. configurable: true
  604. });
  605. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  606. /** Gets or sets the background color */
  607. get: function () {
  608. return this._background;
  609. },
  610. set: function (value) {
  611. if (this._background === value) {
  612. return;
  613. }
  614. this._background = value;
  615. this.markAsDirty();
  616. },
  617. enumerable: true,
  618. configurable: true
  619. });
  620. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  621. /**
  622. * Gets or sets the ideal width used to design controls.
  623. * The GUI will then rescale everything accordingly
  624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  625. */
  626. get: function () {
  627. return this._idealWidth;
  628. },
  629. set: function (value) {
  630. if (this._idealWidth === value) {
  631. return;
  632. }
  633. this._idealWidth = value;
  634. this.markAsDirty();
  635. this._rootContainer._markAllAsDirty();
  636. },
  637. enumerable: true,
  638. configurable: true
  639. });
  640. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  641. /**
  642. * Gets or sets the ideal height used to design controls.
  643. * The GUI will then rescale everything accordingly
  644. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  645. */
  646. get: function () {
  647. return this._idealHeight;
  648. },
  649. set: function (value) {
  650. if (this._idealHeight === value) {
  651. return;
  652. }
  653. this._idealHeight = value;
  654. this.markAsDirty();
  655. this._rootContainer._markAllAsDirty();
  656. },
  657. enumerable: true,
  658. configurable: true
  659. });
  660. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  661. /**
  662. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  663. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  664. */
  665. get: function () {
  666. return this._useSmallestIdeal;
  667. },
  668. set: function (value) {
  669. if (this._useSmallestIdeal === value) {
  670. return;
  671. }
  672. this._useSmallestIdeal = value;
  673. this.markAsDirty();
  674. this._rootContainer._markAllAsDirty();
  675. },
  676. enumerable: true,
  677. configurable: true
  678. });
  679. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  680. /**
  681. * Gets or sets a boolean indicating if adaptive scaling must be used
  682. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  683. */
  684. get: function () {
  685. return this._renderAtIdealSize;
  686. },
  687. set: function (value) {
  688. if (this._renderAtIdealSize === value) {
  689. return;
  690. }
  691. this._renderAtIdealSize = value;
  692. this._onResize();
  693. },
  694. enumerable: true,
  695. configurable: true
  696. });
  697. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  698. /**
  699. * Gets the underlying layer used to render the texture when in fullscreen mode
  700. */
  701. get: function () {
  702. return this._layerToDispose;
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  708. /**
  709. * Gets the root container control
  710. */
  711. get: function () {
  712. return this._rootContainer;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. /**
  718. * Returns an array containing the root container.
  719. * This is mostly used to let the Inspector introspects the ADT
  720. * @returns an array containing the rootContainer
  721. */
  722. AdvancedDynamicTexture.prototype.getChildren = function () {
  723. return [this._rootContainer];
  724. };
  725. /**
  726. * Will return all controls that are inside this texture
  727. * @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
  728. * @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
  729. * @return all child controls
  730. */
  731. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  732. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  733. };
  734. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  735. /**
  736. * Gets or sets the current focused control
  737. */
  738. get: function () {
  739. return this._focusedControl;
  740. },
  741. set: function (control) {
  742. if (this._focusedControl == control) {
  743. return;
  744. }
  745. if (this._focusedControl) {
  746. this._focusedControl.onBlur();
  747. }
  748. if (control) {
  749. control.onFocus();
  750. }
  751. this._focusedControl = control;
  752. },
  753. enumerable: true,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  757. /**
  758. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  759. */
  760. get: function () {
  761. if (!this.layer) {
  762. return true;
  763. }
  764. return (!this.layer.isBackground);
  765. },
  766. set: function (value) {
  767. if (!this.layer) {
  768. return;
  769. }
  770. if (this.layer.isBackground === !value) {
  771. return;
  772. }
  773. this.layer.isBackground = !value;
  774. },
  775. enumerable: true,
  776. configurable: true
  777. });
  778. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  779. /**
  780. * Gets or set information about clipboardData
  781. */
  782. get: function () {
  783. return this._clipboardData;
  784. },
  785. set: function (value) {
  786. this._clipboardData = value;
  787. },
  788. enumerable: true,
  789. configurable: true
  790. });
  791. /**
  792. * Get the current class name of the texture useful for serialization or dynamic coding.
  793. * @returns "AdvancedDynamicTexture"
  794. */
  795. AdvancedDynamicTexture.prototype.getClassName = function () {
  796. return "AdvancedDynamicTexture";
  797. };
  798. /**
  799. * Function used to execute a function on all controls
  800. * @param func defines the function to execute
  801. * @param container defines the container where controls belong. If null the root container will be used
  802. */
  803. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  804. if (!container) {
  805. container = this._rootContainer;
  806. }
  807. func(container);
  808. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  809. var child = _a[_i];
  810. if (child.children) {
  811. this.executeOnAllControls(func, child);
  812. continue;
  813. }
  814. func(child);
  815. }
  816. };
  817. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  818. /**
  819. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  820. */
  821. get: function () {
  822. return this._useInvalidateRectOptimization;
  823. },
  824. set: function (value) {
  825. this._useInvalidateRectOptimization = value;
  826. },
  827. enumerable: true,
  828. configurable: true
  829. });
  830. /**
  831. * Invalidates a rectangle area on the gui texture
  832. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  833. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  834. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  835. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  836. */
  837. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  838. if (!this._useInvalidateRectOptimization) {
  839. return;
  840. }
  841. if (!this._invalidatedRectangle) {
  842. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  843. }
  844. else {
  845. // Compute intersection
  846. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  847. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  848. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  849. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  850. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  851. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  852. }
  853. };
  854. /**
  855. * Marks the texture as dirty forcing a complete update
  856. */
  857. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  858. this._isDirty = true;
  859. };
  860. /**
  861. * Helper function used to create a new style
  862. * @returns a new style
  863. * @see http://doc.babylonjs.com/how_to/gui#styles
  864. */
  865. AdvancedDynamicTexture.prototype.createStyle = function () {
  866. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  867. };
  868. /**
  869. * Adds a new control to the root container
  870. * @param control defines the control to add
  871. * @returns the current texture
  872. */
  873. AdvancedDynamicTexture.prototype.addControl = function (control) {
  874. this._rootContainer.addControl(control);
  875. return this;
  876. };
  877. /**
  878. * Removes a control from the root container
  879. * @param control defines the control to remove
  880. * @returns the current texture
  881. */
  882. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  883. this._rootContainer.removeControl(control);
  884. return this;
  885. };
  886. /**
  887. * Release all resources
  888. */
  889. AdvancedDynamicTexture.prototype.dispose = function () {
  890. var scene = this.getScene();
  891. if (!scene) {
  892. return;
  893. }
  894. this._rootCanvas = null;
  895. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  896. if (this._resizeObserver) {
  897. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  898. }
  899. if (this._pointerMoveObserver) {
  900. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  901. }
  902. if (this._pointerObserver) {
  903. scene.onPointerObservable.remove(this._pointerObserver);
  904. }
  905. if (this._preKeyboardObserver) {
  906. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  907. }
  908. if (this._canvasPointerOutObserver) {
  909. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  910. }
  911. if (this._layerToDispose) {
  912. this._layerToDispose.texture = null;
  913. this._layerToDispose.dispose();
  914. this._layerToDispose = null;
  915. }
  916. this._rootContainer.dispose();
  917. this.onClipboardObservable.clear();
  918. this.onControlPickedObservable.clear();
  919. this.onBeginRenderObservable.clear();
  920. this.onEndRenderObservable.clear();
  921. this.onBeginLayoutObservable.clear();
  922. this.onEndLayoutObservable.clear();
  923. _super.prototype.dispose.call(this);
  924. };
  925. AdvancedDynamicTexture.prototype._onResize = function () {
  926. var scene = this.getScene();
  927. if (!scene) {
  928. return;
  929. }
  930. // Check size
  931. var engine = scene.getEngine();
  932. var textureSize = this.getSize();
  933. var renderWidth = engine.getRenderWidth() * this._renderScale;
  934. var renderHeight = engine.getRenderHeight() * this._renderScale;
  935. if (this._renderAtIdealSize) {
  936. if (this._idealWidth) {
  937. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  938. renderWidth = this._idealWidth;
  939. }
  940. else if (this._idealHeight) {
  941. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  942. renderHeight = this._idealHeight;
  943. }
  944. }
  945. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  946. this.scaleTo(renderWidth, renderHeight);
  947. this.markAsDirty();
  948. if (this._idealWidth || this._idealHeight) {
  949. this._rootContainer._markAllAsDirty();
  950. }
  951. }
  952. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  953. };
  954. /** @hidden */
  955. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  956. var engine = scene.getEngine();
  957. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  958. };
  959. /**
  960. * Get screen coordinates for a vector3
  961. * @param position defines the position to project
  962. * @param worldMatrix defines the world matrix to use
  963. * @returns the projected position
  964. */
  965. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  966. var scene = this.getScene();
  967. if (!scene) {
  968. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  969. }
  970. var globalViewport = this._getGlobalViewport(scene);
  971. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  972. projectedPosition.scaleInPlace(this.renderScale);
  973. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  974. };
  975. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  976. if (this._layerToDispose) {
  977. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  978. return;
  979. }
  980. }
  981. if (this._isFullscreen && this._linkedControls.length) {
  982. var scene = this.getScene();
  983. if (!scene) {
  984. return;
  985. }
  986. var globalViewport = this._getGlobalViewport(scene);
  987. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  988. var control = _a[_i];
  989. if (!control.isVisible) {
  990. continue;
  991. }
  992. var mesh = control._linkedMesh;
  993. if (!mesh || mesh.isDisposed()) {
  994. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  995. control.linkWithMesh(null);
  996. });
  997. continue;
  998. }
  999. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1000. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1001. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1002. control.notRenderable = true;
  1003. continue;
  1004. }
  1005. control.notRenderable = false;
  1006. // Account for RenderScale.
  1007. projectedPosition.scaleInPlace(this.renderScale);
  1008. control._moveToProjectedPosition(projectedPosition);
  1009. }
  1010. }
  1011. if (!this._isDirty && !this._rootContainer.isDirty) {
  1012. return;
  1013. }
  1014. this._isDirty = false;
  1015. this._render();
  1016. this.update(true, this.premulAlpha);
  1017. };
  1018. AdvancedDynamicTexture.prototype._render = function () {
  1019. var textureSize = this.getSize();
  1020. var renderWidth = textureSize.width;
  1021. var renderHeight = textureSize.height;
  1022. var context = this.getContext();
  1023. context.font = "18px Arial";
  1024. context.strokeStyle = "white";
  1025. // Layout
  1026. this.onBeginLayoutObservable.notifyObservers(this);
  1027. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1028. this._rootContainer._layout(measure, context);
  1029. this.onEndLayoutObservable.notifyObservers(this);
  1030. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1031. // Clear
  1032. if (this._invalidatedRectangle) {
  1033. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1034. }
  1035. else {
  1036. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1037. }
  1038. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1039. if (this._background) {
  1040. context.save();
  1041. context.fillStyle = this._background;
  1042. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1043. context.restore();
  1044. }
  1045. // Render
  1046. this.onBeginRenderObservable.notifyObservers(this);
  1047. this._rootContainer._render(context, this._invalidatedRectangle);
  1048. this.onEndRenderObservable.notifyObservers(this);
  1049. this._invalidatedRectangle = null;
  1050. };
  1051. /** @hidden */
  1052. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1053. if (this._rootCanvas) {
  1054. this._rootCanvas.style.cursor = cursor;
  1055. this._cursorChanged = true;
  1056. }
  1057. };
  1058. /** @hidden */
  1059. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1060. this._lastControlDown[pointerId] = control;
  1061. this.onControlPickedObservable.notifyObservers(control);
  1062. };
  1063. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return;
  1067. }
  1068. var engine = scene.getEngine();
  1069. var textureSize = this.getSize();
  1070. if (this._isFullscreen) {
  1071. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1072. var viewport = camera.viewport;
  1073. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1074. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1075. }
  1076. if (this._capturingControl[pointerId]) {
  1077. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1078. return;
  1079. }
  1080. this._cursorChanged = false;
  1081. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1082. this._changeCursor("");
  1083. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1084. if (this._lastControlOver[pointerId]) {
  1085. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1086. delete this._lastControlOver[pointerId];
  1087. }
  1088. }
  1089. }
  1090. if (!this._cursorChanged) {
  1091. this._changeCursor("");
  1092. }
  1093. this._manageFocus();
  1094. };
  1095. /** @hidden */
  1096. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1097. for (var pointerId in list) {
  1098. if (!list.hasOwnProperty(pointerId)) {
  1099. continue;
  1100. }
  1101. var lastControlOver = list[pointerId];
  1102. if (lastControlOver === control) {
  1103. delete list[pointerId];
  1104. }
  1105. }
  1106. };
  1107. /** @hidden */
  1108. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1109. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1110. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1111. };
  1112. /** Attach to all scene events required to support pointer events */
  1113. AdvancedDynamicTexture.prototype.attach = function () {
  1114. var _this = this;
  1115. var scene = this.getScene();
  1116. if (!scene) {
  1117. return;
  1118. }
  1119. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1120. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1121. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1122. return;
  1123. }
  1124. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1125. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1126. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1127. return;
  1128. }
  1129. if (!scene) {
  1130. return;
  1131. }
  1132. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1133. var engine = scene.getEngine();
  1134. if (!camera) {
  1135. tempViewport.x = 0;
  1136. tempViewport.y = 0;
  1137. tempViewport.width = engine.getRenderWidth();
  1138. tempViewport.height = engine.getRenderHeight();
  1139. }
  1140. else {
  1141. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1142. }
  1143. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1144. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1145. _this._shouldBlockPointer = false;
  1146. // Do picking modifies _shouldBlockPointer
  1147. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1148. // Avoid overwriting a true skipOnPointerObservable to false
  1149. if (_this._shouldBlockPointer) {
  1150. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1151. }
  1152. });
  1153. this._attachToOnPointerOut(scene);
  1154. };
  1155. /**
  1156. * Register the clipboard Events onto the canvas
  1157. */
  1158. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1159. self.addEventListener("copy", this.onClipboardCopy, false);
  1160. self.addEventListener("cut", this.onClipboardCut, false);
  1161. self.addEventListener("paste", this.onClipboardPaste, false);
  1162. };
  1163. /**
  1164. * Unregister the clipboard Events from the canvas
  1165. */
  1166. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1167. self.removeEventListener("copy", this.onClipboardCopy);
  1168. self.removeEventListener("cut", this.onClipboardCut);
  1169. self.removeEventListener("paste", this.onClipboardPaste);
  1170. };
  1171. /**
  1172. * Connect the texture to a hosting mesh to enable interactions
  1173. * @param mesh defines the mesh to attach to
  1174. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1175. */
  1176. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1177. var _this = this;
  1178. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1179. var scene = this.getScene();
  1180. if (!scene) {
  1181. return;
  1182. }
  1183. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. var pointerId = pi.event.pointerId || 0;
  1190. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1191. var uv = pi.pickInfo.getTextureCoordinates();
  1192. if (uv) {
  1193. var size = _this.getSize();
  1194. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1195. }
  1196. }
  1197. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1198. if (_this._lastControlDown[pointerId]) {
  1199. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1200. }
  1201. delete _this._lastControlDown[pointerId];
  1202. if (_this.focusedControl) {
  1203. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1204. var canMoveFocus = true;
  1205. if (friendlyControls) {
  1206. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1207. var control = friendlyControls_1[_i];
  1208. // Same host, no need to keep the focus
  1209. if (_this === control._host) {
  1210. continue;
  1211. }
  1212. // Different hosts
  1213. var otherHost = control._host;
  1214. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1215. canMoveFocus = false;
  1216. break;
  1217. }
  1218. }
  1219. }
  1220. if (canMoveFocus) {
  1221. _this.focusedControl = null;
  1222. }
  1223. }
  1224. }
  1225. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1226. if (_this._lastControlOver[pointerId]) {
  1227. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1228. }
  1229. delete _this._lastControlOver[pointerId];
  1230. }
  1231. });
  1232. mesh.enablePointerMoveEvents = supportPointerMove;
  1233. this._attachToOnPointerOut(scene);
  1234. };
  1235. /**
  1236. * Move the focus to a specific control
  1237. * @param control defines the control which will receive the focus
  1238. */
  1239. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1240. this.focusedControl = control;
  1241. this._lastPickedControl = control;
  1242. this._blockNextFocusCheck = true;
  1243. };
  1244. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1245. if (this._blockNextFocusCheck) {
  1246. this._blockNextFocusCheck = false;
  1247. this._lastPickedControl = this._focusedControl;
  1248. return;
  1249. }
  1250. // Focus management
  1251. if (this._focusedControl) {
  1252. if (this._focusedControl !== this._lastPickedControl) {
  1253. if (this._lastPickedControl.isFocusInvisible) {
  1254. return;
  1255. }
  1256. this.focusedControl = null;
  1257. }
  1258. }
  1259. };
  1260. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1261. var _this = this;
  1262. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1263. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1264. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1265. }
  1266. delete _this._lastControlOver[pointerEvent.pointerId];
  1267. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1268. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1269. delete _this._lastControlDown[pointerEvent.pointerId];
  1270. }
  1271. });
  1272. };
  1273. // Statics
  1274. /**
  1275. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1276. * @param mesh defines the mesh which will receive the texture
  1277. * @param width defines the texture width (1024 by default)
  1278. * @param height defines the texture height (1024 by default)
  1279. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1280. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1281. * @returns a new AdvancedDynamicTexture
  1282. */
  1283. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1284. if (width === void 0) { width = 1024; }
  1285. if (height === void 0) { height = 1024; }
  1286. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1287. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1288. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1289. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1290. material.backFaceCulling = false;
  1291. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1292. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1293. if (onlyAlphaTesting) {
  1294. material.diffuseTexture = result;
  1295. material.emissiveTexture = result;
  1296. result.hasAlpha = true;
  1297. }
  1298. else {
  1299. material.emissiveTexture = result;
  1300. material.opacityTexture = result;
  1301. }
  1302. mesh.material = material;
  1303. result.attachToMesh(mesh, supportPointerMove);
  1304. return result;
  1305. };
  1306. /**
  1307. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1308. * In this mode the texture will rely on a layer for its rendering.
  1309. * This allows it to be treated like any other layer.
  1310. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1311. * LayerMask is set through advancedTexture.layer.layerMask
  1312. * @param name defines name for the texture
  1313. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1314. * @param scene defines the hsoting scene
  1315. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1316. * @returns a new AdvancedDynamicTexture
  1317. */
  1318. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1319. if (foreground === void 0) { foreground = true; }
  1320. if (scene === void 0) { scene = null; }
  1321. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1322. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1323. // Display
  1324. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1325. layer.texture = result;
  1326. result._layerToDispose = layer;
  1327. result._isFullscreen = true;
  1328. // Attach
  1329. result.attach();
  1330. return result;
  1331. };
  1332. return AdvancedDynamicTexture;
  1333. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1334. /***/ }),
  1335. /***/ "./2D/controls/button.ts":
  1336. /*!*******************************!*\
  1337. !*** ./2D/controls/button.ts ***!
  1338. \*******************************/
  1339. /*! exports provided: Button */
  1340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1341. "use strict";
  1342. __webpack_require__.r(__webpack_exports__);
  1343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1345. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1346. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1347. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1348. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1349. /**
  1350. * Class used to create 2D buttons
  1351. */
  1352. var Button = /** @class */ (function (_super) {
  1353. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button, _super);
  1354. /**
  1355. * Creates a new Button
  1356. * @param name defines the name of the button
  1357. */
  1358. function Button(name) {
  1359. var _this = _super.call(this, name) || this;
  1360. _this.name = name;
  1361. /**
  1362. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1363. */
  1364. _this.delegatePickingToChildren = false;
  1365. _this.thickness = 1;
  1366. _this.isPointerBlocker = true;
  1367. var alphaStore = null;
  1368. _this.pointerEnterAnimation = function () {
  1369. alphaStore = _this.alpha;
  1370. _this.alpha -= 0.1;
  1371. };
  1372. _this.pointerOutAnimation = function () {
  1373. if (alphaStore !== null) {
  1374. _this.alpha = alphaStore;
  1375. }
  1376. };
  1377. _this.pointerDownAnimation = function () {
  1378. _this.scaleX -= 0.05;
  1379. _this.scaleY -= 0.05;
  1380. };
  1381. _this.pointerUpAnimation = function () {
  1382. _this.scaleX += 0.05;
  1383. _this.scaleY += 0.05;
  1384. };
  1385. return _this;
  1386. }
  1387. Object.defineProperty(Button.prototype, "image", {
  1388. /**
  1389. * Returns the image part of the button (if any)
  1390. */
  1391. get: function () {
  1392. return this._image;
  1393. },
  1394. enumerable: true,
  1395. configurable: true
  1396. });
  1397. Object.defineProperty(Button.prototype, "textBlock", {
  1398. /**
  1399. * Returns the image part of the button (if any)
  1400. */
  1401. get: function () {
  1402. return this._textBlock;
  1403. },
  1404. enumerable: true,
  1405. configurable: true
  1406. });
  1407. Button.prototype._getTypeName = function () {
  1408. return "Button";
  1409. };
  1410. // While being a container, the button behaves like a control.
  1411. /** @hidden */
  1412. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1413. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1414. return false;
  1415. }
  1416. if (!_super.prototype.contains.call(this, x, y)) {
  1417. return false;
  1418. }
  1419. if (this.delegatePickingToChildren) {
  1420. var contains = false;
  1421. for (var index = this._children.length - 1; index >= 0; index--) {
  1422. var child = this._children[index];
  1423. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1424. contains = true;
  1425. break;
  1426. }
  1427. }
  1428. if (!contains) {
  1429. return false;
  1430. }
  1431. }
  1432. this._processObservables(type, x, y, pointerId, buttonIndex);
  1433. return true;
  1434. };
  1435. /** @hidden */
  1436. Button.prototype._onPointerEnter = function (target) {
  1437. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1438. return false;
  1439. }
  1440. if (this.pointerEnterAnimation) {
  1441. this.pointerEnterAnimation();
  1442. }
  1443. return true;
  1444. };
  1445. /** @hidden */
  1446. Button.prototype._onPointerOut = function (target, force) {
  1447. if (force === void 0) { force = false; }
  1448. if (this.pointerOutAnimation) {
  1449. this.pointerOutAnimation();
  1450. }
  1451. _super.prototype._onPointerOut.call(this, target, force);
  1452. };
  1453. /** @hidden */
  1454. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1455. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1456. return false;
  1457. }
  1458. if (this.pointerDownAnimation) {
  1459. this.pointerDownAnimation();
  1460. }
  1461. return true;
  1462. };
  1463. /** @hidden */
  1464. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1465. if (this.pointerUpAnimation) {
  1466. this.pointerUpAnimation();
  1467. }
  1468. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1469. };
  1470. // Statics
  1471. /**
  1472. * Creates a new button made with an image and a text
  1473. * @param name defines the name of the button
  1474. * @param text defines the text of the button
  1475. * @param imageUrl defines the url of the image
  1476. * @returns a new Button
  1477. */
  1478. Button.CreateImageButton = function (name, text, imageUrl) {
  1479. var result = new Button(name);
  1480. // Adding text
  1481. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1482. textBlock.textWrapping = true;
  1483. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1484. textBlock.paddingLeft = "20%";
  1485. result.addControl(textBlock);
  1486. // Adding image
  1487. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1488. iconImage.width = "20%";
  1489. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1490. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1491. result.addControl(iconImage);
  1492. // Store
  1493. result._image = iconImage;
  1494. result._textBlock = textBlock;
  1495. return result;
  1496. };
  1497. /**
  1498. * Creates a new button made with an image
  1499. * @param name defines the name of the button
  1500. * @param imageUrl defines the url of the image
  1501. * @returns a new Button
  1502. */
  1503. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1504. var result = new Button(name);
  1505. // Adding image
  1506. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1507. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1508. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1509. result.addControl(iconImage);
  1510. // Store
  1511. result._image = iconImage;
  1512. return result;
  1513. };
  1514. /**
  1515. * Creates a new button made with a text
  1516. * @param name defines the name of the button
  1517. * @param text defines the text of the button
  1518. * @returns a new Button
  1519. */
  1520. Button.CreateSimpleButton = function (name, text) {
  1521. var result = new Button(name);
  1522. // Adding text
  1523. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1524. textBlock.textWrapping = true;
  1525. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1526. result.addControl(textBlock);
  1527. // Store
  1528. result._textBlock = textBlock;
  1529. return result;
  1530. };
  1531. /**
  1532. * Creates a new button made with an image and a centered text
  1533. * @param name defines the name of the button
  1534. * @param text defines the text of the button
  1535. * @param imageUrl defines the url of the image
  1536. * @returns a new Button
  1537. */
  1538. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1539. var result = new Button(name);
  1540. // Adding image
  1541. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1542. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1543. result.addControl(iconImage);
  1544. // Adding text
  1545. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1546. textBlock.textWrapping = true;
  1547. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1548. result.addControl(textBlock);
  1549. // Store
  1550. result._image = iconImage;
  1551. result._textBlock = textBlock;
  1552. return result;
  1553. };
  1554. return Button;
  1555. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1556. /***/ }),
  1557. /***/ "./2D/controls/checkbox.ts":
  1558. /*!*********************************!*\
  1559. !*** ./2D/controls/checkbox.ts ***!
  1560. \*********************************/
  1561. /*! exports provided: Checkbox */
  1562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1563. "use strict";
  1564. __webpack_require__.r(__webpack_exports__);
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1566. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1567. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1568. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1569. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1570. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1571. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1572. /**
  1573. * Class used to represent a 2D checkbox
  1574. */
  1575. var Checkbox = /** @class */ (function (_super) {
  1576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Checkbox, _super);
  1577. /**
  1578. * Creates a new CheckBox
  1579. * @param name defines the control name
  1580. */
  1581. function Checkbox(name) {
  1582. var _this = _super.call(this, name) || this;
  1583. _this.name = name;
  1584. _this._isChecked = false;
  1585. _this._background = "black";
  1586. _this._checkSizeRatio = 0.8;
  1587. _this._thickness = 1;
  1588. /**
  1589. * Observable raised when isChecked property changes
  1590. */
  1591. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1592. _this.isPointerBlocker = true;
  1593. return _this;
  1594. }
  1595. Object.defineProperty(Checkbox.prototype, "thickness", {
  1596. /** Gets or sets border thickness */
  1597. get: function () {
  1598. return this._thickness;
  1599. },
  1600. set: function (value) {
  1601. if (this._thickness === value) {
  1602. return;
  1603. }
  1604. this._thickness = value;
  1605. this._markAsDirty();
  1606. },
  1607. enumerable: true,
  1608. configurable: true
  1609. });
  1610. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1611. /** Gets or sets a value indicating the ratio between overall size and check size */
  1612. get: function () {
  1613. return this._checkSizeRatio;
  1614. },
  1615. set: function (value) {
  1616. value = Math.max(Math.min(1, value), 0);
  1617. if (this._checkSizeRatio === value) {
  1618. return;
  1619. }
  1620. this._checkSizeRatio = value;
  1621. this._markAsDirty();
  1622. },
  1623. enumerable: true,
  1624. configurable: true
  1625. });
  1626. Object.defineProperty(Checkbox.prototype, "background", {
  1627. /** Gets or sets background color */
  1628. get: function () {
  1629. return this._background;
  1630. },
  1631. set: function (value) {
  1632. if (this._background === value) {
  1633. return;
  1634. }
  1635. this._background = value;
  1636. this._markAsDirty();
  1637. },
  1638. enumerable: true,
  1639. configurable: true
  1640. });
  1641. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1642. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1643. get: function () {
  1644. return this._isChecked;
  1645. },
  1646. set: function (value) {
  1647. if (this._isChecked === value) {
  1648. return;
  1649. }
  1650. this._isChecked = value;
  1651. this._markAsDirty();
  1652. this.onIsCheckedChangedObservable.notifyObservers(value);
  1653. },
  1654. enumerable: true,
  1655. configurable: true
  1656. });
  1657. Checkbox.prototype._getTypeName = function () {
  1658. return "Checkbox";
  1659. };
  1660. /** @hidden */
  1661. Checkbox.prototype._draw = function (context) {
  1662. context.save();
  1663. this._applyStates(context);
  1664. var actualWidth = this._currentMeasure.width - this._thickness;
  1665. var actualHeight = this._currentMeasure.height - this._thickness;
  1666. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1667. context.shadowColor = this.shadowColor;
  1668. context.shadowBlur = this.shadowBlur;
  1669. context.shadowOffsetX = this.shadowOffsetX;
  1670. context.shadowOffsetY = this.shadowOffsetY;
  1671. }
  1672. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1673. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1674. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1675. context.shadowBlur = 0;
  1676. context.shadowOffsetX = 0;
  1677. context.shadowOffsetY = 0;
  1678. }
  1679. if (this._isChecked) {
  1680. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1681. var offsetWidth = actualWidth * this._checkSizeRatio;
  1682. var offseHeight = actualHeight * this._checkSizeRatio;
  1683. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1684. }
  1685. context.strokeStyle = this.color;
  1686. context.lineWidth = this._thickness;
  1687. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1688. context.restore();
  1689. };
  1690. // Events
  1691. /** @hidden */
  1692. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1693. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1694. return false;
  1695. }
  1696. this.isChecked = !this.isChecked;
  1697. return true;
  1698. };
  1699. /**
  1700. * Utility function to easily create a checkbox with a header
  1701. * @param title defines the label to use for the header
  1702. * @param onValueChanged defines the callback to call when value changes
  1703. * @returns a StackPanel containing the checkbox and a textBlock
  1704. */
  1705. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1706. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1707. panel.isVertical = false;
  1708. panel.height = "30px";
  1709. var checkbox = new Checkbox();
  1710. checkbox.width = "20px";
  1711. checkbox.height = "20px";
  1712. checkbox.isChecked = true;
  1713. checkbox.color = "green";
  1714. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1715. panel.addControl(checkbox);
  1716. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1717. header.text = title;
  1718. header.width = "180px";
  1719. header.paddingLeft = "5px";
  1720. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1721. header.color = "white";
  1722. panel.addControl(header);
  1723. return panel;
  1724. };
  1725. return Checkbox;
  1726. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1727. /***/ }),
  1728. /***/ "./2D/controls/colorpicker.ts":
  1729. /*!************************************!*\
  1730. !*** ./2D/controls/colorpicker.ts ***!
  1731. \************************************/
  1732. /*! exports provided: ColorPicker */
  1733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1734. "use strict";
  1735. __webpack_require__.r(__webpack_exports__);
  1736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1737. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1738. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1739. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1740. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1741. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1742. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1743. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1744. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1745. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1746. /** Class used to create color pickers */
  1747. var ColorPicker = /** @class */ (function (_super) {
  1748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorPicker, _super);
  1749. /**
  1750. * Creates a new ColorPicker
  1751. * @param name defines the control name
  1752. */
  1753. function ColorPicker(name) {
  1754. var _this = _super.call(this, name) || this;
  1755. _this.name = name;
  1756. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1757. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1758. _this._pointerStartedOnSquare = false;
  1759. _this._pointerStartedOnWheel = false;
  1760. _this._squareLeft = 0;
  1761. _this._squareTop = 0;
  1762. _this._squareSize = 0;
  1763. _this._h = 360;
  1764. _this._s = 1;
  1765. _this._v = 1;
  1766. _this._lastPointerDownID = -1;
  1767. /**
  1768. * Observable raised when the value changes
  1769. */
  1770. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1771. // Events
  1772. _this._pointerIsDown = false;
  1773. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1774. _this.size = "200px";
  1775. _this.isPointerBlocker = true;
  1776. return _this;
  1777. }
  1778. Object.defineProperty(ColorPicker.prototype, "value", {
  1779. /** Gets or sets the color of the color picker */
  1780. get: function () {
  1781. return this._value;
  1782. },
  1783. set: function (value) {
  1784. if (this._value.equals(value)) {
  1785. return;
  1786. }
  1787. this._value.copyFrom(value);
  1788. this._value.toHSVToRef(this._tmpColor);
  1789. this._h = this._tmpColor.r;
  1790. this._s = Math.max(this._tmpColor.g, 0.00001);
  1791. this._v = Math.max(this._tmpColor.b, 0.00001);
  1792. this._markAsDirty();
  1793. if (this._value.r <= ColorPicker._Epsilon) {
  1794. this._value.r = 0;
  1795. }
  1796. if (this._value.g <= ColorPicker._Epsilon) {
  1797. this._value.g = 0;
  1798. }
  1799. if (this._value.b <= ColorPicker._Epsilon) {
  1800. this._value.b = 0;
  1801. }
  1802. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1803. this._value.r = 1.0;
  1804. }
  1805. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1806. this._value.g = 1.0;
  1807. }
  1808. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1809. this._value.b = 1.0;
  1810. }
  1811. this.onValueChangedObservable.notifyObservers(this._value);
  1812. },
  1813. enumerable: true,
  1814. configurable: true
  1815. });
  1816. Object.defineProperty(ColorPicker.prototype, "width", {
  1817. /**
  1818. * Gets or sets control width
  1819. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1820. */
  1821. get: function () {
  1822. return this._width.toString(this._host);
  1823. },
  1824. set: function (value) {
  1825. if (this._width.toString(this._host) === value) {
  1826. return;
  1827. }
  1828. if (this._width.fromString(value)) {
  1829. this._height.fromString(value);
  1830. this._markAsDirty();
  1831. }
  1832. },
  1833. enumerable: true,
  1834. configurable: true
  1835. });
  1836. Object.defineProperty(ColorPicker.prototype, "height", {
  1837. /**
  1838. * Gets or sets control height
  1839. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1840. */
  1841. get: function () {
  1842. return this._height.toString(this._host);
  1843. },
  1844. /** Gets or sets control height */
  1845. set: function (value) {
  1846. if (this._height.toString(this._host) === value) {
  1847. return;
  1848. }
  1849. if (this._height.fromString(value)) {
  1850. this._width.fromString(value);
  1851. this._markAsDirty();
  1852. }
  1853. },
  1854. enumerable: true,
  1855. configurable: true
  1856. });
  1857. Object.defineProperty(ColorPicker.prototype, "size", {
  1858. /** Gets or sets control size */
  1859. get: function () {
  1860. return this.width;
  1861. },
  1862. set: function (value) {
  1863. this.width = value;
  1864. },
  1865. enumerable: true,
  1866. configurable: true
  1867. });
  1868. ColorPicker.prototype._getTypeName = function () {
  1869. return "ColorPicker";
  1870. };
  1871. /** @hidden */
  1872. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1873. if (parentMeasure.width < parentMeasure.height) {
  1874. this._currentMeasure.height = parentMeasure.width;
  1875. }
  1876. else {
  1877. this._currentMeasure.width = parentMeasure.height;
  1878. }
  1879. };
  1880. ColorPicker.prototype._updateSquareProps = function () {
  1881. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1882. var wheelThickness = radius * .2;
  1883. var innerDiameter = (radius - wheelThickness) * 2;
  1884. var squareSize = innerDiameter / (Math.sqrt(2));
  1885. var offset = radius - squareSize * .5;
  1886. this._squareLeft = this._currentMeasure.left + offset;
  1887. this._squareTop = this._currentMeasure.top + offset;
  1888. this._squareSize = squareSize;
  1889. };
  1890. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1891. var lgh = context.createLinearGradient(left, top, width + left, top);
  1892. lgh.addColorStop(0, '#fff');
  1893. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1894. context.fillStyle = lgh;
  1895. context.fillRect(left, top, width, height);
  1896. var lgv = context.createLinearGradient(left, top, left, height + top);
  1897. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1898. lgv.addColorStop(1, '#000');
  1899. context.fillStyle = lgv;
  1900. context.fillRect(left, top, width, height);
  1901. };
  1902. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1903. context.beginPath();
  1904. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1905. context.lineWidth = 3;
  1906. context.strokeStyle = '#333333';
  1907. context.stroke();
  1908. context.beginPath();
  1909. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1910. context.lineWidth = 3;
  1911. context.strokeStyle = '#ffffff';
  1912. context.stroke();
  1913. };
  1914. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1915. var canvas = document.createElement("canvas");
  1916. canvas.width = radius * 2;
  1917. canvas.height = radius * 2;
  1918. var context = canvas.getContext("2d");
  1919. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1920. var data = image.data;
  1921. var color = this._tmpColor;
  1922. var maxDistSq = radius * radius;
  1923. var innerRadius = radius - thickness;
  1924. var minDistSq = innerRadius * innerRadius;
  1925. for (var x = -radius; x < radius; x++) {
  1926. for (var y = -radius; y < radius; y++) {
  1927. var distSq = x * x + y * y;
  1928. if (distSq > maxDistSq || distSq < minDistSq) {
  1929. continue;
  1930. }
  1931. var dist = Math.sqrt(distSq);
  1932. var ang = Math.atan2(y, x);
  1933. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1934. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1935. data[index] = color.r * 255;
  1936. data[index + 1] = color.g * 255;
  1937. data[index + 2] = color.b * 255;
  1938. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1939. //apply less alpha to bigger color pickers
  1940. var alphaAmount = .2;
  1941. var maxAlpha = .2;
  1942. var minAlpha = .04;
  1943. var lowerRadius = 50;
  1944. var upperRadius = 150;
  1945. if (radius < lowerRadius) {
  1946. alphaAmount = maxAlpha;
  1947. }
  1948. else if (radius > upperRadius) {
  1949. alphaAmount = minAlpha;
  1950. }
  1951. else {
  1952. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1953. }
  1954. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1955. if (alphaRatio < alphaAmount) {
  1956. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1957. }
  1958. else if (alphaRatio > 1 - alphaAmount) {
  1959. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1960. }
  1961. else {
  1962. data[index + 3] = 255;
  1963. }
  1964. }
  1965. }
  1966. context.putImageData(image, 0, 0);
  1967. return canvas;
  1968. };
  1969. /** @hidden */
  1970. ColorPicker.prototype._draw = function (context) {
  1971. context.save();
  1972. this._applyStates(context);
  1973. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1974. var wheelThickness = radius * .2;
  1975. var left = this._currentMeasure.left;
  1976. var top = this._currentMeasure.top;
  1977. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1978. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1979. }
  1980. this._updateSquareProps();
  1981. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1982. context.shadowColor = this.shadowColor;
  1983. context.shadowBlur = this.shadowBlur;
  1984. context.shadowOffsetX = this.shadowOffsetX;
  1985. context.shadowOffsetY = this.shadowOffsetY;
  1986. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  1987. }
  1988. context.drawImage(this._colorWheelCanvas, left, top);
  1989. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1990. context.shadowBlur = 0;
  1991. context.shadowOffsetX = 0;
  1992. context.shadowOffsetY = 0;
  1993. }
  1994. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  1995. var cx = this._squareLeft + this._squareSize * this._s;
  1996. var cy = this._squareTop + this._squareSize * (1 - this._v);
  1997. this._drawCircle(cx, cy, radius * .04, context);
  1998. var dist = radius - wheelThickness * .5;
  1999. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2000. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2001. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2002. context.restore();
  2003. };
  2004. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2005. if (this._pointerStartedOnWheel) {
  2006. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2007. var centerX = radius + this._currentMeasure.left;
  2008. var centerY = radius + this._currentMeasure.top;
  2009. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2010. }
  2011. else if (this._pointerStartedOnSquare) {
  2012. this._updateSquareProps();
  2013. this._s = (x - this._squareLeft) / this._squareSize;
  2014. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2015. this._s = Math.min(this._s, 1);
  2016. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2017. this._v = Math.min(this._v, 1);
  2018. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2019. }
  2020. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2021. this.value = this._tmpColor;
  2022. };
  2023. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2024. this._updateSquareProps();
  2025. var left = this._squareLeft;
  2026. var top = this._squareTop;
  2027. var size = this._squareSize;
  2028. if (x >= left && x <= left + size &&
  2029. y >= top && y <= top + size) {
  2030. return true;
  2031. }
  2032. return false;
  2033. };
  2034. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2035. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2036. var centerX = radius + this._currentMeasure.left;
  2037. var centerY = radius + this._currentMeasure.top;
  2038. var wheelThickness = radius * .2;
  2039. var innerRadius = radius - wheelThickness;
  2040. var radiusSq = radius * radius;
  2041. var innerRadiusSq = innerRadius * innerRadius;
  2042. var dx = x - centerX;
  2043. var dy = y - centerY;
  2044. var distSq = dx * dx + dy * dy;
  2045. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2046. return true;
  2047. }
  2048. return false;
  2049. };
  2050. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2051. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2052. return false;
  2053. }
  2054. this._pointerIsDown = true;
  2055. this._pointerStartedOnSquare = false;
  2056. this._pointerStartedOnWheel = false;
  2057. // Invert transform
  2058. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2059. var x = this._transformedPosition.x;
  2060. var y = this._transformedPosition.y;
  2061. if (this._isPointOnSquare(x, y)) {
  2062. this._pointerStartedOnSquare = true;
  2063. }
  2064. else if (this._isPointOnWheel(x, y)) {
  2065. this._pointerStartedOnWheel = true;
  2066. }
  2067. this._updateValueFromPointer(x, y);
  2068. this._host._capturingControl[pointerId] = this;
  2069. this._lastPointerDownID = pointerId;
  2070. return true;
  2071. };
  2072. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2073. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2074. if (pointerId != this._lastPointerDownID) {
  2075. return;
  2076. }
  2077. // Invert transform
  2078. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2079. var x = this._transformedPosition.x;
  2080. var y = this._transformedPosition.y;
  2081. if (this._pointerIsDown) {
  2082. this._updateValueFromPointer(x, y);
  2083. }
  2084. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2085. };
  2086. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2087. this._pointerIsDown = false;
  2088. delete this._host._capturingControl[pointerId];
  2089. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2090. };
  2091. /**
  2092. * This function expands the color picker by creating a color picker dialog with manual
  2093. * color value input and the ability to save colors into an array to be used later in
  2094. * subsequent launches of the dialogue.
  2095. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2096. * @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.
  2097. * @returns picked color as a hex string and the saved colors array as hex strings.
  2098. */
  2099. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2100. return new Promise(function (resolve, reject) {
  2101. // Default options
  2102. options.pickerWidth = options.pickerWidth || "640px";
  2103. options.pickerHeight = options.pickerHeight || "400px";
  2104. options.headerHeight = options.headerHeight || "35px";
  2105. options.lastColor = options.lastColor || "#000000";
  2106. options.swatchLimit = options.swatchLimit || 20;
  2107. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2108. // Window size settings
  2109. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2110. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2111. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2112. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2113. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2114. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2115. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2116. // Button Colors
  2117. var buttonColor = "#c0c0c0";
  2118. var buttonBackgroundColor = "#535353";
  2119. var buttonBackgroundHoverColor = "#414141";
  2120. var buttonBackgroundClickColor = "515151";
  2121. var buttonDisabledColor = "#555555";
  2122. var buttonDisabledBackgroundColor = "#454545";
  2123. var currentSwatchesOutlineColor = "#404040";
  2124. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2125. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2126. var iconColorDark = "#aaaaaa";
  2127. var iconColorLight = "#ffffff";
  2128. var closeIconColor;
  2129. // Button settings
  2130. var buttonFontSize;
  2131. var butEdit;
  2132. var buttonWidth;
  2133. var buttonHeight;
  2134. // Input Text Colors
  2135. var inputFieldLabels = ["R", "G", "B"];
  2136. var inputTextBackgroundColor = "#454545";
  2137. var inputTextColor = "#f0f0f0";
  2138. // This is the current color as set by either the picker or by entering a value
  2139. var currentColor;
  2140. // This int is used for naming swatches and serves as the index for calling them from the list
  2141. var swatchNumber;
  2142. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2143. var swatchDrawer;
  2144. var editSwatchMode = false;
  2145. // Color InputText fields that will be updated upon value change
  2146. var picker;
  2147. var rValInt;
  2148. var gValInt;
  2149. var bValInt;
  2150. var rValDec;
  2151. var gValDec;
  2152. var bValDec;
  2153. var hexVal;
  2154. var newSwatch;
  2155. var lastVal;
  2156. var activeField;
  2157. /**
  2158. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2159. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2160. * are will receive no update. This is to prevent the input from the user being overwritten.
  2161. */
  2162. function updateValues(value, inputField) {
  2163. activeField = inputField;
  2164. var pickedColor = value.toHexString();
  2165. newSwatch.background = pickedColor;
  2166. if (rValInt.name != activeField) {
  2167. rValInt.text = Math.floor(value.r * 255).toString();
  2168. }
  2169. if (gValInt.name != activeField) {
  2170. gValInt.text = Math.floor(value.g * 255).toString();
  2171. }
  2172. if (bValInt.name != activeField) {
  2173. bValInt.text = Math.floor(value.b * 255).toString();
  2174. }
  2175. if (rValDec.name != activeField) {
  2176. rValDec.text = value.r.toString();
  2177. }
  2178. if (gValDec.name != activeField) {
  2179. gValDec.text = value.g.toString();
  2180. }
  2181. if (bValDec.name != activeField) {
  2182. bValDec.text = value.b.toString();
  2183. }
  2184. if (hexVal.name != activeField) {
  2185. var minusPound = pickedColor.split("#");
  2186. hexVal.text = minusPound[1];
  2187. }
  2188. if (picker.name != activeField) {
  2189. picker.value = value;
  2190. }
  2191. }
  2192. // 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.
  2193. function updateInt(field, channel) {
  2194. var newValue = field.text;
  2195. var checkVal = /[^0-9]/g.test(newValue);
  2196. if (checkVal) {
  2197. field.text = lastVal;
  2198. return;
  2199. }
  2200. else {
  2201. if (newValue != "") {
  2202. if (Math.floor(parseInt(newValue)) < 0) {
  2203. newValue = "0";
  2204. }
  2205. else if (Math.floor(parseInt(newValue)) > 255) {
  2206. newValue = "255";
  2207. }
  2208. else if (isNaN(parseInt(newValue))) {
  2209. newValue = "0";
  2210. }
  2211. }
  2212. if (activeField == field.name) {
  2213. lastVal = newValue;
  2214. }
  2215. }
  2216. if (newValue != "") {
  2217. newValue = parseInt(newValue).toString();
  2218. field.text = newValue;
  2219. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2220. if (activeField == field.name) {
  2221. if (channel == "r") {
  2222. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2223. }
  2224. else if (channel == "g") {
  2225. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2226. }
  2227. else {
  2228. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2229. }
  2230. }
  2231. }
  2232. }
  2233. // 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.
  2234. function updateFloat(field, channel) {
  2235. var newValue = field.text;
  2236. var checkVal = /[^0-9\.]/g.test(newValue);
  2237. if (checkVal) {
  2238. field.text = lastVal;
  2239. return;
  2240. }
  2241. else {
  2242. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2243. if (parseFloat(newValue) < 0.0) {
  2244. newValue = "0.0";
  2245. }
  2246. else if (parseFloat(newValue) > 1.0) {
  2247. newValue = "1.0";
  2248. }
  2249. else if (isNaN(parseFloat(newValue))) {
  2250. newValue = "0.0";
  2251. }
  2252. }
  2253. if (activeField == field.name) {
  2254. lastVal = newValue;
  2255. }
  2256. }
  2257. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2258. newValue = parseFloat(newValue).toString();
  2259. field.text = newValue;
  2260. }
  2261. else {
  2262. newValue = "0.0";
  2263. }
  2264. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2265. if (activeField == field.name) {
  2266. if (channel == "r") {
  2267. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2268. }
  2269. else if (channel == "g") {
  2270. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2271. }
  2272. else {
  2273. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2274. }
  2275. }
  2276. }
  2277. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2278. function deleteSwatch(index) {
  2279. if (options.savedColors) {
  2280. options.savedColors.splice(index, 1);
  2281. }
  2282. if (options.savedColors && options.savedColors.length == 0) {
  2283. setEditButtonVisibility(false);
  2284. editSwatchMode = false;
  2285. }
  2286. }
  2287. // Creates and styles an individual swatch when updateSwatches is called.
  2288. function createSwatch() {
  2289. if (options.savedColors && options.savedColors[swatchNumber]) {
  2290. if (editSwatchMode) {
  2291. var icon = "b";
  2292. }
  2293. else {
  2294. var icon = "";
  2295. }
  2296. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2297. swatch.fontFamily = "BabylonJSglyphs";
  2298. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2299. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2300. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2301. if (swatchLuminence > luminanceLimit) {
  2302. swatch.color = iconColorDark;
  2303. }
  2304. else {
  2305. swatch.color = iconColorLight;
  2306. }
  2307. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2308. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2309. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2310. swatch.background = options.savedColors[swatchNumber];
  2311. swatch.thickness = 2;
  2312. var metadata_1 = swatchNumber;
  2313. swatch.pointerDownAnimation = function () {
  2314. swatch.thickness = 4;
  2315. };
  2316. swatch.pointerUpAnimation = function () {
  2317. swatch.thickness = 3;
  2318. };
  2319. swatch.pointerEnterAnimation = function () {
  2320. swatch.thickness = 3;
  2321. };
  2322. swatch.pointerOutAnimation = function () {
  2323. swatch.thickness = 2;
  2324. };
  2325. swatch.onPointerClickObservable.add(function () {
  2326. if (!editSwatchMode) {
  2327. if (options.savedColors) {
  2328. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2329. }
  2330. }
  2331. else {
  2332. deleteSwatch(metadata_1);
  2333. updateSwatches("", butSave);
  2334. }
  2335. });
  2336. return swatch;
  2337. }
  2338. else {
  2339. return null;
  2340. }
  2341. }
  2342. // Mode switch to render button text and close symbols on swatch controls
  2343. function editSwatches(mode) {
  2344. if (mode !== undefined) {
  2345. editSwatchMode = mode;
  2346. }
  2347. if (editSwatchMode) {
  2348. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2349. var thisButton = swatchDrawer.children[i];
  2350. thisButton.textBlock.text = "b";
  2351. }
  2352. if (butEdit !== undefined) {
  2353. butEdit.textBlock.text = "Done";
  2354. }
  2355. }
  2356. else {
  2357. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2358. var thisButton = swatchDrawer.children[i];
  2359. thisButton.textBlock.text = "";
  2360. }
  2361. if (butEdit !== undefined) {
  2362. butEdit.textBlock.text = "Edit";
  2363. }
  2364. }
  2365. }
  2366. /**
  2367. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2368. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2369. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2370. * saved colors there are and how many can be stored per row.
  2371. */
  2372. function updateSwatches(color, button) {
  2373. if (options.savedColors) {
  2374. if (color != "") {
  2375. options.savedColors.push(color);
  2376. }
  2377. swatchNumber = 0;
  2378. swatchDrawer.clearControls();
  2379. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2380. if (rowCount == 0) {
  2381. var gutterCount = 0;
  2382. }
  2383. else {
  2384. var gutterCount = rowCount + 1;
  2385. }
  2386. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2387. var currentRows = swatchDrawer.rowCount;
  2388. for (var i = 0; i < currentRows; i++) {
  2389. swatchDrawer.removeRowDefinition(0);
  2390. }
  2391. for (var i = 0; i < rowCount + gutterCount; i++) {
  2392. if (i % 2) {
  2393. swatchDrawer.addRowDefinition(swatchSize, true);
  2394. }
  2395. else {
  2396. swatchDrawer.addRowDefinition(gutterSize, true);
  2397. }
  2398. }
  2399. }
  2400. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2401. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2402. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2403. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2404. var totalButtonsThisRow = options.numSwatchesPerLine;
  2405. }
  2406. else {
  2407. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2408. }
  2409. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2410. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2411. if (x > options.numSwatchesPerLine) {
  2412. continue;
  2413. }
  2414. var swatch = createSwatch();
  2415. if (swatch != null) {
  2416. swatchDrawer.addControl(swatch, y, w);
  2417. w += 2;
  2418. swatchNumber++;
  2419. }
  2420. else {
  2421. continue;
  2422. }
  2423. }
  2424. }
  2425. if (options.savedColors.length >= options.swatchLimit) {
  2426. disableButton(button, true);
  2427. }
  2428. else {
  2429. disableButton(button, false);
  2430. }
  2431. }
  2432. }
  2433. // Shows or hides edit swatches button depending on if there are saved swatches
  2434. function setEditButtonVisibility(enableButton) {
  2435. if (enableButton) {
  2436. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2437. butEdit.width = buttonWidth;
  2438. butEdit.height = buttonHeight;
  2439. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2440. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2441. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2442. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2443. butEdit.thickness = 2;
  2444. butEdit.color = buttonColor;
  2445. butEdit.fontSize = buttonFontSize;
  2446. butEdit.background = buttonBackgroundColor;
  2447. butEdit.onPointerEnterObservable.add(function () {
  2448. butEdit.background = buttonBackgroundHoverColor;
  2449. });
  2450. butEdit.onPointerOutObservable.add(function () {
  2451. butEdit.background = buttonBackgroundColor;
  2452. });
  2453. butEdit.pointerDownAnimation = function () {
  2454. butEdit.background = buttonBackgroundClickColor;
  2455. };
  2456. butEdit.pointerUpAnimation = function () {
  2457. butEdit.background = buttonBackgroundHoverColor;
  2458. };
  2459. butEdit.onPointerClickObservable.add(function () {
  2460. if (editSwatchMode) {
  2461. editSwatchMode = false;
  2462. }
  2463. else {
  2464. editSwatchMode = true;
  2465. }
  2466. editSwatches();
  2467. });
  2468. pickerGrid.addControl(butEdit, 1, 0);
  2469. }
  2470. else {
  2471. pickerGrid.removeControl(butEdit);
  2472. }
  2473. }
  2474. // Called when the user hits the limit of saved colors in the drawer.
  2475. function disableButton(button, disabled) {
  2476. if (disabled) {
  2477. button.color = buttonDisabledColor;
  2478. button.background = buttonDisabledBackgroundColor;
  2479. }
  2480. else {
  2481. button.color = buttonColor;
  2482. button.background = buttonBackgroundColor;
  2483. }
  2484. }
  2485. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2486. function closePicker(color) {
  2487. if (options.savedColors && options.savedColors.length > 0) {
  2488. resolve({
  2489. savedColors: options.savedColors,
  2490. pickedColor: color
  2491. });
  2492. }
  2493. else {
  2494. resolve({
  2495. pickedColor: color
  2496. });
  2497. }
  2498. advancedTexture.removeControl(dialogContainer);
  2499. }
  2500. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2501. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2502. dialogContainer.name = "Dialog Container";
  2503. dialogContainer.width = options.pickerWidth;
  2504. if (options.savedColors) {
  2505. dialogContainer.height = containerSize;
  2506. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2507. dialogContainer.addRowDefinition(topRow, false);
  2508. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2509. }
  2510. else {
  2511. dialogContainer.height = options.pickerHeight;
  2512. dialogContainer.addRowDefinition(1.0, false);
  2513. }
  2514. advancedTexture.addControl(dialogContainer);
  2515. // Swatch drawer which contains all saved color buttons
  2516. if (options.savedColors) {
  2517. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2518. swatchDrawer.name = "Swatch Drawer";
  2519. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2520. swatchDrawer.background = buttonBackgroundColor;
  2521. swatchDrawer.width = options.pickerWidth;
  2522. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2523. if (initialRows == 0) {
  2524. var gutterCount = 0;
  2525. }
  2526. else {
  2527. var gutterCount = initialRows + 1;
  2528. }
  2529. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2530. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2531. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2532. if (i % 2 != 0) {
  2533. swatchDrawer.addRowDefinition(swatchSize, true);
  2534. }
  2535. else {
  2536. swatchDrawer.addRowDefinition(gutterSize, true);
  2537. }
  2538. }
  2539. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2540. if (i % 2 != 0) {
  2541. swatchDrawer.addColumnDefinition(swatchSize, true);
  2542. }
  2543. else {
  2544. swatchDrawer.addColumnDefinition(gutterSize, true);
  2545. }
  2546. }
  2547. dialogContainer.addControl(swatchDrawer, 1, 0);
  2548. }
  2549. // Picker container
  2550. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2551. pickerPanel.name = "Picker Panel";
  2552. pickerPanel.height = options.pickerHeight;
  2553. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2554. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2555. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2556. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2557. dialogContainer.addControl(pickerPanel, 0, 0);
  2558. // Picker container header
  2559. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2560. header.name = "Dialogue Header Bar";
  2561. header.background = "#cccccc";
  2562. header.thickness = 0;
  2563. pickerPanel.addControl(header, 0, 0);
  2564. // Header close button
  2565. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2566. closeButton.fontFamily = "BabylonJSglyphs";
  2567. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2568. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2569. closeButton.color = closeIconColor.toHexString();
  2570. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2571. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2572. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2573. closeButton.height = closeButton.width = options.headerHeight;
  2574. closeButton.background = header.background;
  2575. closeButton.thickness = 0;
  2576. closeButton.pointerDownAnimation = function () {
  2577. };
  2578. closeButton.pointerUpAnimation = function () {
  2579. closeButton.background = header.background;
  2580. };
  2581. closeButton.pointerEnterAnimation = function () {
  2582. closeButton.color = header.background;
  2583. closeButton.background = "red";
  2584. };
  2585. closeButton.pointerOutAnimation = function () {
  2586. closeButton.color = closeIconColor.toHexString();
  2587. closeButton.background = header.background;
  2588. };
  2589. closeButton.onPointerClickObservable.add(function () {
  2590. closePicker(currentSwatch.background);
  2591. });
  2592. pickerPanel.addControl(closeButton, 0, 0);
  2593. // Dialog container body
  2594. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2595. dialogBody.name = "Dialogue Body";
  2596. dialogBody.background = buttonBackgroundColor;
  2597. var dialogBodyCols = [0.4375, 0.5625];
  2598. dialogBody.addRowDefinition(1.0, false);
  2599. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2600. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2601. pickerPanel.addControl(dialogBody, 1, 0);
  2602. // Picker grid
  2603. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2604. pickerGrid.name = "Picker Grid";
  2605. pickerGrid.addRowDefinition(0.85, false);
  2606. pickerGrid.addRowDefinition(0.15, false);
  2607. dialogBody.addControl(pickerGrid, 0, 0);
  2608. // Picker control
  2609. picker = new ColorPicker();
  2610. picker.name = "GUI Color Picker";
  2611. if (options.pickerHeight < options.pickerWidth) {
  2612. picker.width = 0.89;
  2613. }
  2614. else {
  2615. picker.height = 0.89;
  2616. }
  2617. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2618. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2619. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2620. picker.onPointerDownObservable.add(function () {
  2621. activeField = picker.name;
  2622. lastVal = "";
  2623. editSwatches(false);
  2624. });
  2625. picker.onValueChangedObservable.add(function (value) {
  2626. if (activeField == picker.name) {
  2627. updateValues(value, picker.name);
  2628. }
  2629. });
  2630. pickerGrid.addControl(picker, 0, 0);
  2631. // Picker body right quarant
  2632. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2633. pickerBodyRight.name = "Dialogue Right Half";
  2634. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2635. var pickerBodyRightRows = [0.514, 0.486];
  2636. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2637. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2638. dialogBody.addControl(pickerBodyRight, 1, 1);
  2639. // Picker container swatches and buttons
  2640. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2641. pickerSwatchesButtons.name = "Swatches and Buttons";
  2642. var pickerButtonsCol = [0.417, 0.583];
  2643. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2644. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2645. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2646. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2647. // Picker Swatches quadrant
  2648. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2649. pickerSwatches.name = "New and Current Swatches";
  2650. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2651. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2652. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2653. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2654. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2655. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2656. // Active swatches
  2657. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2658. activeSwatches.name = "Active Swatches";
  2659. activeSwatches.width = 0.67;
  2660. activeSwatches.addRowDefinition(0.5, false);
  2661. activeSwatches.addRowDefinition(0.5, false);
  2662. pickerSwatches.addControl(activeSwatches, 2, 0);
  2663. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2664. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2665. if (options.pickerWidth > options.pickerHeight) {
  2666. var labelTextSize = labelHeight;
  2667. }
  2668. else {
  2669. var labelTextSize = labelWidth;
  2670. }
  2671. // New color swatch and previous color button
  2672. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2673. newText.text = "new";
  2674. newText.name = "New Color Label";
  2675. newText.color = buttonColor;
  2676. newText.fontSize = labelTextSize;
  2677. pickerSwatches.addControl(newText, 1, 0);
  2678. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2679. newSwatch.name = "New Color Swatch";
  2680. newSwatch.background = options.lastColor;
  2681. newSwatch.thickness = 0;
  2682. activeSwatches.addControl(newSwatch, 0, 0);
  2683. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2684. currentSwatch.background = options.lastColor;
  2685. currentSwatch.thickness = 0;
  2686. currentSwatch.onPointerClickObservable.add(function () {
  2687. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2688. updateValues(revertColor, currentSwatch.name);
  2689. editSwatches(false);
  2690. });
  2691. currentSwatch.pointerDownAnimation = function () { };
  2692. currentSwatch.pointerUpAnimation = function () { };
  2693. currentSwatch.pointerEnterAnimation = function () { };
  2694. currentSwatch.pointerOutAnimation = function () { };
  2695. activeSwatches.addControl(currentSwatch, 1, 0);
  2696. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2697. swatchOutline.name = "Swatch Outline";
  2698. swatchOutline.width = 0.67;
  2699. swatchOutline.thickness = 2;
  2700. swatchOutline.color = currentSwatchesOutlineColor;
  2701. swatchOutline.isHitTestVisible = false;
  2702. pickerSwatches.addControl(swatchOutline, 2, 0);
  2703. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2704. currentText.name = "Current Color Label";
  2705. currentText.text = "current";
  2706. currentText.color = buttonColor;
  2707. currentText.fontSize = labelTextSize;
  2708. pickerSwatches.addControl(currentText, 3, 0);
  2709. // Buttons grid
  2710. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2711. buttonGrid.name = "Button Grid";
  2712. buttonGrid.height = 0.8;
  2713. var buttonGridRows = 1 / 3;
  2714. buttonGrid.addRowDefinition(buttonGridRows, false);
  2715. buttonGrid.addRowDefinition(buttonGridRows, false);
  2716. buttonGrid.addRowDefinition(buttonGridRows, false);
  2717. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2718. // Determine pixel width and height for all buttons from overall panel dimensions
  2719. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2720. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2721. // Determine button type size
  2722. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2723. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2724. }
  2725. else {
  2726. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2727. }
  2728. // Panel Buttons
  2729. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2730. butOK.width = buttonWidth;
  2731. butOK.height = buttonHeight;
  2732. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2733. butOK.thickness = 2;
  2734. butOK.color = buttonColor;
  2735. butOK.fontSize = buttonFontSize;
  2736. butOK.background = buttonBackgroundColor;
  2737. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2738. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2739. butOK.pointerDownAnimation = function () {
  2740. butOK.background = buttonBackgroundClickColor;
  2741. };
  2742. butOK.pointerUpAnimation = function () {
  2743. butOK.background = buttonBackgroundHoverColor;
  2744. };
  2745. butOK.onPointerClickObservable.add(function () {
  2746. editSwatches(false);
  2747. closePicker(newSwatch.background);
  2748. });
  2749. buttonGrid.addControl(butOK, 0, 0);
  2750. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2751. butCancel.width = buttonWidth;
  2752. butCancel.height = buttonHeight;
  2753. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2754. butCancel.thickness = 2;
  2755. butCancel.color = buttonColor;
  2756. butCancel.fontSize = buttonFontSize;
  2757. butCancel.background = buttonBackgroundColor;
  2758. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2759. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2760. butCancel.pointerDownAnimation = function () {
  2761. butCancel.background = buttonBackgroundClickColor;
  2762. };
  2763. butCancel.pointerUpAnimation = function () {
  2764. butCancel.background = buttonBackgroundHoverColor;
  2765. };
  2766. butCancel.onPointerClickObservable.add(function () {
  2767. editSwatches(false);
  2768. closePicker(currentSwatch.background);
  2769. });
  2770. buttonGrid.addControl(butCancel, 1, 0);
  2771. if (options.savedColors) {
  2772. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2773. butSave.width = buttonWidth;
  2774. butSave.height = buttonHeight;
  2775. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2776. butSave.thickness = 2;
  2777. butSave.fontSize = buttonFontSize;
  2778. if (options.savedColors.length < options.swatchLimit) {
  2779. butSave.color = buttonColor;
  2780. butSave.background = buttonBackgroundColor;
  2781. }
  2782. else {
  2783. disableButton(butSave, true);
  2784. }
  2785. butSave.onPointerEnterObservable.add(function () {
  2786. if (options.savedColors) {
  2787. if (options.savedColors.length < options.swatchLimit) {
  2788. butSave.background = buttonBackgroundHoverColor;
  2789. }
  2790. }
  2791. });
  2792. butSave.onPointerOutObservable.add(function () {
  2793. if (options.savedColors) {
  2794. if (options.savedColors.length < options.swatchLimit) {
  2795. butSave.background = buttonBackgroundColor;
  2796. }
  2797. }
  2798. });
  2799. butSave.pointerDownAnimation = function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundClickColor;
  2803. }
  2804. }
  2805. };
  2806. butSave.pointerUpAnimation = function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundHoverColor;
  2810. }
  2811. }
  2812. };
  2813. butSave.onPointerClickObservable.add(function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length == 0) {
  2816. setEditButtonVisibility(true);
  2817. }
  2818. if (options.savedColors.length < options.swatchLimit) {
  2819. updateSwatches(newSwatch.background, butSave);
  2820. }
  2821. editSwatches(false);
  2822. }
  2823. });
  2824. if (options.savedColors.length > 0) {
  2825. setEditButtonVisibility(true);
  2826. }
  2827. buttonGrid.addControl(butSave, 2, 0);
  2828. }
  2829. // Picker color values input
  2830. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2831. pickerColorValues.name = "Dialog Lower Right";
  2832. pickerColorValues.addRowDefinition(0.02, false);
  2833. pickerColorValues.addRowDefinition(0.63, false);
  2834. pickerColorValues.addRowDefinition(0.21, false);
  2835. pickerColorValues.addRowDefinition(0.14, false);
  2836. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2837. // RGB values text boxes
  2838. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2839. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2840. rgbValuesQuadrant.name = "RGB Values";
  2841. rgbValuesQuadrant.width = 0.82;
  2842. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2843. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2844. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2845. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2846. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2847. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2848. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2849. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2850. for (var i = 0; i < inputFieldLabels.length; i++) {
  2851. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2852. labelText.text = inputFieldLabels[i];
  2853. labelText.color = buttonColor;
  2854. labelText.fontSize = buttonFontSize;
  2855. rgbValuesQuadrant.addControl(labelText, i, 0);
  2856. }
  2857. // Input fields for RGB values
  2858. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2859. rValInt.width = 0.83;
  2860. rValInt.height = 0.72;
  2861. rValInt.name = "rIntField";
  2862. rValInt.fontSize = buttonFontSize;
  2863. rValInt.text = (currentColor.r * 255).toString();
  2864. rValInt.color = inputTextColor;
  2865. rValInt.background = inputTextBackgroundColor;
  2866. rValInt.onFocusObservable.add(function () {
  2867. activeField = rValInt.name;
  2868. lastVal = rValInt.text;
  2869. editSwatches(false);
  2870. });
  2871. rValInt.onBlurObservable.add(function () {
  2872. if (rValInt.text == "") {
  2873. rValInt.text = "0";
  2874. }
  2875. updateInt(rValInt, "r");
  2876. if (activeField == rValInt.name) {
  2877. activeField = "";
  2878. }
  2879. });
  2880. rValInt.onTextChangedObservable.add(function () {
  2881. if (activeField == rValInt.name) {
  2882. updateInt(rValInt, "r");
  2883. }
  2884. });
  2885. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2886. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2887. gValInt.width = 0.83;
  2888. gValInt.height = 0.72;
  2889. gValInt.name = "gIntField";
  2890. gValInt.fontSize = buttonFontSize;
  2891. gValInt.text = (currentColor.g * 255).toString();
  2892. gValInt.color = inputTextColor;
  2893. gValInt.background = inputTextBackgroundColor;
  2894. gValInt.onFocusObservable.add(function () {
  2895. activeField = gValInt.name;
  2896. lastVal = gValInt.text;
  2897. editSwatches(false);
  2898. });
  2899. gValInt.onBlurObservable.add(function () {
  2900. if (gValInt.text == "") {
  2901. gValInt.text = "0";
  2902. }
  2903. updateInt(gValInt, "g");
  2904. if (activeField == gValInt.name) {
  2905. activeField = "";
  2906. }
  2907. });
  2908. gValInt.onTextChangedObservable.add(function () {
  2909. if (activeField == gValInt.name) {
  2910. updateInt(gValInt, "g");
  2911. }
  2912. });
  2913. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2914. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2915. bValInt.width = 0.83;
  2916. bValInt.height = 0.72;
  2917. bValInt.name = "bIntField";
  2918. bValInt.fontSize = buttonFontSize;
  2919. bValInt.text = (currentColor.b * 255).toString();
  2920. bValInt.color = inputTextColor;
  2921. bValInt.background = inputTextBackgroundColor;
  2922. bValInt.onFocusObservable.add(function () {
  2923. activeField = bValInt.name;
  2924. lastVal = bValInt.text;
  2925. editSwatches(false);
  2926. });
  2927. bValInt.onBlurObservable.add(function () {
  2928. if (bValInt.text == "") {
  2929. bValInt.text = "0";
  2930. }
  2931. updateInt(bValInt, "b");
  2932. if (activeField == bValInt.name) {
  2933. activeField = "";
  2934. }
  2935. });
  2936. bValInt.onTextChangedObservable.add(function () {
  2937. if (activeField == bValInt.name) {
  2938. updateInt(bValInt, "b");
  2939. }
  2940. });
  2941. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2942. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2943. rValDec.width = 0.95;
  2944. rValDec.height = 0.72;
  2945. rValDec.name = "rDecField";
  2946. rValDec.fontSize = buttonFontSize;
  2947. rValDec.text = currentColor.r.toString();
  2948. rValDec.color = inputTextColor;
  2949. rValDec.background = inputTextBackgroundColor;
  2950. rValDec.onFocusObservable.add(function () {
  2951. activeField = rValDec.name;
  2952. lastVal = rValDec.text;
  2953. editSwatches(false);
  2954. });
  2955. rValDec.onBlurObservable.add(function () {
  2956. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2957. rValDec.text = "0";
  2958. updateFloat(rValDec, "r");
  2959. }
  2960. if (activeField == rValDec.name) {
  2961. activeField = "";
  2962. }
  2963. });
  2964. rValDec.onTextChangedObservable.add(function () {
  2965. if (activeField == rValDec.name) {
  2966. updateFloat(rValDec, "r");
  2967. }
  2968. });
  2969. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2970. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2971. gValDec.width = 0.95;
  2972. gValDec.height = 0.72;
  2973. gValDec.name = "gDecField";
  2974. gValDec.fontSize = buttonFontSize;
  2975. gValDec.text = currentColor.g.toString();
  2976. gValDec.color = inputTextColor;
  2977. gValDec.background = inputTextBackgroundColor;
  2978. gValDec.onFocusObservable.add(function () {
  2979. activeField = gValDec.name;
  2980. lastVal = gValDec.text;
  2981. editSwatches(false);
  2982. });
  2983. gValDec.onBlurObservable.add(function () {
  2984. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2985. gValDec.text = "0";
  2986. updateFloat(gValDec, "g");
  2987. }
  2988. if (activeField == gValDec.name) {
  2989. activeField = "";
  2990. }
  2991. });
  2992. gValDec.onTextChangedObservable.add(function () {
  2993. if (activeField == gValDec.name) {
  2994. updateFloat(gValDec, "g");
  2995. }
  2996. });
  2997. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  2998. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2999. bValDec.width = 0.95;
  3000. bValDec.height = 0.72;
  3001. bValDec.name = "bDecField";
  3002. bValDec.fontSize = buttonFontSize;
  3003. bValDec.text = currentColor.b.toString();
  3004. bValDec.color = inputTextColor;
  3005. bValDec.background = inputTextBackgroundColor;
  3006. bValDec.onFocusObservable.add(function () {
  3007. activeField = bValDec.name;
  3008. lastVal = bValDec.text;
  3009. editSwatches(false);
  3010. });
  3011. bValDec.onBlurObservable.add(function () {
  3012. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3013. bValDec.text = "0";
  3014. updateFloat(bValDec, "b");
  3015. }
  3016. if (activeField == bValDec.name) {
  3017. activeField = "";
  3018. }
  3019. });
  3020. bValDec.onTextChangedObservable.add(function () {
  3021. if (activeField == bValDec.name) {
  3022. updateFloat(bValDec, "b");
  3023. }
  3024. });
  3025. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3026. // Hex value input
  3027. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3028. hexValueQuadrant.name = "Hex Value";
  3029. hexValueQuadrant.width = 0.82;
  3030. hexValueQuadrant.addRowDefinition(1.0, false);
  3031. hexValueQuadrant.addColumnDefinition(0.1, false);
  3032. hexValueQuadrant.addColumnDefinition(0.9, false);
  3033. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3034. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3035. labelText.text = "#";
  3036. labelText.color = buttonColor;
  3037. labelText.fontSize = buttonFontSize;
  3038. hexValueQuadrant.addControl(labelText, 0, 0);
  3039. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3040. hexVal.width = 0.96;
  3041. hexVal.height = 0.72;
  3042. hexVal.name = "hexField";
  3043. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3044. hexVal.fontSize = buttonFontSize;
  3045. var minusPound = options.lastColor.split("#");
  3046. hexVal.text = minusPound[1];
  3047. hexVal.color = inputTextColor;
  3048. hexVal.background = inputTextBackgroundColor;
  3049. hexVal.onFocusObservable.add(function () {
  3050. activeField = hexVal.name;
  3051. lastVal = hexVal.text;
  3052. editSwatches(false);
  3053. });
  3054. hexVal.onBlurObservable.add(function () {
  3055. if (hexVal.text.length == 3) {
  3056. var val = hexVal.text.split("");
  3057. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3058. }
  3059. if (hexVal.text == "") {
  3060. hexVal.text = "000000";
  3061. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3062. }
  3063. if (activeField == hexVal.name) {
  3064. activeField = "";
  3065. }
  3066. });
  3067. hexVal.onTextChangedObservable.add(function () {
  3068. var newHexValue = hexVal.text;
  3069. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3070. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3071. hexVal.text = lastVal;
  3072. }
  3073. else {
  3074. if (hexVal.text.length < 6) {
  3075. var leadingZero = 6 - hexVal.text.length;
  3076. for (var i = 0; i < leadingZero; i++) {
  3077. newHexValue = "0" + newHexValue;
  3078. }
  3079. }
  3080. if (hexVal.text.length == 3) {
  3081. var val = hexVal.text.split("");
  3082. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3083. }
  3084. newHexValue = "#" + newHexValue;
  3085. if (activeField == hexVal.name) {
  3086. lastVal = hexVal.text;
  3087. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3088. }
  3089. }
  3090. });
  3091. hexValueQuadrant.addControl(hexVal, 0, 1);
  3092. if (options.savedColors && options.savedColors.length > 0) {
  3093. updateSwatches("", butSave);
  3094. }
  3095. });
  3096. };
  3097. ColorPicker._Epsilon = 0.000001;
  3098. return ColorPicker;
  3099. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3100. /***/ }),
  3101. /***/ "./2D/controls/container.ts":
  3102. /*!**********************************!*\
  3103. !*** ./2D/controls/container.ts ***!
  3104. \**********************************/
  3105. /*! exports provided: Container */
  3106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3107. "use strict";
  3108. __webpack_require__.r(__webpack_exports__);
  3109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3111. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3112. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3113. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3114. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3115. /**
  3116. * Root class for 2D containers
  3117. * @see http://doc.babylonjs.com/how_to/gui#containers
  3118. */
  3119. var Container = /** @class */ (function (_super) {
  3120. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container, _super);
  3121. /**
  3122. * Creates a new Container
  3123. * @param name defines the name of the container
  3124. */
  3125. function Container(name) {
  3126. var _this = _super.call(this, name) || this;
  3127. _this.name = name;
  3128. /** @hidden */
  3129. _this._children = new Array();
  3130. /** @hidden */
  3131. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3132. /** @hidden */
  3133. _this._background = "";
  3134. /** @hidden */
  3135. _this._adaptWidthToChildren = false;
  3136. /** @hidden */
  3137. _this._adaptHeightToChildren = false;
  3138. return _this;
  3139. }
  3140. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3141. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3142. get: function () {
  3143. return this._adaptHeightToChildren;
  3144. },
  3145. set: function (value) {
  3146. if (this._adaptHeightToChildren === value) {
  3147. return;
  3148. }
  3149. this._adaptHeightToChildren = value;
  3150. if (value) {
  3151. this.height = "100%";
  3152. }
  3153. this._markAsDirty();
  3154. },
  3155. enumerable: true,
  3156. configurable: true
  3157. });
  3158. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3159. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3160. get: function () {
  3161. return this._adaptWidthToChildren;
  3162. },
  3163. set: function (value) {
  3164. if (this._adaptWidthToChildren === value) {
  3165. return;
  3166. }
  3167. this._adaptWidthToChildren = value;
  3168. if (value) {
  3169. this.width = "100%";
  3170. }
  3171. this._markAsDirty();
  3172. },
  3173. enumerable: true,
  3174. configurable: true
  3175. });
  3176. Object.defineProperty(Container.prototype, "background", {
  3177. /** Gets or sets background color */
  3178. get: function () {
  3179. return this._background;
  3180. },
  3181. set: function (value) {
  3182. if (this._background === value) {
  3183. return;
  3184. }
  3185. this._background = value;
  3186. this._markAsDirty();
  3187. },
  3188. enumerable: true,
  3189. configurable: true
  3190. });
  3191. Object.defineProperty(Container.prototype, "children", {
  3192. /** Gets the list of children */
  3193. get: function () {
  3194. return this._children;
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Container.prototype._getTypeName = function () {
  3200. return "Container";
  3201. };
  3202. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3203. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3204. var child = _a[_i];
  3205. child._markMatrixAsDirty();
  3206. }
  3207. };
  3208. /**
  3209. * Gets a child using its name
  3210. * @param name defines the child name to look for
  3211. * @returns the child control if found
  3212. */
  3213. Container.prototype.getChildByName = function (name) {
  3214. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3215. var child = _a[_i];
  3216. if (child.name === name) {
  3217. return child;
  3218. }
  3219. }
  3220. return null;
  3221. };
  3222. /**
  3223. * Gets a child using its type and its name
  3224. * @param name defines the child name to look for
  3225. * @param type defines the child type to look for
  3226. * @returns the child control if found
  3227. */
  3228. Container.prototype.getChildByType = function (name, type) {
  3229. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3230. var child = _a[_i];
  3231. if (child.typeName === type) {
  3232. return child;
  3233. }
  3234. }
  3235. return null;
  3236. };
  3237. /**
  3238. * Search for a specific control in children
  3239. * @param control defines the control to look for
  3240. * @returns true if the control is in child list
  3241. */
  3242. Container.prototype.containsControl = function (control) {
  3243. return this.children.indexOf(control) !== -1;
  3244. };
  3245. /**
  3246. * Adds a new control to the current container
  3247. * @param control defines the control to add
  3248. * @returns the current container
  3249. */
  3250. Container.prototype.addControl = function (control) {
  3251. if (!control) {
  3252. return this;
  3253. }
  3254. var index = this._children.indexOf(control);
  3255. if (index !== -1) {
  3256. return this;
  3257. }
  3258. control._link(this._host);
  3259. control._markAllAsDirty();
  3260. this._reOrderControl(control);
  3261. this._markAsDirty();
  3262. return this;
  3263. };
  3264. /**
  3265. * Removes all controls from the current container
  3266. * @returns the current container
  3267. */
  3268. Container.prototype.clearControls = function () {
  3269. var children = this.children.slice();
  3270. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3271. var child = children_1[_i];
  3272. this.removeControl(child);
  3273. }
  3274. return this;
  3275. };
  3276. /**
  3277. * Removes a control from the current container
  3278. * @param control defines the control to remove
  3279. * @returns the current container
  3280. */
  3281. Container.prototype.removeControl = function (control) {
  3282. var index = this._children.indexOf(control);
  3283. if (index !== -1) {
  3284. this._children.splice(index, 1);
  3285. control.parent = null;
  3286. }
  3287. control.linkWithMesh(null);
  3288. if (this._host) {
  3289. this._host._cleanControlAfterRemoval(control);
  3290. }
  3291. this._markAsDirty();
  3292. return this;
  3293. };
  3294. /** @hidden */
  3295. Container.prototype._reOrderControl = function (control) {
  3296. this.removeControl(control);
  3297. var wasAdded = false;
  3298. for (var index = 0; index < this._children.length; index++) {
  3299. if (this._children[index].zIndex > control.zIndex) {
  3300. this._children.splice(index, 0, control);
  3301. wasAdded = true;
  3302. break;
  3303. }
  3304. }
  3305. if (!wasAdded) {
  3306. this._children.push(control);
  3307. }
  3308. control.parent = this;
  3309. this._markAsDirty();
  3310. };
  3311. /** @hidden */
  3312. Container.prototype._offsetLeft = function (offset) {
  3313. _super.prototype._offsetLeft.call(this, offset);
  3314. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3315. var child = _a[_i];
  3316. child._offsetLeft(offset);
  3317. }
  3318. };
  3319. /** @hidden */
  3320. Container.prototype._offsetTop = function (offset) {
  3321. _super.prototype._offsetTop.call(this, offset);
  3322. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3323. var child = _a[_i];
  3324. child._offsetTop(offset);
  3325. }
  3326. };
  3327. /** @hidden */
  3328. Container.prototype._markAllAsDirty = function () {
  3329. _super.prototype._markAllAsDirty.call(this);
  3330. for (var index = 0; index < this._children.length; index++) {
  3331. this._children[index]._markAllAsDirty();
  3332. }
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._localDraw = function (context) {
  3336. if (this._background) {
  3337. context.save();
  3338. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3339. context.shadowColor = this.shadowColor;
  3340. context.shadowBlur = this.shadowBlur;
  3341. context.shadowOffsetX = this.shadowOffsetX;
  3342. context.shadowOffsetY = this.shadowOffsetY;
  3343. }
  3344. context.fillStyle = this._background;
  3345. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3346. context.restore();
  3347. }
  3348. };
  3349. /** @hidden */
  3350. Container.prototype._link = function (host) {
  3351. _super.prototype._link.call(this, host);
  3352. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3353. var child = _a[_i];
  3354. child._link(host);
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._beforeLayout = function () {
  3359. // Do nothing
  3360. };
  3361. /** @hidden */
  3362. Container.prototype._processMeasures = function (parentMeasure, context) {
  3363. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3364. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3365. this._evaluateClippingState(parentMeasure);
  3366. }
  3367. };
  3368. /** @hidden */
  3369. Container.prototype._layout = function (parentMeasure, context) {
  3370. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3371. return false;
  3372. }
  3373. if (this._isDirty) {
  3374. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3375. }
  3376. var rebuildCount = 0;
  3377. context.save();
  3378. this._applyStates(context);
  3379. this._beforeLayout();
  3380. do {
  3381. var computedWidth = -1;
  3382. var computedHeight = -1;
  3383. this._rebuildLayout = false;
  3384. this._processMeasures(parentMeasure, context);
  3385. if (!this._isClipped) {
  3386. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3387. var child = _a[_i];
  3388. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3389. if (child._layout(this._measureForChildren, context)) {
  3390. if (this.adaptWidthToChildren && child._width.isPixel) {
  3391. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3392. }
  3393. if (this.adaptHeightToChildren && child._height.isPixel) {
  3394. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3395. }
  3396. }
  3397. }
  3398. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3399. if (this.width !== computedWidth + "px") {
  3400. this.width = computedWidth + "px";
  3401. this._rebuildLayout = true;
  3402. }
  3403. }
  3404. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3405. if (this.height !== computedHeight + "px") {
  3406. this.height = computedHeight + "px";
  3407. this._rebuildLayout = true;
  3408. }
  3409. }
  3410. this._postMeasure();
  3411. }
  3412. rebuildCount++;
  3413. } while (this._rebuildLayout && rebuildCount < 3);
  3414. if (rebuildCount >= 3) {
  3415. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3416. }
  3417. context.restore();
  3418. if (this._isDirty) {
  3419. this.invalidateRect();
  3420. this._isDirty = false;
  3421. }
  3422. return true;
  3423. };
  3424. Container.prototype._postMeasure = function () {
  3425. // Do nothing by default
  3426. };
  3427. /** @hidden */
  3428. Container.prototype._draw = function (context, invalidatedRectangle) {
  3429. this._localDraw(context);
  3430. if (this.clipChildren) {
  3431. this._clipForChildren(context);
  3432. }
  3433. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3434. var child = _a[_i];
  3435. // Only redraw parts of the screen that are invalidated
  3436. if (invalidatedRectangle) {
  3437. if (!child._intersectsRect(invalidatedRectangle)) {
  3438. continue;
  3439. }
  3440. }
  3441. child._render(context, invalidatedRectangle);
  3442. }
  3443. };
  3444. /** @hidden */
  3445. Container.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  3446. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3447. if (!this.children) {
  3448. return;
  3449. }
  3450. for (var index = 0; index < this.children.length; index++) {
  3451. var item = this.children[index];
  3452. if (!predicate || predicate(item)) {
  3453. results.push(item);
  3454. }
  3455. if (!directDescendantsOnly) {
  3456. item._getDescendants(results, false, predicate);
  3457. }
  3458. }
  3459. };
  3460. /** @hidden */
  3461. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3462. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3463. return false;
  3464. }
  3465. if (!_super.prototype.contains.call(this, x, y)) {
  3466. return false;
  3467. }
  3468. // Checking backwards to pick closest first
  3469. for (var index = this._children.length - 1; index >= 0; index--) {
  3470. var child = this._children[index];
  3471. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3472. if (child.hoverCursor) {
  3473. this._host._changeCursor(child.hoverCursor);
  3474. }
  3475. return true;
  3476. }
  3477. }
  3478. if (!this.isHitTestVisible) {
  3479. return false;
  3480. }
  3481. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3482. };
  3483. /** @hidden */
  3484. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3485. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3486. this._measureForChildren.copyFrom(this._currentMeasure);
  3487. };
  3488. /** Releases associated resources */
  3489. Container.prototype.dispose = function () {
  3490. _super.prototype.dispose.call(this);
  3491. for (var index = this.children.length - 1; index >= 0; index--) {
  3492. this.children[index].dispose();
  3493. }
  3494. };
  3495. return Container;
  3496. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3497. /***/ }),
  3498. /***/ "./2D/controls/control.ts":
  3499. /*!********************************!*\
  3500. !*** ./2D/controls/control.ts ***!
  3501. \********************************/
  3502. /*! exports provided: Control */
  3503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3504. "use strict";
  3505. __webpack_require__.r(__webpack_exports__);
  3506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3507. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3508. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3509. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3510. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3511. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3512. /**
  3513. * Root class used for all 2D controls
  3514. * @see http://doc.babylonjs.com/how_to/gui#controls
  3515. */
  3516. var Control = /** @class */ (function () {
  3517. // Functions
  3518. /**
  3519. * Creates a new control
  3520. * @param name defines the name of the control
  3521. */
  3522. function Control(
  3523. /** defines the name of the control */
  3524. name) {
  3525. this.name = name;
  3526. this._alpha = 1;
  3527. this._alphaSet = false;
  3528. this._zIndex = 0;
  3529. /** @hidden */
  3530. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3531. this._fontFamily = "Arial";
  3532. this._fontStyle = "";
  3533. this._fontWeight = "";
  3534. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3535. /** @hidden */
  3536. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3537. /** @hidden */
  3538. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3539. this._color = "";
  3540. this._style = null;
  3541. /** @hidden */
  3542. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3543. /** @hidden */
  3544. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3545. /** @hidden */
  3546. this._isDirty = true;
  3547. /** @hidden */
  3548. this._wasDirty = false;
  3549. /** @hidden */
  3550. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3551. /** @hidden */
  3552. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3553. /** @hidden */
  3554. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3555. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3556. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3557. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3558. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3559. /** @hidden */
  3560. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3561. /** @hidden */
  3562. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3563. this._scaleX = 1.0;
  3564. this._scaleY = 1.0;
  3565. this._rotation = 0;
  3566. this._transformCenterX = 0.5;
  3567. this._transformCenterY = 0.5;
  3568. /** @hidden */
  3569. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3570. /** @hidden */
  3571. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3572. /** @hidden */
  3573. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3574. this._isMatrixDirty = true;
  3575. this._isVisible = true;
  3576. this._isHighlighted = false;
  3577. this._fontSet = false;
  3578. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3579. this._downCount = 0;
  3580. this._enterCount = -1;
  3581. this._doNotRender = false;
  3582. this._downPointerIds = {};
  3583. this._isEnabled = true;
  3584. this._disabledColor = "#9a9a9a";
  3585. /** @hidden */
  3586. this._rebuildLayout = false;
  3587. /** @hidden */
  3588. this._isClipped = false;
  3589. /**
  3590. * Gets or sets an object used to store user defined information for the node
  3591. */
  3592. this.metadata = null;
  3593. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3594. this.isHitTestVisible = true;
  3595. /** Gets or sets a boolean indicating if the control can block pointer events */
  3596. this.isPointerBlocker = false;
  3597. /** Gets or sets a boolean indicating if the control can be focusable */
  3598. this.isFocusInvisible = false;
  3599. /**
  3600. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3601. * 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
  3602. */
  3603. this.clipChildren = true;
  3604. /**
  3605. * Gets or sets a boolean indicating that control content must be clipped
  3606. * 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
  3607. */
  3608. this.clipContent = true;
  3609. /**
  3610. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3611. */
  3612. this.useBitmapCache = false;
  3613. this._shadowOffsetX = 0;
  3614. this._shadowOffsetY = 0;
  3615. this._shadowBlur = 0;
  3616. this._shadowColor = 'black';
  3617. /** Gets or sets the cursor to use when the control is hovered */
  3618. this.hoverCursor = "";
  3619. /** @hidden */
  3620. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3621. /** @hidden */
  3622. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3623. /**
  3624. * An event triggered when the pointer move over the control.
  3625. */
  3626. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3627. /**
  3628. * An event triggered when the pointer move out of the control.
  3629. */
  3630. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3631. /**
  3632. * An event triggered when the pointer taps the control
  3633. */
  3634. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3635. /**
  3636. * An event triggered when pointer up
  3637. */
  3638. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3639. /**
  3640. * An event triggered when a control is clicked on
  3641. */
  3642. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3643. /**
  3644. * An event triggered when pointer enters the control
  3645. */
  3646. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3647. /**
  3648. * An event triggered when the control is marked as dirty
  3649. */
  3650. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3651. /**
  3652. * An event triggered before drawing the control
  3653. */
  3654. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3655. /**
  3656. * An event triggered after the control was drawn
  3657. */
  3658. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3659. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3660. }
  3661. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3662. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3663. get: function () {
  3664. return this._shadowOffsetX;
  3665. },
  3666. set: function (value) {
  3667. if (this._shadowOffsetX === value) {
  3668. return;
  3669. }
  3670. this._shadowOffsetX = value;
  3671. this._markAsDirty();
  3672. },
  3673. enumerable: true,
  3674. configurable: true
  3675. });
  3676. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3677. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3678. get: function () {
  3679. return this._shadowOffsetY;
  3680. },
  3681. set: function (value) {
  3682. if (this._shadowOffsetY === value) {
  3683. return;
  3684. }
  3685. this._shadowOffsetY = value;
  3686. this._markAsDirty();
  3687. },
  3688. enumerable: true,
  3689. configurable: true
  3690. });
  3691. Object.defineProperty(Control.prototype, "shadowBlur", {
  3692. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3693. get: function () {
  3694. return this._shadowBlur;
  3695. },
  3696. set: function (value) {
  3697. if (this._shadowBlur === value) {
  3698. return;
  3699. }
  3700. this._shadowBlur = value;
  3701. this._markAsDirty();
  3702. },
  3703. enumerable: true,
  3704. configurable: true
  3705. });
  3706. Object.defineProperty(Control.prototype, "shadowColor", {
  3707. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3708. get: function () {
  3709. return this._shadowColor;
  3710. },
  3711. set: function (value) {
  3712. if (this._shadowColor === value) {
  3713. return;
  3714. }
  3715. this._shadowColor = value;
  3716. this._markAsDirty();
  3717. },
  3718. enumerable: true,
  3719. configurable: true
  3720. });
  3721. Object.defineProperty(Control.prototype, "typeName", {
  3722. // Properties
  3723. /** Gets the control type name */
  3724. get: function () {
  3725. return this._getTypeName();
  3726. },
  3727. enumerable: true,
  3728. configurable: true
  3729. });
  3730. /**
  3731. * Get the current class name of the control.
  3732. * @returns current class name
  3733. */
  3734. Control.prototype.getClassName = function () {
  3735. return this._getTypeName();
  3736. };
  3737. Object.defineProperty(Control.prototype, "host", {
  3738. /**
  3739. * Get the hosting AdvancedDynamicTexture
  3740. */
  3741. get: function () {
  3742. return this._host;
  3743. },
  3744. enumerable: true,
  3745. configurable: true
  3746. });
  3747. Object.defineProperty(Control.prototype, "fontOffset", {
  3748. /** Gets or set information about font offsets (used to render and align text) */
  3749. get: function () {
  3750. return this._fontOffset;
  3751. },
  3752. set: function (offset) {
  3753. this._fontOffset = offset;
  3754. },
  3755. enumerable: true,
  3756. configurable: true
  3757. });
  3758. Object.defineProperty(Control.prototype, "alpha", {
  3759. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3760. get: function () {
  3761. return this._alpha;
  3762. },
  3763. set: function (value) {
  3764. if (this._alpha === value) {
  3765. return;
  3766. }
  3767. this._alphaSet = true;
  3768. this._alpha = value;
  3769. this._markAsDirty();
  3770. },
  3771. enumerable: true,
  3772. configurable: true
  3773. });
  3774. Object.defineProperty(Control.prototype, "isHighlighted", {
  3775. /**
  3776. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3777. */
  3778. get: function () {
  3779. return this._isHighlighted;
  3780. },
  3781. set: function (value) {
  3782. if (this._isHighlighted === value) {
  3783. return;
  3784. }
  3785. this._isHighlighted = value;
  3786. this._markAsDirty();
  3787. },
  3788. enumerable: true,
  3789. configurable: true
  3790. });
  3791. Object.defineProperty(Control.prototype, "scaleX", {
  3792. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3793. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3794. */
  3795. get: function () {
  3796. return this._scaleX;
  3797. },
  3798. set: function (value) {
  3799. if (this._scaleX === value) {
  3800. return;
  3801. }
  3802. this._scaleX = value;
  3803. this._markAsDirty();
  3804. this._markMatrixAsDirty();
  3805. },
  3806. enumerable: true,
  3807. configurable: true
  3808. });
  3809. Object.defineProperty(Control.prototype, "scaleY", {
  3810. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3811. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3812. */
  3813. get: function () {
  3814. return this._scaleY;
  3815. },
  3816. set: function (value) {
  3817. if (this._scaleY === value) {
  3818. return;
  3819. }
  3820. this._scaleY = value;
  3821. this._markAsDirty();
  3822. this._markMatrixAsDirty();
  3823. },
  3824. enumerable: true,
  3825. configurable: true
  3826. });
  3827. Object.defineProperty(Control.prototype, "rotation", {
  3828. /** Gets or sets the rotation angle (0 by default)
  3829. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3830. */
  3831. get: function () {
  3832. return this._rotation;
  3833. },
  3834. set: function (value) {
  3835. if (this._rotation === value) {
  3836. return;
  3837. }
  3838. this._rotation = value;
  3839. this._markAsDirty();
  3840. this._markMatrixAsDirty();
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. Object.defineProperty(Control.prototype, "transformCenterY", {
  3846. /** Gets or sets the transformation center on Y axis (0 by default)
  3847. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3848. */
  3849. get: function () {
  3850. return this._transformCenterY;
  3851. },
  3852. set: function (value) {
  3853. if (this._transformCenterY === value) {
  3854. return;
  3855. }
  3856. this._transformCenterY = value;
  3857. this._markAsDirty();
  3858. this._markMatrixAsDirty();
  3859. },
  3860. enumerable: true,
  3861. configurable: true
  3862. });
  3863. Object.defineProperty(Control.prototype, "transformCenterX", {
  3864. /** Gets or sets the transformation center on X axis (0 by default)
  3865. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3866. */
  3867. get: function () {
  3868. return this._transformCenterX;
  3869. },
  3870. set: function (value) {
  3871. if (this._transformCenterX === value) {
  3872. return;
  3873. }
  3874. this._transformCenterX = value;
  3875. this._markAsDirty();
  3876. this._markMatrixAsDirty();
  3877. },
  3878. enumerable: true,
  3879. configurable: true
  3880. });
  3881. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3882. /**
  3883. * Gets or sets the horizontal alignment
  3884. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3885. */
  3886. get: function () {
  3887. return this._horizontalAlignment;
  3888. },
  3889. set: function (value) {
  3890. if (this._horizontalAlignment === value) {
  3891. return;
  3892. }
  3893. this._horizontalAlignment = value;
  3894. this._markAsDirty();
  3895. },
  3896. enumerable: true,
  3897. configurable: true
  3898. });
  3899. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3900. /**
  3901. * Gets or sets the vertical alignment
  3902. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3903. */
  3904. get: function () {
  3905. return this._verticalAlignment;
  3906. },
  3907. set: function (value) {
  3908. if (this._verticalAlignment === value) {
  3909. return;
  3910. }
  3911. this._verticalAlignment = value;
  3912. this._markAsDirty();
  3913. },
  3914. enumerable: true,
  3915. configurable: true
  3916. });
  3917. Object.defineProperty(Control.prototype, "width", {
  3918. /**
  3919. * Gets or sets control width
  3920. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3921. */
  3922. get: function () {
  3923. return this._width.toString(this._host);
  3924. },
  3925. set: function (value) {
  3926. if (this._width.toString(this._host) === value) {
  3927. return;
  3928. }
  3929. if (this._width.fromString(value)) {
  3930. this._markAsDirty();
  3931. }
  3932. },
  3933. enumerable: true,
  3934. configurable: true
  3935. });
  3936. Object.defineProperty(Control.prototype, "widthInPixels", {
  3937. /**
  3938. * Gets or sets the control width in pixel
  3939. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3940. */
  3941. get: function () {
  3942. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3943. },
  3944. set: function (value) {
  3945. if (isNaN(value)) {
  3946. return;
  3947. }
  3948. this.width = value + "px";
  3949. },
  3950. enumerable: true,
  3951. configurable: true
  3952. });
  3953. Object.defineProperty(Control.prototype, "height", {
  3954. /**
  3955. * Gets or sets control height
  3956. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3957. */
  3958. get: function () {
  3959. return this._height.toString(this._host);
  3960. },
  3961. set: function (value) {
  3962. if (this._height.toString(this._host) === value) {
  3963. return;
  3964. }
  3965. if (this._height.fromString(value)) {
  3966. this._markAsDirty();
  3967. }
  3968. },
  3969. enumerable: true,
  3970. configurable: true
  3971. });
  3972. Object.defineProperty(Control.prototype, "heightInPixels", {
  3973. /**
  3974. * Gets or sets control height in pixel
  3975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3976. */
  3977. get: function () {
  3978. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  3979. },
  3980. set: function (value) {
  3981. if (isNaN(value)) {
  3982. return;
  3983. }
  3984. this.height = value + "px";
  3985. },
  3986. enumerable: true,
  3987. configurable: true
  3988. });
  3989. Object.defineProperty(Control.prototype, "fontFamily", {
  3990. /** Gets or set font family */
  3991. get: function () {
  3992. if (!this._fontSet) {
  3993. return "";
  3994. }
  3995. return this._fontFamily;
  3996. },
  3997. set: function (value) {
  3998. if (this._fontFamily === value) {
  3999. return;
  4000. }
  4001. this._fontFamily = value;
  4002. this._resetFontCache();
  4003. },
  4004. enumerable: true,
  4005. configurable: true
  4006. });
  4007. Object.defineProperty(Control.prototype, "fontStyle", {
  4008. /** Gets or sets font style */
  4009. get: function () {
  4010. return this._fontStyle;
  4011. },
  4012. set: function (value) {
  4013. if (this._fontStyle === value) {
  4014. return;
  4015. }
  4016. this._fontStyle = value;
  4017. this._resetFontCache();
  4018. },
  4019. enumerable: true,
  4020. configurable: true
  4021. });
  4022. Object.defineProperty(Control.prototype, "fontWeight", {
  4023. /** Gets or sets font weight */
  4024. get: function () {
  4025. return this._fontWeight;
  4026. },
  4027. set: function (value) {
  4028. if (this._fontWeight === value) {
  4029. return;
  4030. }
  4031. this._fontWeight = value;
  4032. this._resetFontCache();
  4033. },
  4034. enumerable: true,
  4035. configurable: true
  4036. });
  4037. Object.defineProperty(Control.prototype, "style", {
  4038. /**
  4039. * Gets or sets style
  4040. * @see http://doc.babylonjs.com/how_to/gui#styles
  4041. */
  4042. get: function () {
  4043. return this._style;
  4044. },
  4045. set: function (value) {
  4046. var _this = this;
  4047. if (this._style) {
  4048. this._style.onChangedObservable.remove(this._styleObserver);
  4049. this._styleObserver = null;
  4050. }
  4051. this._style = value;
  4052. if (this._style) {
  4053. this._styleObserver = this._style.onChangedObservable.add(function () {
  4054. _this._markAsDirty();
  4055. _this._resetFontCache();
  4056. });
  4057. }
  4058. this._markAsDirty();
  4059. this._resetFontCache();
  4060. },
  4061. enumerable: true,
  4062. configurable: true
  4063. });
  4064. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4065. /** @hidden */
  4066. get: function () {
  4067. return this._fontSize.isPercentage;
  4068. },
  4069. enumerable: true,
  4070. configurable: true
  4071. });
  4072. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4073. /** Gets or sets font size in pixels */
  4074. get: function () {
  4075. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4076. if (fontSizeToUse.isPixel) {
  4077. return fontSizeToUse.getValue(this._host);
  4078. }
  4079. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4080. },
  4081. set: function (value) {
  4082. if (isNaN(value)) {
  4083. return;
  4084. }
  4085. this.fontSize = value + "px";
  4086. },
  4087. enumerable: true,
  4088. configurable: true
  4089. });
  4090. Object.defineProperty(Control.prototype, "fontSize", {
  4091. /** Gets or sets font size */
  4092. get: function () {
  4093. return this._fontSize.toString(this._host);
  4094. },
  4095. set: function (value) {
  4096. if (this._fontSize.toString(this._host) === value) {
  4097. return;
  4098. }
  4099. if (this._fontSize.fromString(value)) {
  4100. this._markAsDirty();
  4101. this._resetFontCache();
  4102. }
  4103. },
  4104. enumerable: true,
  4105. configurable: true
  4106. });
  4107. Object.defineProperty(Control.prototype, "color", {
  4108. /** Gets or sets foreground color */
  4109. get: function () {
  4110. return this._color;
  4111. },
  4112. set: function (value) {
  4113. if (this._color === value) {
  4114. return;
  4115. }
  4116. this._color = value;
  4117. this._markAsDirty();
  4118. },
  4119. enumerable: true,
  4120. configurable: true
  4121. });
  4122. Object.defineProperty(Control.prototype, "zIndex", {
  4123. /** Gets or sets z index which is used to reorder controls on the z axis */
  4124. get: function () {
  4125. return this._zIndex;
  4126. },
  4127. set: function (value) {
  4128. if (this.zIndex === value) {
  4129. return;
  4130. }
  4131. this._zIndex = value;
  4132. if (this.parent) {
  4133. this.parent._reOrderControl(this);
  4134. }
  4135. },
  4136. enumerable: true,
  4137. configurable: true
  4138. });
  4139. Object.defineProperty(Control.prototype, "notRenderable", {
  4140. /** Gets or sets a boolean indicating if the control can be rendered */
  4141. get: function () {
  4142. return this._doNotRender;
  4143. },
  4144. set: function (value) {
  4145. if (this._doNotRender === value) {
  4146. return;
  4147. }
  4148. this._doNotRender = value;
  4149. this._markAsDirty();
  4150. },
  4151. enumerable: true,
  4152. configurable: true
  4153. });
  4154. Object.defineProperty(Control.prototype, "isVisible", {
  4155. /** Gets or sets a boolean indicating if the control is visible */
  4156. get: function () {
  4157. return this._isVisible;
  4158. },
  4159. set: function (value) {
  4160. if (this._isVisible === value) {
  4161. return;
  4162. }
  4163. this._isVisible = value;
  4164. this._markAsDirty(true);
  4165. },
  4166. enumerable: true,
  4167. configurable: true
  4168. });
  4169. Object.defineProperty(Control.prototype, "isDirty", {
  4170. /** Gets a boolean indicating that the control needs to update its rendering */
  4171. get: function () {
  4172. return this._isDirty;
  4173. },
  4174. enumerable: true,
  4175. configurable: true
  4176. });
  4177. Object.defineProperty(Control.prototype, "linkedMesh", {
  4178. /**
  4179. * Gets the current linked mesh (or null if none)
  4180. */
  4181. get: function () {
  4182. return this._linkedMesh;
  4183. },
  4184. enumerable: true,
  4185. configurable: true
  4186. });
  4187. Object.defineProperty(Control.prototype, "paddingLeft", {
  4188. /**
  4189. * Gets or sets a value indicating the padding to use on the left of the control
  4190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4191. */
  4192. get: function () {
  4193. return this._paddingLeft.toString(this._host);
  4194. },
  4195. set: function (value) {
  4196. if (this._paddingLeft.fromString(value)) {
  4197. this._markAsDirty();
  4198. }
  4199. },
  4200. enumerable: true,
  4201. configurable: true
  4202. });
  4203. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4204. /**
  4205. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4206. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4207. */
  4208. get: function () {
  4209. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4210. },
  4211. set: function (value) {
  4212. if (isNaN(value)) {
  4213. return;
  4214. }
  4215. this.paddingLeft = value + "px";
  4216. },
  4217. enumerable: true,
  4218. configurable: true
  4219. });
  4220. Object.defineProperty(Control.prototype, "paddingRight", {
  4221. /**
  4222. * Gets or sets a value indicating the padding to use on the right of the control
  4223. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4224. */
  4225. get: function () {
  4226. return this._paddingRight.toString(this._host);
  4227. },
  4228. set: function (value) {
  4229. if (this._paddingRight.fromString(value)) {
  4230. this._markAsDirty();
  4231. }
  4232. },
  4233. enumerable: true,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4237. /**
  4238. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4240. */
  4241. get: function () {
  4242. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4243. },
  4244. set: function (value) {
  4245. if (isNaN(value)) {
  4246. return;
  4247. }
  4248. this.paddingRight = value + "px";
  4249. },
  4250. enumerable: true,
  4251. configurable: true
  4252. });
  4253. Object.defineProperty(Control.prototype, "paddingTop", {
  4254. /**
  4255. * Gets or sets a value indicating the padding to use on the top of the control
  4256. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4257. */
  4258. get: function () {
  4259. return this._paddingTop.toString(this._host);
  4260. },
  4261. set: function (value) {
  4262. if (this._paddingTop.fromString(value)) {
  4263. this._markAsDirty();
  4264. }
  4265. },
  4266. enumerable: true,
  4267. configurable: true
  4268. });
  4269. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4270. /**
  4271. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4272. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4273. */
  4274. get: function () {
  4275. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4276. },
  4277. set: function (value) {
  4278. if (isNaN(value)) {
  4279. return;
  4280. }
  4281. this.paddingTop = value + "px";
  4282. },
  4283. enumerable: true,
  4284. configurable: true
  4285. });
  4286. Object.defineProperty(Control.prototype, "paddingBottom", {
  4287. /**
  4288. * Gets or sets a value indicating the padding to use on the bottom of the control
  4289. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4290. */
  4291. get: function () {
  4292. return this._paddingBottom.toString(this._host);
  4293. },
  4294. set: function (value) {
  4295. if (this._paddingBottom.fromString(value)) {
  4296. this._markAsDirty();
  4297. }
  4298. },
  4299. enumerable: true,
  4300. configurable: true
  4301. });
  4302. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4303. /**
  4304. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4305. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4306. */
  4307. get: function () {
  4308. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4309. },
  4310. set: function (value) {
  4311. if (isNaN(value)) {
  4312. return;
  4313. }
  4314. this.paddingBottom = value + "px";
  4315. },
  4316. enumerable: true,
  4317. configurable: true
  4318. });
  4319. Object.defineProperty(Control.prototype, "left", {
  4320. /**
  4321. * Gets or sets a value indicating the left coordinate of the control
  4322. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4323. */
  4324. get: function () {
  4325. return this._left.toString(this._host);
  4326. },
  4327. set: function (value) {
  4328. if (this._left.fromString(value)) {
  4329. this._markAsDirty();
  4330. }
  4331. },
  4332. enumerable: true,
  4333. configurable: true
  4334. });
  4335. Object.defineProperty(Control.prototype, "leftInPixels", {
  4336. /**
  4337. * Gets or sets a value indicating the left coordinate in pixels of the control
  4338. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4339. */
  4340. get: function () {
  4341. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4342. },
  4343. set: function (value) {
  4344. if (isNaN(value)) {
  4345. return;
  4346. }
  4347. this.left = value + "px";
  4348. },
  4349. enumerable: true,
  4350. configurable: true
  4351. });
  4352. Object.defineProperty(Control.prototype, "top", {
  4353. /**
  4354. * Gets or sets a value indicating the top coordinate of the control
  4355. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4356. */
  4357. get: function () {
  4358. return this._top.toString(this._host);
  4359. },
  4360. set: function (value) {
  4361. if (this._top.fromString(value)) {
  4362. this._markAsDirty();
  4363. }
  4364. },
  4365. enumerable: true,
  4366. configurable: true
  4367. });
  4368. Object.defineProperty(Control.prototype, "topInPixels", {
  4369. /**
  4370. * Gets or sets a value indicating the top coordinate in pixels of the control
  4371. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4372. */
  4373. get: function () {
  4374. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4375. },
  4376. set: function (value) {
  4377. if (isNaN(value)) {
  4378. return;
  4379. }
  4380. this.top = value + "px";
  4381. },
  4382. enumerable: true,
  4383. configurable: true
  4384. });
  4385. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4386. /**
  4387. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4388. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4389. */
  4390. get: function () {
  4391. return this._linkOffsetX.toString(this._host);
  4392. },
  4393. set: function (value) {
  4394. if (this._linkOffsetX.fromString(value)) {
  4395. this._markAsDirty();
  4396. }
  4397. },
  4398. enumerable: true,
  4399. configurable: true
  4400. });
  4401. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4402. /**
  4403. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4404. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4405. */
  4406. get: function () {
  4407. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4408. },
  4409. set: function (value) {
  4410. if (isNaN(value)) {
  4411. return;
  4412. }
  4413. this.linkOffsetX = value + "px";
  4414. },
  4415. enumerable: true,
  4416. configurable: true
  4417. });
  4418. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4419. /**
  4420. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4421. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4422. */
  4423. get: function () {
  4424. return this._linkOffsetY.toString(this._host);
  4425. },
  4426. set: function (value) {
  4427. if (this._linkOffsetY.fromString(value)) {
  4428. this._markAsDirty();
  4429. }
  4430. },
  4431. enumerable: true,
  4432. configurable: true
  4433. });
  4434. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4435. /**
  4436. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4437. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4438. */
  4439. get: function () {
  4440. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4441. },
  4442. set: function (value) {
  4443. if (isNaN(value)) {
  4444. return;
  4445. }
  4446. this.linkOffsetY = value + "px";
  4447. },
  4448. enumerable: true,
  4449. configurable: true
  4450. });
  4451. Object.defineProperty(Control.prototype, "centerX", {
  4452. /** Gets the center coordinate on X axis */
  4453. get: function () {
  4454. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "centerY", {
  4460. /** Gets the center coordinate on Y axis */
  4461. get: function () {
  4462. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4463. },
  4464. enumerable: true,
  4465. configurable: true
  4466. });
  4467. Object.defineProperty(Control.prototype, "isEnabled", {
  4468. /** Gets or sets if control is Enabled*/
  4469. get: function () {
  4470. return this._isEnabled;
  4471. },
  4472. set: function (value) {
  4473. if (this._isEnabled === value) {
  4474. return;
  4475. }
  4476. this._isEnabled = value;
  4477. this._markAsDirty();
  4478. },
  4479. enumerable: true,
  4480. configurable: true
  4481. });
  4482. Object.defineProperty(Control.prototype, "disabledColor", {
  4483. /** Gets or sets background color of control if it's disabled*/
  4484. get: function () {
  4485. return this._disabledColor;
  4486. },
  4487. set: function (value) {
  4488. if (this._disabledColor === value) {
  4489. return;
  4490. }
  4491. this._disabledColor = value;
  4492. this._markAsDirty();
  4493. },
  4494. enumerable: true,
  4495. configurable: true
  4496. });
  4497. /** @hidden */
  4498. Control.prototype._getTypeName = function () {
  4499. return "Control";
  4500. };
  4501. /**
  4502. * Gets the first ascendant in the hierarchy of the given type
  4503. * @param className defines the required type
  4504. * @returns the ascendant or null if not found
  4505. */
  4506. Control.prototype.getAscendantOfClass = function (className) {
  4507. if (!this.parent) {
  4508. return null;
  4509. }
  4510. if (this.parent.getClassName() === className) {
  4511. return this.parent;
  4512. }
  4513. return this.parent.getAscendantOfClass(className);
  4514. };
  4515. /** @hidden */
  4516. Control.prototype._resetFontCache = function () {
  4517. this._fontSet = true;
  4518. this._markAsDirty();
  4519. };
  4520. /**
  4521. * Determines if a container is an ascendant of the current control
  4522. * @param container defines the container to look for
  4523. * @returns true if the container is one of the ascendant of the control
  4524. */
  4525. Control.prototype.isAscendant = function (container) {
  4526. if (!this.parent) {
  4527. return false;
  4528. }
  4529. if (this.parent === container) {
  4530. return true;
  4531. }
  4532. return this.parent.isAscendant(container);
  4533. };
  4534. /**
  4535. * Gets coordinates in local control space
  4536. * @param globalCoordinates defines the coordinates to transform
  4537. * @returns the new coordinates in local space
  4538. */
  4539. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4540. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4541. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4542. return result;
  4543. };
  4544. /**
  4545. * Gets coordinates in local control space
  4546. * @param globalCoordinates defines the coordinates to transform
  4547. * @param result defines the target vector2 where to store the result
  4548. * @returns the current control
  4549. */
  4550. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4551. result.x = globalCoordinates.x - this._currentMeasure.left;
  4552. result.y = globalCoordinates.y - this._currentMeasure.top;
  4553. return this;
  4554. };
  4555. /**
  4556. * Gets coordinates in parent local control space
  4557. * @param globalCoordinates defines the coordinates to transform
  4558. * @returns the new coordinates in parent local space
  4559. */
  4560. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4561. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4562. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4563. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4564. return result;
  4565. };
  4566. /**
  4567. * Move the current control to a vector3 position projected onto the screen.
  4568. * @param position defines the target position
  4569. * @param scene defines the hosting scene
  4570. */
  4571. Control.prototype.moveToVector3 = function (position, scene) {
  4572. if (!this._host || this.parent !== this._host._rootContainer) {
  4573. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4574. return;
  4575. }
  4576. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4577. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4578. var globalViewport = this._host._getGlobalViewport(scene);
  4579. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4580. this._moveToProjectedPosition(projectedPosition);
  4581. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4582. this.notRenderable = true;
  4583. return;
  4584. }
  4585. this.notRenderable = false;
  4586. };
  4587. /** @hidden */
  4588. Control.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  4589. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4590. // Do nothing by default
  4591. };
  4592. /**
  4593. * Will return all controls that have this control as ascendant
  4594. * @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
  4595. * @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
  4596. * @return all child controls
  4597. */
  4598. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4599. var results = new Array();
  4600. this._getDescendants(results, directDescendantsOnly, predicate);
  4601. return results;
  4602. };
  4603. /**
  4604. * Link current control with a target mesh
  4605. * @param mesh defines the mesh to link with
  4606. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4607. */
  4608. Control.prototype.linkWithMesh = function (mesh) {
  4609. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4610. if (mesh) {
  4611. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4612. }
  4613. return;
  4614. }
  4615. var index = this._host._linkedControls.indexOf(this);
  4616. if (index !== -1) {
  4617. this._linkedMesh = mesh;
  4618. if (!mesh) {
  4619. this._host._linkedControls.splice(index, 1);
  4620. }
  4621. return;
  4622. }
  4623. else if (!mesh) {
  4624. return;
  4625. }
  4626. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4627. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4628. this._linkedMesh = mesh;
  4629. this._host._linkedControls.push(this);
  4630. };
  4631. /** @hidden */
  4632. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4633. var oldLeft = this._left.getValue(this._host);
  4634. var oldTop = this._top.getValue(this._host);
  4635. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4636. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4637. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4638. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4639. newLeft = oldLeft;
  4640. }
  4641. if (Math.abs(newTop - oldTop) < 0.5) {
  4642. newTop = oldTop;
  4643. }
  4644. }
  4645. this.left = newLeft + "px";
  4646. this.top = newTop + "px";
  4647. this._left.ignoreAdaptiveScaling = true;
  4648. this._top.ignoreAdaptiveScaling = true;
  4649. this._markAsDirty();
  4650. };
  4651. /** @hidden */
  4652. Control.prototype._offsetLeft = function (offset) {
  4653. this._isDirty = true;
  4654. this._currentMeasure.left += offset;
  4655. };
  4656. /** @hidden */
  4657. Control.prototype._offsetTop = function (offset) {
  4658. this._isDirty = true;
  4659. this._currentMeasure.top += offset;
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._markMatrixAsDirty = function () {
  4663. this._isMatrixDirty = true;
  4664. this._flagDescendantsAsMatrixDirty();
  4665. };
  4666. /** @hidden */
  4667. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4668. // No child
  4669. };
  4670. /** @hidden */
  4671. Control.prototype._intersectsRect = function (rect) {
  4672. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4673. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4674. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4675. return false;
  4676. }
  4677. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4678. return false;
  4679. }
  4680. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4681. return false;
  4682. }
  4683. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4684. return false;
  4685. }
  4686. return true;
  4687. };
  4688. /** @hidden */
  4689. Control.prototype.invalidateRect = function () {
  4690. this._transform();
  4691. if (this.host && this.host.useInvalidateRectOptimization) {
  4692. // Rotate by transform to get the measure transformed to global space
  4693. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4694. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4695. // the previous measure is used to properly clear a control that is scaled down
  4696. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4697. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4698. // Expand rect based on shadows
  4699. var shadowOffsetX = this.shadowOffsetX;
  4700. var shadowOffsetY = this.shadowOffsetY;
  4701. var shadowBlur = this.shadowBlur;
  4702. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4703. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4704. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4705. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4706. 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));
  4707. }
  4708. else {
  4709. 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));
  4710. }
  4711. }
  4712. };
  4713. /** @hidden */
  4714. Control.prototype._markAsDirty = function (force) {
  4715. if (force === void 0) { force = false; }
  4716. if (!this._isVisible && !force) {
  4717. return;
  4718. }
  4719. this._isDirty = true;
  4720. // Redraw only this rectangle
  4721. if (this._host) {
  4722. this._host.markAsDirty();
  4723. }
  4724. };
  4725. /** @hidden */
  4726. Control.prototype._markAllAsDirty = function () {
  4727. this._markAsDirty();
  4728. if (this._font) {
  4729. this._prepareFont();
  4730. }
  4731. };
  4732. /** @hidden */
  4733. Control.prototype._link = function (host) {
  4734. this._host = host;
  4735. if (this._host) {
  4736. this.uniqueId = this._host.getScene().getUniqueId();
  4737. }
  4738. };
  4739. /** @hidden */
  4740. Control.prototype._transform = function (context) {
  4741. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4742. return;
  4743. }
  4744. // postTranslate
  4745. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4746. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4747. if (context) {
  4748. context.translate(offsetX, offsetY);
  4749. // rotate
  4750. context.rotate(this._rotation);
  4751. // scale
  4752. context.scale(this._scaleX, this._scaleY);
  4753. // preTranslate
  4754. context.translate(-offsetX, -offsetY);
  4755. }
  4756. // Need to update matrices?
  4757. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4758. this._cachedOffsetX = offsetX;
  4759. this._cachedOffsetY = offsetY;
  4760. this._isMatrixDirty = false;
  4761. this._flagDescendantsAsMatrixDirty();
  4762. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4763. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4764. }
  4765. };
  4766. /** @hidden */
  4767. Control.prototype._renderHighlight = function (context) {
  4768. if (!this.isHighlighted) {
  4769. return;
  4770. }
  4771. context.save();
  4772. context.strokeStyle = "#4affff";
  4773. context.lineWidth = 2;
  4774. this._renderHighlightSpecific(context);
  4775. context.restore();
  4776. };
  4777. /** @hidden */
  4778. Control.prototype._renderHighlightSpecific = function (context) {
  4779. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._applyStates = function (context) {
  4783. if (this._isFontSizeInPercentage) {
  4784. this._fontSet = true;
  4785. }
  4786. if (this._fontSet) {
  4787. this._prepareFont();
  4788. this._fontSet = false;
  4789. }
  4790. if (this._font) {
  4791. context.font = this._font;
  4792. }
  4793. if (this._color) {
  4794. context.fillStyle = this._color;
  4795. }
  4796. if (Control.AllowAlphaInheritance) {
  4797. context.globalAlpha *= this._alpha;
  4798. }
  4799. else if (this._alphaSet) {
  4800. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4801. }
  4802. };
  4803. /** @hidden */
  4804. Control.prototype._layout = function (parentMeasure, context) {
  4805. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4806. return false;
  4807. }
  4808. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4809. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4810. context.save();
  4811. this._applyStates(context);
  4812. var rebuildCount = 0;
  4813. do {
  4814. this._rebuildLayout = false;
  4815. this._processMeasures(parentMeasure, context);
  4816. rebuildCount++;
  4817. } while (this._rebuildLayout && rebuildCount < 3);
  4818. if (rebuildCount >= 3) {
  4819. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4820. }
  4821. context.restore();
  4822. this.invalidateRect();
  4823. this._evaluateClippingState(parentMeasure);
  4824. }
  4825. this._wasDirty = this._isDirty;
  4826. this._isDirty = false;
  4827. return true;
  4828. };
  4829. /** @hidden */
  4830. Control.prototype._processMeasures = function (parentMeasure, context) {
  4831. this._currentMeasure.copyFrom(parentMeasure);
  4832. // Let children take some pre-measurement actions
  4833. this._preMeasure(parentMeasure, context);
  4834. this._measure();
  4835. this._computeAlignment(parentMeasure, context);
  4836. // Convert to int values
  4837. this._currentMeasure.left = this._currentMeasure.left | 0;
  4838. this._currentMeasure.top = this._currentMeasure.top | 0;
  4839. this._currentMeasure.width = this._currentMeasure.width | 0;
  4840. this._currentMeasure.height = this._currentMeasure.height | 0;
  4841. // Let children add more features
  4842. this._additionalProcessing(parentMeasure, context);
  4843. this._cachedParentMeasure.copyFrom(parentMeasure);
  4844. if (this.onDirtyObservable.hasObservers()) {
  4845. this.onDirtyObservable.notifyObservers(this);
  4846. }
  4847. };
  4848. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4849. if (this.parent && this.parent.clipChildren) {
  4850. // Early clip
  4851. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4852. this._isClipped = true;
  4853. return;
  4854. }
  4855. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4856. this._isClipped = true;
  4857. return;
  4858. }
  4859. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4860. this._isClipped = true;
  4861. return;
  4862. }
  4863. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4864. this._isClipped = true;
  4865. return;
  4866. }
  4867. }
  4868. this._isClipped = false;
  4869. };
  4870. /** @hidden */
  4871. Control.prototype._measure = function () {
  4872. // Width / Height
  4873. if (this._width.isPixel) {
  4874. this._currentMeasure.width = this._width.getValue(this._host);
  4875. }
  4876. else {
  4877. this._currentMeasure.width *= this._width.getValue(this._host);
  4878. }
  4879. if (this._height.isPixel) {
  4880. this._currentMeasure.height = this._height.getValue(this._host);
  4881. }
  4882. else {
  4883. this._currentMeasure.height *= this._height.getValue(this._host);
  4884. }
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4888. var width = this._currentMeasure.width;
  4889. var height = this._currentMeasure.height;
  4890. var parentWidth = parentMeasure.width;
  4891. var parentHeight = parentMeasure.height;
  4892. // Left / top
  4893. var x = 0;
  4894. var y = 0;
  4895. switch (this.horizontalAlignment) {
  4896. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4897. x = 0;
  4898. break;
  4899. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4900. x = parentWidth - width;
  4901. break;
  4902. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4903. x = (parentWidth - width) / 2;
  4904. break;
  4905. }
  4906. switch (this.verticalAlignment) {
  4907. case Control.VERTICAL_ALIGNMENT_TOP:
  4908. y = 0;
  4909. break;
  4910. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4911. y = parentHeight - height;
  4912. break;
  4913. case Control.VERTICAL_ALIGNMENT_CENTER:
  4914. y = (parentHeight - height) / 2;
  4915. break;
  4916. }
  4917. if (this._paddingLeft.isPixel) {
  4918. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4919. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4920. }
  4921. else {
  4922. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4923. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4924. }
  4925. if (this._paddingRight.isPixel) {
  4926. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4927. }
  4928. else {
  4929. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4930. }
  4931. if (this._paddingTop.isPixel) {
  4932. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4933. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4934. }
  4935. else {
  4936. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4937. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4938. }
  4939. if (this._paddingBottom.isPixel) {
  4940. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4941. }
  4942. else {
  4943. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4944. }
  4945. if (this._left.isPixel) {
  4946. this._currentMeasure.left += this._left.getValue(this._host);
  4947. }
  4948. else {
  4949. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4950. }
  4951. if (this._top.isPixel) {
  4952. this._currentMeasure.top += this._top.getValue(this._host);
  4953. }
  4954. else {
  4955. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4956. }
  4957. this._currentMeasure.left += x;
  4958. this._currentMeasure.top += y;
  4959. };
  4960. /** @hidden */
  4961. Control.prototype._preMeasure = function (parentMeasure, context) {
  4962. // Do nothing
  4963. };
  4964. /** @hidden */
  4965. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4966. // Do nothing
  4967. };
  4968. /** @hidden */
  4969. Control.prototype._clipForChildren = function (context) {
  4970. // DO nothing
  4971. };
  4972. Control.prototype._clip = function (context, invalidatedRectangle) {
  4973. context.beginPath();
  4974. Control._ClipMeasure.copyFrom(this._currentMeasure);
  4975. if (invalidatedRectangle) {
  4976. // Rotate the invalidated rect into the control's space
  4977. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  4978. // Get the intersection of the rect in context space and the current context
  4979. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  4980. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  4981. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  4982. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  4983. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  4984. Control._ClipMeasure.copyFrom(intersection);
  4985. }
  4986. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4987. var shadowOffsetX = this.shadowOffsetX;
  4988. var shadowOffsetY = this.shadowOffsetY;
  4989. var shadowBlur = this.shadowBlur;
  4990. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4991. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4992. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4993. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4994. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  4995. }
  4996. else {
  4997. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  4998. }
  4999. context.clip();
  5000. };
  5001. /** @hidden */
  5002. Control.prototype._render = function (context, invalidatedRectangle) {
  5003. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5004. this._isDirty = false;
  5005. return false;
  5006. }
  5007. context.save();
  5008. this._applyStates(context);
  5009. // Transform
  5010. this._transform(context);
  5011. // Clip
  5012. if (this.clipContent) {
  5013. this._clip(context, invalidatedRectangle);
  5014. }
  5015. if (this.onBeforeDrawObservable.hasObservers()) {
  5016. this.onBeforeDrawObservable.notifyObservers(this);
  5017. }
  5018. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5019. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5020. }
  5021. else {
  5022. this._draw(context, invalidatedRectangle);
  5023. }
  5024. if (this.useBitmapCache && this._wasDirty) {
  5025. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5026. }
  5027. this._renderHighlight(context);
  5028. if (this.onAfterDrawObservable.hasObservers()) {
  5029. this.onAfterDrawObservable.notifyObservers(this);
  5030. }
  5031. context.restore();
  5032. return true;
  5033. };
  5034. /** @hidden */
  5035. Control.prototype._draw = function (context, invalidatedRectangle) {
  5036. // Do nothing
  5037. };
  5038. /**
  5039. * Tests if a given coordinates belong to the current control
  5040. * @param x defines x coordinate to test
  5041. * @param y defines y coordinate to test
  5042. * @returns true if the coordinates are inside the control
  5043. */
  5044. Control.prototype.contains = function (x, y) {
  5045. // Invert transform
  5046. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5047. x = this._transformedPosition.x;
  5048. y = this._transformedPosition.y;
  5049. // Check
  5050. if (x < this._currentMeasure.left) {
  5051. return false;
  5052. }
  5053. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5054. return false;
  5055. }
  5056. if (y < this._currentMeasure.top) {
  5057. return false;
  5058. }
  5059. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5060. return false;
  5061. }
  5062. if (this.isPointerBlocker) {
  5063. this._host._shouldBlockPointer = true;
  5064. }
  5065. return true;
  5066. };
  5067. /** @hidden */
  5068. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5069. if (!this._isEnabled) {
  5070. return false;
  5071. }
  5072. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5073. return false;
  5074. }
  5075. if (!this.contains(x, y)) {
  5076. return false;
  5077. }
  5078. this._processObservables(type, x, y, pointerId, buttonIndex);
  5079. return true;
  5080. };
  5081. /** @hidden */
  5082. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5083. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5084. if (canNotify && this.parent != null) {
  5085. this.parent._onPointerMove(target, coordinates, pointerId);
  5086. }
  5087. };
  5088. /** @hidden */
  5089. Control.prototype._onPointerEnter = function (target) {
  5090. if (!this._isEnabled) {
  5091. return false;
  5092. }
  5093. if (this._enterCount > 0) {
  5094. return false;
  5095. }
  5096. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5097. this._enterCount = 0;
  5098. }
  5099. this._enterCount++;
  5100. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5101. if (canNotify && this.parent != null) {
  5102. this.parent._onPointerEnter(target);
  5103. }
  5104. return true;
  5105. };
  5106. /** @hidden */
  5107. Control.prototype._onPointerOut = function (target, force) {
  5108. if (force === void 0) { force = false; }
  5109. if (!force && (!this._isEnabled || target === this)) {
  5110. return;
  5111. }
  5112. this._enterCount = 0;
  5113. var canNotify = true;
  5114. if (!target.isAscendant(this)) {
  5115. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5116. }
  5117. if (canNotify && this.parent != null) {
  5118. this.parent._onPointerOut(target, force);
  5119. }
  5120. };
  5121. /** @hidden */
  5122. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5123. // Prevent pointerout to lose control context.
  5124. // Event redundancy is checked inside the function.
  5125. this._onPointerEnter(this);
  5126. if (this._downCount !== 0) {
  5127. return false;
  5128. }
  5129. this._downCount++;
  5130. this._downPointerIds[pointerId] = true;
  5131. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5132. if (canNotify && this.parent != null) {
  5133. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5134. }
  5135. return true;
  5136. };
  5137. /** @hidden */
  5138. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5139. if (!this._isEnabled) {
  5140. return;
  5141. }
  5142. this._downCount = 0;
  5143. delete this._downPointerIds[pointerId];
  5144. var canNotifyClick = notifyClick;
  5145. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5146. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5147. }
  5148. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5149. if (canNotify && this.parent != null) {
  5150. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5151. }
  5152. };
  5153. /** @hidden */
  5154. Control.prototype._forcePointerUp = function (pointerId) {
  5155. if (pointerId === void 0) { pointerId = null; }
  5156. if (pointerId !== null) {
  5157. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5158. }
  5159. else {
  5160. for (var key in this._downPointerIds) {
  5161. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5162. }
  5163. }
  5164. };
  5165. /** @hidden */
  5166. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5167. if (!this._isEnabled) {
  5168. return false;
  5169. }
  5170. this._dummyVector2.copyFromFloats(x, y);
  5171. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5172. this._onPointerMove(this, this._dummyVector2, pointerId);
  5173. var previousControlOver = this._host._lastControlOver[pointerId];
  5174. if (previousControlOver && previousControlOver !== this) {
  5175. previousControlOver._onPointerOut(this);
  5176. }
  5177. if (previousControlOver !== this) {
  5178. this._onPointerEnter(this);
  5179. }
  5180. this._host._lastControlOver[pointerId] = this;
  5181. return true;
  5182. }
  5183. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5184. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5185. this._host._registerLastControlDown(this, pointerId);
  5186. this._host._lastPickedControl = this;
  5187. return true;
  5188. }
  5189. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5190. if (this._host._lastControlDown[pointerId]) {
  5191. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5192. }
  5193. delete this._host._lastControlDown[pointerId];
  5194. return true;
  5195. }
  5196. return false;
  5197. };
  5198. Control.prototype._prepareFont = function () {
  5199. if (!this._font && !this._fontSet) {
  5200. return;
  5201. }
  5202. if (this._style) {
  5203. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5204. }
  5205. else {
  5206. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5207. }
  5208. this._fontOffset = Control._GetFontOffset(this._font);
  5209. };
  5210. /** Releases associated resources */
  5211. Control.prototype.dispose = function () {
  5212. this.onDirtyObservable.clear();
  5213. this.onBeforeDrawObservable.clear();
  5214. this.onAfterDrawObservable.clear();
  5215. this.onPointerDownObservable.clear();
  5216. this.onPointerEnterObservable.clear();
  5217. this.onPointerMoveObservable.clear();
  5218. this.onPointerOutObservable.clear();
  5219. this.onPointerUpObservable.clear();
  5220. this.onPointerClickObservable.clear();
  5221. if (this._styleObserver && this._style) {
  5222. this._style.onChangedObservable.remove(this._styleObserver);
  5223. this._styleObserver = null;
  5224. }
  5225. if (this.parent) {
  5226. this.parent.removeControl(this);
  5227. this.parent = null;
  5228. }
  5229. if (this._host) {
  5230. var index = this._host._linkedControls.indexOf(this);
  5231. if (index > -1) {
  5232. this.linkWithMesh(null);
  5233. }
  5234. }
  5235. };
  5236. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5237. /** HORIZONTAL_ALIGNMENT_LEFT */
  5238. get: function () {
  5239. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5240. },
  5241. enumerable: true,
  5242. configurable: true
  5243. });
  5244. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5245. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5246. get: function () {
  5247. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5248. },
  5249. enumerable: true,
  5250. configurable: true
  5251. });
  5252. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5253. /** HORIZONTAL_ALIGNMENT_CENTER */
  5254. get: function () {
  5255. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5256. },
  5257. enumerable: true,
  5258. configurable: true
  5259. });
  5260. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5261. /** VERTICAL_ALIGNMENT_TOP */
  5262. get: function () {
  5263. return Control._VERTICAL_ALIGNMENT_TOP;
  5264. },
  5265. enumerable: true,
  5266. configurable: true
  5267. });
  5268. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5269. /** VERTICAL_ALIGNMENT_BOTTOM */
  5270. get: function () {
  5271. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5272. },
  5273. enumerable: true,
  5274. configurable: true
  5275. });
  5276. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5277. /** VERTICAL_ALIGNMENT_CENTER */
  5278. get: function () {
  5279. return Control._VERTICAL_ALIGNMENT_CENTER;
  5280. },
  5281. enumerable: true,
  5282. configurable: true
  5283. });
  5284. /** @hidden */
  5285. Control._GetFontOffset = function (font) {
  5286. if (Control._FontHeightSizes[font]) {
  5287. return Control._FontHeightSizes[font];
  5288. }
  5289. var text = document.createElement("span");
  5290. text.innerHTML = "Hg";
  5291. text.style.font = font;
  5292. var block = document.createElement("div");
  5293. block.style.display = "inline-block";
  5294. block.style.width = "1px";
  5295. block.style.height = "0px";
  5296. block.style.verticalAlign = "bottom";
  5297. var div = document.createElement("div");
  5298. div.appendChild(text);
  5299. div.appendChild(block);
  5300. document.body.appendChild(div);
  5301. var fontAscent = 0;
  5302. var fontHeight = 0;
  5303. try {
  5304. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5305. block.style.verticalAlign = "baseline";
  5306. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5307. }
  5308. finally {
  5309. document.body.removeChild(div);
  5310. }
  5311. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5312. Control._FontHeightSizes[font] = result;
  5313. return result;
  5314. };
  5315. /** @hidden */
  5316. Control.drawEllipse = function (x, y, width, height, context) {
  5317. context.translate(x, y);
  5318. context.scale(width, height);
  5319. context.beginPath();
  5320. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5321. context.closePath();
  5322. context.scale(1 / width, 1 / height);
  5323. context.translate(-x, -y);
  5324. };
  5325. /**
  5326. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5327. */
  5328. Control.AllowAlphaInheritance = false;
  5329. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5330. // Statics
  5331. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5332. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5333. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5334. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5335. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5336. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5337. Control._FontHeightSizes = {};
  5338. /**
  5339. * Creates a stack panel that can be used to render headers
  5340. * @param control defines the control to associate with the header
  5341. * @param text defines the text of the header
  5342. * @param size defines the size of the header
  5343. * @param options defines options used to configure the header
  5344. * @returns a new StackPanel
  5345. * @ignore
  5346. * @hidden
  5347. */
  5348. Control.AddHeader = function () { };
  5349. return Control;
  5350. }());
  5351. /***/ }),
  5352. /***/ "./2D/controls/displayGrid.ts":
  5353. /*!************************************!*\
  5354. !*** ./2D/controls/displayGrid.ts ***!
  5355. \************************************/
  5356. /*! exports provided: DisplayGrid */
  5357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5358. "use strict";
  5359. __webpack_require__.r(__webpack_exports__);
  5360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5361. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5362. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5363. /** Class used to render a grid */
  5364. var DisplayGrid = /** @class */ (function (_super) {
  5365. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayGrid, _super);
  5366. /**
  5367. * Creates a new GridDisplayRectangle
  5368. * @param name defines the control name
  5369. */
  5370. function DisplayGrid(name) {
  5371. var _this = _super.call(this, name) || this;
  5372. _this.name = name;
  5373. _this._cellWidth = 20;
  5374. _this._cellHeight = 20;
  5375. _this._minorLineTickness = 1;
  5376. _this._minorLineColor = "DarkGray";
  5377. _this._majorLineTickness = 2;
  5378. _this._majorLineColor = "White";
  5379. _this._majorLineFrequency = 5;
  5380. _this._background = "Black";
  5381. _this._displayMajorLines = true;
  5382. _this._displayMinorLines = true;
  5383. return _this;
  5384. }
  5385. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5386. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5387. get: function () {
  5388. return this._displayMinorLines;
  5389. },
  5390. set: function (value) {
  5391. if (this._displayMinorLines === value) {
  5392. return;
  5393. }
  5394. this._displayMinorLines = value;
  5395. this._markAsDirty();
  5396. },
  5397. enumerable: true,
  5398. configurable: true
  5399. });
  5400. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5401. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5402. get: function () {
  5403. return this._displayMajorLines;
  5404. },
  5405. set: function (value) {
  5406. if (this._displayMajorLines === value) {
  5407. return;
  5408. }
  5409. this._displayMajorLines = value;
  5410. this._markAsDirty();
  5411. },
  5412. enumerable: true,
  5413. configurable: true
  5414. });
  5415. Object.defineProperty(DisplayGrid.prototype, "background", {
  5416. /** Gets or sets background color (Black by default) */
  5417. get: function () {
  5418. return this._background;
  5419. },
  5420. set: function (value) {
  5421. if (this._background === value) {
  5422. return;
  5423. }
  5424. this._background = value;
  5425. this._markAsDirty();
  5426. },
  5427. enumerable: true,
  5428. configurable: true
  5429. });
  5430. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5431. /** Gets or sets the width of each cell (20 by default) */
  5432. get: function () {
  5433. return this._cellWidth;
  5434. },
  5435. set: function (value) {
  5436. this._cellWidth = value;
  5437. this._markAsDirty();
  5438. },
  5439. enumerable: true,
  5440. configurable: true
  5441. });
  5442. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5443. /** Gets or sets the height of each cell (20 by default) */
  5444. get: function () {
  5445. return this._cellHeight;
  5446. },
  5447. set: function (value) {
  5448. this._cellHeight = value;
  5449. this._markAsDirty();
  5450. },
  5451. enumerable: true,
  5452. configurable: true
  5453. });
  5454. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5455. /** Gets or sets the tickness of minor lines (1 by default) */
  5456. get: function () {
  5457. return this._minorLineTickness;
  5458. },
  5459. set: function (value) {
  5460. this._minorLineTickness = value;
  5461. this._markAsDirty();
  5462. },
  5463. enumerable: true,
  5464. configurable: true
  5465. });
  5466. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5467. /** Gets or sets the color of minor lines (DarkGray by default) */
  5468. get: function () {
  5469. return this._minorLineColor;
  5470. },
  5471. set: function (value) {
  5472. this._minorLineColor = value;
  5473. this._markAsDirty();
  5474. },
  5475. enumerable: true,
  5476. configurable: true
  5477. });
  5478. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5479. /** Gets or sets the tickness of major lines (2 by default) */
  5480. get: function () {
  5481. return this._majorLineTickness;
  5482. },
  5483. set: function (value) {
  5484. this._majorLineTickness = value;
  5485. this._markAsDirty();
  5486. },
  5487. enumerable: true,
  5488. configurable: true
  5489. });
  5490. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5491. /** Gets or sets the color of major lines (White by default) */
  5492. get: function () {
  5493. return this._majorLineColor;
  5494. },
  5495. set: function (value) {
  5496. this._majorLineColor = value;
  5497. this._markAsDirty();
  5498. },
  5499. enumerable: true,
  5500. configurable: true
  5501. });
  5502. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5503. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5504. get: function () {
  5505. return this._majorLineFrequency;
  5506. },
  5507. set: function (value) {
  5508. this._majorLineFrequency = value;
  5509. this._markAsDirty();
  5510. },
  5511. enumerable: true,
  5512. configurable: true
  5513. });
  5514. DisplayGrid.prototype._draw = function (context) {
  5515. context.save();
  5516. this._applyStates(context);
  5517. if (this._isEnabled) {
  5518. if (this._background) {
  5519. context.fillStyle = this._background;
  5520. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5521. }
  5522. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5523. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5524. // Minor lines
  5525. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5526. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5527. if (this._displayMinorLines) {
  5528. context.strokeStyle = this._minorLineColor;
  5529. context.lineWidth = this._minorLineTickness;
  5530. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5531. var cellX = left + x * this.cellWidth;
  5532. context.beginPath();
  5533. context.moveTo(cellX, this._currentMeasure.top);
  5534. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5535. context.stroke();
  5536. }
  5537. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5538. var cellY = top_1 + y * this.cellHeight;
  5539. context.beginPath();
  5540. context.moveTo(this._currentMeasure.left, cellY);
  5541. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5542. context.stroke();
  5543. }
  5544. }
  5545. // Major lines
  5546. if (this._displayMajorLines) {
  5547. context.strokeStyle = this._majorLineColor;
  5548. context.lineWidth = this._majorLineTickness;
  5549. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5550. var cellX = left + x * this.cellWidth;
  5551. context.beginPath();
  5552. context.moveTo(cellX, this._currentMeasure.top);
  5553. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5554. context.stroke();
  5555. }
  5556. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5557. var cellY = top_1 + y * this.cellHeight;
  5558. context.moveTo(this._currentMeasure.left, cellY);
  5559. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5560. context.closePath();
  5561. context.stroke();
  5562. }
  5563. }
  5564. }
  5565. context.restore();
  5566. };
  5567. DisplayGrid.prototype._getTypeName = function () {
  5568. return "DisplayGrid";
  5569. };
  5570. return DisplayGrid;
  5571. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5572. /***/ }),
  5573. /***/ "./2D/controls/ellipse.ts":
  5574. /*!********************************!*\
  5575. !*** ./2D/controls/ellipse.ts ***!
  5576. \********************************/
  5577. /*! exports provided: Ellipse */
  5578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5579. "use strict";
  5580. __webpack_require__.r(__webpack_exports__);
  5581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5582. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5583. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5584. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5585. /** Class used to create 2D ellipse containers */
  5586. var Ellipse = /** @class */ (function (_super) {
  5587. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Ellipse, _super);
  5588. /**
  5589. * Creates a new Ellipse
  5590. * @param name defines the control name
  5591. */
  5592. function Ellipse(name) {
  5593. var _this = _super.call(this, name) || this;
  5594. _this.name = name;
  5595. _this._thickness = 1;
  5596. return _this;
  5597. }
  5598. Object.defineProperty(Ellipse.prototype, "thickness", {
  5599. /** Gets or sets border thickness */
  5600. get: function () {
  5601. return this._thickness;
  5602. },
  5603. set: function (value) {
  5604. if (this._thickness === value) {
  5605. return;
  5606. }
  5607. this._thickness = value;
  5608. this._markAsDirty();
  5609. },
  5610. enumerable: true,
  5611. configurable: true
  5612. });
  5613. Ellipse.prototype._getTypeName = function () {
  5614. return "Ellipse";
  5615. };
  5616. Ellipse.prototype._localDraw = function (context) {
  5617. context.save();
  5618. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5619. context.shadowColor = this.shadowColor;
  5620. context.shadowBlur = this.shadowBlur;
  5621. context.shadowOffsetX = this.shadowOffsetX;
  5622. context.shadowOffsetY = this.shadowOffsetY;
  5623. }
  5624. _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);
  5625. if (this._background) {
  5626. context.fillStyle = this._background;
  5627. context.fill();
  5628. }
  5629. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5630. context.shadowBlur = 0;
  5631. context.shadowOffsetX = 0;
  5632. context.shadowOffsetY = 0;
  5633. }
  5634. if (this._thickness) {
  5635. if (this.color) {
  5636. context.strokeStyle = this.color;
  5637. }
  5638. context.lineWidth = this._thickness;
  5639. context.stroke();
  5640. }
  5641. context.restore();
  5642. };
  5643. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5644. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5645. this._measureForChildren.width -= 2 * this._thickness;
  5646. this._measureForChildren.height -= 2 * this._thickness;
  5647. this._measureForChildren.left += this._thickness;
  5648. this._measureForChildren.top += this._thickness;
  5649. };
  5650. Ellipse.prototype._clipForChildren = function (context) {
  5651. _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);
  5652. context.clip();
  5653. };
  5654. return Ellipse;
  5655. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5656. /***/ }),
  5657. /***/ "./2D/controls/grid.ts":
  5658. /*!*****************************!*\
  5659. !*** ./2D/controls/grid.ts ***!
  5660. \*****************************/
  5661. /*! exports provided: Grid */
  5662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5663. "use strict";
  5664. __webpack_require__.r(__webpack_exports__);
  5665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5666. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5667. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5668. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5669. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5670. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5671. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5672. /**
  5673. * Class used to create a 2D grid container
  5674. */
  5675. var Grid = /** @class */ (function (_super) {
  5676. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Grid, _super);
  5677. /**
  5678. * Creates a new Grid
  5679. * @param name defines control name
  5680. */
  5681. function Grid(name) {
  5682. var _this = _super.call(this, name) || this;
  5683. _this.name = name;
  5684. _this._rowDefinitions = new Array();
  5685. _this._columnDefinitions = new Array();
  5686. _this._cells = {};
  5687. _this._childControls = new Array();
  5688. return _this;
  5689. }
  5690. Object.defineProperty(Grid.prototype, "columnCount", {
  5691. /**
  5692. * Gets the number of columns
  5693. */
  5694. get: function () {
  5695. return this._columnDefinitions.length;
  5696. },
  5697. enumerable: true,
  5698. configurable: true
  5699. });
  5700. Object.defineProperty(Grid.prototype, "rowCount", {
  5701. /**
  5702. * Gets the number of rows
  5703. */
  5704. get: function () {
  5705. return this._rowDefinitions.length;
  5706. },
  5707. enumerable: true,
  5708. configurable: true
  5709. });
  5710. Object.defineProperty(Grid.prototype, "children", {
  5711. /** Gets the list of children */
  5712. get: function () {
  5713. return this._childControls;
  5714. },
  5715. enumerable: true,
  5716. configurable: true
  5717. });
  5718. Object.defineProperty(Grid.prototype, "cells", {
  5719. /** Gets the list of cells (e.g. the containers) */
  5720. get: function () {
  5721. return this._cells;
  5722. },
  5723. enumerable: true,
  5724. configurable: true
  5725. });
  5726. /**
  5727. * Gets the definition of a specific row
  5728. * @param index defines the index of the row
  5729. * @returns the row definition
  5730. */
  5731. Grid.prototype.getRowDefinition = function (index) {
  5732. if (index < 0 || index >= this._rowDefinitions.length) {
  5733. return null;
  5734. }
  5735. return this._rowDefinitions[index];
  5736. };
  5737. /**
  5738. * Gets the definition of a specific column
  5739. * @param index defines the index of the column
  5740. * @returns the column definition
  5741. */
  5742. Grid.prototype.getColumnDefinition = function (index) {
  5743. if (index < 0 || index >= this._columnDefinitions.length) {
  5744. return null;
  5745. }
  5746. return this._columnDefinitions[index];
  5747. };
  5748. /**
  5749. * Adds a new row to the grid
  5750. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5751. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5752. * @returns the current grid
  5753. */
  5754. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5755. if (isPixel === void 0) { isPixel = false; }
  5756. 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));
  5757. this._markAsDirty();
  5758. return this;
  5759. };
  5760. /**
  5761. * Adds a new column to the grid
  5762. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5763. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5764. * @returns the current grid
  5765. */
  5766. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5767. if (isPixel === void 0) { isPixel = false; }
  5768. 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));
  5769. this._markAsDirty();
  5770. return this;
  5771. };
  5772. /**
  5773. * Update a row definition
  5774. * @param index defines the index of the row to update
  5775. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5776. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5777. * @returns the current grid
  5778. */
  5779. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5780. if (isPixel === void 0) { isPixel = false; }
  5781. if (index < 0 || index >= this._rowDefinitions.length) {
  5782. return this;
  5783. }
  5784. var current = this._rowDefinitions[index];
  5785. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5786. return this;
  5787. }
  5788. 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);
  5789. this._markAsDirty();
  5790. return this;
  5791. };
  5792. /**
  5793. * Update a column definition
  5794. * @param index defines the index of the column to update
  5795. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5796. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5797. * @returns the current grid
  5798. */
  5799. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5800. if (isPixel === void 0) { isPixel = false; }
  5801. if (index < 0 || index >= this._columnDefinitions.length) {
  5802. return this;
  5803. }
  5804. var current = this._columnDefinitions[index];
  5805. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5806. return this;
  5807. }
  5808. 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);
  5809. this._markAsDirty();
  5810. return this;
  5811. };
  5812. /**
  5813. * Gets the list of children stored in a specific cell
  5814. * @param row defines the row to check
  5815. * @param column defines the column to check
  5816. * @returns the list of controls
  5817. */
  5818. Grid.prototype.getChildrenAt = function (row, column) {
  5819. var cell = this._cells[row + ":" + column];
  5820. if (!cell) {
  5821. return null;
  5822. }
  5823. return cell.children;
  5824. };
  5825. /**
  5826. * Gets a string representing the child cell info (row x column)
  5827. * @param child defines the control to get info from
  5828. * @returns a string containing the child cell info (row x column)
  5829. */
  5830. Grid.prototype.getChildCellInfo = function (child) {
  5831. return child._tag;
  5832. };
  5833. Grid.prototype._removeCell = function (cell, key) {
  5834. if (!cell) {
  5835. return;
  5836. }
  5837. _super.prototype.removeControl.call(this, cell);
  5838. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5839. var control = _a[_i];
  5840. var childIndex = this._childControls.indexOf(control);
  5841. if (childIndex !== -1) {
  5842. this._childControls.splice(childIndex, 1);
  5843. }
  5844. }
  5845. delete this._cells[key];
  5846. };
  5847. Grid.prototype._offsetCell = function (previousKey, key) {
  5848. if (!this._cells[key]) {
  5849. return;
  5850. }
  5851. this._cells[previousKey] = this._cells[key];
  5852. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5853. var control = _a[_i];
  5854. control._tag = previousKey;
  5855. }
  5856. delete this._cells[key];
  5857. };
  5858. /**
  5859. * Remove a column definition at specified index
  5860. * @param index defines the index of the column to remove
  5861. * @returns the current grid
  5862. */
  5863. Grid.prototype.removeColumnDefinition = function (index) {
  5864. if (index < 0 || index >= this._columnDefinitions.length) {
  5865. return this;
  5866. }
  5867. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5868. var key = x + ":" + index;
  5869. var cell = this._cells[key];
  5870. this._removeCell(cell, key);
  5871. }
  5872. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5873. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5874. var previousKey = x + ":" + (y - 1);
  5875. var key = x + ":" + y;
  5876. this._offsetCell(previousKey, key);
  5877. }
  5878. }
  5879. this._columnDefinitions.splice(index, 1);
  5880. this._markAsDirty();
  5881. return this;
  5882. };
  5883. /**
  5884. * Remove a row definition at specified index
  5885. * @param index defines the index of the row to remove
  5886. * @returns the current grid
  5887. */
  5888. Grid.prototype.removeRowDefinition = function (index) {
  5889. if (index < 0 || index >= this._rowDefinitions.length) {
  5890. return this;
  5891. }
  5892. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5893. var key = index + ":" + y;
  5894. var cell = this._cells[key];
  5895. this._removeCell(cell, key);
  5896. }
  5897. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5898. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5899. var previousKey = x - 1 + ":" + y;
  5900. var key = x + ":" + y;
  5901. this._offsetCell(previousKey, key);
  5902. }
  5903. }
  5904. this._rowDefinitions.splice(index, 1);
  5905. this._markAsDirty();
  5906. return this;
  5907. };
  5908. /**
  5909. * Adds a new control to the current grid
  5910. * @param control defines the control to add
  5911. * @param row defines the row where to add the control (0 by default)
  5912. * @param column defines the column where to add the control (0 by default)
  5913. * @returns the current grid
  5914. */
  5915. Grid.prototype.addControl = function (control, row, column) {
  5916. if (row === void 0) { row = 0; }
  5917. if (column === void 0) { column = 0; }
  5918. if (this._rowDefinitions.length === 0) {
  5919. // Add default row definition
  5920. this.addRowDefinition(1, false);
  5921. }
  5922. if (this._columnDefinitions.length === 0) {
  5923. // Add default column definition
  5924. this.addColumnDefinition(1, false);
  5925. }
  5926. if (this._childControls.indexOf(control) !== -1) {
  5927. 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");
  5928. return this;
  5929. }
  5930. var x = Math.min(row, this._rowDefinitions.length - 1);
  5931. var y = Math.min(column, this._columnDefinitions.length - 1);
  5932. var key = x + ":" + y;
  5933. var goodContainer = this._cells[key];
  5934. if (!goodContainer) {
  5935. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5936. this._cells[key] = goodContainer;
  5937. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5938. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5939. _super.prototype.addControl.call(this, goodContainer);
  5940. }
  5941. goodContainer.addControl(control);
  5942. this._childControls.push(control);
  5943. control._tag = key;
  5944. control.parent = this;
  5945. this._markAsDirty();
  5946. return this;
  5947. };
  5948. /**
  5949. * Removes a control from the current container
  5950. * @param control defines the control to remove
  5951. * @returns the current container
  5952. */
  5953. Grid.prototype.removeControl = function (control) {
  5954. var index = this._childControls.indexOf(control);
  5955. if (index !== -1) {
  5956. this._childControls.splice(index, 1);
  5957. }
  5958. var cell = this._cells[control._tag];
  5959. if (cell) {
  5960. cell.removeControl(control);
  5961. control._tag = null;
  5962. }
  5963. this._markAsDirty();
  5964. return this;
  5965. };
  5966. Grid.prototype._getTypeName = function () {
  5967. return "Grid";
  5968. };
  5969. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  5970. var widths = [];
  5971. var heights = [];
  5972. var lefts = [];
  5973. var tops = [];
  5974. var availableWidth = this._currentMeasure.width;
  5975. var globalWidthPercentage = 0;
  5976. var availableHeight = this._currentMeasure.height;
  5977. var globalHeightPercentage = 0;
  5978. // Heights
  5979. var index = 0;
  5980. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  5981. var value = _a[_i];
  5982. if (value.isPixel) {
  5983. var height = value.getValue(this._host);
  5984. availableHeight -= height;
  5985. heights[index] = height;
  5986. }
  5987. else {
  5988. globalHeightPercentage += value.internalValue;
  5989. }
  5990. index++;
  5991. }
  5992. var top = 0;
  5993. index = 0;
  5994. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  5995. var value = _c[_b];
  5996. tops.push(top);
  5997. if (!value.isPixel) {
  5998. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  5999. top += height;
  6000. heights[index] = height;
  6001. }
  6002. else {
  6003. top += value.getValue(this._host);
  6004. }
  6005. index++;
  6006. }
  6007. // Widths
  6008. index = 0;
  6009. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6010. var value = _e[_d];
  6011. if (value.isPixel) {
  6012. var width = value.getValue(this._host);
  6013. availableWidth -= width;
  6014. widths[index] = width;
  6015. }
  6016. else {
  6017. globalWidthPercentage += value.internalValue;
  6018. }
  6019. index++;
  6020. }
  6021. var left = 0;
  6022. index = 0;
  6023. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6024. var value = _g[_f];
  6025. lefts.push(left);
  6026. if (!value.isPixel) {
  6027. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6028. left += width;
  6029. widths[index] = width;
  6030. }
  6031. else {
  6032. left += value.getValue(this._host);
  6033. }
  6034. index++;
  6035. }
  6036. definitionCallback(lefts, tops, widths, heights);
  6037. };
  6038. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6039. var _this = this;
  6040. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6041. // Setting child sizes
  6042. for (var key in _this._cells) {
  6043. if (!_this._cells.hasOwnProperty(key)) {
  6044. continue;
  6045. }
  6046. var split = key.split(":");
  6047. var x = parseInt(split[0]);
  6048. var y = parseInt(split[1]);
  6049. var cell = _this._cells[key];
  6050. cell.left = lefts[y] + "px";
  6051. cell.top = tops[x] + "px";
  6052. cell.width = widths[y] + "px";
  6053. cell.height = heights[x] + "px";
  6054. cell._left.ignoreAdaptiveScaling = true;
  6055. cell._top.ignoreAdaptiveScaling = true;
  6056. cell._width.ignoreAdaptiveScaling = true;
  6057. cell._height.ignoreAdaptiveScaling = true;
  6058. }
  6059. });
  6060. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6061. };
  6062. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6063. for (var key in this._cells) {
  6064. if (!this._cells.hasOwnProperty(key)) {
  6065. continue;
  6066. }
  6067. var child = this._cells[key];
  6068. child._markMatrixAsDirty();
  6069. }
  6070. };
  6071. Grid.prototype._renderHighlightSpecific = function (context) {
  6072. var _this = this;
  6073. _super.prototype._renderHighlightSpecific.call(this, context);
  6074. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6075. // Columns
  6076. for (var index = 0; index < lefts.length; index++) {
  6077. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6078. context.beginPath();
  6079. context.moveTo(left, _this._currentMeasure.top);
  6080. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6081. context.stroke();
  6082. }
  6083. // Rows
  6084. for (var index = 0; index < tops.length; index++) {
  6085. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6086. context.beginPath();
  6087. context.moveTo(_this._currentMeasure.left, top_1);
  6088. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6089. context.stroke();
  6090. }
  6091. });
  6092. context.restore();
  6093. };
  6094. /** Releases associated resources */
  6095. Grid.prototype.dispose = function () {
  6096. _super.prototype.dispose.call(this);
  6097. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6098. var control = _a[_i];
  6099. control.dispose();
  6100. }
  6101. this._childControls = [];
  6102. };
  6103. return Grid;
  6104. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6105. /***/ }),
  6106. /***/ "./2D/controls/image.ts":
  6107. /*!******************************!*\
  6108. !*** ./2D/controls/image.ts ***!
  6109. \******************************/
  6110. /*! exports provided: Image */
  6111. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6112. "use strict";
  6113. __webpack_require__.r(__webpack_exports__);
  6114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6116. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6117. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6118. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6119. /**
  6120. * Class used to create 2D images
  6121. */
  6122. var Image = /** @class */ (function (_super) {
  6123. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Image, _super);
  6124. /**
  6125. * Creates a new Image
  6126. * @param name defines the control name
  6127. * @param url defines the image url
  6128. */
  6129. function Image(name, url) {
  6130. if (url === void 0) { url = null; }
  6131. var _this = _super.call(this, name) || this;
  6132. _this.name = name;
  6133. _this._loaded = false;
  6134. _this._stretch = Image.STRETCH_FILL;
  6135. _this._autoScale = false;
  6136. _this._sourceLeft = 0;
  6137. _this._sourceTop = 0;
  6138. _this._sourceWidth = 0;
  6139. _this._sourceHeight = 0;
  6140. _this._cellWidth = 0;
  6141. _this._cellHeight = 0;
  6142. _this._cellId = -1;
  6143. _this._populateNinePatchSlicesFromImage = false;
  6144. /**
  6145. * Observable notified when the content is loaded
  6146. */
  6147. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6148. _this.source = url;
  6149. return _this;
  6150. }
  6151. Object.defineProperty(Image.prototype, "isLoaded", {
  6152. /**
  6153. * Gets a boolean indicating that the content is loaded
  6154. */
  6155. get: function () {
  6156. return this._loaded;
  6157. },
  6158. enumerable: true,
  6159. configurable: true
  6160. });
  6161. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6162. /**
  6163. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6164. */
  6165. get: function () {
  6166. return this._populateNinePatchSlicesFromImage;
  6167. },
  6168. set: function (value) {
  6169. if (this._populateNinePatchSlicesFromImage === value) {
  6170. return;
  6171. }
  6172. this._populateNinePatchSlicesFromImage = value;
  6173. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6174. this._extractNinePatchSliceDataFromImage();
  6175. }
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6181. /**
  6182. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6183. * Beware using this as this will comsume more memory as the image has to be stored twice
  6184. */
  6185. get: function () {
  6186. return this._detectPointerOnOpaqueOnly;
  6187. },
  6188. set: function (value) {
  6189. if (this._detectPointerOnOpaqueOnly === value) {
  6190. return;
  6191. }
  6192. this._detectPointerOnOpaqueOnly = value;
  6193. },
  6194. enumerable: true,
  6195. configurable: true
  6196. });
  6197. Object.defineProperty(Image.prototype, "sliceLeft", {
  6198. /**
  6199. * Gets or sets the left value for slicing (9-patch)
  6200. */
  6201. get: function () {
  6202. return this._sliceLeft;
  6203. },
  6204. set: function (value) {
  6205. if (this._sliceLeft === value) {
  6206. return;
  6207. }
  6208. this._sliceLeft = value;
  6209. this._markAsDirty();
  6210. },
  6211. enumerable: true,
  6212. configurable: true
  6213. });
  6214. Object.defineProperty(Image.prototype, "sliceRight", {
  6215. /**
  6216. * Gets or sets the right value for slicing (9-patch)
  6217. */
  6218. get: function () {
  6219. return this._sliceRight;
  6220. },
  6221. set: function (value) {
  6222. if (this._sliceRight === value) {
  6223. return;
  6224. }
  6225. this._sliceRight = value;
  6226. this._markAsDirty();
  6227. },
  6228. enumerable: true,
  6229. configurable: true
  6230. });
  6231. Object.defineProperty(Image.prototype, "sliceTop", {
  6232. /**
  6233. * Gets or sets the top value for slicing (9-patch)
  6234. */
  6235. get: function () {
  6236. return this._sliceTop;
  6237. },
  6238. set: function (value) {
  6239. if (this._sliceTop === value) {
  6240. return;
  6241. }
  6242. this._sliceTop = value;
  6243. this._markAsDirty();
  6244. },
  6245. enumerable: true,
  6246. configurable: true
  6247. });
  6248. Object.defineProperty(Image.prototype, "sliceBottom", {
  6249. /**
  6250. * Gets or sets the bottom value for slicing (9-patch)
  6251. */
  6252. get: function () {
  6253. return this._sliceBottom;
  6254. },
  6255. set: function (value) {
  6256. if (this._sliceBottom === value) {
  6257. return;
  6258. }
  6259. this._sliceBottom = value;
  6260. this._markAsDirty();
  6261. },
  6262. enumerable: true,
  6263. configurable: true
  6264. });
  6265. Object.defineProperty(Image.prototype, "sourceLeft", {
  6266. /**
  6267. * Gets or sets the left coordinate in the source image
  6268. */
  6269. get: function () {
  6270. return this._sourceLeft;
  6271. },
  6272. set: function (value) {
  6273. if (this._sourceLeft === value) {
  6274. return;
  6275. }
  6276. this._sourceLeft = value;
  6277. this._markAsDirty();
  6278. },
  6279. enumerable: true,
  6280. configurable: true
  6281. });
  6282. Object.defineProperty(Image.prototype, "sourceTop", {
  6283. /**
  6284. * Gets or sets the top coordinate in the source image
  6285. */
  6286. get: function () {
  6287. return this._sourceTop;
  6288. },
  6289. set: function (value) {
  6290. if (this._sourceTop === value) {
  6291. return;
  6292. }
  6293. this._sourceTop = value;
  6294. this._markAsDirty();
  6295. },
  6296. enumerable: true,
  6297. configurable: true
  6298. });
  6299. Object.defineProperty(Image.prototype, "sourceWidth", {
  6300. /**
  6301. * Gets or sets the width to capture in the source image
  6302. */
  6303. get: function () {
  6304. return this._sourceWidth;
  6305. },
  6306. set: function (value) {
  6307. if (this._sourceWidth === value) {
  6308. return;
  6309. }
  6310. this._sourceWidth = value;
  6311. this._markAsDirty();
  6312. },
  6313. enumerable: true,
  6314. configurable: true
  6315. });
  6316. Object.defineProperty(Image.prototype, "sourceHeight", {
  6317. /**
  6318. * Gets or sets the height to capture in the source image
  6319. */
  6320. get: function () {
  6321. return this._sourceHeight;
  6322. },
  6323. set: function (value) {
  6324. if (this._sourceHeight === value) {
  6325. return;
  6326. }
  6327. this._sourceHeight = value;
  6328. this._markAsDirty();
  6329. },
  6330. enumerable: true,
  6331. configurable: true
  6332. });
  6333. Object.defineProperty(Image.prototype, "autoScale", {
  6334. /**
  6335. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6336. * @see http://doc.babylonjs.com/how_to/gui#image
  6337. */
  6338. get: function () {
  6339. return this._autoScale;
  6340. },
  6341. set: function (value) {
  6342. if (this._autoScale === value) {
  6343. return;
  6344. }
  6345. this._autoScale = value;
  6346. if (value && this._loaded) {
  6347. this.synchronizeSizeWithContent();
  6348. }
  6349. },
  6350. enumerable: true,
  6351. configurable: true
  6352. });
  6353. Object.defineProperty(Image.prototype, "stretch", {
  6354. /** Gets or sets the streching mode used by the image */
  6355. get: function () {
  6356. return this._stretch;
  6357. },
  6358. set: function (value) {
  6359. if (this._stretch === value) {
  6360. return;
  6361. }
  6362. this._stretch = value;
  6363. this._markAsDirty();
  6364. },
  6365. enumerable: true,
  6366. configurable: true
  6367. });
  6368. Object.defineProperty(Image.prototype, "domImage", {
  6369. get: function () {
  6370. return this._domImage;
  6371. },
  6372. /**
  6373. * Gets or sets the internal DOM image used to render the control
  6374. */
  6375. set: function (value) {
  6376. var _this = this;
  6377. this._domImage = value;
  6378. this._loaded = false;
  6379. if (this._domImage.width) {
  6380. this._onImageLoaded();
  6381. }
  6382. else {
  6383. this._domImage.onload = function () {
  6384. _this._onImageLoaded();
  6385. };
  6386. }
  6387. },
  6388. enumerable: true,
  6389. configurable: true
  6390. });
  6391. Image.prototype._onImageLoaded = function () {
  6392. this._imageWidth = this._domImage.width;
  6393. this._imageHeight = this._domImage.height;
  6394. this._loaded = true;
  6395. if (this._populateNinePatchSlicesFromImage) {
  6396. this._extractNinePatchSliceDataFromImage();
  6397. }
  6398. if (this._autoScale) {
  6399. this.synchronizeSizeWithContent();
  6400. }
  6401. this.onImageLoadedObservable.notifyObservers(this);
  6402. this._markAsDirty();
  6403. };
  6404. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6405. if (!Image._WorkingCanvas) {
  6406. Image._WorkingCanvas = document.createElement('canvas');
  6407. }
  6408. var canvas = Image._WorkingCanvas;
  6409. var context = canvas.getContext('2d');
  6410. var width = this._domImage.width;
  6411. var height = this._domImage.height;
  6412. canvas.width = width;
  6413. canvas.height = height;
  6414. context.drawImage(this._domImage, 0, 0, width, height);
  6415. var imageData = context.getImageData(0, 0, width, height);
  6416. // Left and right
  6417. this._sliceLeft = -1;
  6418. this._sliceRight = -1;
  6419. for (var x = 0; x < width; x++) {
  6420. var alpha = imageData.data[x * 4 + 3];
  6421. if (alpha > 127 && this._sliceLeft === -1) {
  6422. this._sliceLeft = x;
  6423. continue;
  6424. }
  6425. if (alpha < 127 && this._sliceLeft > -1) {
  6426. this._sliceRight = x;
  6427. break;
  6428. }
  6429. }
  6430. // top and bottom
  6431. this._sliceTop = -1;
  6432. this._sliceBottom = -1;
  6433. for (var y = 0; y < height; y++) {
  6434. var alpha = imageData.data[y * width * 4 + 3];
  6435. if (alpha > 127 && this._sliceTop === -1) {
  6436. this._sliceTop = y;
  6437. continue;
  6438. }
  6439. if (alpha < 127 && this._sliceTop > -1) {
  6440. this._sliceBottom = y;
  6441. break;
  6442. }
  6443. }
  6444. };
  6445. Object.defineProperty(Image.prototype, "source", {
  6446. /**
  6447. * Gets or sets image source url
  6448. */
  6449. set: function (value) {
  6450. var _this = this;
  6451. if (this._source === value) {
  6452. return;
  6453. }
  6454. this._loaded = false;
  6455. this._source = value;
  6456. this._domImage = document.createElement("img");
  6457. this._domImage.onload = function () {
  6458. _this._onImageLoaded();
  6459. };
  6460. if (value) {
  6461. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6462. this._domImage.src = value;
  6463. }
  6464. },
  6465. enumerable: true,
  6466. configurable: true
  6467. });
  6468. Object.defineProperty(Image.prototype, "cellWidth", {
  6469. /**
  6470. * Gets or sets the cell width to use when animation sheet is enabled
  6471. * @see http://doc.babylonjs.com/how_to/gui#image
  6472. */
  6473. get: function () {
  6474. return this._cellWidth;
  6475. },
  6476. set: function (value) {
  6477. if (this._cellWidth === value) {
  6478. return;
  6479. }
  6480. this._cellWidth = value;
  6481. this._markAsDirty();
  6482. },
  6483. enumerable: true,
  6484. configurable: true
  6485. });
  6486. Object.defineProperty(Image.prototype, "cellHeight", {
  6487. /**
  6488. * Gets or sets the cell height to use when animation sheet is enabled
  6489. * @see http://doc.babylonjs.com/how_to/gui#image
  6490. */
  6491. get: function () {
  6492. return this._cellHeight;
  6493. },
  6494. set: function (value) {
  6495. if (this._cellHeight === value) {
  6496. return;
  6497. }
  6498. this._cellHeight = value;
  6499. this._markAsDirty();
  6500. },
  6501. enumerable: true,
  6502. configurable: true
  6503. });
  6504. Object.defineProperty(Image.prototype, "cellId", {
  6505. /**
  6506. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6507. * @see http://doc.babylonjs.com/how_to/gui#image
  6508. */
  6509. get: function () {
  6510. return this._cellId;
  6511. },
  6512. set: function (value) {
  6513. if (this._cellId === value) {
  6514. return;
  6515. }
  6516. this._cellId = value;
  6517. this._markAsDirty();
  6518. },
  6519. enumerable: true,
  6520. configurable: true
  6521. });
  6522. /**
  6523. * Tests if a given coordinates belong to the current control
  6524. * @param x defines x coordinate to test
  6525. * @param y defines y coordinate to test
  6526. * @returns true if the coordinates are inside the control
  6527. */
  6528. Image.prototype.contains = function (x, y) {
  6529. if (!_super.prototype.contains.call(this, x, y)) {
  6530. return false;
  6531. }
  6532. if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
  6533. return true;
  6534. }
  6535. var canvas = Image._WorkingCanvas;
  6536. var context = canvas.getContext("2d");
  6537. var width = this._currentMeasure.width | 0;
  6538. var height = this._currentMeasure.height | 0;
  6539. var imageData = context.getImageData(0, 0, width, height).data;
  6540. x = (x - this._currentMeasure.left) | 0;
  6541. y = (y - this._currentMeasure.top) | 0;
  6542. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6543. return pickedPixel > 0;
  6544. };
  6545. Image.prototype._getTypeName = function () {
  6546. return "Image";
  6547. };
  6548. /** Force the control to synchronize with its content */
  6549. Image.prototype.synchronizeSizeWithContent = function () {
  6550. if (!this._loaded) {
  6551. return;
  6552. }
  6553. this.width = this._domImage.width + "px";
  6554. this.height = this._domImage.height + "px";
  6555. };
  6556. Image.prototype._processMeasures = function (parentMeasure, context) {
  6557. if (this._loaded) {
  6558. switch (this._stretch) {
  6559. case Image.STRETCH_NONE:
  6560. break;
  6561. case Image.STRETCH_FILL:
  6562. break;
  6563. case Image.STRETCH_UNIFORM:
  6564. break;
  6565. case Image.STRETCH_NINE_PATCH:
  6566. break;
  6567. case Image.STRETCH_EXTEND:
  6568. if (this._autoScale) {
  6569. this.synchronizeSizeWithContent();
  6570. }
  6571. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6572. this.parent.adaptWidthToChildren = true;
  6573. this.parent.adaptHeightToChildren = true;
  6574. }
  6575. break;
  6576. }
  6577. }
  6578. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6579. };
  6580. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6581. if (!this._detectPointerOnOpaqueOnly) {
  6582. return;
  6583. }
  6584. if (!Image._WorkingCanvas) {
  6585. Image._WorkingCanvas = document.createElement('canvas');
  6586. }
  6587. var canvas = Image._WorkingCanvas;
  6588. var width = this._currentMeasure.width;
  6589. var height = this._currentMeasure.height;
  6590. var context = canvas.getContext("2d");
  6591. canvas.width = width;
  6592. canvas.height = height;
  6593. context.clearRect(0, 0, width, height);
  6594. };
  6595. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6596. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6597. if (!this._detectPointerOnOpaqueOnly) {
  6598. return;
  6599. }
  6600. var canvas = Image._WorkingCanvas;
  6601. context = canvas.getContext("2d");
  6602. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6603. };
  6604. Image.prototype._draw = function (context) {
  6605. context.save();
  6606. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6607. context.shadowColor = this.shadowColor;
  6608. context.shadowBlur = this.shadowBlur;
  6609. context.shadowOffsetX = this.shadowOffsetX;
  6610. context.shadowOffsetY = this.shadowOffsetY;
  6611. }
  6612. var x, y, width, height;
  6613. if (this.cellId == -1) {
  6614. x = this._sourceLeft;
  6615. y = this._sourceTop;
  6616. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6617. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6618. }
  6619. else {
  6620. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6621. var column = (this.cellId / rowCount) >> 0;
  6622. var row = this.cellId % rowCount;
  6623. x = this.cellWidth * row;
  6624. y = this.cellHeight * column;
  6625. width = this.cellWidth;
  6626. height = this.cellHeight;
  6627. }
  6628. this._prepareWorkingCanvasForOpaqueDetection();
  6629. this._applyStates(context);
  6630. if (this._loaded) {
  6631. switch (this._stretch) {
  6632. case Image.STRETCH_NONE:
  6633. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6634. break;
  6635. case Image.STRETCH_FILL:
  6636. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6637. break;
  6638. case Image.STRETCH_UNIFORM:
  6639. var hRatio = this._currentMeasure.width / width;
  6640. var vRatio = this._currentMeasure.height / height;
  6641. var ratio = Math.min(hRatio, vRatio);
  6642. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6643. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6644. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6645. break;
  6646. case Image.STRETCH_EXTEND:
  6647. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6648. break;
  6649. case Image.STRETCH_NINE_PATCH:
  6650. this._renderNinePatch(context);
  6651. break;
  6652. }
  6653. }
  6654. context.restore();
  6655. };
  6656. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6657. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6658. };
  6659. Image.prototype._renderNinePatch = function (context) {
  6660. var height = this._imageHeight;
  6661. var leftWidth = this._sliceLeft;
  6662. var topHeight = this._sliceTop;
  6663. var bottomHeight = this._imageHeight - this._sliceBottom;
  6664. var rightWidth = this._imageWidth - this._sliceRight;
  6665. var left = 0;
  6666. var top = 0;
  6667. if (this._populateNinePatchSlicesFromImage) {
  6668. left = 1;
  6669. top = 1;
  6670. height -= 2;
  6671. leftWidth -= 1;
  6672. topHeight -= 1;
  6673. bottomHeight -= 1;
  6674. rightWidth -= 1;
  6675. }
  6676. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6677. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6678. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6679. // Corners
  6680. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6681. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6682. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6683. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6684. // Center
  6685. 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);
  6686. // Borders
  6687. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6688. 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);
  6689. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6690. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6691. };
  6692. Image.prototype.dispose = function () {
  6693. _super.prototype.dispose.call(this);
  6694. this.onImageLoadedObservable.clear();
  6695. };
  6696. Image._WorkingCanvas = null;
  6697. // Static
  6698. /** STRETCH_NONE */
  6699. Image.STRETCH_NONE = 0;
  6700. /** STRETCH_FILL */
  6701. Image.STRETCH_FILL = 1;
  6702. /** STRETCH_UNIFORM */
  6703. Image.STRETCH_UNIFORM = 2;
  6704. /** STRETCH_EXTEND */
  6705. Image.STRETCH_EXTEND = 3;
  6706. /** NINE_PATCH */
  6707. Image.STRETCH_NINE_PATCH = 4;
  6708. return Image;
  6709. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6710. /***/ }),
  6711. /***/ "./2D/controls/index.ts":
  6712. /*!******************************!*\
  6713. !*** ./2D/controls/index.ts ***!
  6714. \******************************/
  6715. /*! 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 */
  6716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6717. "use strict";
  6718. __webpack_require__.r(__webpack_exports__);
  6719. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6721. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6723. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6725. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6727. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6729. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6731. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6733. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6735. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6737. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6739. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6741. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6743. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6745. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6747. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6753. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6755. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6758. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6761. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6763. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6765. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6767. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6769. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6771. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6773. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_24__["name"]; });
  6775. /***/ }),
  6776. /***/ "./2D/controls/inputPassword.ts":
  6777. /*!**************************************!*\
  6778. !*** ./2D/controls/inputPassword.ts ***!
  6779. \**************************************/
  6780. /*! exports provided: InputPassword */
  6781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6782. "use strict";
  6783. __webpack_require__.r(__webpack_exports__);
  6784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6786. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6787. /**
  6788. * Class used to create a password control
  6789. */
  6790. var InputPassword = /** @class */ (function (_super) {
  6791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputPassword, _super);
  6792. function InputPassword() {
  6793. return _super !== null && _super.apply(this, arguments) || this;
  6794. }
  6795. InputPassword.prototype._beforeRenderText = function (text) {
  6796. var txt = "";
  6797. for (var i = 0; i < text.length; i++) {
  6798. txt += "\u2022";
  6799. }
  6800. return txt;
  6801. };
  6802. return InputPassword;
  6803. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6804. /***/ }),
  6805. /***/ "./2D/controls/inputText.ts":
  6806. /*!**********************************!*\
  6807. !*** ./2D/controls/inputText.ts ***!
  6808. \**********************************/
  6809. /*! exports provided: InputText */
  6810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6811. "use strict";
  6812. __webpack_require__.r(__webpack_exports__);
  6813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6814. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6815. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6816. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6817. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6818. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6819. /**
  6820. * Class used to create input text control
  6821. */
  6822. var InputText = /** @class */ (function (_super) {
  6823. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InputText, _super);
  6824. /**
  6825. * Creates a new InputText
  6826. * @param name defines the control name
  6827. * @param text defines the text of the control
  6828. */
  6829. function InputText(name, text) {
  6830. if (text === void 0) { text = ""; }
  6831. var _this = _super.call(this, name) || this;
  6832. _this.name = name;
  6833. _this._text = "";
  6834. _this._placeholderText = "";
  6835. _this._background = "#222222";
  6836. _this._focusedBackground = "#000000";
  6837. _this._focusedColor = "white";
  6838. _this._placeholderColor = "gray";
  6839. _this._thickness = 1;
  6840. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6841. _this._autoStretchWidth = true;
  6842. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6843. _this._isFocused = false;
  6844. _this._blinkIsEven = false;
  6845. _this._cursorOffset = 0;
  6846. _this._deadKey = false;
  6847. _this._addKey = true;
  6848. _this._currentKey = "";
  6849. _this._isTextHighlightOn = false;
  6850. _this._textHighlightColor = "#d5e0ff";
  6851. _this._highligherOpacity = 0.4;
  6852. _this._highlightedText = "";
  6853. _this._startHighlightIndex = 0;
  6854. _this._endHighlightIndex = 0;
  6855. _this._cursorIndex = -1;
  6856. _this._onFocusSelectAll = false;
  6857. _this._isPointerDown = false;
  6858. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  6859. _this.promptMessage = "Please enter text:";
  6860. /** Force disable prompt on mobile device */
  6861. _this.disableMobilePrompt = false;
  6862. /** Observable raised when the text changes */
  6863. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6864. /** Observable raised just before an entered character is to be added */
  6865. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6866. /** Observable raised when the control gets the focus */
  6867. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6868. /** Observable raised when the control loses the focus */
  6869. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6870. /**Observable raised when the text is highlighted */
  6871. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6872. /**Observable raised when copy event is triggered */
  6873. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6874. /** Observable raised when cut event is triggered */
  6875. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6876. /** Observable raised when paste event is triggered */
  6877. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6878. /** Observable raised when a key event was processed */
  6879. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6880. _this.text = text;
  6881. _this.isPointerBlocker = true;
  6882. return _this;
  6883. }
  6884. Object.defineProperty(InputText.prototype, "maxWidth", {
  6885. /** Gets or sets the maximum width allowed by the control */
  6886. get: function () {
  6887. return this._maxWidth.toString(this._host);
  6888. },
  6889. set: function (value) {
  6890. if (this._maxWidth.toString(this._host) === value) {
  6891. return;
  6892. }
  6893. if (this._maxWidth.fromString(value)) {
  6894. this._markAsDirty();
  6895. }
  6896. },
  6897. enumerable: true,
  6898. configurable: true
  6899. });
  6900. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  6901. /** Gets the maximum width allowed by the control in pixels */
  6902. get: function () {
  6903. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6904. },
  6905. enumerable: true,
  6906. configurable: true
  6907. });
  6908. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  6909. /** Gets or sets the text highlighter transparency; default: 0.4 */
  6910. get: function () {
  6911. return this._highligherOpacity;
  6912. },
  6913. set: function (value) {
  6914. if (this._highligherOpacity === value) {
  6915. return;
  6916. }
  6917. this._highligherOpacity = value;
  6918. this._markAsDirty();
  6919. },
  6920. enumerable: true,
  6921. configurable: true
  6922. });
  6923. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  6924. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  6925. get: function () {
  6926. return this._onFocusSelectAll;
  6927. },
  6928. set: function (value) {
  6929. if (this._onFocusSelectAll === value) {
  6930. return;
  6931. }
  6932. this._onFocusSelectAll = value;
  6933. this._markAsDirty();
  6934. },
  6935. enumerable: true,
  6936. configurable: true
  6937. });
  6938. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  6939. /** Gets or sets the text hightlight color */
  6940. get: function () {
  6941. return this._textHighlightColor;
  6942. },
  6943. set: function (value) {
  6944. if (this._textHighlightColor === value) {
  6945. return;
  6946. }
  6947. this._textHighlightColor = value;
  6948. this._markAsDirty();
  6949. },
  6950. enumerable: true,
  6951. configurable: true
  6952. });
  6953. Object.defineProperty(InputText.prototype, "margin", {
  6954. /** Gets or sets control margin */
  6955. get: function () {
  6956. return this._margin.toString(this._host);
  6957. },
  6958. set: function (value) {
  6959. if (this._margin.toString(this._host) === value) {
  6960. return;
  6961. }
  6962. if (this._margin.fromString(value)) {
  6963. this._markAsDirty();
  6964. }
  6965. },
  6966. enumerable: true,
  6967. configurable: true
  6968. });
  6969. Object.defineProperty(InputText.prototype, "marginInPixels", {
  6970. /** Gets control margin in pixels */
  6971. get: function () {
  6972. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  6973. },
  6974. enumerable: true,
  6975. configurable: true
  6976. });
  6977. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  6978. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  6979. get: function () {
  6980. return this._autoStretchWidth;
  6981. },
  6982. set: function (value) {
  6983. if (this._autoStretchWidth === value) {
  6984. return;
  6985. }
  6986. this._autoStretchWidth = value;
  6987. this._markAsDirty();
  6988. },
  6989. enumerable: true,
  6990. configurable: true
  6991. });
  6992. Object.defineProperty(InputText.prototype, "thickness", {
  6993. /** Gets or sets border thickness */
  6994. get: function () {
  6995. return this._thickness;
  6996. },
  6997. set: function (value) {
  6998. if (this._thickness === value) {
  6999. return;
  7000. }
  7001. this._thickness = value;
  7002. this._markAsDirty();
  7003. },
  7004. enumerable: true,
  7005. configurable: true
  7006. });
  7007. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7008. /** Gets or sets the background color when focused */
  7009. get: function () {
  7010. return this._focusedBackground;
  7011. },
  7012. set: function (value) {
  7013. if (this._focusedBackground === value) {
  7014. return;
  7015. }
  7016. this._focusedBackground = value;
  7017. this._markAsDirty();
  7018. },
  7019. enumerable: true,
  7020. configurable: true
  7021. });
  7022. Object.defineProperty(InputText.prototype, "focusedColor", {
  7023. /** Gets or sets the background color when focused */
  7024. get: function () {
  7025. return this._focusedColor;
  7026. },
  7027. set: function (value) {
  7028. if (this._focusedColor === value) {
  7029. return;
  7030. }
  7031. this._focusedColor = value;
  7032. this._markAsDirty();
  7033. },
  7034. enumerable: true,
  7035. configurable: true
  7036. });
  7037. Object.defineProperty(InputText.prototype, "background", {
  7038. /** Gets or sets the background color */
  7039. get: function () {
  7040. return this._background;
  7041. },
  7042. set: function (value) {
  7043. if (this._background === value) {
  7044. return;
  7045. }
  7046. this._background = value;
  7047. this._markAsDirty();
  7048. },
  7049. enumerable: true,
  7050. configurable: true
  7051. });
  7052. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7053. /** Gets or sets the placeholder color */
  7054. get: function () {
  7055. return this._placeholderColor;
  7056. },
  7057. set: function (value) {
  7058. if (this._placeholderColor === value) {
  7059. return;
  7060. }
  7061. this._placeholderColor = value;
  7062. this._markAsDirty();
  7063. },
  7064. enumerable: true,
  7065. configurable: true
  7066. });
  7067. Object.defineProperty(InputText.prototype, "placeholderText", {
  7068. /** Gets or sets the text displayed when the control is empty */
  7069. get: function () {
  7070. return this._placeholderText;
  7071. },
  7072. set: function (value) {
  7073. if (this._placeholderText === value) {
  7074. return;
  7075. }
  7076. this._placeholderText = value;
  7077. this._markAsDirty();
  7078. },
  7079. enumerable: true,
  7080. configurable: true
  7081. });
  7082. Object.defineProperty(InputText.prototype, "deadKey", {
  7083. /** Gets or sets the dead key flag */
  7084. get: function () {
  7085. return this._deadKey;
  7086. },
  7087. set: function (flag) {
  7088. this._deadKey = flag;
  7089. },
  7090. enumerable: true,
  7091. configurable: true
  7092. });
  7093. Object.defineProperty(InputText.prototype, "highlightedText", {
  7094. /** Gets or sets the highlight text */
  7095. get: function () {
  7096. return this._highlightedText;
  7097. },
  7098. set: function (text) {
  7099. if (this._highlightedText === text) {
  7100. return;
  7101. }
  7102. this._highlightedText = text;
  7103. this._markAsDirty();
  7104. },
  7105. enumerable: true,
  7106. configurable: true
  7107. });
  7108. Object.defineProperty(InputText.prototype, "addKey", {
  7109. /** Gets or sets if the current key should be added */
  7110. get: function () {
  7111. return this._addKey;
  7112. },
  7113. set: function (flag) {
  7114. this._addKey = flag;
  7115. },
  7116. enumerable: true,
  7117. configurable: true
  7118. });
  7119. Object.defineProperty(InputText.prototype, "currentKey", {
  7120. /** Gets or sets the value of the current key being entered */
  7121. get: function () {
  7122. return this._currentKey;
  7123. },
  7124. set: function (key) {
  7125. this._currentKey = key;
  7126. },
  7127. enumerable: true,
  7128. configurable: true
  7129. });
  7130. Object.defineProperty(InputText.prototype, "text", {
  7131. /** Gets or sets the text displayed in the control */
  7132. get: function () {
  7133. return this._text;
  7134. },
  7135. set: function (value) {
  7136. var valueAsString = value.toString(); // Forcing convertion
  7137. if (this._text === valueAsString) {
  7138. return;
  7139. }
  7140. this._text = valueAsString;
  7141. this._markAsDirty();
  7142. this.onTextChangedObservable.notifyObservers(this);
  7143. },
  7144. enumerable: true,
  7145. configurable: true
  7146. });
  7147. Object.defineProperty(InputText.prototype, "width", {
  7148. /** Gets or sets control width */
  7149. get: function () {
  7150. return this._width.toString(this._host);
  7151. },
  7152. set: function (value) {
  7153. if (this._width.toString(this._host) === value) {
  7154. return;
  7155. }
  7156. if (this._width.fromString(value)) {
  7157. this._markAsDirty();
  7158. }
  7159. this.autoStretchWidth = false;
  7160. },
  7161. enumerable: true,
  7162. configurable: true
  7163. });
  7164. /** @hidden */
  7165. InputText.prototype.onBlur = function () {
  7166. this._isFocused = false;
  7167. this._scrollLeft = null;
  7168. this._cursorOffset = 0;
  7169. clearTimeout(this._blinkTimeout);
  7170. this._markAsDirty();
  7171. this.onBlurObservable.notifyObservers(this);
  7172. this._host.unRegisterClipboardEvents();
  7173. if (this._onClipboardObserver) {
  7174. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7175. }
  7176. var scene = this._host.getScene();
  7177. if (this._onPointerDblTapObserver && scene) {
  7178. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7179. }
  7180. };
  7181. /** @hidden */
  7182. InputText.prototype.onFocus = function () {
  7183. var _this = this;
  7184. if (!this._isEnabled) {
  7185. return;
  7186. }
  7187. this._scrollLeft = null;
  7188. this._isFocused = true;
  7189. this._blinkIsEven = false;
  7190. this._cursorOffset = 0;
  7191. this._markAsDirty();
  7192. this.onFocusObservable.notifyObservers(this);
  7193. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7194. var value = prompt(this.promptMessage);
  7195. if (value !== null) {
  7196. this.text = value;
  7197. }
  7198. this._host.focusedControl = null;
  7199. return;
  7200. }
  7201. this._host.registerClipboardEvents();
  7202. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7203. // process clipboard event, can be configured.
  7204. switch (clipboardInfo.type) {
  7205. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7206. _this._onCopyText(clipboardInfo.event);
  7207. _this.onTextCopyObservable.notifyObservers(_this);
  7208. break;
  7209. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7210. _this._onCutText(clipboardInfo.event);
  7211. _this.onTextCutObservable.notifyObservers(_this);
  7212. break;
  7213. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7214. _this._onPasteText(clipboardInfo.event);
  7215. _this.onTextPasteObservable.notifyObservers(_this);
  7216. break;
  7217. default: return;
  7218. }
  7219. });
  7220. var scene = this._host.getScene();
  7221. if (scene) {
  7222. //register the pointer double tap event
  7223. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7224. if (!_this._isFocused) {
  7225. return;
  7226. }
  7227. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7228. _this._processDblClick(pointerInfo);
  7229. }
  7230. });
  7231. }
  7232. if (this._onFocusSelectAll) {
  7233. this._selectAllText();
  7234. }
  7235. };
  7236. InputText.prototype._getTypeName = function () {
  7237. return "InputText";
  7238. };
  7239. /**
  7240. * Function called to get the list of controls that should not steal the focus from this control
  7241. * @returns an array of controls
  7242. */
  7243. InputText.prototype.keepsFocusWith = function () {
  7244. if (!this._connectedVirtualKeyboard) {
  7245. return null;
  7246. }
  7247. return [this._connectedVirtualKeyboard];
  7248. };
  7249. /** @hidden */
  7250. InputText.prototype.processKey = function (keyCode, key, evt) {
  7251. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7252. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7253. return;
  7254. }
  7255. //select all
  7256. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7257. this._selectAllText();
  7258. evt.preventDefault();
  7259. return;
  7260. }
  7261. // Specific cases
  7262. switch (keyCode) {
  7263. case 32: //SPACE
  7264. key = " "; //ie11 key for space is "Spacebar"
  7265. break;
  7266. case 191: //SLASH
  7267. if (evt) {
  7268. evt.preventDefault();
  7269. }
  7270. break;
  7271. case 8: // BACKSPACE
  7272. if (this._text && this._text.length > 0) {
  7273. //delete the highlighted text
  7274. if (this._isTextHighlightOn) {
  7275. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7276. this._isTextHighlightOn = false;
  7277. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7278. this._blinkIsEven = false;
  7279. if (evt) {
  7280. evt.preventDefault();
  7281. }
  7282. return;
  7283. }
  7284. //delete single character
  7285. if (this._cursorOffset === 0) {
  7286. this.text = this._text.substr(0, this._text.length - 1);
  7287. }
  7288. else {
  7289. var deletePosition = this._text.length - this._cursorOffset;
  7290. if (deletePosition > 0) {
  7291. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7292. }
  7293. }
  7294. }
  7295. if (evt) {
  7296. evt.preventDefault();
  7297. }
  7298. return;
  7299. case 46: // DELETE
  7300. if (this._isTextHighlightOn) {
  7301. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7302. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7303. while (decrementor > 0 && this._cursorOffset > 0) {
  7304. this._cursorOffset--;
  7305. }
  7306. this._isTextHighlightOn = false;
  7307. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7308. if (evt) {
  7309. evt.preventDefault();
  7310. }
  7311. return;
  7312. }
  7313. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7314. var deletePosition = this._text.length - this._cursorOffset;
  7315. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7316. this._cursorOffset--;
  7317. }
  7318. if (evt) {
  7319. evt.preventDefault();
  7320. }
  7321. return;
  7322. case 13: // RETURN
  7323. this._host.focusedControl = null;
  7324. this._isTextHighlightOn = false;
  7325. return;
  7326. case 35: // END
  7327. this._cursorOffset = 0;
  7328. this._blinkIsEven = false;
  7329. this._isTextHighlightOn = false;
  7330. this._markAsDirty();
  7331. return;
  7332. case 36: // HOME
  7333. this._cursorOffset = this._text.length;
  7334. this._blinkIsEven = false;
  7335. this._isTextHighlightOn = false;
  7336. this._markAsDirty();
  7337. return;
  7338. case 37: // LEFT
  7339. this._cursorOffset++;
  7340. if (this._cursorOffset > this._text.length) {
  7341. this._cursorOffset = this._text.length;
  7342. }
  7343. if (evt && evt.shiftKey) {
  7344. // update the cursor
  7345. this._blinkIsEven = false;
  7346. // shift + ctrl/cmd + <-
  7347. if (evt.ctrlKey || evt.metaKey) {
  7348. if (!this._isTextHighlightOn) {
  7349. if (this._text.length === this._cursorOffset) {
  7350. return;
  7351. }
  7352. else {
  7353. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7354. }
  7355. }
  7356. this._startHighlightIndex = 0;
  7357. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7358. this._cursorOffset = this._text.length;
  7359. this._isTextHighlightOn = true;
  7360. this._markAsDirty();
  7361. return;
  7362. }
  7363. //store the starting point
  7364. if (!this._isTextHighlightOn) {
  7365. this._isTextHighlightOn = true;
  7366. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7367. }
  7368. //if text is already highlighted
  7369. else if (this._cursorIndex === -1) {
  7370. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7371. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7372. }
  7373. //set the highlight indexes
  7374. if (this._cursorIndex < this._cursorOffset) {
  7375. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7376. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7377. }
  7378. else if (this._cursorIndex > this._cursorOffset) {
  7379. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7380. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7381. }
  7382. else {
  7383. this._isTextHighlightOn = false;
  7384. }
  7385. this._markAsDirty();
  7386. return;
  7387. }
  7388. if (this._isTextHighlightOn) {
  7389. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7390. this._isTextHighlightOn = false;
  7391. }
  7392. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7393. this._cursorOffset = this.text.length;
  7394. evt.preventDefault();
  7395. }
  7396. this._blinkIsEven = false;
  7397. this._isTextHighlightOn = false;
  7398. this._cursorIndex = -1;
  7399. this._markAsDirty();
  7400. return;
  7401. case 39: // RIGHT
  7402. this._cursorOffset--;
  7403. if (this._cursorOffset < 0) {
  7404. this._cursorOffset = 0;
  7405. }
  7406. if (evt && evt.shiftKey) {
  7407. //update the cursor
  7408. this._blinkIsEven = false;
  7409. //shift + ctrl/cmd + ->
  7410. if (evt.ctrlKey || evt.metaKey) {
  7411. if (!this._isTextHighlightOn) {
  7412. if (this._cursorOffset === 0) {
  7413. return;
  7414. }
  7415. else {
  7416. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7417. }
  7418. }
  7419. this._endHighlightIndex = this._text.length;
  7420. this._isTextHighlightOn = true;
  7421. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7422. this._cursorOffset = 0;
  7423. this._markAsDirty();
  7424. return;
  7425. }
  7426. if (!this._isTextHighlightOn) {
  7427. this._isTextHighlightOn = true;
  7428. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7429. }
  7430. //if text is already highlighted
  7431. else if (this._cursorIndex === -1) {
  7432. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7433. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7434. }
  7435. //set the highlight indexes
  7436. if (this._cursorIndex < this._cursorOffset) {
  7437. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7438. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7439. }
  7440. else if (this._cursorIndex > this._cursorOffset) {
  7441. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7442. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7443. }
  7444. else {
  7445. this._isTextHighlightOn = false;
  7446. }
  7447. this._markAsDirty();
  7448. return;
  7449. }
  7450. if (this._isTextHighlightOn) {
  7451. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7452. this._isTextHighlightOn = false;
  7453. }
  7454. //ctr + ->
  7455. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7456. this._cursorOffset = 0;
  7457. evt.preventDefault();
  7458. }
  7459. this._blinkIsEven = false;
  7460. this._isTextHighlightOn = false;
  7461. this._cursorIndex = -1;
  7462. this._markAsDirty();
  7463. return;
  7464. case 222: // Dead
  7465. if (evt) {
  7466. evt.preventDefault();
  7467. }
  7468. this._cursorIndex = -1;
  7469. this.deadKey = true;
  7470. break;
  7471. }
  7472. // Printable characters
  7473. if (key &&
  7474. ((keyCode === -1) || // Direct access
  7475. (keyCode === 32) || // Space
  7476. (keyCode > 47 && keyCode < 64) || // Numbers
  7477. (keyCode > 64 && keyCode < 91) || // Letters
  7478. (keyCode > 159 && keyCode < 193) || // Special characters
  7479. (keyCode > 218 && keyCode < 223) || // Special characters
  7480. (keyCode > 95 && keyCode < 112))) { // Numpad
  7481. this._currentKey = key;
  7482. this.onBeforeKeyAddObservable.notifyObservers(this);
  7483. key = this._currentKey;
  7484. if (this._addKey) {
  7485. if (this._isTextHighlightOn) {
  7486. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7487. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7488. this._isTextHighlightOn = false;
  7489. this._blinkIsEven = false;
  7490. this._markAsDirty();
  7491. }
  7492. else if (this._cursorOffset === 0) {
  7493. this.text += key;
  7494. }
  7495. else {
  7496. var insertPosition = this._text.length - this._cursorOffset;
  7497. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7498. }
  7499. }
  7500. }
  7501. };
  7502. /** @hidden */
  7503. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7504. //update the cursor
  7505. this._blinkIsEven = false;
  7506. if (this._cursorIndex === -1) {
  7507. this._cursorIndex = offset;
  7508. }
  7509. else {
  7510. if (this._cursorIndex < this._cursorOffset) {
  7511. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7512. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7513. }
  7514. else if (this._cursorIndex > this._cursorOffset) {
  7515. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7516. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7517. }
  7518. else {
  7519. this._isTextHighlightOn = false;
  7520. this._markAsDirty();
  7521. return;
  7522. }
  7523. }
  7524. this._isTextHighlightOn = true;
  7525. this._markAsDirty();
  7526. };
  7527. /** @hidden */
  7528. InputText.prototype._processDblClick = function (evt) {
  7529. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7530. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7531. this._endHighlightIndex = this._startHighlightIndex;
  7532. var rWord = /\w+/g, moveLeft, moveRight;
  7533. do {
  7534. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7535. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7536. } while (moveLeft || moveRight);
  7537. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7538. this.onTextHighlightObservable.notifyObservers(this);
  7539. this._isTextHighlightOn = true;
  7540. this._clickedCoordinate = null;
  7541. this._blinkIsEven = true;
  7542. this._cursorIndex = -1;
  7543. this._markAsDirty();
  7544. };
  7545. /** @hidden */
  7546. InputText.prototype._selectAllText = function () {
  7547. this._blinkIsEven = true;
  7548. this._isTextHighlightOn = true;
  7549. this._startHighlightIndex = 0;
  7550. this._endHighlightIndex = this._text.length;
  7551. this._cursorOffset = this._text.length;
  7552. this._cursorIndex = -1;
  7553. this._markAsDirty();
  7554. };
  7555. /**
  7556. * Handles the keyboard event
  7557. * @param evt Defines the KeyboardEvent
  7558. */
  7559. InputText.prototype.processKeyboard = function (evt) {
  7560. // process pressed key
  7561. this.processKey(evt.keyCode, evt.key, evt);
  7562. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7563. };
  7564. /** @hidden */
  7565. InputText.prototype._onCopyText = function (ev) {
  7566. this._isTextHighlightOn = false;
  7567. //when write permission to clipbaord data is denied
  7568. try {
  7569. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7570. }
  7571. catch (_a) { } //pass
  7572. this._host.clipboardData = this._highlightedText;
  7573. };
  7574. /** @hidden */
  7575. InputText.prototype._onCutText = function (ev) {
  7576. if (!this._highlightedText) {
  7577. return;
  7578. }
  7579. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7580. this._isTextHighlightOn = false;
  7581. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7582. //when write permission to clipbaord data is denied
  7583. try {
  7584. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7585. }
  7586. catch (_a) { } //pass
  7587. this._host.clipboardData = this._highlightedText;
  7588. this._highlightedText = "";
  7589. };
  7590. /** @hidden */
  7591. InputText.prototype._onPasteText = function (ev) {
  7592. var data = "";
  7593. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7594. data = ev.clipboardData.getData("text/plain");
  7595. }
  7596. else {
  7597. //get the cached data; returns blank string by default
  7598. data = this._host.clipboardData;
  7599. }
  7600. var insertPosition = this._text.length - this._cursorOffset;
  7601. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7602. };
  7603. InputText.prototype._draw = function (context) {
  7604. var _this = this;
  7605. context.save();
  7606. this._applyStates(context);
  7607. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7608. context.shadowColor = this.shadowColor;
  7609. context.shadowBlur = this.shadowBlur;
  7610. context.shadowOffsetX = this.shadowOffsetX;
  7611. context.shadowOffsetY = this.shadowOffsetY;
  7612. }
  7613. // Background
  7614. if (this._isFocused) {
  7615. if (this._focusedBackground) {
  7616. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7617. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7618. }
  7619. }
  7620. else if (this._background) {
  7621. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7622. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7623. }
  7624. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7625. context.shadowBlur = 0;
  7626. context.shadowOffsetX = 0;
  7627. context.shadowOffsetY = 0;
  7628. }
  7629. if (!this._fontOffset) {
  7630. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7631. }
  7632. // Text
  7633. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7634. if (this.color) {
  7635. context.fillStyle = this.color;
  7636. }
  7637. var text = this._beforeRenderText(this._text);
  7638. if (!this._isFocused && !this._text && this._placeholderText) {
  7639. text = this._placeholderText;
  7640. if (this._placeholderColor) {
  7641. context.fillStyle = this._placeholderColor;
  7642. }
  7643. }
  7644. this._textWidth = context.measureText(text).width;
  7645. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7646. if (this._autoStretchWidth) {
  7647. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7648. }
  7649. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7650. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7651. context.save();
  7652. context.beginPath();
  7653. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7654. context.clip();
  7655. if (this._isFocused && this._textWidth > availableWidth) {
  7656. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7657. if (!this._scrollLeft) {
  7658. this._scrollLeft = textLeft;
  7659. }
  7660. }
  7661. else {
  7662. this._scrollLeft = clipTextLeft;
  7663. }
  7664. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7665. // Cursor
  7666. if (this._isFocused) {
  7667. // Need to move cursor
  7668. if (this._clickedCoordinate) {
  7669. var rightPosition = this._scrollLeft + this._textWidth;
  7670. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7671. var currentSize = 0;
  7672. this._cursorOffset = 0;
  7673. var previousDist = 0;
  7674. do {
  7675. if (this._cursorOffset) {
  7676. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7677. }
  7678. this._cursorOffset++;
  7679. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7680. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7681. // Find closest move
  7682. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7683. this._cursorOffset--;
  7684. }
  7685. this._blinkIsEven = false;
  7686. this._clickedCoordinate = null;
  7687. }
  7688. // Render cursor
  7689. if (!this._blinkIsEven) {
  7690. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7691. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7692. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7693. if (cursorLeft < clipTextLeft) {
  7694. this._scrollLeft += (clipTextLeft - cursorLeft);
  7695. cursorLeft = clipTextLeft;
  7696. this._markAsDirty();
  7697. }
  7698. else if (cursorLeft > clipTextLeft + availableWidth) {
  7699. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7700. cursorLeft = clipTextLeft + availableWidth;
  7701. this._markAsDirty();
  7702. }
  7703. if (!this._isTextHighlightOn) {
  7704. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7705. }
  7706. }
  7707. clearTimeout(this._blinkTimeout);
  7708. this._blinkTimeout = setTimeout(function () {
  7709. _this._blinkIsEven = !_this._blinkIsEven;
  7710. _this._markAsDirty();
  7711. }, 500);
  7712. //show the highlighted text
  7713. if (this._isTextHighlightOn) {
  7714. clearTimeout(this._blinkTimeout);
  7715. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7716. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7717. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7718. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7719. if (highlightCursorLeft < clipTextLeft) {
  7720. width = width - (clipTextLeft - highlightCursorLeft);
  7721. if (!width) {
  7722. // when using left arrow on text.length > availableWidth;
  7723. // assigns the width of the first letter after clipTextLeft
  7724. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7725. }
  7726. highlightCursorLeft = clipTextLeft;
  7727. }
  7728. //for transparancy
  7729. context.globalAlpha = this._highligherOpacity;
  7730. context.fillStyle = this._textHighlightColor;
  7731. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7732. context.globalAlpha = 1.0;
  7733. }
  7734. }
  7735. context.restore();
  7736. // Border
  7737. if (this._thickness) {
  7738. if (this._isFocused) {
  7739. if (this.focusedColor) {
  7740. context.strokeStyle = this.focusedColor;
  7741. }
  7742. }
  7743. else {
  7744. if (this.color) {
  7745. context.strokeStyle = this.color;
  7746. }
  7747. }
  7748. context.lineWidth = this._thickness;
  7749. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7750. }
  7751. context.restore();
  7752. };
  7753. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7754. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7755. return false;
  7756. }
  7757. this._clickedCoordinate = coordinates.x;
  7758. this._isTextHighlightOn = false;
  7759. this._highlightedText = "";
  7760. this._cursorIndex = -1;
  7761. this._isPointerDown = true;
  7762. this._host._capturingControl[pointerId] = this;
  7763. if (this._host.focusedControl === this) {
  7764. // Move cursor
  7765. clearTimeout(this._blinkTimeout);
  7766. this._markAsDirty();
  7767. return true;
  7768. }
  7769. if (!this._isEnabled) {
  7770. return false;
  7771. }
  7772. this._host.focusedControl = this;
  7773. return true;
  7774. };
  7775. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7776. if (this._host.focusedControl === this && this._isPointerDown) {
  7777. this._clickedCoordinate = coordinates.x;
  7778. this._markAsDirty();
  7779. this._updateValueFromCursorIndex(this._cursorOffset);
  7780. }
  7781. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7782. };
  7783. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7784. this._isPointerDown = false;
  7785. delete this._host._capturingControl[pointerId];
  7786. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7787. };
  7788. InputText.prototype._beforeRenderText = function (text) {
  7789. return text;
  7790. };
  7791. InputText.prototype.dispose = function () {
  7792. _super.prototype.dispose.call(this);
  7793. this.onBlurObservable.clear();
  7794. this.onFocusObservable.clear();
  7795. this.onTextChangedObservable.clear();
  7796. this.onTextCopyObservable.clear();
  7797. this.onTextCutObservable.clear();
  7798. this.onTextPasteObservable.clear();
  7799. this.onTextHighlightObservable.clear();
  7800. this.onKeyboardEventProcessedObservable.clear();
  7801. };
  7802. return InputText;
  7803. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7804. /***/ }),
  7805. /***/ "./2D/controls/line.ts":
  7806. /*!*****************************!*\
  7807. !*** ./2D/controls/line.ts ***!
  7808. \*****************************/
  7809. /*! exports provided: Line */
  7810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7811. "use strict";
  7812. __webpack_require__.r(__webpack_exports__);
  7813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7814. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7815. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  7816. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7817. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7818. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7819. /** Class used to render 2D lines */
  7820. var Line = /** @class */ (function (_super) {
  7821. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Line, _super);
  7822. /**
  7823. * Creates a new Line
  7824. * @param name defines the control name
  7825. */
  7826. function Line(name) {
  7827. var _this = _super.call(this, name) || this;
  7828. _this.name = name;
  7829. _this._lineWidth = 1;
  7830. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7831. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7832. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7833. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7834. _this._dash = new Array();
  7835. _this.isHitTestVisible = false;
  7836. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7837. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7838. return _this;
  7839. }
  7840. Object.defineProperty(Line.prototype, "dash", {
  7841. /** Gets or sets the dash pattern */
  7842. get: function () {
  7843. return this._dash;
  7844. },
  7845. set: function (value) {
  7846. if (this._dash === value) {
  7847. return;
  7848. }
  7849. this._dash = value;
  7850. this._markAsDirty();
  7851. },
  7852. enumerable: true,
  7853. configurable: true
  7854. });
  7855. Object.defineProperty(Line.prototype, "connectedControl", {
  7856. /** Gets or sets the control connected with the line end */
  7857. get: function () {
  7858. return this._connectedControl;
  7859. },
  7860. set: function (value) {
  7861. var _this = this;
  7862. if (this._connectedControl === value) {
  7863. return;
  7864. }
  7865. if (this._connectedControlDirtyObserver && this._connectedControl) {
  7866. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  7867. this._connectedControlDirtyObserver = null;
  7868. }
  7869. if (value) {
  7870. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  7871. }
  7872. this._connectedControl = value;
  7873. this._markAsDirty();
  7874. },
  7875. enumerable: true,
  7876. configurable: true
  7877. });
  7878. Object.defineProperty(Line.prototype, "x1", {
  7879. /** Gets or sets start coordinates on X axis */
  7880. get: function () {
  7881. return this._x1.toString(this._host);
  7882. },
  7883. set: function (value) {
  7884. if (this._x1.toString(this._host) === value) {
  7885. return;
  7886. }
  7887. if (this._x1.fromString(value)) {
  7888. this._markAsDirty();
  7889. }
  7890. },
  7891. enumerable: true,
  7892. configurable: true
  7893. });
  7894. Object.defineProperty(Line.prototype, "y1", {
  7895. /** Gets or sets start coordinates on Y axis */
  7896. get: function () {
  7897. return this._y1.toString(this._host);
  7898. },
  7899. set: function (value) {
  7900. if (this._y1.toString(this._host) === value) {
  7901. return;
  7902. }
  7903. if (this._y1.fromString(value)) {
  7904. this._markAsDirty();
  7905. }
  7906. },
  7907. enumerable: true,
  7908. configurable: true
  7909. });
  7910. Object.defineProperty(Line.prototype, "x2", {
  7911. /** Gets or sets end coordinates on X axis */
  7912. get: function () {
  7913. return this._x2.toString(this._host);
  7914. },
  7915. set: function (value) {
  7916. if (this._x2.toString(this._host) === value) {
  7917. return;
  7918. }
  7919. if (this._x2.fromString(value)) {
  7920. this._markAsDirty();
  7921. }
  7922. },
  7923. enumerable: true,
  7924. configurable: true
  7925. });
  7926. Object.defineProperty(Line.prototype, "y2", {
  7927. /** Gets or sets end coordinates on Y axis */
  7928. get: function () {
  7929. return this._y2.toString(this._host);
  7930. },
  7931. set: function (value) {
  7932. if (this._y2.toString(this._host) === value) {
  7933. return;
  7934. }
  7935. if (this._y2.fromString(value)) {
  7936. this._markAsDirty();
  7937. }
  7938. },
  7939. enumerable: true,
  7940. configurable: true
  7941. });
  7942. Object.defineProperty(Line.prototype, "lineWidth", {
  7943. /** Gets or sets line width */
  7944. get: function () {
  7945. return this._lineWidth;
  7946. },
  7947. set: function (value) {
  7948. if (this._lineWidth === value) {
  7949. return;
  7950. }
  7951. this._lineWidth = value;
  7952. this._markAsDirty();
  7953. },
  7954. enumerable: true,
  7955. configurable: true
  7956. });
  7957. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  7958. /** Gets or sets horizontal alignment */
  7959. set: function (value) {
  7960. return;
  7961. },
  7962. enumerable: true,
  7963. configurable: true
  7964. });
  7965. Object.defineProperty(Line.prototype, "verticalAlignment", {
  7966. /** Gets or sets vertical alignment */
  7967. set: function (value) {
  7968. return;
  7969. },
  7970. enumerable: true,
  7971. configurable: true
  7972. });
  7973. Object.defineProperty(Line.prototype, "_effectiveX2", {
  7974. get: function () {
  7975. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  7976. },
  7977. enumerable: true,
  7978. configurable: true
  7979. });
  7980. Object.defineProperty(Line.prototype, "_effectiveY2", {
  7981. get: function () {
  7982. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  7983. },
  7984. enumerable: true,
  7985. configurable: true
  7986. });
  7987. Line.prototype._getTypeName = function () {
  7988. return "Line";
  7989. };
  7990. Line.prototype._draw = function (context) {
  7991. context.save();
  7992. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7993. context.shadowColor = this.shadowColor;
  7994. context.shadowBlur = this.shadowBlur;
  7995. context.shadowOffsetX = this.shadowOffsetX;
  7996. context.shadowOffsetY = this.shadowOffsetY;
  7997. }
  7998. this._applyStates(context);
  7999. context.strokeStyle = this.color;
  8000. context.lineWidth = this._lineWidth;
  8001. context.setLineDash(this._dash);
  8002. context.beginPath();
  8003. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8004. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8005. context.stroke();
  8006. context.restore();
  8007. };
  8008. Line.prototype._measure = function () {
  8009. // Width / Height
  8010. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8011. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8012. };
  8013. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8014. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8015. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8016. };
  8017. /**
  8018. * Move one end of the line given 3D cartesian coordinates.
  8019. * @param position Targeted world position
  8020. * @param scene Scene
  8021. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8022. */
  8023. Line.prototype.moveToVector3 = function (position, scene, end) {
  8024. if (end === void 0) { end = false; }
  8025. if (!this._host || this.parent !== this._host._rootContainer) {
  8026. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8027. return;
  8028. }
  8029. var globalViewport = this._host._getGlobalViewport(scene);
  8030. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8031. this._moveToProjectedPosition(projectedPosition, end);
  8032. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8033. this.notRenderable = true;
  8034. return;
  8035. }
  8036. this.notRenderable = false;
  8037. };
  8038. /**
  8039. * Move one end of the line to a position in screen absolute space.
  8040. * @param projectedPosition Position in screen absolute space (X, Y)
  8041. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8042. */
  8043. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8044. if (end === void 0) { end = false; }
  8045. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8046. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8047. if (end) {
  8048. this.x2 = x;
  8049. this.y2 = y;
  8050. this._x2.ignoreAdaptiveScaling = true;
  8051. this._y2.ignoreAdaptiveScaling = true;
  8052. }
  8053. else {
  8054. this.x1 = x;
  8055. this.y1 = y;
  8056. this._x1.ignoreAdaptiveScaling = true;
  8057. this._y1.ignoreAdaptiveScaling = true;
  8058. }
  8059. };
  8060. return Line;
  8061. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8062. /***/ }),
  8063. /***/ "./2D/controls/multiLine.ts":
  8064. /*!**********************************!*\
  8065. !*** ./2D/controls/multiLine.ts ***!
  8066. \**********************************/
  8067. /*! exports provided: MultiLine */
  8068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8069. "use strict";
  8070. __webpack_require__.r(__webpack_exports__);
  8071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8073. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8074. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8075. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8076. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8077. /**
  8078. * Class used to create multi line control
  8079. */
  8080. var MultiLine = /** @class */ (function (_super) {
  8081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiLine, _super);
  8082. /**
  8083. * Creates a new MultiLine
  8084. * @param name defines the control name
  8085. */
  8086. function MultiLine(name) {
  8087. var _this = _super.call(this, name) || this;
  8088. _this.name = name;
  8089. _this._lineWidth = 1;
  8090. /** Function called when a point is updated */
  8091. _this.onPointUpdate = function () {
  8092. _this._markAsDirty();
  8093. };
  8094. _this.isHitTestVisible = false;
  8095. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8096. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8097. _this._dash = [];
  8098. _this._points = [];
  8099. return _this;
  8100. }
  8101. Object.defineProperty(MultiLine.prototype, "dash", {
  8102. /** Gets or sets dash pattern */
  8103. get: function () {
  8104. return this._dash;
  8105. },
  8106. set: function (value) {
  8107. if (this._dash === value) {
  8108. return;
  8109. }
  8110. this._dash = value;
  8111. this._markAsDirty();
  8112. },
  8113. enumerable: true,
  8114. configurable: true
  8115. });
  8116. /**
  8117. * Gets point stored at specified index
  8118. * @param index defines the index to look for
  8119. * @returns the requested point if found
  8120. */
  8121. MultiLine.prototype.getAt = function (index) {
  8122. if (!this._points[index]) {
  8123. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8124. }
  8125. return this._points[index];
  8126. };
  8127. /**
  8128. * Adds new points to the point collection
  8129. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8130. * @returns the list of created MultiLinePoint
  8131. */
  8132. MultiLine.prototype.add = function () {
  8133. var _this = this;
  8134. var items = [];
  8135. for (var _i = 0; _i < arguments.length; _i++) {
  8136. items[_i] = arguments[_i];
  8137. }
  8138. return items.map(function (item) { return _this.push(item); });
  8139. };
  8140. /**
  8141. * Adds a new point to the point collection
  8142. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8143. * @returns the created MultiLinePoint
  8144. */
  8145. MultiLine.prototype.push = function (item) {
  8146. var point = this.getAt(this._points.length);
  8147. if (item == null) {
  8148. return point;
  8149. }
  8150. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8151. point.mesh = item;
  8152. }
  8153. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8154. point.control = item;
  8155. }
  8156. else if (item.x != null && item.y != null) {
  8157. point.x = item.x;
  8158. point.y = item.y;
  8159. }
  8160. return point;
  8161. };
  8162. /**
  8163. * Remove a specific value or point from the active point collection
  8164. * @param value defines the value or point to remove
  8165. */
  8166. MultiLine.prototype.remove = function (value) {
  8167. var index;
  8168. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8169. index = this._points.indexOf(value);
  8170. if (index === -1) {
  8171. return;
  8172. }
  8173. }
  8174. else {
  8175. index = value;
  8176. }
  8177. var point = this._points[index];
  8178. if (!point) {
  8179. return;
  8180. }
  8181. point.dispose();
  8182. this._points.splice(index, 1);
  8183. };
  8184. /**
  8185. * Resets this object to initial state (no point)
  8186. */
  8187. MultiLine.prototype.reset = function () {
  8188. while (this._points.length > 0) {
  8189. this.remove(this._points.length - 1);
  8190. }
  8191. };
  8192. /**
  8193. * Resets all links
  8194. */
  8195. MultiLine.prototype.resetLinks = function () {
  8196. this._points.forEach(function (point) {
  8197. if (point != null) {
  8198. point.resetLinks();
  8199. }
  8200. });
  8201. };
  8202. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8203. /** Gets or sets line width */
  8204. get: function () {
  8205. return this._lineWidth;
  8206. },
  8207. set: function (value) {
  8208. if (this._lineWidth === value) {
  8209. return;
  8210. }
  8211. this._lineWidth = value;
  8212. this._markAsDirty();
  8213. },
  8214. enumerable: true,
  8215. configurable: true
  8216. });
  8217. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8218. set: function (value) {
  8219. return;
  8220. },
  8221. enumerable: true,
  8222. configurable: true
  8223. });
  8224. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8225. set: function (value) {
  8226. return;
  8227. },
  8228. enumerable: true,
  8229. configurable: true
  8230. });
  8231. MultiLine.prototype._getTypeName = function () {
  8232. return "MultiLine";
  8233. };
  8234. MultiLine.prototype._draw = function (context) {
  8235. context.save();
  8236. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8237. context.shadowColor = this.shadowColor;
  8238. context.shadowBlur = this.shadowBlur;
  8239. context.shadowOffsetX = this.shadowOffsetX;
  8240. context.shadowOffsetY = this.shadowOffsetY;
  8241. }
  8242. this._applyStates(context);
  8243. context.strokeStyle = this.color;
  8244. context.lineWidth = this._lineWidth;
  8245. context.setLineDash(this._dash);
  8246. context.beginPath();
  8247. var first = true; //first index is not necessarily 0
  8248. this._points.forEach(function (point) {
  8249. if (!point) {
  8250. return;
  8251. }
  8252. if (first) {
  8253. context.moveTo(point._point.x, point._point.y);
  8254. first = false;
  8255. }
  8256. else {
  8257. context.lineTo(point._point.x, point._point.y);
  8258. }
  8259. });
  8260. context.stroke();
  8261. context.restore();
  8262. };
  8263. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8264. var _this = this;
  8265. this._minX = null;
  8266. this._minY = null;
  8267. this._maxX = null;
  8268. this._maxY = null;
  8269. this._points.forEach(function (point, index) {
  8270. if (!point) {
  8271. return;
  8272. }
  8273. point.translate();
  8274. if (_this._minX == null || point._point.x < _this._minX) {
  8275. _this._minX = point._point.x;
  8276. }
  8277. if (_this._minY == null || point._point.y < _this._minY) {
  8278. _this._minY = point._point.y;
  8279. }
  8280. if (_this._maxX == null || point._point.x > _this._maxX) {
  8281. _this._maxX = point._point.x;
  8282. }
  8283. if (_this._maxY == null || point._point.y > _this._maxY) {
  8284. _this._maxY = point._point.y;
  8285. }
  8286. });
  8287. if (this._minX == null) {
  8288. this._minX = 0;
  8289. }
  8290. if (this._minY == null) {
  8291. this._minY = 0;
  8292. }
  8293. if (this._maxX == null) {
  8294. this._maxX = 0;
  8295. }
  8296. if (this._maxY == null) {
  8297. this._maxY = 0;
  8298. }
  8299. };
  8300. MultiLine.prototype._measure = function () {
  8301. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8302. return;
  8303. }
  8304. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8305. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8306. };
  8307. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8308. if (this._minX == null || this._minY == null) {
  8309. return;
  8310. }
  8311. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8312. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8313. };
  8314. MultiLine.prototype.dispose = function () {
  8315. this.reset();
  8316. _super.prototype.dispose.call(this);
  8317. };
  8318. return MultiLine;
  8319. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8320. /***/ }),
  8321. /***/ "./2D/controls/radioButton.ts":
  8322. /*!************************************!*\
  8323. !*** ./2D/controls/radioButton.ts ***!
  8324. \************************************/
  8325. /*! exports provided: RadioButton */
  8326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8327. "use strict";
  8328. __webpack_require__.r(__webpack_exports__);
  8329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8330. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8331. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8332. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8333. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8334. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8335. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8336. /**
  8337. * Class used to create radio button controls
  8338. */
  8339. var RadioButton = /** @class */ (function (_super) {
  8340. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioButton, _super);
  8341. /**
  8342. * Creates a new RadioButton
  8343. * @param name defines the control name
  8344. */
  8345. function RadioButton(name) {
  8346. var _this = _super.call(this, name) || this;
  8347. _this.name = name;
  8348. _this._isChecked = false;
  8349. _this._background = "black";
  8350. _this._checkSizeRatio = 0.8;
  8351. _this._thickness = 1;
  8352. /** Gets or sets group name */
  8353. _this.group = "";
  8354. /** Observable raised when isChecked is changed */
  8355. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8356. _this.isPointerBlocker = true;
  8357. return _this;
  8358. }
  8359. Object.defineProperty(RadioButton.prototype, "thickness", {
  8360. /** Gets or sets border thickness */
  8361. get: function () {
  8362. return this._thickness;
  8363. },
  8364. set: function (value) {
  8365. if (this._thickness === value) {
  8366. return;
  8367. }
  8368. this._thickness = value;
  8369. this._markAsDirty();
  8370. },
  8371. enumerable: true,
  8372. configurable: true
  8373. });
  8374. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8375. /** Gets or sets a value indicating the ratio between overall size and check size */
  8376. get: function () {
  8377. return this._checkSizeRatio;
  8378. },
  8379. set: function (value) {
  8380. value = Math.max(Math.min(1, value), 0);
  8381. if (this._checkSizeRatio === value) {
  8382. return;
  8383. }
  8384. this._checkSizeRatio = value;
  8385. this._markAsDirty();
  8386. },
  8387. enumerable: true,
  8388. configurable: true
  8389. });
  8390. Object.defineProperty(RadioButton.prototype, "background", {
  8391. /** Gets or sets background color */
  8392. get: function () {
  8393. return this._background;
  8394. },
  8395. set: function (value) {
  8396. if (this._background === value) {
  8397. return;
  8398. }
  8399. this._background = value;
  8400. this._markAsDirty();
  8401. },
  8402. enumerable: true,
  8403. configurable: true
  8404. });
  8405. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8406. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8407. get: function () {
  8408. return this._isChecked;
  8409. },
  8410. set: function (value) {
  8411. var _this = this;
  8412. if (this._isChecked === value) {
  8413. return;
  8414. }
  8415. this._isChecked = value;
  8416. this._markAsDirty();
  8417. this.onIsCheckedChangedObservable.notifyObservers(value);
  8418. if (this._isChecked && this._host) {
  8419. // Update all controls from same group
  8420. this._host.executeOnAllControls(function (control) {
  8421. if (control === _this) {
  8422. return;
  8423. }
  8424. if (control.group === undefined) {
  8425. return;
  8426. }
  8427. var childRadio = control;
  8428. if (childRadio.group === _this.group) {
  8429. childRadio.isChecked = false;
  8430. }
  8431. });
  8432. }
  8433. },
  8434. enumerable: true,
  8435. configurable: true
  8436. });
  8437. RadioButton.prototype._getTypeName = function () {
  8438. return "RadioButton";
  8439. };
  8440. RadioButton.prototype._draw = function (context) {
  8441. context.save();
  8442. this._applyStates(context);
  8443. var actualWidth = this._currentMeasure.width - this._thickness;
  8444. var actualHeight = this._currentMeasure.height - this._thickness;
  8445. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8446. context.shadowColor = this.shadowColor;
  8447. context.shadowBlur = this.shadowBlur;
  8448. context.shadowOffsetX = this.shadowOffsetX;
  8449. context.shadowOffsetY = this.shadowOffsetY;
  8450. }
  8451. // Outer
  8452. _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);
  8453. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8454. context.fill();
  8455. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8456. context.shadowBlur = 0;
  8457. context.shadowOffsetX = 0;
  8458. context.shadowOffsetY = 0;
  8459. }
  8460. context.strokeStyle = this.color;
  8461. context.lineWidth = this._thickness;
  8462. context.stroke();
  8463. // Inner
  8464. if (this._isChecked) {
  8465. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8466. var offsetWidth = actualWidth * this._checkSizeRatio;
  8467. var offseHeight = actualHeight * this._checkSizeRatio;
  8468. _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);
  8469. context.fill();
  8470. }
  8471. context.restore();
  8472. };
  8473. // Events
  8474. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8475. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8476. return false;
  8477. }
  8478. if (!this.isChecked) {
  8479. this.isChecked = true;
  8480. }
  8481. return true;
  8482. };
  8483. /**
  8484. * Utility function to easily create a radio button with a header
  8485. * @param title defines the label to use for the header
  8486. * @param group defines the group to use for the radio button
  8487. * @param isChecked defines the initial state of the radio button
  8488. * @param onValueChanged defines the callback to call when value changes
  8489. * @returns a StackPanel containing the radio button and a textBlock
  8490. */
  8491. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8492. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8493. panel.isVertical = false;
  8494. panel.height = "30px";
  8495. var radio = new RadioButton();
  8496. radio.width = "20px";
  8497. radio.height = "20px";
  8498. radio.isChecked = isChecked;
  8499. radio.color = "green";
  8500. radio.group = group;
  8501. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8502. panel.addControl(radio);
  8503. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8504. header.text = title;
  8505. header.width = "180px";
  8506. header.paddingLeft = "5px";
  8507. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8508. header.color = "white";
  8509. panel.addControl(header);
  8510. return panel;
  8511. };
  8512. return RadioButton;
  8513. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8514. /***/ }),
  8515. /***/ "./2D/controls/rectangle.ts":
  8516. /*!**********************************!*\
  8517. !*** ./2D/controls/rectangle.ts ***!
  8518. \**********************************/
  8519. /*! exports provided: Rectangle */
  8520. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8521. "use strict";
  8522. __webpack_require__.r(__webpack_exports__);
  8523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8524. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8525. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8526. /** Class used to create rectangle container */
  8527. var Rectangle = /** @class */ (function (_super) {
  8528. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Rectangle, _super);
  8529. /**
  8530. * Creates a new Rectangle
  8531. * @param name defines the control name
  8532. */
  8533. function Rectangle(name) {
  8534. var _this = _super.call(this, name) || this;
  8535. _this.name = name;
  8536. _this._thickness = 1;
  8537. _this._cornerRadius = 0;
  8538. return _this;
  8539. }
  8540. Object.defineProperty(Rectangle.prototype, "thickness", {
  8541. /** Gets or sets border thickness */
  8542. get: function () {
  8543. return this._thickness;
  8544. },
  8545. set: function (value) {
  8546. if (this._thickness === value) {
  8547. return;
  8548. }
  8549. this._thickness = value;
  8550. this._markAsDirty();
  8551. },
  8552. enumerable: true,
  8553. configurable: true
  8554. });
  8555. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8556. /** Gets or sets the corner radius angle */
  8557. get: function () {
  8558. return this._cornerRadius;
  8559. },
  8560. set: function (value) {
  8561. if (value < 0) {
  8562. value = 0;
  8563. }
  8564. if (this._cornerRadius === value) {
  8565. return;
  8566. }
  8567. this._cornerRadius = value;
  8568. this._markAsDirty();
  8569. },
  8570. enumerable: true,
  8571. configurable: true
  8572. });
  8573. Rectangle.prototype._getTypeName = function () {
  8574. return "Rectangle";
  8575. };
  8576. Rectangle.prototype._localDraw = function (context) {
  8577. context.save();
  8578. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8579. context.shadowColor = this.shadowColor;
  8580. context.shadowBlur = this.shadowBlur;
  8581. context.shadowOffsetX = this.shadowOffsetX;
  8582. context.shadowOffsetY = this.shadowOffsetY;
  8583. }
  8584. if (this._background) {
  8585. context.fillStyle = this._background;
  8586. if (this._cornerRadius) {
  8587. this._drawRoundedRect(context, this._thickness / 2);
  8588. context.fill();
  8589. }
  8590. else {
  8591. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8592. }
  8593. }
  8594. if (this._thickness) {
  8595. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8596. context.shadowBlur = 0;
  8597. context.shadowOffsetX = 0;
  8598. context.shadowOffsetY = 0;
  8599. }
  8600. if (this.color) {
  8601. context.strokeStyle = this.color;
  8602. }
  8603. context.lineWidth = this._thickness;
  8604. if (this._cornerRadius) {
  8605. this._drawRoundedRect(context, this._thickness / 2);
  8606. context.stroke();
  8607. }
  8608. else {
  8609. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8610. }
  8611. }
  8612. context.restore();
  8613. };
  8614. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8615. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8616. this._measureForChildren.width -= 2 * this._thickness;
  8617. this._measureForChildren.height -= 2 * this._thickness;
  8618. this._measureForChildren.left += this._thickness;
  8619. this._measureForChildren.top += this._thickness;
  8620. };
  8621. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8622. if (offset === void 0) { offset = 0; }
  8623. var x = this._currentMeasure.left + offset;
  8624. var y = this._currentMeasure.top + offset;
  8625. var width = this._currentMeasure.width - offset * 2;
  8626. var height = this._currentMeasure.height - offset * 2;
  8627. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8628. context.beginPath();
  8629. context.moveTo(x + radius, y);
  8630. context.lineTo(x + width - radius, y);
  8631. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8632. context.lineTo(x + width, y + height - radius);
  8633. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8634. context.lineTo(x + radius, y + height);
  8635. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8636. context.lineTo(x, y + radius);
  8637. context.quadraticCurveTo(x, y, x + radius, y);
  8638. context.closePath();
  8639. };
  8640. Rectangle.prototype._clipForChildren = function (context) {
  8641. if (this._cornerRadius) {
  8642. this._drawRoundedRect(context, this._thickness);
  8643. context.clip();
  8644. }
  8645. };
  8646. return Rectangle;
  8647. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8648. /***/ }),
  8649. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8650. /*!***************************************************!*\
  8651. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8652. \***************************************************/
  8653. /*! exports provided: ScrollViewer */
  8654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8655. "use strict";
  8656. __webpack_require__.r(__webpack_exports__);
  8657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8659. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8660. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8661. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8662. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8663. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8664. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8665. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8666. /**
  8667. * Class used to hold a viewer window and sliders in a grid
  8668. */
  8669. var ScrollViewer = /** @class */ (function (_super) {
  8670. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollViewer, _super);
  8671. /**
  8672. * Creates a new ScrollViewer
  8673. * @param name of ScrollViewer
  8674. */
  8675. function ScrollViewer(name) {
  8676. var _this = _super.call(this, name) || this;
  8677. _this._barSize = 20;
  8678. _this._pointerIsOver = false;
  8679. _this._wheelPrecision = 0.05;
  8680. _this.onDirtyObservable.add(function () {
  8681. _this._horizontalBarSpace.color = _this.color;
  8682. _this._verticalBarSpace.color = _this.color;
  8683. _this._dragSpace.color = _this.color;
  8684. });
  8685. _this.onPointerEnterObservable.add(function () {
  8686. _this._pointerIsOver = true;
  8687. });
  8688. _this.onPointerOutObservable.add(function () {
  8689. _this._pointerIsOver = false;
  8690. });
  8691. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8692. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8693. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8694. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8695. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8696. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8697. _this._grid.addColumnDefinition(1);
  8698. _this._grid.addColumnDefinition(0, true);
  8699. _this._grid.addRowDefinition(1);
  8700. _this._grid.addRowDefinition(0, true);
  8701. _super.prototype.addControl.call(_this, _this._grid);
  8702. _this._grid.addControl(_this._window, 0, 0);
  8703. _this._verticalBar.paddingLeft = 0;
  8704. _this._verticalBar.width = "100%";
  8705. _this._verticalBar.height = "100%";
  8706. _this._verticalBar.barOffset = 0;
  8707. _this._verticalBar.value = 0;
  8708. _this._verticalBar.maximum = 1;
  8709. _this._verticalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8710. _this._verticalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8711. _this._verticalBar.isVertical = true;
  8712. _this._verticalBar.rotation = Math.PI;
  8713. _this._verticalBar.isVisible = false;
  8714. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8715. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8716. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8717. _this._verticalBarSpace.thickness = 1;
  8718. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8719. _this._verticalBarSpace.addControl(_this._verticalBar);
  8720. _this._verticalBar.onValueChangedObservable.add(function (value) {
  8721. _this._window.top = value * _this._endTop + "px";
  8722. });
  8723. _this._horizontalBar.paddingLeft = 0;
  8724. _this._horizontalBar.width = "100%";
  8725. _this._horizontalBar.height = "100%";
  8726. _this._horizontalBar.barOffset = 0;
  8727. _this._horizontalBar.value = 0;
  8728. _this._horizontalBar.maximum = 1;
  8729. _this._horizontalBar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  8730. _this._horizontalBar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  8731. _this._horizontalBar.isVisible = false;
  8732. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8733. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8734. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8735. _this._horizontalBarSpace.thickness = 1;
  8736. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8737. _this._horizontalBarSpace.addControl(_this._horizontalBar);
  8738. _this._horizontalBar.onValueChangedObservable.add(function (value) {
  8739. _this._window.left = value * _this._endLeft + "px";
  8740. });
  8741. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8742. _this._dragSpace.thickness = 1;
  8743. _this._grid.addControl(_this._dragSpace, 1, 1);
  8744. // Colors
  8745. _this.barColor = "grey";
  8746. _this.barBackground = "transparent";
  8747. return _this;
  8748. }
  8749. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8750. /**
  8751. * Gets the horizontal scrollbar
  8752. */
  8753. get: function () {
  8754. return this._horizontalBar;
  8755. },
  8756. enumerable: true,
  8757. configurable: true
  8758. });
  8759. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8760. /**
  8761. * Gets the vertical scrollbar
  8762. */
  8763. get: function () {
  8764. return this._verticalBar;
  8765. },
  8766. enumerable: true,
  8767. configurable: true
  8768. });
  8769. /**
  8770. * Adds a new control to the current container
  8771. * @param control defines the control to add
  8772. * @returns the current container
  8773. */
  8774. ScrollViewer.prototype.addControl = function (control) {
  8775. if (!control) {
  8776. return this;
  8777. }
  8778. this._window.addControl(control);
  8779. return this;
  8780. };
  8781. /**
  8782. * Removes a control from the current container
  8783. * @param control defines the control to remove
  8784. * @returns the current container
  8785. */
  8786. ScrollViewer.prototype.removeControl = function (control) {
  8787. this._window.removeControl(control);
  8788. return this;
  8789. };
  8790. Object.defineProperty(ScrollViewer.prototype, "children", {
  8791. /** Gets the list of children */
  8792. get: function () {
  8793. return this._window.children;
  8794. },
  8795. enumerable: true,
  8796. configurable: true
  8797. });
  8798. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8799. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8800. var child = _a[_i];
  8801. child._markMatrixAsDirty();
  8802. }
  8803. };
  8804. /** Reset the scroll viewer window to initial size */
  8805. ScrollViewer.prototype.resetWindow = function () {
  8806. this._window.width = "100%";
  8807. this._window.height = "100%";
  8808. };
  8809. ScrollViewer.prototype._getTypeName = function () {
  8810. return "ScrollViewer";
  8811. };
  8812. ScrollViewer.prototype._buildClientSizes = function () {
  8813. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8814. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8815. this._clientWidth = this._window.parentClientWidth;
  8816. this._clientHeight = this._window.parentClientHeight;
  8817. };
  8818. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8819. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8820. this._buildClientSizes();
  8821. };
  8822. ScrollViewer.prototype._postMeasure = function () {
  8823. _super.prototype._postMeasure.call(this);
  8824. this._updateScroller();
  8825. };
  8826. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8827. /**
  8828. * Gets or sets the mouse wheel precision
  8829. * from 0 to 1 with a default value of 0.05
  8830. * */
  8831. get: function () {
  8832. return this._wheelPrecision;
  8833. },
  8834. set: function (value) {
  8835. if (this._wheelPrecision === value) {
  8836. return;
  8837. }
  8838. if (value < 0) {
  8839. value = 0;
  8840. }
  8841. if (value > 1) {
  8842. value = 1;
  8843. }
  8844. this._wheelPrecision = value;
  8845. },
  8846. enumerable: true,
  8847. configurable: true
  8848. });
  8849. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  8850. /** Gets or sets the bar color */
  8851. get: function () {
  8852. return this._barColor;
  8853. },
  8854. set: function (color) {
  8855. if (this._barColor === color) {
  8856. return;
  8857. }
  8858. this._barColor = color;
  8859. this._horizontalBar.color = color;
  8860. this._verticalBar.color = color;
  8861. },
  8862. enumerable: true,
  8863. configurable: true
  8864. });
  8865. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  8866. /** Gets or sets the size of the bar */
  8867. get: function () {
  8868. return this._barSize;
  8869. },
  8870. set: function (value) {
  8871. if (this._barSize === value) {
  8872. return;
  8873. }
  8874. this._barSize = value;
  8875. this._markAsDirty();
  8876. if (this._horizontalBar.isVisible) {
  8877. this._grid.setRowDefinition(1, this._barSize, true);
  8878. }
  8879. if (this._verticalBar.isVisible) {
  8880. this._grid.setColumnDefinition(1, this._barSize, true);
  8881. }
  8882. },
  8883. enumerable: true,
  8884. configurable: true
  8885. });
  8886. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  8887. /** Gets or sets the bar background */
  8888. get: function () {
  8889. return this._barBackground;
  8890. },
  8891. set: function (color) {
  8892. if (this._barBackground === color) {
  8893. return;
  8894. }
  8895. this._barBackground = color;
  8896. this._horizontalBar.background = color;
  8897. this._verticalBar.background = color;
  8898. this._dragSpace.background = color;
  8899. },
  8900. enumerable: true,
  8901. configurable: true
  8902. });
  8903. /** @hidden */
  8904. ScrollViewer.prototype._updateScroller = function () {
  8905. var windowContentsWidth = this._window._currentMeasure.width;
  8906. var windowContentsHeight = this._window._currentMeasure.height;
  8907. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  8908. this._grid.setRowDefinition(1, 0, true);
  8909. this._horizontalBar.isVisible = false;
  8910. this._horizontalBar.value = 0;
  8911. this._rebuildLayout = true;
  8912. }
  8913. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  8914. this._grid.setRowDefinition(1, this._barSize, true);
  8915. this._horizontalBar.isVisible = true;
  8916. this._rebuildLayout = true;
  8917. }
  8918. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  8919. this._grid.setColumnDefinition(1, 0, true);
  8920. this._verticalBar.isVisible = false;
  8921. this._verticalBar.value = 0;
  8922. this._rebuildLayout = true;
  8923. }
  8924. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  8925. this._grid.setColumnDefinition(1, this._barSize, true);
  8926. this._verticalBar.isVisible = true;
  8927. this._rebuildLayout = true;
  8928. }
  8929. this._buildClientSizes();
  8930. this._endLeft = this._clientWidth - windowContentsWidth;
  8931. this._endTop = this._clientHeight - windowContentsHeight;
  8932. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  8933. var newTop = this._verticalBar.value * this._endTop + "px";
  8934. if (newLeft !== this._window.left) {
  8935. this._window.left = newLeft;
  8936. this._rebuildLayout = true;
  8937. }
  8938. if (newTop !== this._window.top) {
  8939. this._window.top = newTop;
  8940. this._rebuildLayout = true;
  8941. }
  8942. var horizontalMultiplicator = this._clientWidth / windowContentsWidth;
  8943. var verticalMultiplicator = this._clientHeight / windowContentsHeight;
  8944. this._horizontalBar.thumbWidth = (this._clientWidth * horizontalMultiplicator) + "px";
  8945. this._verticalBar.thumbWidth = (this._clientHeight * verticalMultiplicator) + "px";
  8946. };
  8947. ScrollViewer.prototype._link = function (host) {
  8948. _super.prototype._link.call(this, host);
  8949. this._attachWheel();
  8950. };
  8951. /** @hidden */
  8952. ScrollViewer.prototype._attachWheel = function () {
  8953. var _this = this;
  8954. if (!this._host || this._onPointerObserver) {
  8955. return;
  8956. }
  8957. var scene = this._host.getScene();
  8958. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  8959. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  8960. return;
  8961. }
  8962. if (_this._verticalBar.isVisible == true) {
  8963. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  8964. _this._verticalBar.value -= _this._wheelPrecision;
  8965. }
  8966. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  8967. _this._verticalBar.value += _this._wheelPrecision;
  8968. }
  8969. }
  8970. if (_this._horizontalBar.isVisible == true) {
  8971. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  8972. _this._horizontalBar.value += _this._wheelPrecision;
  8973. }
  8974. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  8975. _this._horizontalBar.value -= _this._wheelPrecision;
  8976. }
  8977. }
  8978. });
  8979. };
  8980. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  8981. if (!this.isHighlighted) {
  8982. return;
  8983. }
  8984. _super.prototype._renderHighlightSpecific.call(this, context);
  8985. this._grid._renderHighlightSpecific(context);
  8986. context.restore();
  8987. };
  8988. /** Releases associated resources */
  8989. ScrollViewer.prototype.dispose = function () {
  8990. var scene = this._host.getScene();
  8991. if (scene && this._onPointerObserver) {
  8992. scene.onPointerObservable.remove(this._onPointerObserver);
  8993. this._onPointerObserver = null;
  8994. }
  8995. _super.prototype.dispose.call(this);
  8996. };
  8997. return ScrollViewer;
  8998. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  8999. /***/ }),
  9000. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9001. /*!*********************************************************!*\
  9002. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9003. \*********************************************************/
  9004. /*! exports provided: _ScrollViewerWindow */
  9005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9006. "use strict";
  9007. __webpack_require__.r(__webpack_exports__);
  9008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9009. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9010. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9011. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9012. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9013. /**
  9014. * Class used to hold a the container for ScrollViewer
  9015. * @hidden
  9016. */
  9017. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9018. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](_ScrollViewerWindow, _super);
  9019. /**
  9020. * Creates a new ScrollViewerWindow
  9021. * @param name of ScrollViewerWindow
  9022. */
  9023. function _ScrollViewerWindow(name) {
  9024. return _super.call(this, name) || this;
  9025. }
  9026. _ScrollViewerWindow.prototype._getTypeName = function () {
  9027. return "ScrollViewerWindow";
  9028. };
  9029. /** @hidden */
  9030. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9031. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9032. this._measureForChildren.left = this._currentMeasure.left;
  9033. this._measureForChildren.top = this._currentMeasure.top;
  9034. this._measureForChildren.width = parentMeasure.width;
  9035. this._measureForChildren.height = parentMeasure.height;
  9036. };
  9037. _ScrollViewerWindow.prototype._postMeasure = function () {
  9038. var maxWidth = this.parentClientWidth;
  9039. var maxHeight = this.parentClientHeight;
  9040. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9041. var child = _a[_i];
  9042. if (!child.isVisible || child.notRenderable) {
  9043. continue;
  9044. }
  9045. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9046. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9047. }
  9048. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9049. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9050. }
  9051. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9052. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9053. }
  9054. if (this._currentMeasure.width !== maxWidth) {
  9055. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9056. this._currentMeasure.width = maxWidth;
  9057. this._rebuildLayout = true;
  9058. this._isDirty = true;
  9059. }
  9060. if (this._currentMeasure.height !== maxHeight) {
  9061. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9062. this._currentMeasure.height = maxHeight;
  9063. this._rebuildLayout = true;
  9064. this._isDirty = true;
  9065. }
  9066. _super.prototype._postMeasure.call(this);
  9067. };
  9068. return _ScrollViewerWindow;
  9069. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9070. /***/ }),
  9071. /***/ "./2D/controls/selector.ts":
  9072. /*!*********************************!*\
  9073. !*** ./2D/controls/selector.ts ***!
  9074. \*********************************/
  9075. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9077. "use strict";
  9078. __webpack_require__.r(__webpack_exports__);
  9079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9080. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9084. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9085. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9086. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9087. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9088. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9089. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9090. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9091. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9092. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9093. /** Class used to create a RadioGroup
  9094. * which contains groups of radio buttons
  9095. */
  9096. var SelectorGroup = /** @class */ (function () {
  9097. /**
  9098. * Creates a new SelectorGroup
  9099. * @param name of group, used as a group heading
  9100. */
  9101. function SelectorGroup(
  9102. /** name of SelectorGroup */
  9103. name) {
  9104. this.name = name;
  9105. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9106. this._selectors = new Array();
  9107. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9108. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9109. this._groupHeader = this._addGroupHeader(name);
  9110. }
  9111. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9112. /** Gets the groupPanel of the SelectorGroup */
  9113. get: function () {
  9114. return this._groupPanel;
  9115. },
  9116. enumerable: true,
  9117. configurable: true
  9118. });
  9119. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9120. /** Gets the selectors array */
  9121. get: function () {
  9122. return this._selectors;
  9123. },
  9124. enumerable: true,
  9125. configurable: true
  9126. });
  9127. Object.defineProperty(SelectorGroup.prototype, "header", {
  9128. /** Gets and sets the group header */
  9129. get: function () {
  9130. return this._groupHeader.text;
  9131. },
  9132. set: function (label) {
  9133. if (this._groupHeader.text === "label") {
  9134. return;
  9135. }
  9136. this._groupHeader.text = label;
  9137. },
  9138. enumerable: true,
  9139. configurable: true
  9140. });
  9141. /** @hidden */
  9142. SelectorGroup.prototype._addGroupHeader = function (text) {
  9143. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9144. groupHeading.width = 0.9;
  9145. groupHeading.height = "30px";
  9146. groupHeading.textWrapping = true;
  9147. groupHeading.color = "black";
  9148. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9149. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9150. groupHeading.left = "2px";
  9151. this._groupPanel.addControl(groupHeading);
  9152. return groupHeading;
  9153. };
  9154. /** @hidden*/
  9155. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9156. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9157. return;
  9158. }
  9159. return this._selectors[selectorNb];
  9160. };
  9161. /** Removes the selector at the given position
  9162. * @param selectorNb the position of the selector within the group
  9163. */
  9164. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9165. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9166. return;
  9167. }
  9168. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9169. this._selectors.splice(selectorNb, 1);
  9170. };
  9171. return SelectorGroup;
  9172. }());
  9173. /** Class used to create a CheckboxGroup
  9174. * which contains groups of checkbox buttons
  9175. */
  9176. var CheckboxGroup = /** @class */ (function (_super) {
  9177. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CheckboxGroup, _super);
  9178. function CheckboxGroup() {
  9179. return _super !== null && _super.apply(this, arguments) || this;
  9180. }
  9181. /** Adds a checkbox as a control
  9182. * @param text is the label for the selector
  9183. * @param func is the function called when the Selector is checked
  9184. * @param checked is true when Selector is checked
  9185. */
  9186. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9187. if (func === void 0) { func = function (s) { }; }
  9188. if (checked === void 0) { checked = false; }
  9189. var checked = checked || false;
  9190. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9191. button.width = "20px";
  9192. button.height = "20px";
  9193. button.color = "#364249";
  9194. button.background = "#CCCCCC";
  9195. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9196. button.onIsCheckedChangedObservable.add(function (state) {
  9197. func(state);
  9198. });
  9199. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9200. _selector.height = "30px";
  9201. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9202. _selector.left = "4px";
  9203. this.groupPanel.addControl(_selector);
  9204. this.selectors.push(_selector);
  9205. button.isChecked = checked;
  9206. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9207. button.color = this.groupPanel.parent.parent.buttonColor;
  9208. button.background = this.groupPanel.parent.parent.buttonBackground;
  9209. }
  9210. };
  9211. /** @hidden */
  9212. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9213. this.selectors[selectorNb].children[1].text = label;
  9214. };
  9215. /** @hidden */
  9216. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9217. this.selectors[selectorNb].children[1].color = color;
  9218. };
  9219. /** @hidden */
  9220. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9221. this.selectors[selectorNb].children[0].color = color;
  9222. };
  9223. /** @hidden */
  9224. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9225. this.selectors[selectorNb].children[0].background = color;
  9226. };
  9227. return CheckboxGroup;
  9228. }(SelectorGroup));
  9229. /** Class used to create a RadioGroup
  9230. * which contains groups of radio buttons
  9231. */
  9232. var RadioGroup = /** @class */ (function (_super) {
  9233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RadioGroup, _super);
  9234. function RadioGroup() {
  9235. var _this = _super !== null && _super.apply(this, arguments) || this;
  9236. _this._selectNb = 0;
  9237. return _this;
  9238. }
  9239. /** Adds a radio button as a control
  9240. * @param label is the label for the selector
  9241. * @param func is the function called when the Selector is checked
  9242. * @param checked is true when Selector is checked
  9243. */
  9244. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9245. if (func === void 0) { func = function (n) { }; }
  9246. if (checked === void 0) { checked = false; }
  9247. var nb = this._selectNb++;
  9248. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9249. button.name = label;
  9250. button.width = "20px";
  9251. button.height = "20px";
  9252. button.color = "#364249";
  9253. button.background = "#CCCCCC";
  9254. button.group = this.name;
  9255. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9256. button.onIsCheckedChangedObservable.add(function (state) {
  9257. if (state) {
  9258. func(nb);
  9259. }
  9260. });
  9261. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9262. _selector.height = "30px";
  9263. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9264. _selector.left = "4px";
  9265. this.groupPanel.addControl(_selector);
  9266. this.selectors.push(_selector);
  9267. button.isChecked = checked;
  9268. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9269. button.color = this.groupPanel.parent.parent.buttonColor;
  9270. button.background = this.groupPanel.parent.parent.buttonBackground;
  9271. }
  9272. };
  9273. /** @hidden */
  9274. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9275. this.selectors[selectorNb].children[1].text = label;
  9276. };
  9277. /** @hidden */
  9278. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9279. this.selectors[selectorNb].children[1].color = color;
  9280. };
  9281. /** @hidden */
  9282. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9283. this.selectors[selectorNb].children[0].color = color;
  9284. };
  9285. /** @hidden */
  9286. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9287. this.selectors[selectorNb].children[0].background = color;
  9288. };
  9289. return RadioGroup;
  9290. }(SelectorGroup));
  9291. /** Class used to create a SliderGroup
  9292. * which contains groups of slider buttons
  9293. */
  9294. var SliderGroup = /** @class */ (function (_super) {
  9295. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SliderGroup, _super);
  9296. function SliderGroup() {
  9297. return _super !== null && _super.apply(this, arguments) || this;
  9298. }
  9299. /**
  9300. * Adds a slider to the SelectorGroup
  9301. * @param label is the label for the SliderBar
  9302. * @param func is the function called when the Slider moves
  9303. * @param unit is a string describing the units used, eg degrees or metres
  9304. * @param min is the minimum value for the Slider
  9305. * @param max is the maximum value for the Slider
  9306. * @param value is the start value for the Slider between min and max
  9307. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9308. */
  9309. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9310. if (func === void 0) { func = function (v) { }; }
  9311. if (unit === void 0) { unit = "Units"; }
  9312. if (min === void 0) { min = 0; }
  9313. if (max === void 0) { max = 0; }
  9314. if (value === void 0) { value = 0; }
  9315. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9316. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9317. button.name = unit;
  9318. button.value = value;
  9319. button.minimum = min;
  9320. button.maximum = max;
  9321. button.width = 0.9;
  9322. button.height = "20px";
  9323. button.color = "#364249";
  9324. button.background = "#CCCCCC";
  9325. button.borderColor = "black";
  9326. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9327. button.left = "4px";
  9328. button.paddingBottom = "4px";
  9329. button.onValueChangedObservable.add(function (value) {
  9330. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9331. func(value);
  9332. });
  9333. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9334. _selector.height = "60px";
  9335. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9336. _selector.left = "4px";
  9337. _selector.children[0].name = label;
  9338. this.groupPanel.addControl(_selector);
  9339. this.selectors.push(_selector);
  9340. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9341. button.color = this.groupPanel.parent.parent.buttonColor;
  9342. button.background = this.groupPanel.parent.parent.buttonBackground;
  9343. }
  9344. };
  9345. /** @hidden */
  9346. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9347. this.selectors[selectorNb].children[0].name = label;
  9348. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9349. };
  9350. /** @hidden */
  9351. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9352. this.selectors[selectorNb].children[0].color = color;
  9353. };
  9354. /** @hidden */
  9355. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9356. this.selectors[selectorNb].children[1].color = color;
  9357. };
  9358. /** @hidden */
  9359. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9360. this.selectors[selectorNb].children[1].background = color;
  9361. };
  9362. return SliderGroup;
  9363. }(SelectorGroup));
  9364. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9365. * @see http://doc.babylonjs.com/how_to/selector
  9366. */
  9367. var SelectionPanel = /** @class */ (function (_super) {
  9368. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SelectionPanel, _super);
  9369. /**
  9370. * Creates a new SelectionPanel
  9371. * @param name of SelectionPanel
  9372. * @param groups is an array of SelectionGroups
  9373. */
  9374. function SelectionPanel(
  9375. /** name of SelectionPanel */
  9376. name,
  9377. /** an array of SelectionGroups */
  9378. groups) {
  9379. if (groups === void 0) { groups = []; }
  9380. var _this = _super.call(this, name) || this;
  9381. _this.name = name;
  9382. _this.groups = groups;
  9383. _this._buttonColor = "#364249";
  9384. _this._buttonBackground = "#CCCCCC";
  9385. _this._headerColor = "black";
  9386. _this._barColor = "white";
  9387. _this._barHeight = "2px";
  9388. _this._spacerHeight = "20px";
  9389. _this._bars = new Array();
  9390. _this._groups = groups;
  9391. _this.thickness = 2;
  9392. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9393. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9394. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9395. _this._panel.top = 5;
  9396. _this._panel.left = 5;
  9397. _this._panel.width = 0.95;
  9398. if (groups.length > 0) {
  9399. for (var i = 0; i < groups.length - 1; i++) {
  9400. _this._panel.addControl(groups[i].groupPanel);
  9401. _this._addSpacer();
  9402. }
  9403. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9404. }
  9405. _this.addControl(_this._panel);
  9406. return _this;
  9407. }
  9408. SelectionPanel.prototype._getTypeName = function () {
  9409. return "SelectionPanel";
  9410. };
  9411. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9412. /** Gets or sets the headerColor */
  9413. get: function () {
  9414. return this._headerColor;
  9415. },
  9416. set: function (color) {
  9417. if (this._headerColor === color) {
  9418. return;
  9419. }
  9420. this._headerColor = color;
  9421. this._setHeaderColor();
  9422. },
  9423. enumerable: true,
  9424. configurable: true
  9425. });
  9426. SelectionPanel.prototype._setHeaderColor = function () {
  9427. for (var i = 0; i < this._groups.length; i++) {
  9428. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9429. }
  9430. };
  9431. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9432. /** Gets or sets the button color */
  9433. get: function () {
  9434. return this._buttonColor;
  9435. },
  9436. set: function (color) {
  9437. if (this._buttonColor === color) {
  9438. return;
  9439. }
  9440. this._buttonColor = color;
  9441. this._setbuttonColor();
  9442. },
  9443. enumerable: true,
  9444. configurable: true
  9445. });
  9446. SelectionPanel.prototype._setbuttonColor = function () {
  9447. for (var i = 0; i < this._groups.length; i++) {
  9448. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9449. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9450. }
  9451. }
  9452. };
  9453. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9454. /** Gets or sets the label color */
  9455. get: function () {
  9456. return this._labelColor;
  9457. },
  9458. set: function (color) {
  9459. if (this._labelColor === color) {
  9460. return;
  9461. }
  9462. this._labelColor = color;
  9463. this._setLabelColor();
  9464. },
  9465. enumerable: true,
  9466. configurable: true
  9467. });
  9468. SelectionPanel.prototype._setLabelColor = function () {
  9469. for (var i = 0; i < this._groups.length; i++) {
  9470. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9471. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9472. }
  9473. }
  9474. };
  9475. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9476. /** Gets or sets the button background */
  9477. get: function () {
  9478. return this._buttonBackground;
  9479. },
  9480. set: function (color) {
  9481. if (this._buttonBackground === color) {
  9482. return;
  9483. }
  9484. this._buttonBackground = color;
  9485. this._setButtonBackground();
  9486. },
  9487. enumerable: true,
  9488. configurable: true
  9489. });
  9490. SelectionPanel.prototype._setButtonBackground = function () {
  9491. for (var i = 0; i < this._groups.length; i++) {
  9492. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9493. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9494. }
  9495. }
  9496. };
  9497. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9498. /** Gets or sets the color of separator bar */
  9499. get: function () {
  9500. return this._barColor;
  9501. },
  9502. set: function (color) {
  9503. if (this._barColor === color) {
  9504. return;
  9505. }
  9506. this._barColor = color;
  9507. this._setBarColor();
  9508. },
  9509. enumerable: true,
  9510. configurable: true
  9511. });
  9512. SelectionPanel.prototype._setBarColor = function () {
  9513. for (var i = 0; i < this._bars.length; i++) {
  9514. this._bars[i].children[0].background = this._barColor;
  9515. }
  9516. };
  9517. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9518. /** Gets or sets the height of separator bar */
  9519. get: function () {
  9520. return this._barHeight;
  9521. },
  9522. set: function (value) {
  9523. if (this._barHeight === value) {
  9524. return;
  9525. }
  9526. this._barHeight = value;
  9527. this._setBarHeight();
  9528. },
  9529. enumerable: true,
  9530. configurable: true
  9531. });
  9532. SelectionPanel.prototype._setBarHeight = function () {
  9533. for (var i = 0; i < this._bars.length; i++) {
  9534. this._bars[i].children[0].height = this._barHeight;
  9535. }
  9536. };
  9537. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9538. /** Gets or sets the height of spacers*/
  9539. get: function () {
  9540. return this._spacerHeight;
  9541. },
  9542. set: function (value) {
  9543. if (this._spacerHeight === value) {
  9544. return;
  9545. }
  9546. this._spacerHeight = value;
  9547. this._setSpacerHeight();
  9548. },
  9549. enumerable: true,
  9550. configurable: true
  9551. });
  9552. SelectionPanel.prototype._setSpacerHeight = function () {
  9553. for (var i = 0; i < this._bars.length; i++) {
  9554. this._bars[i].height = this._spacerHeight;
  9555. }
  9556. };
  9557. /** Adds a bar between groups */
  9558. SelectionPanel.prototype._addSpacer = function () {
  9559. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9560. separator.width = 1;
  9561. separator.height = this._spacerHeight;
  9562. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9563. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9564. bar.width = 1;
  9565. bar.height = this._barHeight;
  9566. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9567. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9568. bar.background = this._barColor;
  9569. bar.color = "transparent";
  9570. separator.addControl(bar);
  9571. this._panel.addControl(separator);
  9572. this._bars.push(separator);
  9573. };
  9574. /** Add a group to the selection panel
  9575. * @param group is the selector group to add
  9576. */
  9577. SelectionPanel.prototype.addGroup = function (group) {
  9578. if (this._groups.length > 0) {
  9579. this._addSpacer();
  9580. }
  9581. this._panel.addControl(group.groupPanel);
  9582. this._groups.push(group);
  9583. group.groupPanel.children[0].color = this._headerColor;
  9584. for (var j = 0; j < group.selectors.length; j++) {
  9585. group._setSelectorButtonColor(j, this._buttonColor);
  9586. group._setSelectorButtonBackground(j, this._buttonBackground);
  9587. }
  9588. };
  9589. /** Remove the group from the given position
  9590. * @param groupNb is the position of the group in the list
  9591. */
  9592. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9593. if (groupNb < 0 || groupNb >= this._groups.length) {
  9594. return;
  9595. }
  9596. var group = this._groups[groupNb];
  9597. this._panel.removeControl(group.groupPanel);
  9598. this._groups.splice(groupNb, 1);
  9599. if (groupNb < this._bars.length) {
  9600. this._panel.removeControl(this._bars[groupNb]);
  9601. this._bars.splice(groupNb, 1);
  9602. }
  9603. };
  9604. /** Change a group header label
  9605. * @param label is the new group header label
  9606. * @param groupNb is the number of the group to relabel
  9607. * */
  9608. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9609. if (groupNb < 0 || groupNb >= this._groups.length) {
  9610. return;
  9611. }
  9612. var group = this._groups[groupNb];
  9613. group.groupPanel.children[0].text = label;
  9614. };
  9615. /** Change selector label to the one given
  9616. * @param label is the new selector label
  9617. * @param groupNb is the number of the groupcontaining the selector
  9618. * @param selectorNb is the number of the selector within a group to relabel
  9619. * */
  9620. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9621. if (groupNb < 0 || groupNb >= this._groups.length) {
  9622. return;
  9623. }
  9624. var group = this._groups[groupNb];
  9625. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9626. return;
  9627. }
  9628. group._setSelectorLabel(selectorNb, label);
  9629. };
  9630. /** For a given group position remove the selector at the given position
  9631. * @param groupNb is the number of the group to remove the selector from
  9632. * @param selectorNb is the number of the selector within the group
  9633. */
  9634. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9635. if (groupNb < 0 || groupNb >= this._groups.length) {
  9636. return;
  9637. }
  9638. var group = this._groups[groupNb];
  9639. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9640. return;
  9641. }
  9642. group.removeSelector(selectorNb);
  9643. };
  9644. /** For a given group position of correct type add a checkbox button
  9645. * @param groupNb is the number of the group to remove the selector from
  9646. * @param label is the label for the selector
  9647. * @param func is the function called when the Selector is checked
  9648. * @param checked is true when Selector is checked
  9649. */
  9650. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9651. if (func === void 0) { func = function () { }; }
  9652. if (checked === void 0) { checked = false; }
  9653. if (groupNb < 0 || groupNb >= this._groups.length) {
  9654. return;
  9655. }
  9656. var group = this._groups[groupNb];
  9657. group.addCheckbox(label, func, checked);
  9658. };
  9659. /** For a given group position of correct type add a radio button
  9660. * @param groupNb is the number of the group to remove the selector from
  9661. * @param label is the label for the selector
  9662. * @param func is the function called when the Selector is checked
  9663. * @param checked is true when Selector is checked
  9664. */
  9665. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9666. if (func === void 0) { func = function () { }; }
  9667. if (checked === void 0) { checked = false; }
  9668. if (groupNb < 0 || groupNb >= this._groups.length) {
  9669. return;
  9670. }
  9671. var group = this._groups[groupNb];
  9672. group.addRadio(label, func, checked);
  9673. };
  9674. /**
  9675. * For a given slider group add a slider
  9676. * @param groupNb is the number of the group to add the slider to
  9677. * @param label is the label for the Slider
  9678. * @param func is the function called when the Slider moves
  9679. * @param unit is a string describing the units used, eg degrees or metres
  9680. * @param min is the minimum value for the Slider
  9681. * @param max is the maximum value for the Slider
  9682. * @param value is the start value for the Slider between min and max
  9683. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9684. */
  9685. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9686. if (func === void 0) { func = function () { }; }
  9687. if (unit === void 0) { unit = "Units"; }
  9688. if (min === void 0) { min = 0; }
  9689. if (max === void 0) { max = 0; }
  9690. if (value === void 0) { value = 0; }
  9691. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9692. if (groupNb < 0 || groupNb >= this._groups.length) {
  9693. return;
  9694. }
  9695. var group = this._groups[groupNb];
  9696. group.addSlider(label, func, unit, min, max, value, onVal);
  9697. };
  9698. return SelectionPanel;
  9699. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9700. /***/ }),
  9701. /***/ "./2D/controls/sliders/baseSlider.ts":
  9702. /*!*******************************************!*\
  9703. !*** ./2D/controls/sliders/baseSlider.ts ***!
  9704. \*******************************************/
  9705. /*! exports provided: BaseSlider */
  9706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9707. "use strict";
  9708. __webpack_require__.r(__webpack_exports__);
  9709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  9710. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9711. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  9712. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9713. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9714. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9715. /**
  9716. * Class used to create slider controls
  9717. */
  9718. var BaseSlider = /** @class */ (function (_super) {
  9719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BaseSlider, _super);
  9720. /**
  9721. * Creates a new BaseSlider
  9722. * @param name defines the control name
  9723. */
  9724. function BaseSlider(name) {
  9725. var _this = _super.call(this, name) || this;
  9726. _this.name = name;
  9727. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9728. _this._minimum = 0;
  9729. _this._maximum = 100;
  9730. _this._value = 50;
  9731. _this._isVertical = false;
  9732. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  9733. _this._isThumbClamped = false;
  9734. _this._displayThumb = true;
  9735. _this._step = 0;
  9736. _this._lastPointerDownID = -1;
  9737. // Shared rendering info
  9738. _this._effectiveBarOffset = 0;
  9739. /** Observable raised when the sldier value changes */
  9740. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9741. // Events
  9742. _this._pointerIsDown = false;
  9743. _this.isPointerBlocker = true;
  9744. return _this;
  9745. }
  9746. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  9747. /** Gets or sets a boolean indicating if the thumb must be rendered */
  9748. get: function () {
  9749. return this._displayThumb;
  9750. },
  9751. set: function (value) {
  9752. if (this._displayThumb === value) {
  9753. return;
  9754. }
  9755. this._displayThumb = value;
  9756. this._markAsDirty();
  9757. },
  9758. enumerable: true,
  9759. configurable: true
  9760. });
  9761. Object.defineProperty(BaseSlider.prototype, "step", {
  9762. /** Gets or sets a step to apply to values (0 by default) */
  9763. get: function () {
  9764. return this._step;
  9765. },
  9766. set: function (value) {
  9767. if (this._step === value) {
  9768. return;
  9769. }
  9770. this._step = value;
  9771. this._markAsDirty();
  9772. },
  9773. enumerable: true,
  9774. configurable: true
  9775. });
  9776. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  9777. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  9778. get: function () {
  9779. return this._barOffset.toString(this._host);
  9780. },
  9781. set: function (value) {
  9782. if (this._barOffset.toString(this._host) === value) {
  9783. return;
  9784. }
  9785. if (this._barOffset.fromString(value)) {
  9786. this._markAsDirty();
  9787. }
  9788. },
  9789. enumerable: true,
  9790. configurable: true
  9791. });
  9792. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  9793. /** Gets main bar offset in pixels*/
  9794. get: function () {
  9795. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9796. },
  9797. enumerable: true,
  9798. configurable: true
  9799. });
  9800. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  9801. /** Gets or sets thumb width */
  9802. get: function () {
  9803. return this._thumbWidth.toString(this._host);
  9804. },
  9805. set: function (value) {
  9806. if (this._thumbWidth.toString(this._host) === value) {
  9807. return;
  9808. }
  9809. if (this._thumbWidth.fromString(value)) {
  9810. this._markAsDirty();
  9811. }
  9812. },
  9813. enumerable: true,
  9814. configurable: true
  9815. });
  9816. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  9817. /** Gets thumb width in pixels */
  9818. get: function () {
  9819. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  9820. },
  9821. enumerable: true,
  9822. configurable: true
  9823. });
  9824. Object.defineProperty(BaseSlider.prototype, "minimum", {
  9825. /** Gets or sets minimum value */
  9826. get: function () {
  9827. return this._minimum;
  9828. },
  9829. set: function (value) {
  9830. if (this._minimum === value) {
  9831. return;
  9832. }
  9833. this._minimum = value;
  9834. this._markAsDirty();
  9835. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9836. },
  9837. enumerable: true,
  9838. configurable: true
  9839. });
  9840. Object.defineProperty(BaseSlider.prototype, "maximum", {
  9841. /** Gets or sets maximum value */
  9842. get: function () {
  9843. return this._maximum;
  9844. },
  9845. set: function (value) {
  9846. if (this._maximum === value) {
  9847. return;
  9848. }
  9849. this._maximum = value;
  9850. this._markAsDirty();
  9851. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  9852. },
  9853. enumerable: true,
  9854. configurable: true
  9855. });
  9856. Object.defineProperty(BaseSlider.prototype, "value", {
  9857. /** Gets or sets current value */
  9858. get: function () {
  9859. return this._value;
  9860. },
  9861. set: function (value) {
  9862. value = Math.max(Math.min(value, this._maximum), this._minimum);
  9863. if (this._value === value) {
  9864. return;
  9865. }
  9866. this._value = value;
  9867. this._markAsDirty();
  9868. this.onValueChangedObservable.notifyObservers(this._value);
  9869. },
  9870. enumerable: true,
  9871. configurable: true
  9872. });
  9873. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  9874. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  9875. get: function () {
  9876. return this._isVertical;
  9877. },
  9878. set: function (value) {
  9879. if (this._isVertical === value) {
  9880. return;
  9881. }
  9882. this._isVertical = value;
  9883. this._markAsDirty();
  9884. },
  9885. enumerable: true,
  9886. configurable: true
  9887. });
  9888. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  9889. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  9890. get: function () {
  9891. return this._isThumbClamped;
  9892. },
  9893. set: function (value) {
  9894. if (this._isThumbClamped === value) {
  9895. return;
  9896. }
  9897. this._isThumbClamped = value;
  9898. this._markAsDirty();
  9899. },
  9900. enumerable: true,
  9901. configurable: true
  9902. });
  9903. BaseSlider.prototype._getTypeName = function () {
  9904. return "BaseSlider";
  9905. };
  9906. BaseSlider.prototype._getThumbPosition = function () {
  9907. if (this.isVertical) {
  9908. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9909. }
  9910. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  9911. };
  9912. BaseSlider.prototype._getThumbThickness = function (type) {
  9913. var thumbThickness = 0;
  9914. switch (type) {
  9915. case "circle":
  9916. if (this._thumbWidth.isPixel) {
  9917. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9918. }
  9919. else {
  9920. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9921. }
  9922. break;
  9923. case "rectangle":
  9924. if (this._thumbWidth.isPixel) {
  9925. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  9926. }
  9927. else {
  9928. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  9929. }
  9930. }
  9931. return thumbThickness;
  9932. };
  9933. BaseSlider.prototype._prepareRenderingData = function (type) {
  9934. // Main bar
  9935. this._effectiveBarOffset = 0;
  9936. this._renderLeft = this._currentMeasure.left;
  9937. this._renderTop = this._currentMeasure.top;
  9938. this._renderWidth = this._currentMeasure.width;
  9939. this._renderHeight = this._currentMeasure.height;
  9940. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  9941. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  9942. this._effectiveThumbThickness = this._getThumbThickness(type);
  9943. if (this.displayThumb) {
  9944. this._backgroundBoxLength -= this._effectiveThumbThickness;
  9945. }
  9946. //throw error when height is less than width for vertical slider
  9947. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  9948. console.error("Height should be greater than width");
  9949. return;
  9950. }
  9951. if (this._barOffset.isPixel) {
  9952. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  9953. }
  9954. else {
  9955. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  9956. }
  9957. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  9958. if (this.isVertical) {
  9959. this._renderLeft += this._effectiveBarOffset;
  9960. if (!this.isThumbClamped && this.displayThumb) {
  9961. this._renderTop += (this._effectiveThumbThickness / 2);
  9962. }
  9963. this._renderHeight = this._backgroundBoxLength;
  9964. this._renderWidth = this._backgroundBoxThickness;
  9965. }
  9966. else {
  9967. this._renderTop += this._effectiveBarOffset;
  9968. if (!this.isThumbClamped && this.displayThumb) {
  9969. this._renderLeft += (this._effectiveThumbThickness / 2);
  9970. }
  9971. this._renderHeight = this._backgroundBoxThickness;
  9972. this._renderWidth = this._backgroundBoxLength;
  9973. }
  9974. };
  9975. /** @hidden */
  9976. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  9977. if (this.rotation != 0) {
  9978. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  9979. x = this._transformedPosition.x;
  9980. y = this._transformedPosition.y;
  9981. }
  9982. var value;
  9983. if (this._isVertical) {
  9984. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  9985. }
  9986. else {
  9987. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  9988. }
  9989. var mult = (1 / this._step) | 0;
  9990. this.value = this._step ? ((value * mult) | 0) / mult : value;
  9991. };
  9992. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  9993. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  9994. return false;
  9995. }
  9996. this._pointerIsDown = true;
  9997. this._updateValueFromPointer(coordinates.x, coordinates.y);
  9998. this._host._capturingControl[pointerId] = this;
  9999. this._lastPointerDownID = pointerId;
  10000. return true;
  10001. };
  10002. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10003. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10004. if (pointerId != this._lastPointerDownID) {
  10005. return;
  10006. }
  10007. if (this._pointerIsDown) {
  10008. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10009. }
  10010. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10011. };
  10012. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10013. this._pointerIsDown = false;
  10014. delete this._host._capturingControl[pointerId];
  10015. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10016. };
  10017. return BaseSlider;
  10018. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10019. /***/ }),
  10020. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10021. /*!*************************************************!*\
  10022. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10023. \*************************************************/
  10024. /*! exports provided: ImageBasedSlider */
  10025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10026. "use strict";
  10027. __webpack_require__.r(__webpack_exports__);
  10028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10029. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10030. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10031. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10032. /**
  10033. * Class used to create slider controls based on images
  10034. */
  10035. var ImageBasedSlider = /** @class */ (function (_super) {
  10036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageBasedSlider, _super);
  10037. /**
  10038. * Creates a new ImageBasedSlider
  10039. * @param name defines the control name
  10040. */
  10041. function ImageBasedSlider(name) {
  10042. var _this = _super.call(this, name) || this;
  10043. _this.name = name;
  10044. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10045. return _this;
  10046. }
  10047. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10048. get: function () {
  10049. return this._displayThumb && this.thumbImage != null;
  10050. },
  10051. set: function (value) {
  10052. if (this._displayThumb === value) {
  10053. return;
  10054. }
  10055. this._displayThumb = value;
  10056. this._markAsDirty();
  10057. },
  10058. enumerable: true,
  10059. configurable: true
  10060. });
  10061. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10062. /**
  10063. * Gets or sets the image used to render the background
  10064. */
  10065. get: function () {
  10066. return this._backgroundImage;
  10067. },
  10068. set: function (value) {
  10069. var _this = this;
  10070. if (this._backgroundImage === value) {
  10071. return;
  10072. }
  10073. this._backgroundImage = value;
  10074. if (value && !value.isLoaded) {
  10075. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10076. }
  10077. this._markAsDirty();
  10078. },
  10079. enumerable: true,
  10080. configurable: true
  10081. });
  10082. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10083. /**
  10084. * Gets or sets the image used to render the value bar
  10085. */
  10086. get: function () {
  10087. return this._valueBarImage;
  10088. },
  10089. set: function (value) {
  10090. var _this = this;
  10091. if (this._valueBarImage === value) {
  10092. return;
  10093. }
  10094. this._valueBarImage = value;
  10095. if (value && !value.isLoaded) {
  10096. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10097. }
  10098. this._markAsDirty();
  10099. },
  10100. enumerable: true,
  10101. configurable: true
  10102. });
  10103. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10104. /**
  10105. * Gets or sets the image used to render the thumb
  10106. */
  10107. get: function () {
  10108. return this._thumbImage;
  10109. },
  10110. set: function (value) {
  10111. var _this = this;
  10112. if (this._thumbImage === value) {
  10113. return;
  10114. }
  10115. this._thumbImage = value;
  10116. if (value && !value.isLoaded) {
  10117. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10118. }
  10119. this._markAsDirty();
  10120. },
  10121. enumerable: true,
  10122. configurable: true
  10123. });
  10124. ImageBasedSlider.prototype._getTypeName = function () {
  10125. return "ImageBasedSlider";
  10126. };
  10127. ImageBasedSlider.prototype._draw = function (context) {
  10128. context.save();
  10129. this._applyStates(context);
  10130. this._prepareRenderingData("rectangle");
  10131. var thumbPosition = this._getThumbPosition();
  10132. var left = this._renderLeft;
  10133. var top = this._renderTop;
  10134. var width = this._renderWidth;
  10135. var height = this._renderHeight;
  10136. // Background
  10137. if (this._backgroundImage) {
  10138. this._tempMeasure.copyFromFloats(left, top, width, height);
  10139. if (this.isThumbClamped && this.displayThumb) {
  10140. if (this.isVertical) {
  10141. this._tempMeasure.height += this._effectiveThumbThickness;
  10142. }
  10143. else {
  10144. this._tempMeasure.width += this._effectiveThumbThickness;
  10145. }
  10146. }
  10147. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10148. this._backgroundImage._draw(context);
  10149. }
  10150. // Bar
  10151. if (this._valueBarImage) {
  10152. if (this.isVertical) {
  10153. if (this.isThumbClamped && this.displayThumb) {
  10154. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10155. }
  10156. else {
  10157. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10158. }
  10159. }
  10160. else {
  10161. if (this.isThumbClamped && this.displayThumb) {
  10162. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10163. }
  10164. else {
  10165. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10166. }
  10167. }
  10168. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10169. this._valueBarImage._draw(context);
  10170. }
  10171. // Thumb
  10172. if (this.displayThumb) {
  10173. if (this.isVertical) {
  10174. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10175. }
  10176. else {
  10177. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10178. }
  10179. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10180. this._thumbImage._draw(context);
  10181. }
  10182. context.restore();
  10183. };
  10184. return ImageBasedSlider;
  10185. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10186. /***/ }),
  10187. /***/ "./2D/controls/sliders/scrollBar.ts":
  10188. /*!******************************************!*\
  10189. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10190. \******************************************/
  10191. /*! exports provided: ScrollBar */
  10192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10193. "use strict";
  10194. __webpack_require__.r(__webpack_exports__);
  10195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10196. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10197. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10198. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10199. /**
  10200. * Class used to create slider controls
  10201. */
  10202. var ScrollBar = /** @class */ (function (_super) {
  10203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScrollBar, _super);
  10204. /**
  10205. * Creates a new Slider
  10206. * @param name defines the control name
  10207. */
  10208. function ScrollBar(name) {
  10209. var _this = _super.call(this, name) || this;
  10210. _this.name = name;
  10211. _this._background = "black";
  10212. _this._borderColor = "white";
  10213. _this._thumbMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10214. return _this;
  10215. }
  10216. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10217. /** Gets or sets border color */
  10218. get: function () {
  10219. return this._borderColor;
  10220. },
  10221. set: function (value) {
  10222. if (this._borderColor === value) {
  10223. return;
  10224. }
  10225. this._borderColor = value;
  10226. this._markAsDirty();
  10227. },
  10228. enumerable: true,
  10229. configurable: true
  10230. });
  10231. Object.defineProperty(ScrollBar.prototype, "background", {
  10232. /** Gets or sets background color */
  10233. get: function () {
  10234. return this._background;
  10235. },
  10236. set: function (value) {
  10237. if (this._background === value) {
  10238. return;
  10239. }
  10240. this._background = value;
  10241. this._markAsDirty();
  10242. },
  10243. enumerable: true,
  10244. configurable: true
  10245. });
  10246. ScrollBar.prototype._getTypeName = function () {
  10247. return "Scrollbar";
  10248. };
  10249. ScrollBar.prototype._getThumbThickness = function () {
  10250. var thumbThickness = 0;
  10251. if (this._thumbWidth.isPixel) {
  10252. thumbThickness = this._thumbWidth.getValue(this._host);
  10253. }
  10254. else {
  10255. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10256. }
  10257. return thumbThickness;
  10258. };
  10259. ScrollBar.prototype._draw = function (context) {
  10260. context.save();
  10261. this._applyStates(context);
  10262. this._prepareRenderingData("rectangle");
  10263. var left = this._renderLeft;
  10264. var thumbPosition = this._getThumbPosition();
  10265. context.fillStyle = this._background;
  10266. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10267. // Value bar
  10268. context.fillStyle = this.color;
  10269. // Thumb
  10270. if (this.isVertical) {
  10271. this._thumbMeasure.left = left - this._effectiveBarOffset;
  10272. this._thumbMeasure.top = this._currentMeasure.top + thumbPosition;
  10273. this._thumbMeasure.width = this._currentMeasure.width;
  10274. this._thumbMeasure.height = this._effectiveThumbThickness;
  10275. }
  10276. else {
  10277. this._thumbMeasure.left = this._currentMeasure.left + thumbPosition;
  10278. this._thumbMeasure.top = this._currentMeasure.top;
  10279. this._thumbMeasure.width = this._effectiveThumbThickness;
  10280. this._thumbMeasure.height = this._currentMeasure.height;
  10281. }
  10282. context.fillRect(this._thumbMeasure.left, this._thumbMeasure.top, this._thumbMeasure.width, this._thumbMeasure.height);
  10283. context.restore();
  10284. };
  10285. /** @hidden */
  10286. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10287. if (this.rotation != 0) {
  10288. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10289. x = this._transformedPosition.x;
  10290. y = this._transformedPosition.y;
  10291. }
  10292. if (this._first) {
  10293. this._first = false;
  10294. this._originX = x;
  10295. this._originY = y;
  10296. // Check if move is required
  10297. if (x < this._thumbMeasure.left || x > this._thumbMeasure.left + this._thumbMeasure.width || y < this._thumbMeasure.top || y > this._thumbMeasure.top + this._thumbMeasure.height) {
  10298. if (this.isVertical) {
  10299. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10300. }
  10301. else {
  10302. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10303. }
  10304. }
  10305. }
  10306. // Delta mode
  10307. var delta = 0;
  10308. if (this.isVertical) {
  10309. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10310. }
  10311. else {
  10312. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10313. }
  10314. this.value += delta * (this.maximum - this.minimum);
  10315. this._originX = x;
  10316. this._originY = y;
  10317. };
  10318. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10319. this._first = true;
  10320. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10321. };
  10322. return ScrollBar;
  10323. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10324. /***/ }),
  10325. /***/ "./2D/controls/sliders/slider.ts":
  10326. /*!***************************************!*\
  10327. !*** ./2D/controls/sliders/slider.ts ***!
  10328. \***************************************/
  10329. /*! exports provided: Slider */
  10330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10331. "use strict";
  10332. __webpack_require__.r(__webpack_exports__);
  10333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10334. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10335. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10336. /**
  10337. * Class used to create slider controls
  10338. */
  10339. var Slider = /** @class */ (function (_super) {
  10340. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Slider, _super);
  10341. /**
  10342. * Creates a new Slider
  10343. * @param name defines the control name
  10344. */
  10345. function Slider(name) {
  10346. var _this = _super.call(this, name) || this;
  10347. _this.name = name;
  10348. _this._background = "black";
  10349. _this._borderColor = "white";
  10350. _this._isThumbCircle = false;
  10351. _this._displayValueBar = true;
  10352. return _this;
  10353. }
  10354. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10355. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10356. get: function () {
  10357. return this._displayValueBar;
  10358. },
  10359. set: function (value) {
  10360. if (this._displayValueBar === value) {
  10361. return;
  10362. }
  10363. this._displayValueBar = value;
  10364. this._markAsDirty();
  10365. },
  10366. enumerable: true,
  10367. configurable: true
  10368. });
  10369. Object.defineProperty(Slider.prototype, "borderColor", {
  10370. /** Gets or sets border color */
  10371. get: function () {
  10372. return this._borderColor;
  10373. },
  10374. set: function (value) {
  10375. if (this._borderColor === value) {
  10376. return;
  10377. }
  10378. this._borderColor = value;
  10379. this._markAsDirty();
  10380. },
  10381. enumerable: true,
  10382. configurable: true
  10383. });
  10384. Object.defineProperty(Slider.prototype, "background", {
  10385. /** Gets or sets background color */
  10386. get: function () {
  10387. return this._background;
  10388. },
  10389. set: function (value) {
  10390. if (this._background === value) {
  10391. return;
  10392. }
  10393. this._background = value;
  10394. this._markAsDirty();
  10395. },
  10396. enumerable: true,
  10397. configurable: true
  10398. });
  10399. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10400. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10401. get: function () {
  10402. return this._isThumbCircle;
  10403. },
  10404. set: function (value) {
  10405. if (this._isThumbCircle === value) {
  10406. return;
  10407. }
  10408. this._isThumbCircle = value;
  10409. this._markAsDirty();
  10410. },
  10411. enumerable: true,
  10412. configurable: true
  10413. });
  10414. Slider.prototype._getTypeName = function () {
  10415. return "Slider";
  10416. };
  10417. Slider.prototype._draw = function (context) {
  10418. context.save();
  10419. this._applyStates(context);
  10420. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10421. var left = this._renderLeft;
  10422. var top = this._renderTop;
  10423. var width = this._renderWidth;
  10424. var height = this._renderHeight;
  10425. var radius = 0;
  10426. if (this.isThumbClamped && this.isThumbCircle) {
  10427. if (this.isVertical) {
  10428. top += (this._effectiveThumbThickness / 2);
  10429. }
  10430. else {
  10431. left += (this._effectiveThumbThickness / 2);
  10432. }
  10433. radius = this._backgroundBoxThickness / 2;
  10434. }
  10435. else {
  10436. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10437. }
  10438. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10439. context.shadowColor = this.shadowColor;
  10440. context.shadowBlur = this.shadowBlur;
  10441. context.shadowOffsetX = this.shadowOffsetX;
  10442. context.shadowOffsetY = this.shadowOffsetY;
  10443. }
  10444. var thumbPosition = this._getThumbPosition();
  10445. context.fillStyle = this._background;
  10446. if (this.isVertical) {
  10447. if (this.isThumbClamped) {
  10448. if (this.isThumbCircle) {
  10449. context.beginPath();
  10450. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  10451. context.fill();
  10452. context.fillRect(left, top, width, height);
  10453. }
  10454. else {
  10455. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  10456. }
  10457. }
  10458. else {
  10459. context.fillRect(left, top, width, height);
  10460. }
  10461. }
  10462. else {
  10463. if (this.isThumbClamped) {
  10464. if (this.isThumbCircle) {
  10465. context.beginPath();
  10466. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10467. context.fill();
  10468. context.fillRect(left, top, width, height);
  10469. }
  10470. else {
  10471. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  10472. }
  10473. }
  10474. else {
  10475. context.fillRect(left, top, width, height);
  10476. }
  10477. }
  10478. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10479. context.shadowBlur = 0;
  10480. context.shadowOffsetX = 0;
  10481. context.shadowOffsetY = 0;
  10482. }
  10483. // Value bar
  10484. context.fillStyle = this.color;
  10485. if (this._displayValueBar) {
  10486. if (this.isVertical) {
  10487. if (this.isThumbClamped) {
  10488. if (this.isThumbCircle) {
  10489. context.beginPath();
  10490. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  10491. context.fill();
  10492. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10493. }
  10494. else {
  10495. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10496. }
  10497. }
  10498. else {
  10499. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  10500. }
  10501. }
  10502. else {
  10503. if (this.isThumbClamped) {
  10504. if (this.isThumbCircle) {
  10505. context.beginPath();
  10506. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  10507. context.fill();
  10508. context.fillRect(left, top, thumbPosition, height);
  10509. }
  10510. else {
  10511. context.fillRect(left, top, thumbPosition, height);
  10512. }
  10513. }
  10514. else {
  10515. context.fillRect(left, top, thumbPosition, height);
  10516. }
  10517. }
  10518. }
  10519. // Thumb
  10520. if (this.displayThumb) {
  10521. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10522. context.shadowColor = this.shadowColor;
  10523. context.shadowBlur = this.shadowBlur;
  10524. context.shadowOffsetX = this.shadowOffsetX;
  10525. context.shadowOffsetY = this.shadowOffsetY;
  10526. }
  10527. if (this._isThumbCircle) {
  10528. context.beginPath();
  10529. if (this.isVertical) {
  10530. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  10531. }
  10532. else {
  10533. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  10534. }
  10535. context.fill();
  10536. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10537. context.shadowBlur = 0;
  10538. context.shadowOffsetX = 0;
  10539. context.shadowOffsetY = 0;
  10540. }
  10541. context.strokeStyle = this._borderColor;
  10542. context.stroke();
  10543. }
  10544. else {
  10545. if (this.isVertical) {
  10546. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10547. }
  10548. else {
  10549. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10550. }
  10551. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10552. context.shadowBlur = 0;
  10553. context.shadowOffsetX = 0;
  10554. context.shadowOffsetY = 0;
  10555. }
  10556. context.strokeStyle = this._borderColor;
  10557. if (this.isVertical) {
  10558. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10559. }
  10560. else {
  10561. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10562. }
  10563. }
  10564. }
  10565. context.restore();
  10566. };
  10567. return Slider;
  10568. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10569. /***/ }),
  10570. /***/ "./2D/controls/stackPanel.ts":
  10571. /*!***********************************!*\
  10572. !*** ./2D/controls/stackPanel.ts ***!
  10573. \***********************************/
  10574. /*! exports provided: StackPanel */
  10575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10576. "use strict";
  10577. __webpack_require__.r(__webpack_exports__);
  10578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  10579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10580. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  10581. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  10582. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10583. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10584. /**
  10585. * Class used to create a 2D stack panel container
  10586. */
  10587. var StackPanel = /** @class */ (function (_super) {
  10588. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel, _super);
  10589. /**
  10590. * Creates a new StackPanel
  10591. * @param name defines control name
  10592. */
  10593. function StackPanel(name) {
  10594. var _this = _super.call(this, name) || this;
  10595. _this.name = name;
  10596. _this._isVertical = true;
  10597. _this._manualWidth = false;
  10598. _this._manualHeight = false;
  10599. _this._doNotTrackManualChanges = false;
  10600. return _this;
  10601. }
  10602. Object.defineProperty(StackPanel.prototype, "isVertical", {
  10603. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  10604. get: function () {
  10605. return this._isVertical;
  10606. },
  10607. set: function (value) {
  10608. if (this._isVertical === value) {
  10609. return;
  10610. }
  10611. this._isVertical = value;
  10612. this._markAsDirty();
  10613. },
  10614. enumerable: true,
  10615. configurable: true
  10616. });
  10617. Object.defineProperty(StackPanel.prototype, "width", {
  10618. get: function () {
  10619. return this._width.toString(this._host);
  10620. },
  10621. /**
  10622. * Gets or sets panel width.
  10623. * This value should not be set when in horizontal mode as it will be computed automatically
  10624. */
  10625. set: function (value) {
  10626. if (!this._doNotTrackManualChanges) {
  10627. this._manualWidth = true;
  10628. }
  10629. if (this._width.toString(this._host) === value) {
  10630. return;
  10631. }
  10632. if (this._width.fromString(value)) {
  10633. this._markAsDirty();
  10634. }
  10635. },
  10636. enumerable: true,
  10637. configurable: true
  10638. });
  10639. Object.defineProperty(StackPanel.prototype, "height", {
  10640. get: function () {
  10641. return this._height.toString(this._host);
  10642. },
  10643. /**
  10644. * Gets or sets panel height.
  10645. * This value should not be set when in vertical mode as it will be computed automatically
  10646. */
  10647. set: function (value) {
  10648. if (!this._doNotTrackManualChanges) {
  10649. this._manualHeight = true;
  10650. }
  10651. if (this._height.toString(this._host) === value) {
  10652. return;
  10653. }
  10654. if (this._height.fromString(value)) {
  10655. this._markAsDirty();
  10656. }
  10657. },
  10658. enumerable: true,
  10659. configurable: true
  10660. });
  10661. StackPanel.prototype._getTypeName = function () {
  10662. return "StackPanel";
  10663. };
  10664. /** @hidden */
  10665. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  10666. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10667. var child = _a[_i];
  10668. if (this._isVertical) {
  10669. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10670. }
  10671. else {
  10672. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10673. }
  10674. }
  10675. _super.prototype._preMeasure.call(this, parentMeasure, context);
  10676. };
  10677. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  10678. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10679. this._measureForChildren.copyFrom(parentMeasure);
  10680. this._measureForChildren.left = this._currentMeasure.left;
  10681. this._measureForChildren.top = this._currentMeasure.top;
  10682. if (!this.isVertical || this._manualWidth) {
  10683. this._measureForChildren.width = this._currentMeasure.width;
  10684. }
  10685. if (this.isVertical || this._manualHeight) {
  10686. this._measureForChildren.height = this._currentMeasure.height;
  10687. }
  10688. };
  10689. StackPanel.prototype._postMeasure = function () {
  10690. var stackWidth = 0;
  10691. var stackHeight = 0;
  10692. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10693. var child = _a[_i];
  10694. if (!child.isVisible || child.notRenderable) {
  10695. continue;
  10696. }
  10697. if (this._isVertical) {
  10698. if (child.top !== stackHeight + "px") {
  10699. child.top = stackHeight + "px";
  10700. this._rebuildLayout = true;
  10701. child._top.ignoreAdaptiveScaling = true;
  10702. }
  10703. if (child._height.isPercentage) {
  10704. 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");
  10705. }
  10706. else {
  10707. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  10708. }
  10709. }
  10710. else {
  10711. if (child.left !== stackWidth + "px") {
  10712. child.left = stackWidth + "px";
  10713. this._rebuildLayout = true;
  10714. child._left.ignoreAdaptiveScaling = true;
  10715. }
  10716. if (child._width.isPercentage) {
  10717. 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");
  10718. }
  10719. else {
  10720. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  10721. }
  10722. }
  10723. }
  10724. this._doNotTrackManualChanges = true;
  10725. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  10726. // User can now define their own height and width for stack panel.
  10727. var panelWidthChanged = false;
  10728. var panelHeightChanged = false;
  10729. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  10730. var previousHeight = this.height;
  10731. this.height = stackHeight + "px";
  10732. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  10733. }
  10734. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  10735. var previousWidth = this.width;
  10736. this.width = stackWidth + "px";
  10737. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  10738. }
  10739. if (panelHeightChanged) {
  10740. this._height.ignoreAdaptiveScaling = true;
  10741. }
  10742. if (panelWidthChanged) {
  10743. this._width.ignoreAdaptiveScaling = true;
  10744. }
  10745. this._doNotTrackManualChanges = false;
  10746. if (panelWidthChanged || panelHeightChanged) {
  10747. this._rebuildLayout = true;
  10748. }
  10749. _super.prototype._postMeasure.call(this);
  10750. };
  10751. return StackPanel;
  10752. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10753. /***/ }),
  10754. /***/ "./2D/controls/statics.ts":
  10755. /*!********************************!*\
  10756. !*** ./2D/controls/statics.ts ***!
  10757. \********************************/
  10758. /*! exports provided: name */
  10759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10760. "use strict";
  10761. __webpack_require__.r(__webpack_exports__);
  10762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  10763. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10764. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10765. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10766. /**
  10767. * Forcing an export so that this code will execute
  10768. * @hidden
  10769. */
  10770. var name = "Statics";
  10771. /**
  10772. * Creates a stack panel that can be used to render headers
  10773. * @param control defines the control to associate with the header
  10774. * @param text defines the text of the header
  10775. * @param size defines the size of the header
  10776. * @param options defines options used to configure the header
  10777. * @returns a new StackPanel
  10778. */
  10779. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  10780. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  10781. var isHorizontal = options ? options.isHorizontal : true;
  10782. var controlFirst = options ? options.controlFirst : true;
  10783. panel.isVertical = !isHorizontal;
  10784. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  10785. header.text = text;
  10786. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10787. if (isHorizontal) {
  10788. header.width = size;
  10789. }
  10790. else {
  10791. header.height = size;
  10792. }
  10793. if (controlFirst) {
  10794. panel.addControl(control);
  10795. panel.addControl(header);
  10796. header.paddingLeft = "5px";
  10797. }
  10798. else {
  10799. panel.addControl(header);
  10800. panel.addControl(control);
  10801. header.paddingRight = "5px";
  10802. }
  10803. header.shadowBlur = control.shadowBlur;
  10804. header.shadowColor = control.shadowColor;
  10805. header.shadowOffsetX = control.shadowOffsetX;
  10806. header.shadowOffsetY = control.shadowOffsetY;
  10807. return panel;
  10808. };
  10809. /***/ }),
  10810. /***/ "./2D/controls/textBlock.ts":
  10811. /*!**********************************!*\
  10812. !*** ./2D/controls/textBlock.ts ***!
  10813. \**********************************/
  10814. /*! exports provided: TextWrapping, TextBlock */
  10815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10816. "use strict";
  10817. __webpack_require__.r(__webpack_exports__);
  10818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  10819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  10820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10821. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10822. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10823. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  10824. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10825. /**
  10826. * Enum that determines the text-wrapping mode to use.
  10827. */
  10828. var TextWrapping;
  10829. (function (TextWrapping) {
  10830. /**
  10831. * Clip the text when it's larger than Control.width; this is the default mode.
  10832. */
  10833. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  10834. /**
  10835. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  10836. */
  10837. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  10838. /**
  10839. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  10840. */
  10841. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  10842. })(TextWrapping || (TextWrapping = {}));
  10843. /**
  10844. * Class used to create text block control
  10845. */
  10846. var TextBlock = /** @class */ (function (_super) {
  10847. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextBlock, _super);
  10848. /**
  10849. * Creates a new TextBlock object
  10850. * @param name defines the name of the control
  10851. * @param text defines the text to display (emptry string by default)
  10852. */
  10853. function TextBlock(
  10854. /**
  10855. * Defines the name of the control
  10856. */
  10857. name, text) {
  10858. if (text === void 0) { text = ""; }
  10859. var _this = _super.call(this, name) || this;
  10860. _this.name = name;
  10861. _this._text = "";
  10862. _this._textWrapping = TextWrapping.Clip;
  10863. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10864. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10865. _this._resizeToFit = false;
  10866. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  10867. _this._outlineWidth = 0;
  10868. _this._outlineColor = "white";
  10869. /**
  10870. * An event triggered after the text is changed
  10871. */
  10872. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10873. /**
  10874. * An event triggered after the text was broken up into lines
  10875. */
  10876. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10877. _this.text = text;
  10878. return _this;
  10879. }
  10880. Object.defineProperty(TextBlock.prototype, "lines", {
  10881. /**
  10882. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  10883. */
  10884. get: function () {
  10885. return this._lines;
  10886. },
  10887. enumerable: true,
  10888. configurable: true
  10889. });
  10890. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  10891. /**
  10892. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10893. */
  10894. get: function () {
  10895. return this._resizeToFit;
  10896. },
  10897. /**
  10898. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  10899. */
  10900. set: function (value) {
  10901. if (this._resizeToFit === value) {
  10902. return;
  10903. }
  10904. this._resizeToFit = value;
  10905. if (this._resizeToFit) {
  10906. this._width.ignoreAdaptiveScaling = true;
  10907. this._height.ignoreAdaptiveScaling = true;
  10908. }
  10909. this._markAsDirty();
  10910. },
  10911. enumerable: true,
  10912. configurable: true
  10913. });
  10914. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  10915. /**
  10916. * Gets or sets a boolean indicating if text must be wrapped
  10917. */
  10918. get: function () {
  10919. return this._textWrapping;
  10920. },
  10921. /**
  10922. * Gets or sets a boolean indicating if text must be wrapped
  10923. */
  10924. set: function (value) {
  10925. if (this._textWrapping === value) {
  10926. return;
  10927. }
  10928. this._textWrapping = +value;
  10929. this._markAsDirty();
  10930. },
  10931. enumerable: true,
  10932. configurable: true
  10933. });
  10934. Object.defineProperty(TextBlock.prototype, "text", {
  10935. /**
  10936. * Gets or sets text to display
  10937. */
  10938. get: function () {
  10939. return this._text;
  10940. },
  10941. /**
  10942. * Gets or sets text to display
  10943. */
  10944. set: function (value) {
  10945. if (this._text === value) {
  10946. return;
  10947. }
  10948. this._text = value;
  10949. this._markAsDirty();
  10950. this.onTextChangedObservable.notifyObservers(this);
  10951. },
  10952. enumerable: true,
  10953. configurable: true
  10954. });
  10955. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  10956. /**
  10957. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10958. */
  10959. get: function () {
  10960. return this._textHorizontalAlignment;
  10961. },
  10962. /**
  10963. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  10964. */
  10965. set: function (value) {
  10966. if (this._textHorizontalAlignment === value) {
  10967. return;
  10968. }
  10969. this._textHorizontalAlignment = value;
  10970. this._markAsDirty();
  10971. },
  10972. enumerable: true,
  10973. configurable: true
  10974. });
  10975. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  10976. /**
  10977. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10978. */
  10979. get: function () {
  10980. return this._textVerticalAlignment;
  10981. },
  10982. /**
  10983. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  10984. */
  10985. set: function (value) {
  10986. if (this._textVerticalAlignment === value) {
  10987. return;
  10988. }
  10989. this._textVerticalAlignment = value;
  10990. this._markAsDirty();
  10991. },
  10992. enumerable: true,
  10993. configurable: true
  10994. });
  10995. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  10996. /**
  10997. * Gets or sets line spacing value
  10998. */
  10999. get: function () {
  11000. return this._lineSpacing.toString(this._host);
  11001. },
  11002. /**
  11003. * Gets or sets line spacing value
  11004. */
  11005. set: function (value) {
  11006. if (this._lineSpacing.fromString(value)) {
  11007. this._markAsDirty();
  11008. }
  11009. },
  11010. enumerable: true,
  11011. configurable: true
  11012. });
  11013. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11014. /**
  11015. * Gets or sets outlineWidth of the text to display
  11016. */
  11017. get: function () {
  11018. return this._outlineWidth;
  11019. },
  11020. /**
  11021. * Gets or sets outlineWidth of the text to display
  11022. */
  11023. set: function (value) {
  11024. if (this._outlineWidth === value) {
  11025. return;
  11026. }
  11027. this._outlineWidth = value;
  11028. this._markAsDirty();
  11029. },
  11030. enumerable: true,
  11031. configurable: true
  11032. });
  11033. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11034. /**
  11035. * Gets or sets outlineColor of the text to display
  11036. */
  11037. get: function () {
  11038. return this._outlineColor;
  11039. },
  11040. /**
  11041. * Gets or sets outlineColor of the text to display
  11042. */
  11043. set: function (value) {
  11044. if (this._outlineColor === value) {
  11045. return;
  11046. }
  11047. this._outlineColor = value;
  11048. this._markAsDirty();
  11049. },
  11050. enumerable: true,
  11051. configurable: true
  11052. });
  11053. TextBlock.prototype._getTypeName = function () {
  11054. return "TextBlock";
  11055. };
  11056. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11057. if (!this._fontOffset) {
  11058. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11059. }
  11060. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11061. // Prepare lines
  11062. this._lines = this._breakLines(this._currentMeasure.width, context);
  11063. this.onLinesReadyObservable.notifyObservers(this);
  11064. var maxLineWidth = 0;
  11065. for (var i = 0; i < this._lines.length; i++) {
  11066. var line = this._lines[i];
  11067. if (line.width > maxLineWidth) {
  11068. maxLineWidth = line.width;
  11069. }
  11070. }
  11071. if (this._resizeToFit) {
  11072. if (this._textWrapping === TextWrapping.Clip) {
  11073. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11074. if (newWidth !== this._width.internalValue) {
  11075. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11076. this._rebuildLayout = true;
  11077. }
  11078. }
  11079. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11080. if (newHeight !== this._height.internalValue) {
  11081. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11082. this._rebuildLayout = true;
  11083. }
  11084. }
  11085. };
  11086. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11087. var width = this._currentMeasure.width;
  11088. var x = 0;
  11089. switch (this._textHorizontalAlignment) {
  11090. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11091. x = 0;
  11092. break;
  11093. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11094. x = width - textWidth;
  11095. break;
  11096. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11097. x = (width - textWidth) / 2;
  11098. break;
  11099. }
  11100. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11101. context.shadowColor = this.shadowColor;
  11102. context.shadowBlur = this.shadowBlur;
  11103. context.shadowOffsetX = this.shadowOffsetX;
  11104. context.shadowOffsetY = this.shadowOffsetY;
  11105. }
  11106. if (this.outlineWidth) {
  11107. context.strokeText(text, this._currentMeasure.left + x, y);
  11108. }
  11109. context.fillText(text, this._currentMeasure.left + x, y);
  11110. };
  11111. /** @hidden */
  11112. TextBlock.prototype._draw = function (context) {
  11113. context.save();
  11114. this._applyStates(context);
  11115. // Render lines
  11116. this._renderLines(context);
  11117. context.restore();
  11118. };
  11119. TextBlock.prototype._applyStates = function (context) {
  11120. _super.prototype._applyStates.call(this, context);
  11121. if (this.outlineWidth) {
  11122. context.lineWidth = this.outlineWidth;
  11123. context.strokeStyle = this.outlineColor;
  11124. }
  11125. };
  11126. TextBlock.prototype._breakLines = function (refWidth, context) {
  11127. var lines = [];
  11128. var _lines = this.text.split("\n");
  11129. if (this._textWrapping === TextWrapping.Ellipsis) {
  11130. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11131. var _line = _lines_1[_i];
  11132. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11133. }
  11134. }
  11135. else if (this._textWrapping === TextWrapping.WordWrap) {
  11136. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11137. var _line = _lines_2[_a];
  11138. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11139. }
  11140. }
  11141. else {
  11142. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11143. var _line = _lines_3[_b];
  11144. lines.push(this._parseLine(_line, context));
  11145. }
  11146. }
  11147. return lines;
  11148. };
  11149. TextBlock.prototype._parseLine = function (line, context) {
  11150. if (line === void 0) { line = ''; }
  11151. return { text: line, width: context.measureText(line).width };
  11152. };
  11153. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11154. if (line === void 0) { line = ''; }
  11155. var lineWidth = context.measureText(line).width;
  11156. if (lineWidth > width) {
  11157. line += '…';
  11158. }
  11159. while (line.length > 2 && lineWidth > width) {
  11160. line = line.slice(0, -2) + '…';
  11161. lineWidth = context.measureText(line).width;
  11162. }
  11163. return { text: line, width: lineWidth };
  11164. };
  11165. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11166. if (line === void 0) { line = ''; }
  11167. var lines = [];
  11168. var words = line.split(' ');
  11169. var lineWidth = 0;
  11170. for (var n = 0; n < words.length; n++) {
  11171. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11172. var metrics = context.measureText(testLine);
  11173. var testWidth = metrics.width;
  11174. if (testWidth > width && n > 0) {
  11175. lines.push({ text: line, width: lineWidth });
  11176. line = words[n];
  11177. lineWidth = context.measureText(line).width;
  11178. }
  11179. else {
  11180. lineWidth = testWidth;
  11181. line = testLine;
  11182. }
  11183. }
  11184. lines.push({ text: line, width: lineWidth });
  11185. return lines;
  11186. };
  11187. TextBlock.prototype._renderLines = function (context) {
  11188. var height = this._currentMeasure.height;
  11189. var rootY = 0;
  11190. switch (this._textVerticalAlignment) {
  11191. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11192. rootY = this._fontOffset.ascent;
  11193. break;
  11194. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11195. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11196. break;
  11197. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11198. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11199. break;
  11200. }
  11201. rootY += this._currentMeasure.top;
  11202. for (var i = 0; i < this._lines.length; i++) {
  11203. var line = this._lines[i];
  11204. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11205. if (this._lineSpacing.isPixel) {
  11206. rootY += this._lineSpacing.getValue(this._host);
  11207. }
  11208. else {
  11209. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11210. }
  11211. }
  11212. this._drawText(line.text, line.width, rootY, context);
  11213. rootY += this._fontOffset.height;
  11214. }
  11215. };
  11216. /**
  11217. * Given a width constraint applied on the text block, find the expected height
  11218. * @returns expected height
  11219. */
  11220. TextBlock.prototype.computeExpectedHeight = function () {
  11221. if (this.text && this.widthInPixels) {
  11222. var context_1 = document.createElement('canvas').getContext('2d');
  11223. if (context_1) {
  11224. this._applyStates(context_1);
  11225. if (!this._fontOffset) {
  11226. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11227. }
  11228. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11229. return this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11230. }
  11231. }
  11232. return 0;
  11233. };
  11234. TextBlock.prototype.dispose = function () {
  11235. _super.prototype.dispose.call(this);
  11236. this.onTextChangedObservable.clear();
  11237. };
  11238. return TextBlock;
  11239. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11240. /***/ }),
  11241. /***/ "./2D/controls/virtualKeyboard.ts":
  11242. /*!****************************************!*\
  11243. !*** ./2D/controls/virtualKeyboard.ts ***!
  11244. \****************************************/
  11245. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11247. "use strict";
  11248. __webpack_require__.r(__webpack_exports__);
  11249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11252. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11253. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11254. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11255. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11256. /**
  11257. * Class used to store key control properties
  11258. */
  11259. var KeyPropertySet = /** @class */ (function () {
  11260. function KeyPropertySet() {
  11261. }
  11262. return KeyPropertySet;
  11263. }());
  11264. /**
  11265. * Class used to create virtual keyboard
  11266. */
  11267. var VirtualKeyboard = /** @class */ (function (_super) {
  11268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualKeyboard, _super);
  11269. function VirtualKeyboard() {
  11270. var _this = _super !== null && _super.apply(this, arguments) || this;
  11271. /** Observable raised when a key is pressed */
  11272. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11273. /** Gets or sets default key button width */
  11274. _this.defaultButtonWidth = "40px";
  11275. /** Gets or sets default key button height */
  11276. _this.defaultButtonHeight = "40px";
  11277. /** Gets or sets default key button left padding */
  11278. _this.defaultButtonPaddingLeft = "2px";
  11279. /** Gets or sets default key button right padding */
  11280. _this.defaultButtonPaddingRight = "2px";
  11281. /** Gets or sets default key button top padding */
  11282. _this.defaultButtonPaddingTop = "2px";
  11283. /** Gets or sets default key button bottom padding */
  11284. _this.defaultButtonPaddingBottom = "2px";
  11285. /** Gets or sets default key button foreground color */
  11286. _this.defaultButtonColor = "#DDD";
  11287. /** Gets or sets default key button background color */
  11288. _this.defaultButtonBackground = "#070707";
  11289. /** Gets or sets shift button foreground color */
  11290. _this.shiftButtonColor = "#7799FF";
  11291. /** Gets or sets shift button thickness*/
  11292. _this.selectedShiftThickness = 1;
  11293. /** Gets shift key state */
  11294. _this.shiftState = 0;
  11295. _this._currentlyConnectedInputText = null;
  11296. _this._connectedInputTexts = [];
  11297. _this._onKeyPressObserver = null;
  11298. return _this;
  11299. }
  11300. VirtualKeyboard.prototype._getTypeName = function () {
  11301. return "VirtualKeyboard";
  11302. };
  11303. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11304. var _this = this;
  11305. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11306. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11307. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11308. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11309. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11310. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11311. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11312. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11313. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11314. button.thickness = 0;
  11315. button.isFocusInvisible = true;
  11316. button.shadowColor = this.shadowColor;
  11317. button.shadowBlur = this.shadowBlur;
  11318. button.shadowOffsetX = this.shadowOffsetX;
  11319. button.shadowOffsetY = this.shadowOffsetY;
  11320. button.onPointerUpObservable.add(function () {
  11321. _this.onKeyPressObservable.notifyObservers(key);
  11322. });
  11323. return button;
  11324. };
  11325. /**
  11326. * Adds a new row of keys
  11327. * @param keys defines the list of keys to add
  11328. * @param propertySets defines the associated property sets
  11329. */
  11330. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11331. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11332. panel.isVertical = false;
  11333. panel.isFocusInvisible = true;
  11334. var maxKey = null;
  11335. for (var i = 0; i < keys.length; i++) {
  11336. var properties = null;
  11337. if (propertySets && propertySets.length === keys.length) {
  11338. properties = propertySets[i];
  11339. }
  11340. var key = this._createKey(keys[i], properties);
  11341. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11342. maxKey = key;
  11343. }
  11344. panel.addControl(key);
  11345. }
  11346. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11347. this.addControl(panel);
  11348. };
  11349. /**
  11350. * Set the shift key to a specific state
  11351. * @param shiftState defines the new shift state
  11352. */
  11353. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11354. if (!this.children) {
  11355. return;
  11356. }
  11357. for (var i = 0; i < this.children.length; i++) {
  11358. var row = this.children[i];
  11359. if (!row || !row.children) {
  11360. continue;
  11361. }
  11362. var rowContainer = row;
  11363. for (var j = 0; j < rowContainer.children.length; j++) {
  11364. var button = rowContainer.children[j];
  11365. if (!button || !button.children[0]) {
  11366. continue;
  11367. }
  11368. var button_tblock = button.children[0];
  11369. if (button_tblock.text === "\u21E7") {
  11370. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11371. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11372. }
  11373. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11374. }
  11375. }
  11376. };
  11377. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11378. /** Gets the input text control currently attached to the keyboard */
  11379. get: function () {
  11380. return this._currentlyConnectedInputText;
  11381. },
  11382. enumerable: true,
  11383. configurable: true
  11384. });
  11385. /**
  11386. * Connects the keyboard with an input text control
  11387. *
  11388. * @param input defines the target control
  11389. */
  11390. VirtualKeyboard.prototype.connect = function (input) {
  11391. var _this = this;
  11392. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11393. if (inputTextAlreadyConnected) {
  11394. return;
  11395. }
  11396. if (this._onKeyPressObserver === null) {
  11397. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11398. if (!_this._currentlyConnectedInputText) {
  11399. return;
  11400. }
  11401. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11402. switch (key) {
  11403. case "\u21E7":
  11404. _this.shiftState++;
  11405. if (_this.shiftState > 2) {
  11406. _this.shiftState = 0;
  11407. }
  11408. _this.applyShiftState(_this.shiftState);
  11409. return;
  11410. case "\u2190":
  11411. _this._currentlyConnectedInputText.processKey(8);
  11412. return;
  11413. case "\u21B5":
  11414. _this._currentlyConnectedInputText.processKey(13);
  11415. return;
  11416. }
  11417. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  11418. if (_this.shiftState === 1) {
  11419. _this.shiftState = 0;
  11420. _this.applyShiftState(_this.shiftState);
  11421. }
  11422. });
  11423. }
  11424. this.isVisible = false;
  11425. this._currentlyConnectedInputText = input;
  11426. input._connectedVirtualKeyboard = this;
  11427. // Events hooking
  11428. var onFocusObserver = input.onFocusObservable.add(function () {
  11429. _this._currentlyConnectedInputText = input;
  11430. input._connectedVirtualKeyboard = _this;
  11431. _this.isVisible = true;
  11432. });
  11433. var onBlurObserver = input.onBlurObservable.add(function () {
  11434. input._connectedVirtualKeyboard = null;
  11435. _this._currentlyConnectedInputText = null;
  11436. _this.isVisible = false;
  11437. });
  11438. this._connectedInputTexts.push({
  11439. input: input,
  11440. onBlurObserver: onBlurObserver,
  11441. onFocusObserver: onFocusObserver
  11442. });
  11443. };
  11444. /**
  11445. * Disconnects the keyboard from connected InputText controls
  11446. *
  11447. * @param input optionally defines a target control, otherwise all are disconnected
  11448. */
  11449. VirtualKeyboard.prototype.disconnect = function (input) {
  11450. var _this = this;
  11451. if (input) {
  11452. // .find not available on IE
  11453. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  11454. if (filtered.length === 1) {
  11455. this._removeConnectedInputObservables(filtered[0]);
  11456. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  11457. if (this._currentlyConnectedInputText === input) {
  11458. this._currentlyConnectedInputText = null;
  11459. }
  11460. }
  11461. }
  11462. else {
  11463. this._connectedInputTexts.forEach(function (connectedInputText) {
  11464. _this._removeConnectedInputObservables(connectedInputText);
  11465. });
  11466. this._connectedInputTexts = [];
  11467. }
  11468. if (this._connectedInputTexts.length === 0) {
  11469. this._currentlyConnectedInputText = null;
  11470. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  11471. this._onKeyPressObserver = null;
  11472. }
  11473. };
  11474. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  11475. connectedInputText.input._connectedVirtualKeyboard = null;
  11476. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  11477. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  11478. };
  11479. /**
  11480. * Release all resources
  11481. */
  11482. VirtualKeyboard.prototype.dispose = function () {
  11483. _super.prototype.dispose.call(this);
  11484. this.disconnect();
  11485. };
  11486. // Statics
  11487. /**
  11488. * Creates a new keyboard using a default layout
  11489. *
  11490. * @param name defines control name
  11491. * @returns a new VirtualKeyboard
  11492. */
  11493. VirtualKeyboard.CreateDefaultLayout = function (name) {
  11494. var returnValue = new VirtualKeyboard(name);
  11495. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  11496. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  11497. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  11498. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  11499. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  11500. return returnValue;
  11501. };
  11502. return VirtualKeyboard;
  11503. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  11504. /***/ }),
  11505. /***/ "./2D/index.ts":
  11506. /*!*********************!*\
  11507. !*** ./2D/index.ts ***!
  11508. \*********************/
  11509. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, 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 */
  11510. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11511. "use strict";
  11512. __webpack_require__.r(__webpack_exports__);
  11513. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  11514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  11515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  11516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  11517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  11518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  11519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  11520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  11521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  11522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  11523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  11524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  11525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  11526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  11527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  11528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  11529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  11530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  11531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  11532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  11533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  11534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  11535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  11536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  11537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  11538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  11539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  11540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  11541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  11542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  11543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  11544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  11545. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  11546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  11547. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  11548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  11549. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  11550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  11551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  11552. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  11553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  11554. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  11555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  11556. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  11557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  11558. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  11560. /***/ }),
  11561. /***/ "./2D/math2D.ts":
  11562. /*!**********************!*\
  11563. !*** ./2D/math2D.ts ***!
  11564. \**********************/
  11565. /*! exports provided: Vector2WithInfo, Matrix2D */
  11566. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11567. "use strict";
  11568. __webpack_require__.r(__webpack_exports__);
  11569. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  11570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  11571. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11572. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11573. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  11574. /**
  11575. * Class used to transport Vector2 information for pointer events
  11576. */
  11577. var Vector2WithInfo = /** @class */ (function (_super) {
  11578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector2WithInfo, _super);
  11579. /**
  11580. * Creates a new Vector2WithInfo
  11581. * @param source defines the vector2 data to transport
  11582. * @param buttonIndex defines the current mouse button index
  11583. */
  11584. function Vector2WithInfo(source,
  11585. /** defines the current mouse button index */
  11586. buttonIndex) {
  11587. if (buttonIndex === void 0) { buttonIndex = 0; }
  11588. var _this = _super.call(this, source.x, source.y) || this;
  11589. _this.buttonIndex = buttonIndex;
  11590. return _this;
  11591. }
  11592. return Vector2WithInfo;
  11593. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  11594. /** Class used to provide 2D matrix features */
  11595. var Matrix2D = /** @class */ (function () {
  11596. /**
  11597. * Creates a new matrix
  11598. * @param m00 defines value for (0, 0)
  11599. * @param m01 defines value for (0, 1)
  11600. * @param m10 defines value for (1, 0)
  11601. * @param m11 defines value for (1, 1)
  11602. * @param m20 defines value for (2, 0)
  11603. * @param m21 defines value for (2, 1)
  11604. */
  11605. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  11606. /** Gets the internal array of 6 floats used to store matrix data */
  11607. this.m = new Float32Array(6);
  11608. this.fromValues(m00, m01, m10, m11, m20, m21);
  11609. }
  11610. /**
  11611. * Fills the matrix from direct values
  11612. * @param m00 defines value for (0, 0)
  11613. * @param m01 defines value for (0, 1)
  11614. * @param m10 defines value for (1, 0)
  11615. * @param m11 defines value for (1, 1)
  11616. * @param m20 defines value for (2, 0)
  11617. * @param m21 defines value for (2, 1)
  11618. * @returns the current modified matrix
  11619. */
  11620. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  11621. this.m[0] = m00;
  11622. this.m[1] = m01;
  11623. this.m[2] = m10;
  11624. this.m[3] = m11;
  11625. this.m[4] = m20;
  11626. this.m[5] = m21;
  11627. return this;
  11628. };
  11629. /**
  11630. * Gets matrix determinant
  11631. * @returns the determinant
  11632. */
  11633. Matrix2D.prototype.determinant = function () {
  11634. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  11635. };
  11636. /**
  11637. * Inverses the matrix and stores it in a target matrix
  11638. * @param result defines the target matrix
  11639. * @returns the current matrix
  11640. */
  11641. Matrix2D.prototype.invertToRef = function (result) {
  11642. var l0 = this.m[0];
  11643. var l1 = this.m[1];
  11644. var l2 = this.m[2];
  11645. var l3 = this.m[3];
  11646. var l4 = this.m[4];
  11647. var l5 = this.m[5];
  11648. var det = this.determinant();
  11649. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  11650. result.m[0] = 0;
  11651. result.m[1] = 0;
  11652. result.m[2] = 0;
  11653. result.m[3] = 0;
  11654. result.m[4] = 0;
  11655. result.m[5] = 0;
  11656. return this;
  11657. }
  11658. var detDiv = 1 / det;
  11659. var det4 = l2 * l5 - l3 * l4;
  11660. var det5 = l1 * l4 - l0 * l5;
  11661. result.m[0] = l3 * detDiv;
  11662. result.m[1] = -l1 * detDiv;
  11663. result.m[2] = -l2 * detDiv;
  11664. result.m[3] = l0 * detDiv;
  11665. result.m[4] = det4 * detDiv;
  11666. result.m[5] = det5 * detDiv;
  11667. return this;
  11668. };
  11669. /**
  11670. * Multiplies the current matrix with another one
  11671. * @param other defines the second operand
  11672. * @param result defines the target matrix
  11673. * @returns the current matrix
  11674. */
  11675. Matrix2D.prototype.multiplyToRef = function (other, result) {
  11676. var l0 = this.m[0];
  11677. var l1 = this.m[1];
  11678. var l2 = this.m[2];
  11679. var l3 = this.m[3];
  11680. var l4 = this.m[4];
  11681. var l5 = this.m[5];
  11682. var r0 = other.m[0];
  11683. var r1 = other.m[1];
  11684. var r2 = other.m[2];
  11685. var r3 = other.m[3];
  11686. var r4 = other.m[4];
  11687. var r5 = other.m[5];
  11688. result.m[0] = l0 * r0 + l1 * r2;
  11689. result.m[1] = l0 * r1 + l1 * r3;
  11690. result.m[2] = l2 * r0 + l3 * r2;
  11691. result.m[3] = l2 * r1 + l3 * r3;
  11692. result.m[4] = l4 * r0 + l5 * r2 + r4;
  11693. result.m[5] = l4 * r1 + l5 * r3 + r5;
  11694. return this;
  11695. };
  11696. /**
  11697. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  11698. * @param x defines the x coordinate to transform
  11699. * @param y defines the x coordinate to transform
  11700. * @param result defines the target vector2
  11701. * @returns the current matrix
  11702. */
  11703. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  11704. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  11705. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  11706. return this;
  11707. };
  11708. // Statics
  11709. /**
  11710. * Creates an identity matrix
  11711. * @returns a new matrix
  11712. */
  11713. Matrix2D.Identity = function () {
  11714. return new Matrix2D(1, 0, 0, 1, 0, 0);
  11715. };
  11716. /**
  11717. * Creates a translation matrix and stores it in a target matrix
  11718. * @param x defines the x coordinate of the translation
  11719. * @param y defines the y coordinate of the translation
  11720. * @param result defines the target matrix
  11721. */
  11722. Matrix2D.TranslationToRef = function (x, y, result) {
  11723. result.fromValues(1, 0, 0, 1, x, y);
  11724. };
  11725. /**
  11726. * Creates a scaling matrix and stores it in a target matrix
  11727. * @param x defines the x coordinate of the scaling
  11728. * @param y defines the y coordinate of the scaling
  11729. * @param result defines the target matrix
  11730. */
  11731. Matrix2D.ScalingToRef = function (x, y, result) {
  11732. result.fromValues(x, 0, 0, y, 0, 0);
  11733. };
  11734. /**
  11735. * Creates a rotation matrix and stores it in a target matrix
  11736. * @param angle defines the rotation angle
  11737. * @param result defines the target matrix
  11738. */
  11739. Matrix2D.RotationToRef = function (angle, result) {
  11740. var s = Math.sin(angle);
  11741. var c = Math.cos(angle);
  11742. result.fromValues(c, s, -s, c, 0, 0);
  11743. };
  11744. /**
  11745. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  11746. * @param tx defines the x coordinate of the translation
  11747. * @param ty defines the y coordinate of the translation
  11748. * @param angle defines the rotation angle
  11749. * @param scaleX defines the x coordinate of the scaling
  11750. * @param scaleY defines the y coordinate of the scaling
  11751. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  11752. * @param result defines the target matrix
  11753. */
  11754. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  11755. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  11756. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  11757. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  11758. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  11759. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  11760. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  11761. if (parentMatrix) {
  11762. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  11763. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  11764. }
  11765. else {
  11766. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  11767. }
  11768. };
  11769. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  11770. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  11771. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  11772. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  11773. Matrix2D._TempCompose0 = Matrix2D.Identity();
  11774. Matrix2D._TempCompose1 = Matrix2D.Identity();
  11775. Matrix2D._TempCompose2 = Matrix2D.Identity();
  11776. return Matrix2D;
  11777. }());
  11778. /***/ }),
  11779. /***/ "./2D/measure.ts":
  11780. /*!***********************!*\
  11781. !*** ./2D/measure.ts ***!
  11782. \***********************/
  11783. /*! exports provided: Measure */
  11784. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11785. "use strict";
  11786. __webpack_require__.r(__webpack_exports__);
  11787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  11788. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11789. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11790. /**
  11791. * Class used to store 2D control sizes
  11792. */
  11793. var Measure = /** @class */ (function () {
  11794. /**
  11795. * Creates a new measure
  11796. * @param left defines left coordinate
  11797. * @param top defines top coordinate
  11798. * @param width defines width dimension
  11799. * @param height defines height dimension
  11800. */
  11801. function Measure(
  11802. /** defines left coordinate */
  11803. left,
  11804. /** defines top coordinate */
  11805. top,
  11806. /** defines width dimension */
  11807. width,
  11808. /** defines height dimension */
  11809. height) {
  11810. this.left = left;
  11811. this.top = top;
  11812. this.width = width;
  11813. this.height = height;
  11814. }
  11815. /**
  11816. * Copy from another measure
  11817. * @param other defines the other measure to copy from
  11818. */
  11819. Measure.prototype.copyFrom = function (other) {
  11820. this.left = other.left;
  11821. this.top = other.top;
  11822. this.width = other.width;
  11823. this.height = other.height;
  11824. };
  11825. /**
  11826. * Copy from a group of 4 floats
  11827. * @param left defines left coordinate
  11828. * @param top defines top coordinate
  11829. * @param width defines width dimension
  11830. * @param height defines height dimension
  11831. */
  11832. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  11833. this.left = left;
  11834. this.top = top;
  11835. this.width = width;
  11836. this.height = height;
  11837. };
  11838. /**
  11839. * Computes the axis aligned bounding box measure for two given measures
  11840. * @param a Input measure
  11841. * @param b Input measure
  11842. * @param result the resulting bounding measure
  11843. */
  11844. Measure.CombineToRef = function (a, b, result) {
  11845. var left = Math.min(a.left, b.left);
  11846. var top = Math.min(a.top, b.top);
  11847. var right = Math.max(a.left + a.width, b.left + b.width);
  11848. var bottom = Math.max(a.top + a.height, b.top + b.height);
  11849. result.left = left;
  11850. result.top = top;
  11851. result.width = right - left;
  11852. result.height = bottom - top;
  11853. };
  11854. /**
  11855. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  11856. * @param transform the matrix to transform the measure before computing the AABB
  11857. * @param result the resulting AABB
  11858. */
  11859. Measure.prototype.transformToRef = function (transform, result) {
  11860. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  11861. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  11862. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11863. for (var i = 0; i < 4; i++) {
  11864. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  11865. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  11866. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  11867. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  11868. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  11869. }
  11870. result.left = min.x;
  11871. result.top = min.y;
  11872. result.width = max.x - min.x;
  11873. result.height = max.y - min.y;
  11874. };
  11875. /**
  11876. * Check equality between this measure and another one
  11877. * @param other defines the other measures
  11878. * @returns true if both measures are equals
  11879. */
  11880. Measure.prototype.isEqualsTo = function (other) {
  11881. if (this.left !== other.left) {
  11882. return false;
  11883. }
  11884. if (this.top !== other.top) {
  11885. return false;
  11886. }
  11887. if (this.width !== other.width) {
  11888. return false;
  11889. }
  11890. if (this.height !== other.height) {
  11891. return false;
  11892. }
  11893. return true;
  11894. };
  11895. /**
  11896. * Creates an empty measure
  11897. * @returns a new measure
  11898. */
  11899. Measure.Empty = function () {
  11900. return new Measure(0, 0, 0, 0);
  11901. };
  11902. return Measure;
  11903. }());
  11904. /***/ }),
  11905. /***/ "./2D/multiLinePoint.ts":
  11906. /*!******************************!*\
  11907. !*** ./2D/multiLinePoint.ts ***!
  11908. \******************************/
  11909. /*! exports provided: MultiLinePoint */
  11910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11911. "use strict";
  11912. __webpack_require__.r(__webpack_exports__);
  11913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  11914. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  11915. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  11916. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  11917. /**
  11918. * Class used to store a point for a MultiLine object.
  11919. * The point can be pure 2D coordinates, a mesh or a control
  11920. */
  11921. var MultiLinePoint = /** @class */ (function () {
  11922. /**
  11923. * Creates a new MultiLinePoint
  11924. * @param multiLine defines the source MultiLine object
  11925. */
  11926. function MultiLinePoint(multiLine) {
  11927. this._multiLine = multiLine;
  11928. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11929. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  11930. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  11931. }
  11932. Object.defineProperty(MultiLinePoint.prototype, "x", {
  11933. /** Gets or sets x coordinate */
  11934. get: function () {
  11935. return this._x.toString(this._multiLine._host);
  11936. },
  11937. set: function (value) {
  11938. if (this._x.toString(this._multiLine._host) === value) {
  11939. return;
  11940. }
  11941. if (this._x.fromString(value)) {
  11942. this._multiLine._markAsDirty();
  11943. }
  11944. },
  11945. enumerable: true,
  11946. configurable: true
  11947. });
  11948. Object.defineProperty(MultiLinePoint.prototype, "y", {
  11949. /** Gets or sets y coordinate */
  11950. get: function () {
  11951. return this._y.toString(this._multiLine._host);
  11952. },
  11953. set: function (value) {
  11954. if (this._y.toString(this._multiLine._host) === value) {
  11955. return;
  11956. }
  11957. if (this._y.fromString(value)) {
  11958. this._multiLine._markAsDirty();
  11959. }
  11960. },
  11961. enumerable: true,
  11962. configurable: true
  11963. });
  11964. Object.defineProperty(MultiLinePoint.prototype, "control", {
  11965. /** Gets or sets the control associated with this point */
  11966. get: function () {
  11967. return this._control;
  11968. },
  11969. set: function (value) {
  11970. if (this._control === value) {
  11971. return;
  11972. }
  11973. if (this._control && this._controlObserver) {
  11974. this._control.onDirtyObservable.remove(this._controlObserver);
  11975. this._controlObserver = null;
  11976. }
  11977. this._control = value;
  11978. if (this._control) {
  11979. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  11980. }
  11981. this._multiLine._markAsDirty();
  11982. },
  11983. enumerable: true,
  11984. configurable: true
  11985. });
  11986. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  11987. /** Gets or sets the mesh associated with this point */
  11988. get: function () {
  11989. return this._mesh;
  11990. },
  11991. set: function (value) {
  11992. if (this._mesh === value) {
  11993. return;
  11994. }
  11995. if (this._mesh && this._meshObserver) {
  11996. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  11997. }
  11998. this._mesh = value;
  11999. if (this._mesh) {
  12000. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12001. }
  12002. this._multiLine._markAsDirty();
  12003. },
  12004. enumerable: true,
  12005. configurable: true
  12006. });
  12007. /** Resets links */
  12008. MultiLinePoint.prototype.resetLinks = function () {
  12009. this.control = null;
  12010. this.mesh = null;
  12011. };
  12012. /**
  12013. * Gets a translation vector
  12014. * @returns the translation vector
  12015. */
  12016. MultiLinePoint.prototype.translate = function () {
  12017. this._point = this._translatePoint();
  12018. return this._point;
  12019. };
  12020. MultiLinePoint.prototype._translatePoint = function () {
  12021. if (this._mesh != null) {
  12022. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12023. }
  12024. else if (this._control != null) {
  12025. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12026. }
  12027. else {
  12028. var host = this._multiLine._host;
  12029. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12030. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12031. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12032. }
  12033. };
  12034. /** Release associated resources */
  12035. MultiLinePoint.prototype.dispose = function () {
  12036. this.resetLinks();
  12037. };
  12038. return MultiLinePoint;
  12039. }());
  12040. /***/ }),
  12041. /***/ "./2D/style.ts":
  12042. /*!*********************!*\
  12043. !*** ./2D/style.ts ***!
  12044. \*********************/
  12045. /*! exports provided: Style */
  12046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12047. "use strict";
  12048. __webpack_require__.r(__webpack_exports__);
  12049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12050. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12051. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12052. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12053. /**
  12054. * Define a style used by control to automatically setup properties based on a template.
  12055. * Only support font related properties so far
  12056. */
  12057. var Style = /** @class */ (function () {
  12058. /**
  12059. * Creates a new style object
  12060. * @param host defines the AdvancedDynamicTexture which hosts this style
  12061. */
  12062. function Style(host) {
  12063. this._fontFamily = "Arial";
  12064. this._fontStyle = "";
  12065. this._fontWeight = "";
  12066. /** @hidden */
  12067. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12068. /**
  12069. * Observable raised when the style values are changed
  12070. */
  12071. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12072. this._host = host;
  12073. }
  12074. Object.defineProperty(Style.prototype, "fontSize", {
  12075. /**
  12076. * Gets or sets the font size
  12077. */
  12078. get: function () {
  12079. return this._fontSize.toString(this._host);
  12080. },
  12081. set: function (value) {
  12082. if (this._fontSize.toString(this._host) === value) {
  12083. return;
  12084. }
  12085. if (this._fontSize.fromString(value)) {
  12086. this.onChangedObservable.notifyObservers(this);
  12087. }
  12088. },
  12089. enumerable: true,
  12090. configurable: true
  12091. });
  12092. Object.defineProperty(Style.prototype, "fontFamily", {
  12093. /**
  12094. * Gets or sets the font family
  12095. */
  12096. get: function () {
  12097. return this._fontFamily;
  12098. },
  12099. set: function (value) {
  12100. if (this._fontFamily === value) {
  12101. return;
  12102. }
  12103. this._fontFamily = value;
  12104. this.onChangedObservable.notifyObservers(this);
  12105. },
  12106. enumerable: true,
  12107. configurable: true
  12108. });
  12109. Object.defineProperty(Style.prototype, "fontStyle", {
  12110. /**
  12111. * Gets or sets the font style
  12112. */
  12113. get: function () {
  12114. return this._fontStyle;
  12115. },
  12116. set: function (value) {
  12117. if (this._fontStyle === value) {
  12118. return;
  12119. }
  12120. this._fontStyle = value;
  12121. this.onChangedObservable.notifyObservers(this);
  12122. },
  12123. enumerable: true,
  12124. configurable: true
  12125. });
  12126. Object.defineProperty(Style.prototype, "fontWeight", {
  12127. /** Gets or sets font weight */
  12128. get: function () {
  12129. return this._fontWeight;
  12130. },
  12131. set: function (value) {
  12132. if (this._fontWeight === value) {
  12133. return;
  12134. }
  12135. this._fontWeight = value;
  12136. this.onChangedObservable.notifyObservers(this);
  12137. },
  12138. enumerable: true,
  12139. configurable: true
  12140. });
  12141. /** Dispose all associated resources */
  12142. Style.prototype.dispose = function () {
  12143. this.onChangedObservable.clear();
  12144. };
  12145. return Style;
  12146. }());
  12147. /***/ }),
  12148. /***/ "./2D/valueAndUnit.ts":
  12149. /*!****************************!*\
  12150. !*** ./2D/valueAndUnit.ts ***!
  12151. \****************************/
  12152. /*! exports provided: ValueAndUnit */
  12153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12154. "use strict";
  12155. __webpack_require__.r(__webpack_exports__);
  12156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12157. /**
  12158. * Class used to specific a value and its associated unit
  12159. */
  12160. var ValueAndUnit = /** @class */ (function () {
  12161. /**
  12162. * Creates a new ValueAndUnit
  12163. * @param value defines the value to store
  12164. * @param unit defines the unit to store
  12165. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12166. */
  12167. function ValueAndUnit(value,
  12168. /** defines the unit to store */
  12169. unit,
  12170. /** defines a boolean indicating if the value can be negative */
  12171. negativeValueAllowed) {
  12172. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12173. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12174. this.unit = unit;
  12175. this.negativeValueAllowed = negativeValueAllowed;
  12176. this._value = 1;
  12177. /**
  12178. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12179. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12180. */
  12181. this.ignoreAdaptiveScaling = false;
  12182. this._value = value;
  12183. this._originalUnit = unit;
  12184. }
  12185. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12186. /** Gets a boolean indicating if the value is a percentage */
  12187. get: function () {
  12188. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12189. },
  12190. enumerable: true,
  12191. configurable: true
  12192. });
  12193. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12194. /** Gets a boolean indicating if the value is store as pixel */
  12195. get: function () {
  12196. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12197. },
  12198. enumerable: true,
  12199. configurable: true
  12200. });
  12201. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12202. /** Gets direct internal value */
  12203. get: function () {
  12204. return this._value;
  12205. },
  12206. enumerable: true,
  12207. configurable: true
  12208. });
  12209. /**
  12210. * Gets value as pixel
  12211. * @param host defines the root host
  12212. * @param refValue defines the reference value for percentages
  12213. * @returns the value as pixel
  12214. */
  12215. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12216. if (this.isPixel) {
  12217. return this.getValue(host);
  12218. }
  12219. return this.getValue(host) * refValue;
  12220. };
  12221. /**
  12222. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12223. * @param value defines the value to store
  12224. * @param unit defines the unit to store
  12225. * @returns the current ValueAndUnit
  12226. */
  12227. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12228. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12229. this._value = value;
  12230. this.unit = unit;
  12231. return this;
  12232. };
  12233. /**
  12234. * Gets the value accordingly to its unit
  12235. * @param host defines the root host
  12236. * @returns the value
  12237. */
  12238. ValueAndUnit.prototype.getValue = function (host) {
  12239. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12240. var width = 0;
  12241. var height = 0;
  12242. if (host.idealWidth) {
  12243. width = (this._value * host.getSize().width) / host.idealWidth;
  12244. }
  12245. if (host.idealHeight) {
  12246. height = (this._value * host.getSize().height) / host.idealHeight;
  12247. }
  12248. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12249. return window.innerWidth < window.innerHeight ? width : height;
  12250. }
  12251. if (host.idealWidth) { // horizontal
  12252. return width;
  12253. }
  12254. if (host.idealHeight) { // vertical
  12255. return height;
  12256. }
  12257. }
  12258. return this._value;
  12259. };
  12260. /**
  12261. * Gets a string representation of the value
  12262. * @param host defines the root host
  12263. * @param decimals defines an optional number of decimals to display
  12264. * @returns a string
  12265. */
  12266. ValueAndUnit.prototype.toString = function (host, decimals) {
  12267. switch (this.unit) {
  12268. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12269. var percentage = this.getValue(host) * 100;
  12270. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12271. case ValueAndUnit.UNITMODE_PIXEL:
  12272. var pixels = this.getValue(host);
  12273. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12274. }
  12275. return this.unit.toString();
  12276. };
  12277. /**
  12278. * Store a value parsed from a string
  12279. * @param source defines the source string
  12280. * @returns true if the value was successfully parsed
  12281. */
  12282. ValueAndUnit.prototype.fromString = function (source) {
  12283. var match = ValueAndUnit._Regex.exec(source.toString());
  12284. if (!match || match.length === 0) {
  12285. return false;
  12286. }
  12287. var sourceValue = parseFloat(match[1]);
  12288. var sourceUnit = this._originalUnit;
  12289. if (!this.negativeValueAllowed) {
  12290. if (sourceValue < 0) {
  12291. sourceValue = 0;
  12292. }
  12293. }
  12294. if (match.length === 4) {
  12295. switch (match[3]) {
  12296. case "px":
  12297. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12298. break;
  12299. case "%":
  12300. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12301. sourceValue /= 100.0;
  12302. break;
  12303. }
  12304. }
  12305. if (sourceValue === this._value && sourceUnit === this.unit) {
  12306. return false;
  12307. }
  12308. this._value = sourceValue;
  12309. this.unit = sourceUnit;
  12310. return true;
  12311. };
  12312. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12313. /** UNITMODE_PERCENTAGE */
  12314. get: function () {
  12315. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12316. },
  12317. enumerable: true,
  12318. configurable: true
  12319. });
  12320. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12321. /** UNITMODE_PIXEL */
  12322. get: function () {
  12323. return ValueAndUnit._UNITMODE_PIXEL;
  12324. },
  12325. enumerable: true,
  12326. configurable: true
  12327. });
  12328. // Static
  12329. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12330. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12331. ValueAndUnit._UNITMODE_PIXEL = 1;
  12332. return ValueAndUnit;
  12333. }());
  12334. /***/ }),
  12335. /***/ "./3D/controls/abstractButton3D.ts":
  12336. /*!*****************************************!*\
  12337. !*** ./3D/controls/abstractButton3D.ts ***!
  12338. \*****************************************/
  12339. /*! exports provided: AbstractButton3D */
  12340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12341. "use strict";
  12342. __webpack_require__.r(__webpack_exports__);
  12343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  12344. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12345. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12346. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12347. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12348. /**
  12349. * Class used as a root to all buttons
  12350. */
  12351. var AbstractButton3D = /** @class */ (function (_super) {
  12352. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractButton3D, _super);
  12353. /**
  12354. * Creates a new button
  12355. * @param name defines the control name
  12356. */
  12357. function AbstractButton3D(name) {
  12358. return _super.call(this, name) || this;
  12359. }
  12360. AbstractButton3D.prototype._getTypeName = function () {
  12361. return "AbstractButton3D";
  12362. };
  12363. // Mesh association
  12364. AbstractButton3D.prototype._createNode = function (scene) {
  12365. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  12366. };
  12367. return AbstractButton3D;
  12368. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12369. /***/ }),
  12370. /***/ "./3D/controls/button3D.ts":
  12371. /*!*********************************!*\
  12372. !*** ./3D/controls/button3D.ts ***!
  12373. \*********************************/
  12374. /*! exports provided: Button3D */
  12375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12376. "use strict";
  12377. __webpack_require__.r(__webpack_exports__);
  12378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  12379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12380. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12381. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12382. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  12383. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12384. /**
  12385. * Class used to create a button in 3D
  12386. */
  12387. var Button3D = /** @class */ (function (_super) {
  12388. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Button3D, _super);
  12389. /**
  12390. * Creates a new button
  12391. * @param name defines the control name
  12392. */
  12393. function Button3D(name) {
  12394. var _this = _super.call(this, name) || this;
  12395. _this._contentResolution = 512;
  12396. _this._contentScaleRatio = 2;
  12397. // Default animations
  12398. _this.pointerEnterAnimation = function () {
  12399. if (!_this.mesh) {
  12400. return;
  12401. }
  12402. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  12403. };
  12404. _this.pointerOutAnimation = function () {
  12405. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12406. };
  12407. _this.pointerDownAnimation = function () {
  12408. if (!_this.mesh) {
  12409. return;
  12410. }
  12411. _this.mesh.scaling.scaleInPlace(0.95);
  12412. };
  12413. _this.pointerUpAnimation = function () {
  12414. if (!_this.mesh) {
  12415. return;
  12416. }
  12417. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  12418. };
  12419. return _this;
  12420. }
  12421. Object.defineProperty(Button3D.prototype, "contentResolution", {
  12422. /**
  12423. * Gets or sets the texture resolution used to render content (512 by default)
  12424. */
  12425. get: function () {
  12426. return this._contentResolution;
  12427. },
  12428. set: function (value) {
  12429. if (this._contentResolution === value) {
  12430. return;
  12431. }
  12432. this._contentResolution = value;
  12433. this._resetContent();
  12434. },
  12435. enumerable: true,
  12436. configurable: true
  12437. });
  12438. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  12439. /**
  12440. * Gets or sets the texture scale ratio used to render content (2 by default)
  12441. */
  12442. get: function () {
  12443. return this._contentScaleRatio;
  12444. },
  12445. set: function (value) {
  12446. if (this._contentScaleRatio === value) {
  12447. return;
  12448. }
  12449. this._contentScaleRatio = value;
  12450. this._resetContent();
  12451. },
  12452. enumerable: true,
  12453. configurable: true
  12454. });
  12455. Button3D.prototype._disposeFacadeTexture = function () {
  12456. if (this._facadeTexture) {
  12457. this._facadeTexture.dispose();
  12458. this._facadeTexture = null;
  12459. }
  12460. };
  12461. Button3D.prototype._resetContent = function () {
  12462. this._disposeFacadeTexture();
  12463. this.content = this._content;
  12464. };
  12465. Object.defineProperty(Button3D.prototype, "content", {
  12466. /**
  12467. * Gets or sets the GUI 2D content used to display the button's facade
  12468. */
  12469. get: function () {
  12470. return this._content;
  12471. },
  12472. set: function (value) {
  12473. this._content = value;
  12474. if (!this._host || !this._host.utilityLayer) {
  12475. return;
  12476. }
  12477. if (!this._facadeTexture) {
  12478. 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);
  12479. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  12480. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  12481. this._facadeTexture.premulAlpha = true;
  12482. }
  12483. this._facadeTexture.addControl(value);
  12484. this._applyFacade(this._facadeTexture);
  12485. },
  12486. enumerable: true,
  12487. configurable: true
  12488. });
  12489. /**
  12490. * Apply the facade texture (created from the content property).
  12491. * This function can be overloaded by child classes
  12492. * @param facadeTexture defines the AdvancedDynamicTexture to use
  12493. */
  12494. Button3D.prototype._applyFacade = function (facadeTexture) {
  12495. this._currentMaterial.emissiveTexture = facadeTexture;
  12496. };
  12497. Button3D.prototype._getTypeName = function () {
  12498. return "Button3D";
  12499. };
  12500. // Mesh association
  12501. Button3D.prototype._createNode = function (scene) {
  12502. var faceUV = new Array(6);
  12503. for (var i = 0; i < 6; i++) {
  12504. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  12505. }
  12506. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  12507. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  12508. width: 1.0,
  12509. height: 1.0,
  12510. depth: 0.08,
  12511. faceUV: faceUV
  12512. }, scene);
  12513. return mesh;
  12514. };
  12515. Button3D.prototype._affectMaterial = function (mesh) {
  12516. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  12517. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  12518. mesh.material = material;
  12519. this._currentMaterial = material;
  12520. this._resetContent();
  12521. };
  12522. /**
  12523. * Releases all associated resources
  12524. */
  12525. Button3D.prototype.dispose = function () {
  12526. _super.prototype.dispose.call(this);
  12527. this._disposeFacadeTexture();
  12528. if (this._currentMaterial) {
  12529. this._currentMaterial.dispose();
  12530. }
  12531. };
  12532. return Button3D;
  12533. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  12534. /***/ }),
  12535. /***/ "./3D/controls/container3D.ts":
  12536. /*!************************************!*\
  12537. !*** ./3D/controls/container3D.ts ***!
  12538. \************************************/
  12539. /*! exports provided: Container3D */
  12540. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12541. "use strict";
  12542. __webpack_require__.r(__webpack_exports__);
  12543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  12544. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12545. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  12546. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  12547. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  12548. /**
  12549. * Class used to create containers for controls
  12550. */
  12551. var Container3D = /** @class */ (function (_super) {
  12552. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Container3D, _super);
  12553. /**
  12554. * Creates a new container
  12555. * @param name defines the container name
  12556. */
  12557. function Container3D(name) {
  12558. var _this = _super.call(this, name) || this;
  12559. _this._blockLayout = false;
  12560. /**
  12561. * Gets the list of child controls
  12562. */
  12563. _this._children = new Array();
  12564. return _this;
  12565. }
  12566. Object.defineProperty(Container3D.prototype, "children", {
  12567. /**
  12568. * Gets the list of child controls
  12569. */
  12570. get: function () {
  12571. return this._children;
  12572. },
  12573. enumerable: true,
  12574. configurable: true
  12575. });
  12576. Object.defineProperty(Container3D.prototype, "blockLayout", {
  12577. /**
  12578. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  12579. * This is helpful to optimize layout operation when adding multiple children in a row
  12580. */
  12581. get: function () {
  12582. return this._blockLayout;
  12583. },
  12584. set: function (value) {
  12585. if (this._blockLayout === value) {
  12586. return;
  12587. }
  12588. this._blockLayout = value;
  12589. if (!this._blockLayout) {
  12590. this._arrangeChildren();
  12591. }
  12592. },
  12593. enumerable: true,
  12594. configurable: true
  12595. });
  12596. /**
  12597. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  12598. * @returns the current container
  12599. */
  12600. Container3D.prototype.updateLayout = function () {
  12601. this._arrangeChildren();
  12602. return this;
  12603. };
  12604. /**
  12605. * Gets a boolean indicating if the given control is in the children of this control
  12606. * @param control defines the control to check
  12607. * @returns true if the control is in the child list
  12608. */
  12609. Container3D.prototype.containsControl = function (control) {
  12610. return this._children.indexOf(control) !== -1;
  12611. };
  12612. /**
  12613. * Adds a control to the children of this control
  12614. * @param control defines the control to add
  12615. * @returns the current container
  12616. */
  12617. Container3D.prototype.addControl = function (control) {
  12618. var index = this._children.indexOf(control);
  12619. if (index !== -1) {
  12620. return this;
  12621. }
  12622. control.parent = this;
  12623. control._host = this._host;
  12624. this._children.push(control);
  12625. if (this._host.utilityLayer) {
  12626. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  12627. if (control.node) {
  12628. control.node.parent = this.node;
  12629. }
  12630. if (!this.blockLayout) {
  12631. this._arrangeChildren();
  12632. }
  12633. }
  12634. return this;
  12635. };
  12636. /**
  12637. * This function will be called everytime a new control is added
  12638. */
  12639. Container3D.prototype._arrangeChildren = function () {
  12640. };
  12641. Container3D.prototype._createNode = function (scene) {
  12642. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  12643. };
  12644. /**
  12645. * Removes a control from the children of this control
  12646. * @param control defines the control to remove
  12647. * @returns the current container
  12648. */
  12649. Container3D.prototype.removeControl = function (control) {
  12650. var index = this._children.indexOf(control);
  12651. if (index !== -1) {
  12652. this._children.splice(index, 1);
  12653. control.parent = null;
  12654. control._disposeNode();
  12655. }
  12656. return this;
  12657. };
  12658. Container3D.prototype._getTypeName = function () {
  12659. return "Container3D";
  12660. };
  12661. /**
  12662. * Releases all associated resources
  12663. */
  12664. Container3D.prototype.dispose = function () {
  12665. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12666. var control = _a[_i];
  12667. control.dispose();
  12668. }
  12669. this._children = [];
  12670. _super.prototype.dispose.call(this);
  12671. };
  12672. /** Control rotation will remain unchanged */
  12673. Container3D.UNSET_ORIENTATION = 0;
  12674. /** Control will rotate to make it look at sphere central axis */
  12675. Container3D.FACEORIGIN_ORIENTATION = 1;
  12676. /** Control will rotate to make it look back at sphere central axis */
  12677. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  12678. /** Control will rotate to look at z axis (0, 0, 1) */
  12679. Container3D.FACEFORWARD_ORIENTATION = 3;
  12680. /** Control will rotate to look at negative z axis (0, 0, -1) */
  12681. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  12682. return Container3D;
  12683. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  12684. /***/ }),
  12685. /***/ "./3D/controls/control3D.ts":
  12686. /*!**********************************!*\
  12687. !*** ./3D/controls/control3D.ts ***!
  12688. \**********************************/
  12689. /*! exports provided: Control3D */
  12690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12691. "use strict";
  12692. __webpack_require__.r(__webpack_exports__);
  12693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  12694. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12695. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12696. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  12697. /**
  12698. * Class used as base class for controls
  12699. */
  12700. var Control3D = /** @class */ (function () {
  12701. /**
  12702. * Creates a new control
  12703. * @param name defines the control name
  12704. */
  12705. function Control3D(
  12706. /** Defines the control name */
  12707. name) {
  12708. this.name = name;
  12709. this._downCount = 0;
  12710. this._enterCount = -1;
  12711. this._downPointerIds = {};
  12712. this._isVisible = true;
  12713. /**
  12714. * An event triggered when the pointer move over the control
  12715. */
  12716. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12717. /**
  12718. * An event triggered when the pointer move out of the control
  12719. */
  12720. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12721. /**
  12722. * An event triggered when the pointer taps the control
  12723. */
  12724. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12725. /**
  12726. * An event triggered when pointer is up
  12727. */
  12728. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12729. /**
  12730. * An event triggered when a control is clicked on (with a mouse)
  12731. */
  12732. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12733. /**
  12734. * An event triggered when pointer enters the control
  12735. */
  12736. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12737. // Behaviors
  12738. this._behaviors = new Array();
  12739. }
  12740. Object.defineProperty(Control3D.prototype, "position", {
  12741. /** Gets or sets the control position in world space */
  12742. get: function () {
  12743. if (!this._node) {
  12744. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  12745. }
  12746. return this._node.position;
  12747. },
  12748. set: function (value) {
  12749. if (!this._node) {
  12750. return;
  12751. }
  12752. this._node.position = value;
  12753. },
  12754. enumerable: true,
  12755. configurable: true
  12756. });
  12757. Object.defineProperty(Control3D.prototype, "scaling", {
  12758. /** Gets or sets the control scaling in world space */
  12759. get: function () {
  12760. if (!this._node) {
  12761. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  12762. }
  12763. return this._node.scaling;
  12764. },
  12765. set: function (value) {
  12766. if (!this._node) {
  12767. return;
  12768. }
  12769. this._node.scaling = value;
  12770. },
  12771. enumerable: true,
  12772. configurable: true
  12773. });
  12774. Object.defineProperty(Control3D.prototype, "behaviors", {
  12775. /**
  12776. * Gets the list of attached behaviors
  12777. * @see http://doc.babylonjs.com/features/behaviour
  12778. */
  12779. get: function () {
  12780. return this._behaviors;
  12781. },
  12782. enumerable: true,
  12783. configurable: true
  12784. });
  12785. /**
  12786. * Attach a behavior to the control
  12787. * @see http://doc.babylonjs.com/features/behaviour
  12788. * @param behavior defines the behavior to attach
  12789. * @returns the current control
  12790. */
  12791. Control3D.prototype.addBehavior = function (behavior) {
  12792. var _this = this;
  12793. var index = this._behaviors.indexOf(behavior);
  12794. if (index !== -1) {
  12795. return this;
  12796. }
  12797. behavior.init();
  12798. var scene = this._host.scene;
  12799. if (scene.isLoading) {
  12800. // We defer the attach when the scene will be loaded
  12801. scene.onDataLoadedObservable.addOnce(function () {
  12802. behavior.attach(_this);
  12803. });
  12804. }
  12805. else {
  12806. behavior.attach(this);
  12807. }
  12808. this._behaviors.push(behavior);
  12809. return this;
  12810. };
  12811. /**
  12812. * Remove an attached behavior
  12813. * @see http://doc.babylonjs.com/features/behaviour
  12814. * @param behavior defines the behavior to attach
  12815. * @returns the current control
  12816. */
  12817. Control3D.prototype.removeBehavior = function (behavior) {
  12818. var index = this._behaviors.indexOf(behavior);
  12819. if (index === -1) {
  12820. return this;
  12821. }
  12822. this._behaviors[index].detach();
  12823. this._behaviors.splice(index, 1);
  12824. return this;
  12825. };
  12826. /**
  12827. * Gets an attached behavior by name
  12828. * @param name defines the name of the behavior to look for
  12829. * @see http://doc.babylonjs.com/features/behaviour
  12830. * @returns null if behavior was not found else the requested behavior
  12831. */
  12832. Control3D.prototype.getBehaviorByName = function (name) {
  12833. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  12834. var behavior = _a[_i];
  12835. if (behavior.name === name) {
  12836. return behavior;
  12837. }
  12838. }
  12839. return null;
  12840. };
  12841. Object.defineProperty(Control3D.prototype, "isVisible", {
  12842. /** Gets or sets a boolean indicating if the control is visible */
  12843. get: function () {
  12844. return this._isVisible;
  12845. },
  12846. set: function (value) {
  12847. if (this._isVisible === value) {
  12848. return;
  12849. }
  12850. this._isVisible = value;
  12851. var mesh = this.mesh;
  12852. if (mesh) {
  12853. mesh.setEnabled(value);
  12854. }
  12855. },
  12856. enumerable: true,
  12857. configurable: true
  12858. });
  12859. Object.defineProperty(Control3D.prototype, "typeName", {
  12860. /**
  12861. * Gets a string representing the class name
  12862. */
  12863. get: function () {
  12864. return this._getTypeName();
  12865. },
  12866. enumerable: true,
  12867. configurable: true
  12868. });
  12869. /**
  12870. * Get the current class name of the control.
  12871. * @returns current class name
  12872. */
  12873. Control3D.prototype.getClassName = function () {
  12874. return this._getTypeName();
  12875. };
  12876. Control3D.prototype._getTypeName = function () {
  12877. return "Control3D";
  12878. };
  12879. Object.defineProperty(Control3D.prototype, "node", {
  12880. /**
  12881. * Gets the transform node used by this control
  12882. */
  12883. get: function () {
  12884. return this._node;
  12885. },
  12886. enumerable: true,
  12887. configurable: true
  12888. });
  12889. Object.defineProperty(Control3D.prototype, "mesh", {
  12890. /**
  12891. * Gets the mesh used to render this control
  12892. */
  12893. get: function () {
  12894. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  12895. return this._node;
  12896. }
  12897. return null;
  12898. },
  12899. enumerable: true,
  12900. configurable: true
  12901. });
  12902. /**
  12903. * Link the control as child of the given node
  12904. * @param node defines the node to link to. Use null to unlink the control
  12905. * @returns the current control
  12906. */
  12907. Control3D.prototype.linkToTransformNode = function (node) {
  12908. if (this._node) {
  12909. this._node.parent = node;
  12910. }
  12911. return this;
  12912. };
  12913. /** @hidden **/
  12914. Control3D.prototype._prepareNode = function (scene) {
  12915. if (!this._node) {
  12916. this._node = this._createNode(scene);
  12917. if (!this.node) {
  12918. return;
  12919. }
  12920. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  12921. this._node.position = this.position;
  12922. this._node.scaling = this.scaling;
  12923. var mesh = this.mesh;
  12924. if (mesh) {
  12925. mesh.isPickable = true;
  12926. this._affectMaterial(mesh);
  12927. }
  12928. }
  12929. };
  12930. /**
  12931. * Node creation.
  12932. * Can be overriden by children
  12933. * @param scene defines the scene where the node must be attached
  12934. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  12935. */
  12936. Control3D.prototype._createNode = function (scene) {
  12937. // Do nothing by default
  12938. return null;
  12939. };
  12940. /**
  12941. * Affect a material to the given mesh
  12942. * @param mesh defines the mesh which will represent the control
  12943. */
  12944. Control3D.prototype._affectMaterial = function (mesh) {
  12945. mesh.material = null;
  12946. };
  12947. // Pointers
  12948. /** @hidden */
  12949. Control3D.prototype._onPointerMove = function (target, coordinates) {
  12950. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  12951. };
  12952. /** @hidden */
  12953. Control3D.prototype._onPointerEnter = function (target) {
  12954. if (this._enterCount > 0) {
  12955. return false;
  12956. }
  12957. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  12958. this._enterCount = 0;
  12959. }
  12960. this._enterCount++;
  12961. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  12962. if (this.pointerEnterAnimation) {
  12963. this.pointerEnterAnimation();
  12964. }
  12965. return true;
  12966. };
  12967. /** @hidden */
  12968. Control3D.prototype._onPointerOut = function (target) {
  12969. this._enterCount = 0;
  12970. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  12971. if (this.pointerOutAnimation) {
  12972. this.pointerOutAnimation();
  12973. }
  12974. };
  12975. /** @hidden */
  12976. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  12977. if (this._downCount !== 0) {
  12978. this._downCount++;
  12979. return false;
  12980. }
  12981. this._downCount++;
  12982. this._downPointerIds[pointerId] = true;
  12983. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  12984. if (this.pointerDownAnimation) {
  12985. this.pointerDownAnimation();
  12986. }
  12987. return true;
  12988. };
  12989. /** @hidden */
  12990. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  12991. this._downCount--;
  12992. delete this._downPointerIds[pointerId];
  12993. if (this._downCount < 0) {
  12994. // Handle if forcePointerUp was called prior to this
  12995. this._downCount = 0;
  12996. return;
  12997. }
  12998. if (this._downCount == 0) {
  12999. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13000. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13001. }
  13002. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13003. if (this.pointerUpAnimation) {
  13004. this.pointerUpAnimation();
  13005. }
  13006. }
  13007. };
  13008. /** @hidden */
  13009. Control3D.prototype.forcePointerUp = function (pointerId) {
  13010. if (pointerId === void 0) { pointerId = null; }
  13011. if (pointerId !== null) {
  13012. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13013. }
  13014. else {
  13015. for (var key in this._downPointerIds) {
  13016. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13017. }
  13018. if (this._downCount > 0) {
  13019. this._downCount = 1;
  13020. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13021. }
  13022. }
  13023. };
  13024. /** @hidden */
  13025. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13026. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13027. this._onPointerMove(this, pickedPoint);
  13028. var previousControlOver = this._host._lastControlOver[pointerId];
  13029. if (previousControlOver && previousControlOver !== this) {
  13030. previousControlOver._onPointerOut(this);
  13031. }
  13032. if (previousControlOver !== this) {
  13033. this._onPointerEnter(this);
  13034. }
  13035. this._host._lastControlOver[pointerId] = this;
  13036. return true;
  13037. }
  13038. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13039. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13040. this._host._lastControlDown[pointerId] = this;
  13041. this._host._lastPickedControl = this;
  13042. return true;
  13043. }
  13044. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13045. if (this._host._lastControlDown[pointerId]) {
  13046. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13047. }
  13048. delete this._host._lastControlDown[pointerId];
  13049. return true;
  13050. }
  13051. return false;
  13052. };
  13053. /** @hidden */
  13054. Control3D.prototype._disposeNode = function () {
  13055. if (this._node) {
  13056. this._node.dispose();
  13057. this._node = null;
  13058. }
  13059. };
  13060. /**
  13061. * Releases all associated resources
  13062. */
  13063. Control3D.prototype.dispose = function () {
  13064. this.onPointerDownObservable.clear();
  13065. this.onPointerEnterObservable.clear();
  13066. this.onPointerMoveObservable.clear();
  13067. this.onPointerOutObservable.clear();
  13068. this.onPointerUpObservable.clear();
  13069. this.onPointerClickObservable.clear();
  13070. this._disposeNode();
  13071. // Behaviors
  13072. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13073. var behavior = _a[_i];
  13074. behavior.detach();
  13075. }
  13076. };
  13077. return Control3D;
  13078. }());
  13079. /***/ }),
  13080. /***/ "./3D/controls/cylinderPanel.ts":
  13081. /*!**************************************!*\
  13082. !*** ./3D/controls/cylinderPanel.ts ***!
  13083. \**************************************/
  13084. /*! exports provided: CylinderPanel */
  13085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13086. "use strict";
  13087. __webpack_require__.r(__webpack_exports__);
  13088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13089. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13090. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13091. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13092. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13093. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13094. /**
  13095. * Class used to create a container panel deployed on the surface of a cylinder
  13096. */
  13097. var CylinderPanel = /** @class */ (function (_super) {
  13098. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderPanel, _super);
  13099. function CylinderPanel() {
  13100. var _this = _super !== null && _super.apply(this, arguments) || this;
  13101. _this._radius = 5.0;
  13102. return _this;
  13103. }
  13104. Object.defineProperty(CylinderPanel.prototype, "radius", {
  13105. /**
  13106. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  13107. */
  13108. get: function () {
  13109. return this._radius;
  13110. },
  13111. set: function (value) {
  13112. var _this = this;
  13113. if (this._radius === value) {
  13114. return;
  13115. }
  13116. this._radius = value;
  13117. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13118. _this._arrangeChildren();
  13119. });
  13120. },
  13121. enumerable: true,
  13122. configurable: true
  13123. });
  13124. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  13125. var mesh = control.mesh;
  13126. if (!mesh) {
  13127. return;
  13128. }
  13129. var newPos = this._cylindricalMapping(nodePosition);
  13130. control.position = newPos;
  13131. switch (this.orientation) {
  13132. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13133. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  13134. break;
  13135. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13136. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  13137. break;
  13138. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13139. break;
  13140. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13141. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13142. break;
  13143. }
  13144. };
  13145. CylinderPanel.prototype._cylindricalMapping = function (source) {
  13146. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  13147. var yAngle = (source.x / this._radius);
  13148. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13149. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13150. };
  13151. return CylinderPanel;
  13152. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13153. /***/ }),
  13154. /***/ "./3D/controls/holographicButton.ts":
  13155. /*!******************************************!*\
  13156. !*** ./3D/controls/holographicButton.ts ***!
  13157. \******************************************/
  13158. /*! exports provided: HolographicButton */
  13159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13160. "use strict";
  13161. __webpack_require__.r(__webpack_exports__);
  13162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  13163. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13164. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13165. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13166. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  13167. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  13168. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  13169. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  13170. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  13171. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13172. /**
  13173. * Class used to create a holographic button in 3D
  13174. */
  13175. var HolographicButton = /** @class */ (function (_super) {
  13176. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HolographicButton, _super);
  13177. /**
  13178. * Creates a new button
  13179. * @param name defines the control name
  13180. */
  13181. function HolographicButton(name, shareMaterials) {
  13182. if (shareMaterials === void 0) { shareMaterials = true; }
  13183. var _this = _super.call(this, name) || this;
  13184. _this._shareMaterials = true;
  13185. _this._shareMaterials = shareMaterials;
  13186. // Default animations
  13187. _this.pointerEnterAnimation = function () {
  13188. if (!_this.mesh) {
  13189. return;
  13190. }
  13191. _this._frontPlate.setEnabled(true);
  13192. };
  13193. _this.pointerOutAnimation = function () {
  13194. if (!_this.mesh) {
  13195. return;
  13196. }
  13197. _this._frontPlate.setEnabled(false);
  13198. };
  13199. return _this;
  13200. }
  13201. HolographicButton.prototype._disposeTooltip = function () {
  13202. this._tooltipFade = null;
  13203. if (this._tooltipTextBlock) {
  13204. this._tooltipTextBlock.dispose();
  13205. }
  13206. if (this._tooltipTexture) {
  13207. this._tooltipTexture.dispose();
  13208. }
  13209. if (this._tooltipMesh) {
  13210. this._tooltipMesh.dispose();
  13211. }
  13212. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  13213. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  13214. };
  13215. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  13216. get: function () {
  13217. if (this._tooltipTextBlock) {
  13218. return this._tooltipTextBlock.text;
  13219. }
  13220. return null;
  13221. },
  13222. /**
  13223. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  13224. */
  13225. set: function (text) {
  13226. var _this = this;
  13227. if (!text) {
  13228. this._disposeTooltip();
  13229. return;
  13230. }
  13231. if (!this._tooltipFade) {
  13232. // Create tooltip with mesh and text
  13233. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  13234. 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);
  13235. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  13236. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  13237. tooltipBackground.material = mat;
  13238. tooltipBackground.isPickable = false;
  13239. this._tooltipMesh.addChild(tooltipBackground);
  13240. tooltipBackground.position.z = 0.05;
  13241. this._tooltipMesh.scaling.y = 1 / 3;
  13242. this._tooltipMesh.position.y = 0.7;
  13243. this._tooltipMesh.position.z = -0.15;
  13244. this._tooltipMesh.isPickable = false;
  13245. this._tooltipMesh.parent = this._backPlate;
  13246. // Create text texture for the tooltip
  13247. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  13248. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13249. this._tooltipTextBlock.scaleY = 3;
  13250. this._tooltipTextBlock.color = "white";
  13251. this._tooltipTextBlock.fontSize = 130;
  13252. this._tooltipTexture.addControl(this._tooltipTextBlock);
  13253. // Add hover action to tooltip
  13254. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  13255. this._tooltipFade.delay = 500;
  13256. this._tooltipMesh.addBehavior(this._tooltipFade);
  13257. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  13258. if (_this._tooltipFade) {
  13259. _this._tooltipFade.fadeIn(true);
  13260. }
  13261. });
  13262. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  13263. if (_this._tooltipFade) {
  13264. _this._tooltipFade.fadeIn(false);
  13265. }
  13266. });
  13267. }
  13268. if (this._tooltipTextBlock) {
  13269. this._tooltipTextBlock.text = text;
  13270. }
  13271. },
  13272. enumerable: true,
  13273. configurable: true
  13274. });
  13275. Object.defineProperty(HolographicButton.prototype, "text", {
  13276. /**
  13277. * Gets or sets text for the button
  13278. */
  13279. get: function () {
  13280. return this._text;
  13281. },
  13282. set: function (value) {
  13283. if (this._text === value) {
  13284. return;
  13285. }
  13286. this._text = value;
  13287. this._rebuildContent();
  13288. },
  13289. enumerable: true,
  13290. configurable: true
  13291. });
  13292. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  13293. /**
  13294. * Gets or sets the image url for the button
  13295. */
  13296. get: function () {
  13297. return this._imageUrl;
  13298. },
  13299. set: function (value) {
  13300. if (this._imageUrl === value) {
  13301. return;
  13302. }
  13303. this._imageUrl = value;
  13304. this._rebuildContent();
  13305. },
  13306. enumerable: true,
  13307. configurable: true
  13308. });
  13309. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  13310. /**
  13311. * Gets the back material used by this button
  13312. */
  13313. get: function () {
  13314. return this._backMaterial;
  13315. },
  13316. enumerable: true,
  13317. configurable: true
  13318. });
  13319. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  13320. /**
  13321. * Gets the front material used by this button
  13322. */
  13323. get: function () {
  13324. return this._frontMaterial;
  13325. },
  13326. enumerable: true,
  13327. configurable: true
  13328. });
  13329. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  13330. /**
  13331. * Gets the plate material used by this button
  13332. */
  13333. get: function () {
  13334. return this._plateMaterial;
  13335. },
  13336. enumerable: true,
  13337. configurable: true
  13338. });
  13339. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  13340. /**
  13341. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  13342. */
  13343. get: function () {
  13344. return this._shareMaterials;
  13345. },
  13346. enumerable: true,
  13347. configurable: true
  13348. });
  13349. HolographicButton.prototype._getTypeName = function () {
  13350. return "HolographicButton";
  13351. };
  13352. HolographicButton.prototype._rebuildContent = function () {
  13353. this._disposeFacadeTexture();
  13354. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  13355. panel.isVertical = true;
  13356. if (this._imageUrl) {
  13357. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  13358. image.source = this._imageUrl;
  13359. image.paddingTop = "40px";
  13360. image.height = "180px";
  13361. image.width = "100px";
  13362. image.paddingBottom = "40px";
  13363. panel.addControl(image);
  13364. }
  13365. if (this._text) {
  13366. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  13367. text.text = this._text;
  13368. text.color = "white";
  13369. text.height = "30px";
  13370. text.fontSize = 24;
  13371. panel.addControl(text);
  13372. }
  13373. if (this._frontPlate) {
  13374. this.content = panel;
  13375. }
  13376. };
  13377. // Mesh association
  13378. HolographicButton.prototype._createNode = function (scene) {
  13379. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  13380. width: 1.0,
  13381. height: 1.0,
  13382. depth: 0.08
  13383. }, scene);
  13384. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  13385. width: 1.0,
  13386. height: 1.0,
  13387. depth: 0.08
  13388. }, scene);
  13389. this._frontPlate.parent = this._backPlate;
  13390. this._frontPlate.position.z = -0.08;
  13391. this._frontPlate.isPickable = false;
  13392. this._frontPlate.setEnabled(false);
  13393. this._textPlate = _super.prototype._createNode.call(this, scene);
  13394. this._textPlate.parent = this._backPlate;
  13395. this._textPlate.position.z = -0.08;
  13396. this._textPlate.isPickable = false;
  13397. return this._backPlate;
  13398. };
  13399. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  13400. this._plateMaterial.emissiveTexture = facadeTexture;
  13401. this._plateMaterial.opacityTexture = facadeTexture;
  13402. };
  13403. HolographicButton.prototype._createBackMaterial = function (mesh) {
  13404. var _this = this;
  13405. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  13406. this._backMaterial.renderHoverLight = true;
  13407. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  13408. if (pickedPoint) {
  13409. _this._backMaterial.hoverPosition = pickedPoint;
  13410. _this._backMaterial.hoverColor.a = 1.0;
  13411. }
  13412. else {
  13413. _this._backMaterial.hoverColor.a = 0;
  13414. }
  13415. });
  13416. };
  13417. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  13418. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  13419. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  13420. this._frontMaterial.alpha = 0.5; // Additive
  13421. this._frontMaterial.renderBorders = true;
  13422. };
  13423. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  13424. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  13425. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  13426. };
  13427. HolographicButton.prototype._affectMaterial = function (mesh) {
  13428. // Back
  13429. if (this._shareMaterials) {
  13430. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  13431. this._createBackMaterial(mesh);
  13432. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  13433. }
  13434. else {
  13435. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  13436. }
  13437. // Front
  13438. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  13439. this._createFrontMaterial(mesh);
  13440. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  13441. }
  13442. else {
  13443. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  13444. }
  13445. }
  13446. else {
  13447. this._createBackMaterial(mesh);
  13448. this._createFrontMaterial(mesh);
  13449. }
  13450. this._createPlateMaterial(mesh);
  13451. this._backPlate.material = this._backMaterial;
  13452. this._frontPlate.material = this._frontMaterial;
  13453. this._textPlate.material = this._plateMaterial;
  13454. this._rebuildContent();
  13455. };
  13456. /**
  13457. * Releases all associated resources
  13458. */
  13459. HolographicButton.prototype.dispose = function () {
  13460. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  13461. this._disposeTooltip();
  13462. if (!this.shareMaterials) {
  13463. this._backMaterial.dispose();
  13464. this._frontMaterial.dispose();
  13465. this._plateMaterial.dispose();
  13466. if (this._pickedPointObserver) {
  13467. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  13468. this._pickedPointObserver = null;
  13469. }
  13470. }
  13471. };
  13472. return HolographicButton;
  13473. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13474. /***/ }),
  13475. /***/ "./3D/controls/index.ts":
  13476. /*!******************************!*\
  13477. !*** ./3D/controls/index.ts ***!
  13478. \******************************/
  13479. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  13480. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13481. "use strict";
  13482. __webpack_require__.r(__webpack_exports__);
  13483. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  13485. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  13487. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  13489. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  13491. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  13492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  13493. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  13494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  13495. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  13496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  13497. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  13498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  13499. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  13500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  13501. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  13502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  13503. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  13504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  13505. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  13507. /***/ }),
  13508. /***/ "./3D/controls/meshButton3D.ts":
  13509. /*!*************************************!*\
  13510. !*** ./3D/controls/meshButton3D.ts ***!
  13511. \*************************************/
  13512. /*! exports provided: MeshButton3D */
  13513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13514. "use strict";
  13515. __webpack_require__.r(__webpack_exports__);
  13516. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  13517. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13518. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  13519. /**
  13520. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  13521. */
  13522. var MeshButton3D = /** @class */ (function (_super) {
  13523. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshButton3D, _super);
  13524. /**
  13525. * Creates a new 3D button based on a mesh
  13526. * @param mesh mesh to become a 3D button
  13527. * @param name defines the control name
  13528. */
  13529. function MeshButton3D(mesh, name) {
  13530. var _this = _super.call(this, name) || this;
  13531. _this._currentMesh = mesh;
  13532. /**
  13533. * Provides a default behavior on hover/out & up/down
  13534. * Override those function to create your own desired behavior specific to your mesh
  13535. */
  13536. _this.pointerEnterAnimation = function () {
  13537. if (!_this.mesh) {
  13538. return;
  13539. }
  13540. _this.mesh.scaling.scaleInPlace(1.1);
  13541. };
  13542. _this.pointerOutAnimation = function () {
  13543. if (!_this.mesh) {
  13544. return;
  13545. }
  13546. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  13547. };
  13548. _this.pointerDownAnimation = function () {
  13549. if (!_this.mesh) {
  13550. return;
  13551. }
  13552. _this.mesh.scaling.scaleInPlace(0.95);
  13553. };
  13554. _this.pointerUpAnimation = function () {
  13555. if (!_this.mesh) {
  13556. return;
  13557. }
  13558. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13559. };
  13560. return _this;
  13561. }
  13562. MeshButton3D.prototype._getTypeName = function () {
  13563. return "MeshButton3D";
  13564. };
  13565. // Mesh association
  13566. MeshButton3D.prototype._createNode = function (scene) {
  13567. var _this = this;
  13568. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  13569. mesh.metadata = _this;
  13570. });
  13571. return this._currentMesh;
  13572. };
  13573. MeshButton3D.prototype._affectMaterial = function (mesh) {
  13574. };
  13575. return MeshButton3D;
  13576. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  13577. /***/ }),
  13578. /***/ "./3D/controls/planePanel.ts":
  13579. /*!***********************************!*\
  13580. !*** ./3D/controls/planePanel.ts ***!
  13581. \***********************************/
  13582. /*! exports provided: PlanePanel */
  13583. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13584. "use strict";
  13585. __webpack_require__.r(__webpack_exports__);
  13586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  13587. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13588. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13589. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13590. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13591. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13592. /**
  13593. * Class used to create a container panel deployed on the surface of a plane
  13594. */
  13595. var PlanePanel = /** @class */ (function (_super) {
  13596. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlanePanel, _super);
  13597. function PlanePanel() {
  13598. return _super !== null && _super.apply(this, arguments) || this;
  13599. }
  13600. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  13601. var mesh = control.mesh;
  13602. if (!mesh) {
  13603. return;
  13604. }
  13605. control.position = nodePosition.clone();
  13606. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13607. target.copyFrom(nodePosition);
  13608. switch (this.orientation) {
  13609. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  13610. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  13611. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13612. mesh.lookAt(target);
  13613. break;
  13614. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13615. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13616. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13617. mesh.lookAt(target);
  13618. break;
  13619. }
  13620. };
  13621. return PlanePanel;
  13622. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  13623. /***/ }),
  13624. /***/ "./3D/controls/scatterPanel.ts":
  13625. /*!*************************************!*\
  13626. !*** ./3D/controls/scatterPanel.ts ***!
  13627. \*************************************/
  13628. /*! exports provided: ScatterPanel */
  13629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13630. "use strict";
  13631. __webpack_require__.r(__webpack_exports__);
  13632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  13633. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13634. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13635. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13636. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13637. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13638. /**
  13639. * Class used to create a container panel where items get randomized planar mapping
  13640. */
  13641. var ScatterPanel = /** @class */ (function (_super) {
  13642. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScatterPanel, _super);
  13643. function ScatterPanel() {
  13644. var _this = _super !== null && _super.apply(this, arguments) || this;
  13645. _this._iteration = 100.0;
  13646. return _this;
  13647. }
  13648. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  13649. /**
  13650. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  13651. */
  13652. get: function () {
  13653. return this._iteration;
  13654. },
  13655. set: function (value) {
  13656. var _this = this;
  13657. if (this._iteration === value) {
  13658. return;
  13659. }
  13660. this._iteration = value;
  13661. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13662. _this._arrangeChildren();
  13663. });
  13664. },
  13665. enumerable: true,
  13666. configurable: true
  13667. });
  13668. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  13669. var mesh = control.mesh;
  13670. var newPos = this._scatterMapping(nodePosition);
  13671. if (!mesh) {
  13672. return;
  13673. }
  13674. switch (this.orientation) {
  13675. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13676. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13677. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  13678. break;
  13679. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13680. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13681. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  13682. break;
  13683. }
  13684. control.position = newPos;
  13685. };
  13686. ScatterPanel.prototype._scatterMapping = function (source) {
  13687. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  13688. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  13689. return source;
  13690. };
  13691. ScatterPanel.prototype._finalProcessing = function () {
  13692. var meshes = [];
  13693. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13694. var child = _a[_i];
  13695. if (!child.mesh) {
  13696. continue;
  13697. }
  13698. meshes.push(child.mesh);
  13699. }
  13700. for (var count = 0; count < this._iteration; count++) {
  13701. meshes.sort(function (a, b) {
  13702. var distance1 = a.position.lengthSquared();
  13703. var distance2 = b.position.lengthSquared();
  13704. if (distance1 < distance2) {
  13705. return 1;
  13706. }
  13707. else if (distance1 > distance2) {
  13708. return -1;
  13709. }
  13710. return 0;
  13711. });
  13712. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  13713. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  13714. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  13715. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  13716. for (var i = 0; i < meshes.length - 1; i++) {
  13717. for (var j = i + 1; j < meshes.length; j++) {
  13718. if (i != j) {
  13719. meshes[j].position.subtractToRef(meshes[i].position, difference);
  13720. // Ignore Z axis
  13721. difference2D.x = difference.x;
  13722. difference2D.y = difference.y;
  13723. var combinedRadius = cellSize;
  13724. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  13725. var minSeparation = Math.min(distance, radiusPaddingSquared);
  13726. distance -= minSeparation;
  13727. if (distance < (Math.pow(combinedRadius, 2.0))) {
  13728. difference2D.normalize();
  13729. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  13730. meshes[j].position.addInPlace(difference);
  13731. meshes[i].position.subtractInPlace(difference);
  13732. }
  13733. }
  13734. }
  13735. }
  13736. }
  13737. };
  13738. return ScatterPanel;
  13739. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13740. /***/ }),
  13741. /***/ "./3D/controls/spherePanel.ts":
  13742. /*!************************************!*\
  13743. !*** ./3D/controls/spherePanel.ts ***!
  13744. \************************************/
  13745. /*! exports provided: SpherePanel */
  13746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13747. "use strict";
  13748. __webpack_require__.r(__webpack_exports__);
  13749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  13750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13751. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13752. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13753. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  13754. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13755. /**
  13756. * Class used to create a container panel deployed on the surface of a sphere
  13757. */
  13758. var SpherePanel = /** @class */ (function (_super) {
  13759. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpherePanel, _super);
  13760. function SpherePanel() {
  13761. var _this = _super !== null && _super.apply(this, arguments) || this;
  13762. _this._radius = 5.0;
  13763. return _this;
  13764. }
  13765. Object.defineProperty(SpherePanel.prototype, "radius", {
  13766. /**
  13767. * Gets or sets the radius of the sphere where to project controls (5 by default)
  13768. */
  13769. get: function () {
  13770. return this._radius;
  13771. },
  13772. set: function (value) {
  13773. var _this = this;
  13774. if (this._radius === value) {
  13775. return;
  13776. }
  13777. this._radius = value;
  13778. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13779. _this._arrangeChildren();
  13780. });
  13781. },
  13782. enumerable: true,
  13783. configurable: true
  13784. });
  13785. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  13786. var mesh = control.mesh;
  13787. if (!mesh) {
  13788. return;
  13789. }
  13790. var newPos = this._sphericalMapping(nodePosition);
  13791. control.position = newPos;
  13792. switch (this.orientation) {
  13793. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  13794. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  13795. break;
  13796. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  13797. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  13798. break;
  13799. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  13800. break;
  13801. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  13802. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  13803. break;
  13804. }
  13805. };
  13806. SpherePanel.prototype._sphericalMapping = function (source) {
  13807. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  13808. var xAngle = (source.y / this._radius);
  13809. var yAngle = -(source.x / this._radius);
  13810. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13811. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13812. };
  13813. return SpherePanel;
  13814. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  13815. /***/ }),
  13816. /***/ "./3D/controls/stackPanel3D.ts":
  13817. /*!*************************************!*\
  13818. !*** ./3D/controls/stackPanel3D.ts ***!
  13819. \*************************************/
  13820. /*! exports provided: StackPanel3D */
  13821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13822. "use strict";
  13823. __webpack_require__.r(__webpack_exports__);
  13824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  13825. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13826. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13827. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13828. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13829. /**
  13830. * Class used to create a stack panel in 3D on XY plane
  13831. */
  13832. var StackPanel3D = /** @class */ (function (_super) {
  13833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StackPanel3D, _super);
  13834. /**
  13835. * Creates new StackPanel
  13836. * @param isVertical
  13837. */
  13838. function StackPanel3D(isVertical) {
  13839. if (isVertical === void 0) { isVertical = false; }
  13840. var _this = _super.call(this) || this;
  13841. _this._isVertical = false;
  13842. /**
  13843. * Gets or sets the distance between elements
  13844. */
  13845. _this.margin = 0.1;
  13846. _this._isVertical = isVertical;
  13847. return _this;
  13848. }
  13849. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  13850. /**
  13851. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  13852. */
  13853. get: function () {
  13854. return this._isVertical;
  13855. },
  13856. set: function (value) {
  13857. var _this = this;
  13858. if (this._isVertical === value) {
  13859. return;
  13860. }
  13861. this._isVertical = value;
  13862. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13863. _this._arrangeChildren();
  13864. });
  13865. },
  13866. enumerable: true,
  13867. configurable: true
  13868. });
  13869. StackPanel3D.prototype._arrangeChildren = function () {
  13870. var width = 0;
  13871. var height = 0;
  13872. var controlCount = 0;
  13873. var extendSizes = [];
  13874. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  13875. // Measure
  13876. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13877. var child = _a[_i];
  13878. if (!child.mesh) {
  13879. continue;
  13880. }
  13881. controlCount++;
  13882. child.mesh.computeWorldMatrix(true);
  13883. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13884. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  13885. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  13886. extendSizes.push(extendSize);
  13887. if (this._isVertical) {
  13888. height += extendSize.y;
  13889. }
  13890. else {
  13891. width += extendSize.x;
  13892. }
  13893. }
  13894. if (this._isVertical) {
  13895. height += (controlCount - 1) * this.margin / 2;
  13896. }
  13897. else {
  13898. width += (controlCount - 1) * this.margin / 2;
  13899. }
  13900. // Arrange
  13901. var offset;
  13902. if (this._isVertical) {
  13903. offset = -height;
  13904. }
  13905. else {
  13906. offset = -width;
  13907. }
  13908. var index = 0;
  13909. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  13910. var child = _c[_b];
  13911. if (!child.mesh) {
  13912. continue;
  13913. }
  13914. controlCount--;
  13915. var extendSize = extendSizes[index++];
  13916. if (this._isVertical) {
  13917. child.position.y = offset + extendSize.y;
  13918. child.position.x = 0;
  13919. offset += extendSize.y * 2;
  13920. }
  13921. else {
  13922. child.position.x = offset + extendSize.x;
  13923. child.position.y = 0;
  13924. offset += extendSize.x * 2;
  13925. }
  13926. offset += (controlCount > 0 ? this.margin : 0);
  13927. }
  13928. };
  13929. return StackPanel3D;
  13930. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  13931. /***/ }),
  13932. /***/ "./3D/controls/volumeBasedPanel.ts":
  13933. /*!*****************************************!*\
  13934. !*** ./3D/controls/volumeBasedPanel.ts ***!
  13935. \*****************************************/
  13936. /*! exports provided: VolumeBasedPanel */
  13937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13938. "use strict";
  13939. __webpack_require__.r(__webpack_exports__);
  13940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  13941. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13942. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  13943. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13944. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  13945. /**
  13946. * Abstract class used to create a container panel deployed on the surface of a volume
  13947. */
  13948. var VolumeBasedPanel = /** @class */ (function (_super) {
  13949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumeBasedPanel, _super);
  13950. /**
  13951. * Creates new VolumeBasedPanel
  13952. */
  13953. function VolumeBasedPanel() {
  13954. var _this = _super.call(this) || this;
  13955. _this._columns = 10;
  13956. _this._rows = 0;
  13957. _this._rowThenColum = true;
  13958. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  13959. /**
  13960. * Gets or sets the distance between elements
  13961. */
  13962. _this.margin = 0;
  13963. return _this;
  13964. }
  13965. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  13966. /**
  13967. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  13968. * | Value | Type | Description |
  13969. * | ----- | ----------------------------------- | ----------- |
  13970. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  13971. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  13972. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  13973. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  13974. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  13975. */
  13976. get: function () {
  13977. return this._orientation;
  13978. },
  13979. set: function (value) {
  13980. var _this = this;
  13981. if (this._orientation === value) {
  13982. return;
  13983. }
  13984. this._orientation = value;
  13985. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  13986. _this._arrangeChildren();
  13987. });
  13988. },
  13989. enumerable: true,
  13990. configurable: true
  13991. });
  13992. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  13993. /**
  13994. * Gets or sets the number of columns requested (10 by default).
  13995. * The panel will automatically compute the number of rows based on number of child controls.
  13996. */
  13997. get: function () {
  13998. return this._columns;
  13999. },
  14000. set: function (value) {
  14001. var _this = this;
  14002. if (this._columns === value) {
  14003. return;
  14004. }
  14005. this._columns = value;
  14006. this._rowThenColum = true;
  14007. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14008. _this._arrangeChildren();
  14009. });
  14010. },
  14011. enumerable: true,
  14012. configurable: true
  14013. });
  14014. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14015. /**
  14016. * Gets or sets a the number of rows requested.
  14017. * The panel will automatically compute the number of columns based on number of child controls.
  14018. */
  14019. get: function () {
  14020. return this._rows;
  14021. },
  14022. set: function (value) {
  14023. var _this = this;
  14024. if (this._rows === value) {
  14025. return;
  14026. }
  14027. this._rows = value;
  14028. this._rowThenColum = false;
  14029. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14030. _this._arrangeChildren();
  14031. });
  14032. },
  14033. enumerable: true,
  14034. configurable: true
  14035. });
  14036. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14037. this._cellWidth = 0;
  14038. this._cellHeight = 0;
  14039. var rows = 0;
  14040. var columns = 0;
  14041. var controlCount = 0;
  14042. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14043. // Measure
  14044. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14045. var child = _a[_i];
  14046. if (!child.mesh) {
  14047. continue;
  14048. }
  14049. controlCount++;
  14050. child.mesh.computeWorldMatrix(true);
  14051. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14052. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14053. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14054. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14055. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14056. diff.scaleInPlace(0.5);
  14057. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14058. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14059. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14060. }
  14061. this._cellWidth += this.margin * 2;
  14062. this._cellHeight += this.margin * 2;
  14063. // Arrange
  14064. if (this._rowThenColum) {
  14065. columns = this._columns;
  14066. rows = Math.ceil(controlCount / this._columns);
  14067. }
  14068. else {
  14069. rows = this._rows;
  14070. columns = Math.ceil(controlCount / this._rows);
  14071. }
  14072. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14073. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14074. var nodeGrid = [];
  14075. var cellCounter = 0;
  14076. if (this._rowThenColum) {
  14077. for (var r = 0; r < rows; r++) {
  14078. for (var c = 0; c < columns; c++) {
  14079. 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));
  14080. cellCounter++;
  14081. if (cellCounter > controlCount) {
  14082. break;
  14083. }
  14084. }
  14085. }
  14086. }
  14087. else {
  14088. for (var c = 0; c < columns; c++) {
  14089. for (var r = 0; r < rows; r++) {
  14090. 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));
  14091. cellCounter++;
  14092. if (cellCounter > controlCount) {
  14093. break;
  14094. }
  14095. }
  14096. }
  14097. }
  14098. cellCounter = 0;
  14099. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14100. var child = _c[_b];
  14101. if (!child.mesh) {
  14102. continue;
  14103. }
  14104. this._mapGridNode(child, nodeGrid[cellCounter]);
  14105. cellCounter++;
  14106. }
  14107. this._finalProcessing();
  14108. };
  14109. /** Child classes can implement this function to provide additional processing */
  14110. VolumeBasedPanel.prototype._finalProcessing = function () {
  14111. };
  14112. return VolumeBasedPanel;
  14113. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14114. /***/ }),
  14115. /***/ "./3D/gui3DManager.ts":
  14116. /*!****************************!*\
  14117. !*** ./3D/gui3DManager.ts ***!
  14118. \****************************/
  14119. /*! exports provided: GUI3DManager */
  14120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14121. "use strict";
  14122. __webpack_require__.r(__webpack_exports__);
  14123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  14124. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14125. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14126. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  14127. /**
  14128. * Class used to manage 3D user interface
  14129. * @see http://doc.babylonjs.com/how_to/gui3d
  14130. */
  14131. var GUI3DManager = /** @class */ (function () {
  14132. /**
  14133. * Creates a new GUI3DManager
  14134. * @param scene
  14135. */
  14136. function GUI3DManager(scene) {
  14137. var _this = this;
  14138. /** @hidden */
  14139. this._lastControlOver = {};
  14140. /** @hidden */
  14141. this._lastControlDown = {};
  14142. /**
  14143. * Observable raised when the point picked by the pointer events changed
  14144. */
  14145. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14146. // Shared resources
  14147. /** @hidden */
  14148. this._sharedMaterials = {};
  14149. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  14150. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  14151. _this._sceneDisposeObserver = null;
  14152. _this._utilityLayer = null;
  14153. _this.dispose();
  14154. });
  14155. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  14156. this._utilityLayer.onlyCheckPointerDownEvents = false;
  14157. this._utilityLayer.pickUtilitySceneFirst = false;
  14158. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  14159. return mesh && mesh.metadata && mesh.metadata._node;
  14160. };
  14161. // Root
  14162. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  14163. this._rootContainer._host = this;
  14164. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  14165. // Events
  14166. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  14167. _this._handlePointerOut(pointerId, true);
  14168. });
  14169. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  14170. _this._doPicking(pi);
  14171. });
  14172. // Scene
  14173. this._utilityLayer.utilityLayerScene.autoClear = false;
  14174. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  14175. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  14176. }
  14177. Object.defineProperty(GUI3DManager.prototype, "scene", {
  14178. /** Gets the hosting scene */
  14179. get: function () {
  14180. return this._scene;
  14181. },
  14182. enumerable: true,
  14183. configurable: true
  14184. });
  14185. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  14186. /** Gets associated utility layer */
  14187. get: function () {
  14188. return this._utilityLayer;
  14189. },
  14190. enumerable: true,
  14191. configurable: true
  14192. });
  14193. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  14194. var previousControlOver = this._lastControlOver[pointerId];
  14195. if (previousControlOver) {
  14196. previousControlOver._onPointerOut(previousControlOver);
  14197. delete this._lastControlOver[pointerId];
  14198. }
  14199. if (isPointerUp) {
  14200. if (this._lastControlDown[pointerId]) {
  14201. this._lastControlDown[pointerId].forcePointerUp();
  14202. delete this._lastControlDown[pointerId];
  14203. }
  14204. }
  14205. this.onPickedPointChangedObservable.notifyObservers(null);
  14206. };
  14207. GUI3DManager.prototype._doPicking = function (pi) {
  14208. if (!this._utilityLayer || !this._utilityLayer.utilityLayerScene.activeCamera) {
  14209. return false;
  14210. }
  14211. var pointerEvent = (pi.event);
  14212. var pointerId = pointerEvent.pointerId || 0;
  14213. var buttonIndex = pointerEvent.button;
  14214. var pickingInfo = pi.pickInfo;
  14215. if (!pickingInfo || !pickingInfo.hit) {
  14216. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  14217. return false;
  14218. }
  14219. var control = (pickingInfo.pickedMesh.metadata);
  14220. if (pickingInfo.pickedPoint) {
  14221. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  14222. }
  14223. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  14224. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14225. if (this._lastControlOver[pointerId]) {
  14226. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  14227. }
  14228. delete this._lastControlOver[pointerId];
  14229. }
  14230. }
  14231. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14232. if (this._lastControlDown[pointerEvent.pointerId]) {
  14233. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  14234. delete this._lastControlDown[pointerEvent.pointerId];
  14235. }
  14236. if (pointerEvent.pointerType === "touch") {
  14237. this._handlePointerOut(pointerId, false);
  14238. }
  14239. }
  14240. return true;
  14241. };
  14242. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  14243. /**
  14244. * Gets the root container
  14245. */
  14246. get: function () {
  14247. return this._rootContainer;
  14248. },
  14249. enumerable: true,
  14250. configurable: true
  14251. });
  14252. /**
  14253. * Gets a boolean indicating if the given control is in the root child list
  14254. * @param control defines the control to check
  14255. * @returns true if the control is in the root child list
  14256. */
  14257. GUI3DManager.prototype.containsControl = function (control) {
  14258. return this._rootContainer.containsControl(control);
  14259. };
  14260. /**
  14261. * Adds a control to the root child list
  14262. * @param control defines the control to add
  14263. * @returns the current manager
  14264. */
  14265. GUI3DManager.prototype.addControl = function (control) {
  14266. this._rootContainer.addControl(control);
  14267. return this;
  14268. };
  14269. /**
  14270. * Removes a control from the root child list
  14271. * @param control defines the control to remove
  14272. * @returns the current container
  14273. */
  14274. GUI3DManager.prototype.removeControl = function (control) {
  14275. this._rootContainer.removeControl(control);
  14276. return this;
  14277. };
  14278. /**
  14279. * Releases all associated resources
  14280. */
  14281. GUI3DManager.prototype.dispose = function () {
  14282. this._rootContainer.dispose();
  14283. for (var materialName in this._sharedMaterials) {
  14284. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  14285. continue;
  14286. }
  14287. this._sharedMaterials[materialName].dispose();
  14288. }
  14289. this._sharedMaterials = {};
  14290. if (this._pointerOutObserver && this._utilityLayer) {
  14291. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  14292. this._pointerOutObserver = null;
  14293. }
  14294. this.onPickedPointChangedObservable.clear();
  14295. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  14296. if (utilityLayerScene) {
  14297. if (this._pointerObserver) {
  14298. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  14299. this._pointerObserver = null;
  14300. }
  14301. }
  14302. if (this._scene) {
  14303. if (this._sceneDisposeObserver) {
  14304. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  14305. this._sceneDisposeObserver = null;
  14306. }
  14307. }
  14308. if (this._utilityLayer) {
  14309. this._utilityLayer.dispose();
  14310. }
  14311. };
  14312. return GUI3DManager;
  14313. }());
  14314. /***/ }),
  14315. /***/ "./3D/index.ts":
  14316. /*!*********************!*\
  14317. !*** ./3D/index.ts ***!
  14318. \*********************/
  14319. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  14320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14321. "use strict";
  14322. __webpack_require__.r(__webpack_exports__);
  14323. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  14324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14336. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  14337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14339. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  14340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  14341. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  14343. /***/ }),
  14344. /***/ "./3D/materials/fluentMaterial.ts":
  14345. /*!****************************************!*\
  14346. !*** ./3D/materials/fluentMaterial.ts ***!
  14347. \****************************************/
  14348. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14350. "use strict";
  14351. __webpack_require__.r(__webpack_exports__);
  14352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  14353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  14354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14355. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  14356. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  14357. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  14358. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  14359. /** @hidden */
  14360. var FluentMaterialDefines = /** @class */ (function (_super) {
  14361. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterialDefines, _super);
  14362. function FluentMaterialDefines() {
  14363. var _this = _super.call(this) || this;
  14364. _this.INNERGLOW = false;
  14365. _this.BORDER = false;
  14366. _this.HOVERLIGHT = false;
  14367. _this.TEXTURE = false;
  14368. _this.rebuild();
  14369. return _this;
  14370. }
  14371. return FluentMaterialDefines;
  14372. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  14373. /**
  14374. * Class used to render controls with fluent desgin
  14375. */
  14376. var FluentMaterial = /** @class */ (function (_super) {
  14377. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FluentMaterial, _super);
  14378. /**
  14379. * Creates a new Fluent material
  14380. * @param name defines the name of the material
  14381. * @param scene defines the hosting scene
  14382. */
  14383. function FluentMaterial(name, scene) {
  14384. var _this = _super.call(this, name, scene) || this;
  14385. /**
  14386. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  14387. */
  14388. _this.innerGlowColorIntensity = 0.5;
  14389. /**
  14390. * Gets or sets the inner glow color (white by default)
  14391. */
  14392. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  14393. /**
  14394. * Gets or sets alpha value (default is 1.0)
  14395. */
  14396. _this.alpha = 1.0;
  14397. /**
  14398. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  14399. */
  14400. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  14401. /**
  14402. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  14403. */
  14404. _this.renderBorders = false;
  14405. /**
  14406. * Gets or sets border width (default is 0.5)
  14407. */
  14408. _this.borderWidth = 0.5;
  14409. /**
  14410. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  14411. */
  14412. _this.edgeSmoothingValue = 0.02;
  14413. /**
  14414. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  14415. */
  14416. _this.borderMinValue = 0.1;
  14417. /**
  14418. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  14419. */
  14420. _this.renderHoverLight = false;
  14421. /**
  14422. * Gets or sets the radius used to render the hover light (default is 1.0)
  14423. */
  14424. _this.hoverRadius = 1.0;
  14425. /**
  14426. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  14427. */
  14428. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  14429. /**
  14430. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  14431. */
  14432. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  14433. return _this;
  14434. }
  14435. FluentMaterial.prototype.needAlphaBlending = function () {
  14436. return this.alpha !== 1.0;
  14437. };
  14438. FluentMaterial.prototype.needAlphaTesting = function () {
  14439. return false;
  14440. };
  14441. FluentMaterial.prototype.getAlphaTestTexture = function () {
  14442. return null;
  14443. };
  14444. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  14445. if (this.isFrozen) {
  14446. if (this._wasPreviouslyReady && subMesh.effect) {
  14447. return true;
  14448. }
  14449. }
  14450. if (!subMesh._materialDefines) {
  14451. subMesh._materialDefines = new FluentMaterialDefines();
  14452. }
  14453. var scene = this.getScene();
  14454. var defines = subMesh._materialDefines;
  14455. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  14456. if (defines._renderId === scene.getRenderId()) {
  14457. return true;
  14458. }
  14459. }
  14460. if (defines._areTexturesDirty) {
  14461. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  14462. defines.BORDER = this.renderBorders;
  14463. defines.HOVERLIGHT = this.renderHoverLight;
  14464. if (this._albedoTexture) {
  14465. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  14466. return false;
  14467. }
  14468. else {
  14469. defines.TEXTURE = true;
  14470. }
  14471. }
  14472. else {
  14473. defines.TEXTURE = false;
  14474. }
  14475. }
  14476. var engine = scene.getEngine();
  14477. // Get correct effect
  14478. if (defines.isDirty) {
  14479. defines.markAsProcessed();
  14480. scene.resetCachedMaterial();
  14481. //Attributes
  14482. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  14483. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  14484. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  14485. var shaderName = "fluent";
  14486. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  14487. "hoverColor", "hoverPosition", "hoverRadius"
  14488. ];
  14489. var samplers = ["albedoSampler"];
  14490. var uniformBuffers = new Array();
  14491. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  14492. uniformsNames: uniforms,
  14493. uniformBuffersNames: uniformBuffers,
  14494. samplers: samplers,
  14495. defines: defines,
  14496. maxSimultaneousLights: 4
  14497. });
  14498. var join = defines.toString();
  14499. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  14500. attributes: attribs,
  14501. uniformsNames: uniforms,
  14502. uniformBuffersNames: uniformBuffers,
  14503. samplers: samplers,
  14504. defines: join,
  14505. fallbacks: null,
  14506. onCompiled: this.onCompiled,
  14507. onError: this.onError,
  14508. indexParameters: { maxSimultaneousLights: 4 }
  14509. }, engine));
  14510. }
  14511. if (!subMesh.effect || !subMesh.effect.isReady()) {
  14512. return false;
  14513. }
  14514. defines._renderId = scene.getRenderId();
  14515. this._wasPreviouslyReady = true;
  14516. return true;
  14517. };
  14518. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  14519. var scene = this.getScene();
  14520. var defines = subMesh._materialDefines;
  14521. if (!defines) {
  14522. return;
  14523. }
  14524. var effect = subMesh.effect;
  14525. if (!effect) {
  14526. return;
  14527. }
  14528. this._activeEffect = effect;
  14529. // Matrices
  14530. this.bindOnlyWorldMatrix(world);
  14531. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  14532. if (this._mustRebind(scene, effect)) {
  14533. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  14534. if (defines.INNERGLOW) {
  14535. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  14536. }
  14537. if (defines.BORDER) {
  14538. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  14539. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  14540. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  14541. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14542. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  14543. }
  14544. if (defines.HOVERLIGHT) {
  14545. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  14546. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  14547. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  14548. }
  14549. if (defines.TEXTURE) {
  14550. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  14551. }
  14552. }
  14553. this._afterBind(mesh, this._activeEffect);
  14554. };
  14555. FluentMaterial.prototype.getActiveTextures = function () {
  14556. var activeTextures = _super.prototype.getActiveTextures.call(this);
  14557. return activeTextures;
  14558. };
  14559. FluentMaterial.prototype.hasTexture = function (texture) {
  14560. if (_super.prototype.hasTexture.call(this, texture)) {
  14561. return true;
  14562. }
  14563. return false;
  14564. };
  14565. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  14566. _super.prototype.dispose.call(this, forceDisposeEffect);
  14567. };
  14568. FluentMaterial.prototype.clone = function (name) {
  14569. var _this = this;
  14570. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  14571. };
  14572. FluentMaterial.prototype.serialize = function () {
  14573. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  14574. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  14575. return serializationObject;
  14576. };
  14577. FluentMaterial.prototype.getClassName = function () {
  14578. return "FluentMaterial";
  14579. };
  14580. // Statics
  14581. FluentMaterial.Parse = function (source, scene, rootUrl) {
  14582. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  14583. };
  14584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14585. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14586. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14587. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  14588. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14589. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14590. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  14591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14592. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14593. ], FluentMaterial.prototype, "alpha", void 0);
  14594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14595. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  14596. ], FluentMaterial.prototype, "albedoColor", void 0);
  14597. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14598. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14599. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14600. ], FluentMaterial.prototype, "renderBorders", void 0);
  14601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14602. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14603. ], FluentMaterial.prototype, "borderWidth", void 0);
  14604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14605. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14606. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  14607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14608. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14609. ], FluentMaterial.prototype, "borderMinValue", void 0);
  14610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14611. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  14612. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  14613. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  14614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14615. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14616. ], FluentMaterial.prototype, "hoverRadius", void 0);
  14617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14618. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  14619. ], FluentMaterial.prototype, "hoverColor", void 0);
  14620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14621. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  14622. ], FluentMaterial.prototype, "hoverPosition", void 0);
  14623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14624. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  14625. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  14626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14627. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  14628. ], FluentMaterial.prototype, "albedoTexture", void 0);
  14629. return FluentMaterial;
  14630. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  14631. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  14632. /***/ }),
  14633. /***/ "./3D/materials/index.ts":
  14634. /*!*******************************!*\
  14635. !*** ./3D/materials/index.ts ***!
  14636. \*******************************/
  14637. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  14638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14639. "use strict";
  14640. __webpack_require__.r(__webpack_exports__);
  14641. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14644. /***/ }),
  14645. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  14646. /*!*************************************************!*\
  14647. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  14648. \*************************************************/
  14649. /*! exports provided: fluentPixelShader */
  14650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14651. "use strict";
  14652. __webpack_require__.r(__webpack_exports__);
  14653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  14654. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14655. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14656. var name = 'fluentPixelShader';
  14657. 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}";
  14658. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14659. /** @hidden */
  14660. var fluentPixelShader = { name: name, shader: shader };
  14661. /***/ }),
  14662. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  14663. /*!***********************************************!*\
  14664. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  14665. \***********************************************/
  14666. /*! exports provided: fluentVertexShader */
  14667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14668. "use strict";
  14669. __webpack_require__.r(__webpack_exports__);
  14670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  14671. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  14672. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  14673. var name = 'fluentVertexShader';
  14674. 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";
  14675. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  14676. /** @hidden */
  14677. var fluentVertexShader = { name: name, shader: shader };
  14678. /***/ }),
  14679. /***/ "./3D/vector3WithInfo.ts":
  14680. /*!*******************************!*\
  14681. !*** ./3D/vector3WithInfo.ts ***!
  14682. \*******************************/
  14683. /*! exports provided: Vector3WithInfo */
  14684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14685. "use strict";
  14686. __webpack_require__.r(__webpack_exports__);
  14687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  14688. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14689. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14690. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14691. /**
  14692. * Class used to transport Vector3 information for pointer events
  14693. */
  14694. var Vector3WithInfo = /** @class */ (function (_super) {
  14695. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Vector3WithInfo, _super);
  14696. /**
  14697. * Creates a new Vector3WithInfo
  14698. * @param source defines the vector3 data to transport
  14699. * @param buttonIndex defines the current mouse button index
  14700. */
  14701. function Vector3WithInfo(source,
  14702. /** defines the current mouse button index */
  14703. buttonIndex) {
  14704. if (buttonIndex === void 0) { buttonIndex = 0; }
  14705. var _this = _super.call(this, source.x, source.y, source.z) || this;
  14706. _this.buttonIndex = buttonIndex;
  14707. return _this;
  14708. }
  14709. return Vector3WithInfo;
  14710. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  14711. /***/ }),
  14712. /***/ "./index.ts":
  14713. /*!******************!*\
  14714. !*** ./index.ts ***!
  14715. \******************/
  14716. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, 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 */
  14717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14718. "use strict";
  14719. __webpack_require__.r(__webpack_exports__);
  14720. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  14721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14760. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  14761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  14762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  14763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  14764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  14766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  14767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  14768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  14769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  14770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  14771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  14772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  14773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  14774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  14775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  14776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  14777. /***/ }),
  14778. /***/ "./legacy/legacy.ts":
  14779. /*!**************************!*\
  14780. !*** ./legacy/legacy.ts ***!
  14781. \**************************/
  14782. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, 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 */
  14783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14784. "use strict";
  14785. __webpack_require__.r(__webpack_exports__);
  14786. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  14787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  14788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  14789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  14790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  14791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  14792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  14793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  14794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  14795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  14796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  14797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  14830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  14831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  14832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  14833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  14834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  14835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  14836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  14837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  14838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  14839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  14840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  14841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  14842. /**
  14843. * Legacy support, defining window.BABYLON.GUI (global variable).
  14844. *
  14845. * This is the entry point for the UMD module.
  14846. * The entry point for a future ESM package should be index.ts
  14847. */
  14848. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  14849. if (typeof globalObject !== "undefined") {
  14850. globalObject.BABYLON = globalObject.BABYLON || {};
  14851. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  14852. }
  14853. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  14854. /***/ }),
  14855. /***/ "babylonjs/Misc/perfCounter":
  14856. /*!****************************************************************************************************!*\
  14857. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  14858. \****************************************************************************************************/
  14859. /*! no static exports found */
  14860. /***/ (function(module, exports) {
  14861. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  14862. /***/ })
  14863. /******/ });
  14864. });
  14865. //# sourceMappingURL=babylon.gui.js.map